0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 05:33:02 -05:00
penpot-exporter-figma-plugin/ui-src/metrics/mixpanel.ts

35 lines
867 B
TypeScript
Raw Normal View History

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
});
}
};