How to use mixpanel-browser - 10 common examples

To help you get started, we’ve selected a few mixpanel-browser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joshwcomeau / guppy / src / services / analytics.service.js View on Github external
export const createLogger = (environment?: ?string = process.env.NODE_ENV) => {
  mixpanel.init(MIXPANEL_KEY);

  // Every user is given a distinct ID so that we can track return visits.
  // Because electron doesn't persist cookies, we have to do this ourselves.
  let distinctId = electronStore.get(DISTINCT_ID_KEY);
  if (!distinctId) {
    distinctId = uuid();
    electronStore.set(DISTINCT_ID_KEY, distinctId);
  }

  mixpanel.identify(distinctId);

  return {
    logEvent: (event: EventType, data: any) => {
      if (environment !== 'production') {
        console.info('Event tracked', event, data);
        return;
github studentinsights / studentinsights / app / assets / javascripts / helpers / MixpanelUtils.js View on Github external
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
github studentinsights / studentinsights / app / assets / javascripts / helpers / MixpanelUtils.js View on Github external
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
    }
  },
github studentinsights / studentinsights / app / assets / javascripts / helpers / MixpanelUtils.js View on Github external
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
    }
github bodhiproject / bodhi-ui / src / helpers / mixpanelUtil.js View on Github external
static track(eventName) {
    if (process.env && process.env.NODE_ENV !== 'production') {
      return;
    }

    if (_.isEmpty(eventName)) {
      console.error('Mixpanel eventName cannot be empty'); // eslint-disable-line
      return;
    }

    // Instantiate if not instantiated yet
    if (!initialized) {
      mixpanel.init(MIXPANEL_TOKEN);
      initialized = true;
    }

    // Only track in production build
    if (process.env && process.env.NODE_ENV === 'production') {
      mixpanel.track(eventName, { id: getTrackingId() });
    }
  }
}
github bodhiproject / bodhi-ui / src / helpers / mixpanelUtil.js View on Github external
}

    if (_.isEmpty(eventName)) {
      console.error('Mixpanel eventName cannot be empty'); // eslint-disable-line
      return;
    }

    // Instantiate if not instantiated yet
    if (!initialized) {
      mixpanel.init(MIXPANEL_TOKEN);
      initialized = true;
    }

    // Only track in production build
    if (process.env && process.env.NODE_ENV === 'production') {
      mixpanel.track(eventName, { id: getTrackingId() });
    }
  }
}
github DataTurks / DataTurks / bazaar / src / helpers / dthelper.js View on Github external
export const logEvent = (category, action, label) => {
  try {
    if (label) {
      ReactGA.event({
        category,
        action,
        label
      });
      mixpanel.track(action);
    } else {
      ReactGA.event({
        category,
        action
      });
      mixpanel.track(action);
    }
  } catch (exception) {
    // statements
    console.log(exception);
  }
};
github rodi01 / RenameIt / resources / views / components / findReplaceLayer / index.jsx View on Github external
replaceFocus: false,
      previewData: [],
      searchScope: this.hasSelection > 0 ? "layers" : "page"
    }
    this.findReplace = new FindReplace()
    this.enterFunction = this.enterFunction.bind(this)
    this.onSubmit = this.onSubmit.bind(this)
    this.onCaseSensitiveChange = this.onCaseSensitiveChange.bind(this)
    this.handleFindHistory = this.handleFindHistory.bind(this)
    this.handleRadioSelection = this.handleRadioSelection.bind(this)
    this.handleReplaceHistory = this.handleReplaceHistory.bind(this)
    this.onChange = this.onChange.bind(this)
    this.clearInput = this.clearInput.bind(this)

    // Tracking
    mixpanel.init(mixpanelId)
  }
github pubpub / pubpub / src / client.js View on Github external
import { useRouterHistory } from 'react-router';

import createStore from './createStore';
import ApiClient from './helpers/ApiClient';
// import io from 'socket.io-client';
import {Provider} from 'react-redux';
import {reduxReactRouter, ReduxRouter} from 'redux-router';
import match from 'react-router/lib/match';

import getRoutes from './routes';
import makeRouteHooksSafe from './helpers/makeRouteHooksSafe';

import ga from 'react-ga';
import mixpanel from 'mixpanel-browser';
ga.initialize('UA-61723493-3');
mixpanel.init('f85adcbd0f97f6101ebd440e931197b2');

const client = new ApiClient();
import Html from './helpers/Html';

const appHistory = useScroll(useRouterHistory(createBrowserHistory))();

const newHistory = () => appHistory;

const dest = document.getElementById('content');
const store = createStore(reduxReactRouter, makeRouteHooksSafe(getRoutes), newHistory, client, window.__INITIAL_STATE__);

const routes = getRoutes(store, history);
const component = (
github pingcap / tidb-dashboard / ui / lib / utils / telemetry.ts View on Github external
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()
  }
}