Skip to content

Commit

Permalink
Merge pull request #72 from artsy/promo-space-helper
Browse files Browse the repository at this point in the history
Adds helper for promo space tap tracking
  • Loading branch information
eessex committed Jul 2, 2020
2 parents 86d63e6 + 386fa1e commit dcb1c5f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/Helpers/Tap/TappedPromoSpace.ts
@@ -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,
}
}
18 changes: 18 additions & 0 deletions src/Helpers/Tap/__tests__/TappedPromoSpace.test.ts
@@ -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!",
})
})
})

0 comments on commit dcb1c5f

Please sign in to comment.