Skip to content

Commit

Permalink
Mixpanel post merge changes (#486)
Browse files Browse the repository at this point in the history
* Change order mixpanel analytics variables

* Add comment about usefulness of delaying showing cookie banner
  • Loading branch information
oskarvu authored Dec 11, 2024
1 parent ddc974d commit 201bf42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/app/src/domain/analytics/mixpanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ export interface Analytics {
trackEvent(event: string, props?: Record<string, any>): void
}

const analyticsDisabled: Analytics = {
optInTracking: () => {},
optOutTracking: () => {},
trackUserAddress: (_address: CheckedAddress) => {},
trackEvent: (_event: string, _props: Record<string, any> = {}) => {},
}

const analyticsEnabled: Analytics = {
optInTracking: () => {
if (!mixpanel.has_opted_in_tracking()) {
Expand All @@ -48,6 +41,13 @@ const analyticsEnabled: Analytics = {
},
}

const analyticsDisabled: Analytics = {
optInTracking: () => {},
optOutTracking: () => {},
trackUserAddress: (_address: CheckedAddress) => {},
trackEvent: (_event: string, _props: Record<string, any> = {}) => {},
}

export const { optInTracking, optOutTracking, trackUserAddress, trackEvent } = MIXPANEL_ENABLED
? analyticsEnabled
: analyticsDisabled
2 changes: 2 additions & 0 deletions packages/app/src/features/analytics/logic/useAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export function useAnalytics(): UseAnalyticsResult {
optOutTracking()
}

// @note: We are delaying showing the banner until the initial data is loaded and skeleton is removed.
// This is because we need to drag user's attention to the banner and we don't want to show it too early.
const initialDataLoaded = useInitialDataLoaded()

return {
Expand Down

0 comments on commit 201bf42

Please sign in to comment.