'use strict';

var mixpanel_module = require('../mixpanel.module-ajRn5e0J.js');

function initializeMixpanel(skip) {
  var _globalProps$user, _globalProps$organiza;
  var analyticsId = "".concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email, "-").concat((_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain);
  if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
    var _globalProps$user2, _globalProps$user3, _globalProps$user4, _globalProps$user5, _globalProps$organiza2;
    mixpanel_module.mixpanel.init(globalProps.mixpanelProjectToken);
    mixpanel_module.mixpanel.people.set({
      $first_name: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.firstName,
      $last_name: (_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.lastName,
      $email: (_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.email,
      user: (_globalProps$user5 = globalProps.user) === null || _globalProps$user5 === void 0 ? void 0 : _globalProps$user5.email,
      subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
    });
    mixpanel_module.mixpanel.identify(analyticsId);
  } else {
    /*
    We need to initialize mixpanel with a bogus token in development and test environment to
    prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.
    */
    mixpanel_module.mixpanel.init("TEST_TOKEN");
  }
}

module.exports = initializeMixpanel;
//# sourceMappingURL=mixpanel.js.map
