-
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.
* Revert "Revert "Revert "Revert "Don't track mixpanel events on dev."""" This reverts commit 1ef4520. * Remove track. * Update. * Update. * Update logo image.
- Loading branch information
1 parent
b32bda0
commit 07c1557
Showing
9 changed files
with
84 additions
and
69 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,4 +1,5 @@ | ||
NEXT_PUBLIC_FIREBASE_API_KEY="AIzaSyDa_YMeyzV0SkVe92vBZ1tVikWBmOU5KVE" | ||
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN="dreamboothy-dev.firebaseapp.com" | ||
NEXT_PUBLIC_FIREBASE_PROJECT_ID="dreamboothy-dev" | ||
NEXT_PUBLIC_BACKEND_URL="http://localhost:8080" | ||
NEXT_PUBLIC_BACKEND_URL="http://localhost:8080" | ||
NEXT_PUBLIC_MIXPANEL_KEY="" |
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
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 was deleted.
Oops, something went wrong.
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,56 @@ | ||
import mixpanel from 'mixpanel-browser' | ||
|
||
interface UserProfile { | ||
$email: string | null | ||
$first_name?: string | ||
$last_name?: string | ||
$phone?: string | ||
[key: string]: any | ||
} | ||
|
||
class MixpanelAnalytics { | ||
private isProduction: boolean | ||
|
||
constructor() { | ||
this.isProduction = process.env.NODE_ENV === 'production' | ||
|
||
if (this.isProduction && process.env.NEXT_PUBLIC_MIXPANEL_KEY) { | ||
mixpanel.init(process.env.NEXT_PUBLIC_MIXPANEL_KEY, { | ||
debug: true, | ||
track_pageview: true, | ||
persistence: 'localStorage', | ||
}) | ||
} | ||
} | ||
|
||
public track(event: string, properties?: object): void { | ||
if (this.isProduction) { | ||
mixpanel.track(event, properties) | ||
} else { | ||
console.log( | ||
`Mixpanel Track - Event: ${event}, Properties: ${JSON.stringify(properties)}` | ||
) | ||
} | ||
} | ||
|
||
public identify(distinctId: string): void { | ||
if (this.isProduction) { | ||
mixpanel.identify(distinctId) | ||
} else { | ||
console.log(`Mixpanel Identify - Distinct ID: ${distinctId}`) | ||
} | ||
} | ||
|
||
public setProfile(updates: UserProfile): void { | ||
if (this.isProduction) { | ||
mixpanel.people.set(updates) | ||
} else { | ||
console.log( | ||
`Mixpanel Set Profile - Updates: ${JSON.stringify(updates)}` | ||
) | ||
} | ||
} | ||
} | ||
|
||
const analytic = new MixpanelAnalytics() | ||
export default analytic |