-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from shapeshift/add-mixpanel
feat: mixpanel wiring
- Loading branch information
Showing
9 changed files
with
63 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
VITE_FOO=bar | ||
VITE_FEATURE_MIXPANEL=true | ||
VITE_MIXPANEL_TOKEN=faf859177254ec1a02752132c2f73954 |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// <reference types="vite/client" /> | ||
|
||
interface ImportMetaEnv { | ||
readonly VITE_FOO: string | ||
readonly VITE_FEATURE_MIXPANEL: boolean | ||
readonly VITE_MIXPANEL_TOKEN: string | ||
} | ||
|
||
interface ImportMeta { | ||
readonly env: ImportMetaEnv | ||
} |
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,2 @@ | ||
export * from './mixpanelSingleton' | ||
export * from './types' |
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,19 @@ | ||
import Mixpanel from 'mixpanel-browser' | ||
|
||
import type { MixPanelType } from './types' | ||
|
||
// we need to be able to access this outside react | ||
export const mixpanel = (() => { | ||
let _mixPanel: MixPanelType | undefined = undefined | ||
|
||
const mixPanelEnabled = import.meta.env.VITE_FEATURE_MIXPANEL | ||
if (!mixPanelEnabled) return undefined | ||
if (_mixPanel) return _mixPanel | ||
const mixpanelToken = import.meta.env.VITE_MIXPANEL_TOKEN | ||
Mixpanel.init(mixpanelToken) | ||
_mixPanel = Mixpanel // identify once per session | ||
_mixPanel.set_config({ persistence: 'localStorage' }) | ||
_mixPanel.identify() | ||
|
||
return _mixPanel | ||
})() |
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,8 @@ | ||
import type Mixpanel from 'mixpanel-browser' | ||
|
||
export type MixPanelType = typeof Mixpanel | ||
|
||
export enum MixPanelEvent { | ||
PairSelected = 'Pair Selected', | ||
StartTransaction = 'Start Transaction', | ||
} |
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