0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/ui-src/metrics/mixpanel.ts
Alex Sánchez a079f168df
Analytics (#228)
* metricts-sentry

* fixes

* refactor

* mixpanel integration

* improvements

* improvements

* fixes

* changeset

* fixes

* fixes

* Update .changeset/few-scissors-sleep.md

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

* Update manifest.json

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

* Update vite.config.ts

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

* fixes

* fixes

* fixes

* lint

---------

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
2024-10-28 11:22:50 +01:00

34 lines
867 B
TypeScript

import mixpanel from 'mixpanel-figma';
export const track = (name: string, opts = {}) => {
if (import.meta.env.VITE_MIXPANEL_TOKEN && import.meta.env.PROD) {
opts = {
...opts,
'Plugin Version': APP_VERSION
};
mixpanel.track(name, opts);
}
};
export const identify = ({ userId }: { userId: string }) => {
if (import.meta.env.VITE_MIXPANEL_TOKEN && import.meta.env.PROD) {
mixpanel.identify(userId);
mixpanel.people.set({
'USER_ID': userId,
'Plugin Version': APP_VERSION
});
}
};
export const initializeMixpanel = () => {
if (import.meta.env.VITE_MIXPANEL_TOKEN && import.meta.env.PROD) {
mixpanel.init(import.meta.env.VITE_MIXPANEL_TOKEN, {
disable_cookie: true,
disable_persistence: true,
opt_out_tracking_by_default: true,
ip: false,
track_pageview: true
});
}
};