package.cjs.initializers.mixpanel.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = initializeMixpanel;
var _mixpanelBrowser = _interopRequireDefault(require("mixpanel-browser"));
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;
_mixpanelBrowser["default"].init(globalProps.mixpanelProjectToken);
_mixpanelBrowser["default"].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
});
_mixpanelBrowser["default"].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.
*/
_mixpanelBrowser["default"].init("TEST_TOKEN");
}
}
//# sourceMappingURL=mixpanel.js.map