Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from artsy/promo-space-helper
Adds helper for promo space tap tracking
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
ActionType, | ||
ContextModule, | ||
OwnerType, | ||
TappedPromoSpace, | ||
} from "../../Schema" | ||
|
||
export interface TappedPromoSpaceArgs { | ||
path: string | ||
subject: string | ||
} | ||
|
||
/** | ||
* A user taps a promo space on the home page of the app | ||
* | ||
* subject is the text of the tapped promo space | ||
* | ||
* @example | ||
* ``` | ||
* tappedPromoSpace({ | ||
* path: "/collection/a-collection-id", | ||
* subject: "Check out this sweet collection!" | ||
* }) | ||
* ``` | ||
*/ | ||
export const tappedPromoSpace = ({ | ||
path, | ||
subject, | ||
}: TappedPromoSpaceArgs): TappedPromoSpace => { | ||
return { | ||
action: ActionType.tappedPromoSpace, | ||
context_module: ContextModule.promoSpace, | ||
context_screen_owner_type: OwnerType.home, | ||
destination_path: path, | ||
subject, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { tappedPromoSpace } from "../TappedPromoSpace" | ||
|
||
describe(tappedPromoSpace, () => { | ||
it("Returns expected args", () => { | ||
const event = tappedPromoSpace({ | ||
path: "/collection/a-collection-id", | ||
subject: "Check out this sweet collection!", | ||
}) | ||
|
||
expect(event).toEqual({ | ||
action: "tappedPromoSpace", | ||
context_module: "promoSpace", | ||
context_screen_owner_type: "home", | ||
destination_path: "/collection/a-collection-id", | ||
subject: "Check out this sweet collection!", | ||
}) | ||
}) | ||
}) |