Skip to content

Commit

Permalink
Merge pull request #15006 from artsy/dzucconi/fix/adds-experiment-vie…
Browse files Browse the repository at this point in the history
…wed-event

fix(home): adds experiment tracking
  • Loading branch information
dzucconi authored Dec 17, 2024
2 parents 413968e + 38c8198 commit 566248b
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Apps/Home/Components/HomeHeroUnits/HomeHeroUnitLoggedOut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import * as React from "react"
import { HomeHeroUnitBase, HomeHeroUnitBaseProps } from "./HomeHeroUnit"
import { useDeviceDetection } from "Utils/Hooks/useDeviceDetection"
import { useFeatureVariant } from "System/Hooks/useFeatureFlag"
import { useOnce } from "Utils/Hooks/useOnce"
import { ActionType, ExperimentViewed, OwnerType } from "@artsy/cohesion"
import { useTracking } from "react-tracking"

const EXPERIMENT_NAME = "diamond_hero-app-download"

export const HomeHeroUnitLoggedOut: React.FC<{ index: number }> = ({
index,
Expand Down Expand Up @@ -44,8 +49,23 @@ export const HomeHeroUnitLoggedOut: React.FC<{ index: number }> = ({
},
}

const featureVariant = useFeatureVariant("diamond_hero-app-download")
const variant = variants[featureVariant?.name || "control"]
const featureVariant = useFeatureVariant(EXPERIMENT_NAME)
const variantName = featureVariant?.name || "control"
const variant = variants[variantName]

const { trackEvent } = useTracking()

useOnce(() => {
const payload: ExperimentViewed = {
action: ActionType.experimentViewed,
experiment_name: EXPERIMENT_NAME,
service: "unleash",
variant_name: variantName,
context_owner_type: OwnerType.home,
}

trackEvent(payload)
})

return (
<HomeHeroUnitBase
Expand Down

0 comments on commit 566248b

Please sign in to comment.