<commit_before>import {readEnv} from '../app/assets/javascripts/envForJs';

// Load Rollbar and Mixpanel
// This file expects readEnv() to work because data has been
// written to the page on boot.
const {
  shouldReportErrors,
  rollbarJsAccessToken,
  shouldReportAnalytics,
  mixpanelToken
} = readEnv();
if (shouldReportErrors && rollbarJsAccessToken) loadRollbar();
if (shouldReportAnalytics && mixpanelToken) loadMixpanel();


function loadMixpanel() {
  // Pasted loader stub
  /* eslint-disable */
  (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
  /* eslint-enable */

  // Our code
  window.mixpanel.init(readEnv().mixpanelToken);
  window.mixpanel.set_config({
    track_pageview: true,
    secure_cookie: true
  });
}
  

function loadRollbar() {
  loadRollbarLibrary({
    accessToken: readEnv().rollbarJsAccessToken,
    captureUncaught: true,
    captureUnhandledRejections: true,
    transform: transform,
    autoInstrument: {<commit_msg>Set Mixpanel cookie to isolate across subdomains<commit_after>import {readEnv} from '../app/assets/javascripts/envForJs';

// Load Rollbar and Mixpanel
// This file expects readEnv() to work because data has been
// written to the page on boot.
const {
  shouldReportErrors,
  rollbarJsAccessToken,
  shouldReportAnalytics,
  mixpanelToken
} = readEnv();
if (shouldReportErrors && rollbarJsAccessToken) loadRollbar();
if (shouldReportAnalytics && mixpanelToken) loadMixpanel();


function loadMixpanel() {
  // Pasted loader stub
  /* eslint-disable */
  (function(e,b){if(!b.__SV){var a,f,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" "); for(g=0;g<i.length;g++)f(c,i[g]);b._i.push([a,e,d])};b.__SV=1.2;a=e.createElement("script");a.type="text/javascript";a.async=!0;a.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";f=e.getElementsByTagName("script")[0];f.parentNode.insertBefore(a,f)}})(document,window.mixpanel||[]);
  /* eslint-enable */

  // Our code
  window.mixpanel.init(readEnv().mixpanelToken);
  window.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
  });
}
  

function loadRollbar() {
  loadRollbarLibrary({
    accessToken: readEnv().rollbarJsAccessToken,
    captureUncaught: true,
    captureUnhandledRejections: true,
    transform: transform,
    autoInstrument: {
{'fraction_non_alphanumeric': 0.1913896944010707, 'fraction_numerical': 0.008476466651795673, 'mean_word_length': 6.350819672131148, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3463158', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1611, 'n_words': 205}