Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
registerUser(currentEducator) {
try {
if (!isEnabled()) return;
mixpanel.init(readEnv().mixpanelToken);
mixpanel.set_config({
track_pageview: true,
secure_cookie: true,
cross_subdomain_cookie: false // https://help.mixpanel.com/hc/en-us/articles/115004507486-Track-Across-Hosted-Subdomains
});
mixpanel.identify(currentEducator.id);
mixpanel.register({
'deployment_key': readEnv().deploymentKey,
'district_key': readEnv().districtKey,
'educator_id': currentEducator.id,
'educator_is_admin': currentEducator.admin,
'educator_school_id': currentEducator.school_id
});
}
catch (err) {
console.error(err); // eslint-disable-line no-console
}
},
.then(({ distinctId, doNotTrack }) => {
if (!doNotTrack) {
init()
mixpanel.identify(distinctId)
if (window.FS) {
window.FS.identify(distinctId);
window.FS.identify(distinctId);
}
track('Opened on Local')
} else {
if (window.FS) {
window.FS.shutdown()
}
isAnalyticsEnabled = false
}
resolve()
});
}
identify: id => {
if (envCheck) mixpanel.identify(id);
},
alias: id => {
export function initRemoteTracker({gatherUsageStats, email}: {gatherUsageStats?: boolean; email?: string}): void {
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()
}
}
}
map(user => {
if (!user.agreement) {
this.authService.saveLoginRedirectPath(state.url);
this.router.navigate(['/', 'agreement']);
if (environment.analytics && environment.mixpanelKey) {
const userHash = hashUserId(user.id);
mixpanel.alias(userHash);
mixpanel.identify(userHash);
}
} else {
if (environment.analytics && environment.mixpanelKey) {
const userHash = hashUserId(user.id);
mixpanel.identify(userHash);
}
}
return user.agreement;
})
);
function identifyInSentryAndMixpanel(host: string, userData: any): void {
if (process.env.DISABLE_MIXPANEL !== '1') {
mixpanel.identify((`${host} - ${userData.emailAddress}`));
mixpanel.people.set({
host,
version,
locale: userData.locale,
$timezone: userData.timeZone,
$name: userData.displayName,
$email: userData.emailAddress,
$distinct_id: `${host} - ${userData.emailAddress}`,
});
Sentry.configureScope((scope) => {
scope.setUser({
host,
locale: userData.locale,
timeZone: userData.timeZone,
name: userData.displayName,
email: userData.emailAddress,
identify: (id: string) => {
if (doTracking) { Mixpanel.identify(id); }
},
alias: (id: string) => {
function identifyInSentryAndMixpanel(host: URL, userData: User): void {
if (process.env.DISABLE_MIXPANEL !== '1') {
mixpanel.identify((`${host.origin} - ${userData.emailAddress}`));
mixpanel.people.set({
host: host.origin,
locale: userData.locale,
$timezone: userData.timeZone,
$name: userData.displayName,
$email: userData.emailAddress,
$distinct_id: `${host.origin} - ${userData.emailAddress}`,
});
Raven.setUserContext({
host: host.origin,
locale: userData.locale,
timeZone: userData.timeZone,
name: userData.displayName,
email: userData.emailAddress,
});
}