-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telemetry): add telemetry for Trial Dialogs (#5643)
* feat: ✨ add telemetry for trial dialogs * feat: add ability to test dialogs using query params * fix: 🐛 add spaces between tracking event names * fix: 🐛 fix bug where incorrect tracking object was being passed when closing popover * refactor: ♻️ follow naming convention for prop vs internal component functions * refactor: ♻️ remove mixing of UI types from data types * fix: camelCase all the strings * refactor: add comment and toLowerCase handler for dialog id * chore(core): format files --------- Co-authored-by: Ash <[email protected]>
- Loading branch information
Showing
5 changed files
with
217 additions
and
18 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
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
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
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
58 changes: 58 additions & 0 deletions
58
...src/core/studio/components/navbar/free-trial/__telemetry__/trialDialogEvents.telemetry.ts
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,58 @@ | ||
import {defineEvent} from '@sanity/telemetry' | ||
|
||
type TrialStage = 'trialStarted' | 'trialActive' | 'trialEndingSoon' | 'trialEnded' | 'postTrial' | ||
|
||
type BaseDialogEventAttributes = { | ||
source: 'studio' | ||
trialDaysLeft: number | ||
dialogType: 'modal' | 'popover' | ||
dialogId: string | ||
dialogRevision: string | ||
dialogTrialStage: TrialStage | ||
} | ||
|
||
export interface TrialDialogViewedInfo extends BaseDialogEventAttributes { | ||
dialogTrigger: 'fromClick' | 'auto' | ||
} | ||
|
||
export const TrialDialogViewed = defineEvent<TrialDialogViewedInfo>({ | ||
name: 'Trial Dialog Viewed', | ||
version: 1, | ||
description: 'User viewed a dialog or popover related to free trial', | ||
}) | ||
|
||
export interface TrialDialogDismissedInfo extends BaseDialogEventAttributes { | ||
dialogDismissAction: 'ctaClicked' | 'xClick' | 'outsideClick' | ||
} | ||
|
||
export const TrialDialogDismissed = defineEvent<TrialDialogDismissedInfo>({ | ||
name: 'Trial Dialog Dismissed', | ||
version: 1, | ||
description: 'User dismissed a dialog or popover related to free trial', | ||
}) | ||
|
||
export interface TrialDialogCTAClickedInfo extends BaseDialogEventAttributes { | ||
dialogCtaType: 'upgrade' | 'learnMore' | ||
} | ||
|
||
export const TrialDialogCTAClicked = defineEvent<TrialDialogCTAClickedInfo>({ | ||
name: 'Trial Dialog CTA Clicked', | ||
version: 1, | ||
description: 'User clicked a CTA in a dialog or popover related to free trial', | ||
}) | ||
|
||
export function getTrialStage({ | ||
showOnLoad, | ||
dialogId, | ||
}: { | ||
showOnLoad: boolean | ||
dialogId: string | ||
}): TrialStage { | ||
// Note: some of the ids in the trial experience studio have uppercase letters | ||
// so the toLowerCase is important here | ||
if (showOnLoad && dialogId.toLowerCase() === 'free-upgrade-popover') return 'trialStarted' | ||
if (showOnLoad && dialogId.toLowerCase() === 'trial-ending-popover') return 'trialEndingSoon' | ||
if (showOnLoad && dialogId.toLowerCase() === 'project-downgraded-to-free') return 'trialEnded' | ||
if (!showOnLoad && dialogId.toLowerCase() === 'after-trial-upgrade') return 'postTrial' | ||
return 'trialActive' | ||
} |