How to use the mixpanel-browser/src/loader-module.init function in mixpanel-browser

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 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() });
    }
  }
}