-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
68 additions
and
68 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
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 |
---|---|---|
@@ -1,19 +1,33 @@ | ||
import Mixpanel from 'mixpanel-browser' | ||
import { trackWalletConnected, trackWalletDiscoveryRequest } from './telemetry' | ||
import * as Mixpanel from 'mixpanel-browser' | ||
import { TelemetryDataClient } from './types' | ||
import { FCL_SERVICE_METHODS } from '../constants' | ||
|
||
let mixpanel: any = null | ||
let mixpanel: Mixpanel.Mixpanel | null = null | ||
|
||
export function getTelemetryClient(baseData: TelemetryDataClient) { | ||
if (process.env.NEXT_PUBLIC_MIXPANEL_ID && !mixpanel) { | ||
mixpanel = Mixpanel.init(process.env.NEXT_PUBLIC_MIXPANEL_ID) | ||
} | ||
|
||
return { | ||
trackWalletDiscoveryRequest: trackWalletDiscoveryRequest( | ||
mixpanel, | ||
baseData, | ||
), | ||
trackWalletConnected: trackWalletConnected(mixpanel, baseData), | ||
trackWalletConnected: async ({ | ||
walletUid, | ||
serviceMethod, | ||
}: { | ||
walletUid: string | ||
serviceMethod: FCL_SERVICE_METHODS | ||
}) => { | ||
return new Promise<void>(resolve => { | ||
mixpanel?.track( | ||
'Wallet Connected', | ||
{ | ||
walletUid: walletUid, | ||
method: serviceMethod, | ||
...baseData, | ||
}, | ||
() => resolve(), | ||
) | ||
}) | ||
}, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,19 +1,17 @@ | ||
import Mixpanel from 'mixpanel' | ||
import { TelemetryDataServer } from './types' | ||
import { trackWalletConnected, trackWalletDiscoveryRequest } from './telemetry' | ||
|
||
let mixpanel: Mixpanel.Mixpanel | null = null | ||
let hasInitialized = false | ||
|
||
export function getTelemetryServer(baseData: TelemetryDataServer) { | ||
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) | ||
} | ||
|
||
return { | ||
trackWalletDiscoveryRequest: trackWalletDiscoveryRequest( | ||
mixpanel, | ||
baseData, | ||
), | ||
trackWalletConnected: trackWalletConnected(mixpanel, baseData), | ||
trackWalletDiscoveryRequest: async () => | ||
new Promise<void>(resolve => { | ||
Mixpanel.track('Wallet Discovery Request', baseData, () => resolve()) | ||
}), | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.