-
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.
- Loading branch information
1 parent
25a77a6
commit 6a9ba46
Showing
5 changed files
with
29 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Mixpanel from 'mixpanel-browser' | ||
|
||
export type MixPanelType = typeof Mixpanel | ||
|
||
// don't export me, access me through the getter | ||
let _mixPanel: typeof Mixpanel | undefined = undefined | ||
|
||
// we need to be able to access this outside react | ||
export const getMixPanel = (): MixPanelType | undefined => { | ||
const mixPanelEnabled = import.meta.env.VITE_MIXPANEL_ENABLED | ||
if (!mixPanelEnabled) return | ||
if (_mixPanel) return _mixPanel | ||
const mixpanelToken = import.meta.env.VITE_MIXPANEL_TOKEN | ||
Mixpanel.init(mixpanelToken) | ||
_mixPanel = Mixpanel // identify once per session | ||
_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