All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.initializers.mixpanel.js Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
import mixpanel from "mixpanel-browser";
export default 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.init(globalProps.mixpanelProjectToken);
    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.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.init("TEST_TOKEN");
  }
}
//# sourceMappingURL=mixpanel.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy