Skip to content

Commit

Permalink
feat: add Mixpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
bonustrack committed Oct 29, 2023
1 parent 375f210 commit 45743a4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ VITE_IPFS_GATEWAY=snapshot.mypinata.cloud
VITE_DEFAULT_NETWORK=1
VITE_PUSHER_BEAMS_INSTANCE_ID=2e080021-d495-456d-b2cf-84f9fd718442
VITE_SHUTTER_EON_PUBKEY=0x0e6493bbb4ee8b19aa9b70367685049ff01dc9382c46aed83f8bc07d2a5ba3e6030bd83b942c1fd3dff5b79bef3b40bf6b666e51e7f0be14ed62daaffad47435265f5c9403b1a801921981f7d8659a9bd91fe92fb1cf9afdb16178a532adfaf51a237103874bb03afafe9cab2118dae1be5f08a0a28bf488c1581e9db4bc23ca
VITE_ENV=develop
VITE_ENV=develop
VITE_MIXPANEL_TOKEN=2ec6cd1b19e790f45cc9a9bb83980c8d
3 changes: 2 additions & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"useFlaggedMessageStatus": true,
"useEmailSubscription": true,
"useEmailFetchClient": true,
"useStatement": true
"useStatement": true,
"useMixpanel": true
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"js-sha256": "^0.9.0",
"jsonexport": "^3.2.0",
"lodash": "^4.17.21",
"mixpanel-browser": "^2.47.0",
"readable-stream": "3.6.0",
"remarkable": "^2.0.1",
"remove-markdown": "^0.5.0",
Expand Down
7 changes: 7 additions & 0 deletions src/composables/useMixpanel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import mixpanel from 'mixpanel-browser';

export function useMixpanel() {
mixpanel.init(import.meta.env.VITE_MIXPANEL_TOKEN, { ip: false });

return { mixpanel };
}
10 changes: 10 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createRouter, createWebHashHistory, RouteLocation } from 'vue-router';
import { useMixpanel } from '@/composables/useMixpanel';

import DelegateView from '@/views/DelegateView.vue';
import ExploreView from '@/views/ExploreView.vue';
Expand All @@ -25,6 +26,8 @@ import SpaceDelegate from './views/SpaceDelegate.vue';
// The frontend shows all spaces or just a single one, when being accessed
// through that space's custom domain.
const { domain, domainAlias } = useApp();
const { mixpanel } = useMixpanel();

const routes: any[] = [];

// These routes get prefixed with the respective space's ENS domain (/:key)
Expand Down Expand Up @@ -173,6 +176,13 @@ const router = createRouter({
}
});

router.afterEach(to => {
mixpanel.track_pageview({
page_name: to.name,
page_path: to.path
});
});

export { routes };

export default router;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5594,6 +5594,11 @@ minisearch@^6.0.1:
resolved "https://registry.yarnpkg.com/minisearch/-/minisearch-6.1.0.tgz#6e74e743dbd0e88fa5ca52fef2391e0aa7055252"
integrity sha512-PNxA/X8pWk+TiqPbsoIYH0GQ5Di7m6326/lwU/S4mlo4wGQddIcf/V//1f9TB0V4j59b57b+HZxt8h3iMROGvg==

mixpanel-browser@^2.47.0:
version "2.47.0"
resolved "https://registry.yarnpkg.com/mixpanel-browser/-/mixpanel-browser-2.47.0.tgz#4e7fd3bb660c6f63443efbd169d1cd327db71ed4"
integrity sha512-Ldrva0fRBEIFWmEibBQO1PulfpJVF3pf28Guk09lDirDaSQqqU/xs9zQLwN2rL5VwVtsP1aD3JaCgaa98EjojQ==

mlly@^1.1.1, mlly@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mlly/-/mlly-1.2.0.tgz#f0f6c2fc8d2d12ea6907cd869066689b5031b613"
Expand Down

1 comment on commit 45743a4

@vercel
Copy link

@vercel vercel bot commented on 45743a4 Oct 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.