Skip to content

Commit

Permalink
fx
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Dec 16, 2024
1 parent 233c1c2 commit 9359f43
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions helpers/telemetry/telemetry.client.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as Mixpanel from 'mixpanel-browser'
import * as mixpanel from 'mixpanel-browser'
import { TelemetryDataClient } from './types'
import { FCL_SERVICE_METHODS } from '../constants'

let mixpanel: Mixpanel.Mixpanel | null = null
let hasInitialized = false

export function getTelemetryClient(baseData: TelemetryDataClient) {
if (process.env.NEXT_PUBLIC_MIXPANEL_ID && !mixpanel) {
mixpanel = Mixpanel.init(process.env.NEXT_PUBLIC_MIXPANEL_ID)
if (process.env.NEXT_PUBLIC_MIXPANEL_ID && !hasInitialized) {
mixpanel.init(process.env.NEXT_PUBLIC_MIXPANEL_ID)
hasInitialized = true
}

return {
Expand Down
6 changes: 3 additions & 3 deletions helpers/telemetry/telemetry.server.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Mixpanel from 'mixpanel'
import { TelemetryDataServer } from './types'

let hasInitialized = false
let mixpanel: Mixpanel.Mixpanel | null = null

export function getTelemetryServer(baseData: TelemetryDataServer) {
if (process.env.NEXT_PUBLIC_MIXPANEL_ID && !hasInitialized) {
if (process.env.NEXT_PUBLIC_MIXPANEL_ID && !mixpanel) {
Mixpanel.init(process.env.NEXT_PUBLIC_MIXPANEL_ID)
}

return {
trackWalletDiscoveryRequest: async () =>
new Promise<void>(resolve => {
Mixpanel.track('Wallet Discovery Request', baseData, () => resolve())
mixpanel?.track('Wallet Discovery Request', baseData, () => resolve())
}),
}
}

0 comments on commit 9359f43

Please sign in to comment.