mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 05:33:02 -05:00
35 lines
867 B
TypeScript
35 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
|
||
|
});
|
||
|
}
|
||
|
};
|