Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
batch_requests: true,
persistence: 'localStorage',
property_blacklist: [
'$initial_referrer',
'$initial_referring_domain',
'$referrer',
'$referring_domain',
],
}
const apiHost = process.env.REACT_APP_MIXPANEL_HOST
if (apiHost) {
options['api_host'] = apiHost
}
mixpanel.init(token, options)
// disable mixpanel to report data immediately
mixpanel.opt_out_tracking()
if (info?.disable_telemetry === false) {
mixpanel.register({
$current_url: getPathInLocationHash(),
})
mixpanel.opt_in_tracking()
}
}
if (gatherUsageStats != null) {
trackUsage = gatherUsageStats
}
if (trackUsage) {
mixpanel.identify(INSTALLATION_ID)
if (email) {
logMessage(`Email: ${email}`)
mixpanel.people.set({
'$email': email,
'$created': new Date().toISOString(),
})
}
mixpanel.opt_in_tracking()
} else {
mixpanel.opt_out_tracking()
}
logAlways('Track stats remotely: ', trackUsage)
preInitializationEventQueue.forEach(([eventName, opts]) => {
trackEventRemotely(eventName, opts)
})
}
export function setMixpanelTracking(config: AnalyticsConfig) {
if (MIXPANEL_ID) {
if (config.optedIn) {
log.debug('User has opted into analytics; tracking with Mixpanel')
mixpanel.identify(config.appId)
mixpanel.opt_in_tracking()
mixpanel.register({ appVersion: CURRENT_VERSION, appId: config.appId })
} else {
log.debug('User has opted out of analytics; stopping tracking')
mixpanel.opt_out_tracking()
mixpanel.reset()
}
}
}