@bigbinary/neeto-commons-frontend 3.6.0-beta3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ const { TRANSFORM_RULES } = require("./constants");
2
+
1
3
  // eslint-disable-next-line @bigbinary/neeto/no-dangling-constants
2
4
  const VALID_ENVIRONMENTS = ["development", "test", "production"];
3
5
 
@@ -48,35 +50,7 @@ module.exports = function (api) {
48
50
  "babel-plugin-transform-react-remove-prop-types",
49
51
  { removeImport: true },
50
52
  ],
51
- [
52
- "transform-imports",
53
- {
54
- "@bigbinary/neetoui": {
55
- transform: "@bigbinary/neetoui/${member}",
56
- preventFullImport: true,
57
- },
58
- neetoui: {
59
- transform: "neetoui/${member}",
60
- preventFullImport: true,
61
- },
62
- "@bigbinary/neetoui/formik": {
63
- transform: "@bigbinary/neetoui/formik/${member}",
64
- preventFullImport: true,
65
- },
66
- "neetoui/formik": {
67
- transform: "neetoui/formik/${member}",
68
- preventFullImport: true,
69
- },
70
- "@bigbinary/neeto-thank-you-frontend": {
71
- transform: "@bigbinary/neeto-thank-you-frontend/${member}",
72
- preventFullImport: true,
73
- },
74
- neetothankyou: {
75
- transform: "neetothankyou/${member}",
76
- preventFullImport: true,
77
- },
78
- },
79
- ],
53
+ ...TRANSFORM_RULES,
80
54
  ].filter(Boolean),
81
55
  };
82
56
  };
@@ -0,0 +1,120 @@
1
+ const TRANSFORM_RULES = [
2
+ [
3
+ "transform-imports",
4
+ {
5
+ // neetoui
6
+ "@bigbinary/neetoui": {
7
+ transform: "@bigbinary/neetoui/${member}",
8
+ preventFullImport: true,
9
+ },
10
+ neetoui: {
11
+ transform: "neetoui/${member}",
12
+ preventFullImport: true,
13
+ },
14
+ "@bigbinary/neetoui/formik": {
15
+ transform: "@bigbinary/neetoui/formik/${member}",
16
+ preventFullImport: true,
17
+ },
18
+ "neetoui/formik": {
19
+ transform: "neetoui/formik/${member}",
20
+ preventFullImport: true,
21
+ },
22
+
23
+ // neeto-thank-you-frontend
24
+ "@bigbinary/neeto-thank-you-frontend": {
25
+ transform: "@bigbinary/neeto-thank-you-frontend/${member}",
26
+ preventFullImport: true,
27
+ },
28
+ neetothankyou: {
29
+ transform: "neetothankyou/${member}",
30
+ preventFullImport: true,
31
+ },
32
+
33
+ // neeto-payments-frontend
34
+ "@bigbinary/neeto-payments-frontend": {
35
+ transform: "@bigbinary/neeto-payments-frontend/${member}",
36
+ preventFullImport: true,
37
+ },
38
+ neetopayments: {
39
+ transform: "neetopayments/${member}",
40
+ preventFullImport: true,
41
+ },
42
+
43
+ // neeto-editor
44
+ "@bigbinary/neeto-editor": {
45
+ transform: importName => {
46
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
47
+ return `@bigbinary/neeto-editor/${importName}`;
48
+ }
49
+
50
+ return "@bigbinary/neeto-editor/utils";
51
+ },
52
+ preventFullImport: true,
53
+ skipDefaultConversion: true,
54
+ },
55
+ neetoeditor: {
56
+ transform: importName => {
57
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
58
+ return `neetoeditor/${importName}`;
59
+ }
60
+
61
+ return "neetoeditor/utils";
62
+ },
63
+ preventFullImport: true,
64
+ skipDefaultConversion: true,
65
+ },
66
+ "neetoeditor/([A-Z][a-zA-Z]+)$": {
67
+ transform: "neetoeditor/${member}",
68
+ preventFullImport: false,
69
+ },
70
+ "@bigbinary/neeto-editor/([A-Z][a-zA-Z]+)$": {
71
+ transform: "@bigbinary/neeto-editor/${member}",
72
+ preventFullImport: false,
73
+ },
74
+
75
+ // neeto-icons
76
+ "@bigbinary/neeto-icons": {
77
+ transform: "@bigbinary/neeto-icons/${member}",
78
+ preventFullImport: false,
79
+ },
80
+ neetoicons: {
81
+ transform: "neetoicons/${member}",
82
+ preventFullImport: false,
83
+ },
84
+ "@bigbinary/neeto-icons/typeface-logos": {
85
+ transform: "@bigbinary/neeto-icons/typeface-logos/${member}",
86
+ preventFullImport: false,
87
+ },
88
+ "neetoicons/typeface-logos": {
89
+ transform: "neetoicons/typeface-logos/${member}",
90
+ preventFullImport: false,
91
+ },
92
+ "@bigbinary/neeto-icons/app-icons": {
93
+ transform: "@bigbinary/neeto-icons/app-icons/${member}",
94
+ preventFullImport: false,
95
+ },
96
+ "neetoicons/app-icons": {
97
+ transform: "neetoicons/app-icons/${member}",
98
+ preventFullImport: false,
99
+ },
100
+ "@bigbinary/neeto-icons/neeto-logos": {
101
+ transform: "@bigbinary/neeto-icons/neeto-logos/${member}",
102
+ preventFullImport: false,
103
+ },
104
+ "neetoicons/neeto-logos": {
105
+ transform: "neetoicons/neeto-logos/${member}",
106
+ preventFullImport: false,
107
+ },
108
+ "@bigbinary/neeto-icons/misc": {
109
+ transform: "@bigbinary/neeto-icons/misc/${member}",
110
+ preventFullImport: false,
111
+ },
112
+ "neetoicons/misc": {
113
+ transform: "neetoicons/misc/${member}",
114
+ preventFullImport: false,
115
+ },
116
+ },
117
+ ],
118
+ ];
119
+
120
+ module.exports = { TRANSFORM_RULES };
@@ -22,7 +22,7 @@ var shouldNot = function shouldNot(skip) {
22
22
  return (0, _typeof2["default"])(skip) === "object" || !skip;
23
23
  };
24
24
  var shouldShowToastr = function shouldShowToastr(response) {
25
- return typeof response === "string" || (0, _typeof2["default"])(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
25
+ return typeof response === "string" && (0, _neetoCist.isNotEmpty)(response) || (0, _typeof2["default"])(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
26
26
  };
27
27
  var setAuthHeaders = function setAuthHeaders() {
28
28
  var _document$querySelect, _axios$defaults$heade;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_ramda","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","shouldNot","skip","_typeof2","shouldShowToastr","response","notice","noticeCode","setAuthHeaders","_document$querySelect","_axios$defaults$heade","axios","defaults","headers","_defineProperty2","HEADERS_KEYS","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","keysToCamelCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config$show","showToastr","matches","showThumbsUpToastr","Toastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","resetAuthTokens","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","toast","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","useErrorDisplayStore","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","evolve","omit","transformDataToSnakeCase","_request$transformReq","transformRequestCase","serializeKeysToSnakeCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer","setParamsSerializer"],"sources":["../../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport { keysToCamelCase, matches, serializeKeysToSnakeCase } from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n typeof response === \"string\" ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const { showToastr = true } = response.config;\n if (!showToastr) return response;\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAA+E,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAE/E,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,IAAAQ,iBAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAEA,IAAIU,mBAAmB,GAAG,IAAI;AAE9B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAI,IAAAC,QAAA,aAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC/B,OAAOA,QAAQ,KAAK,QAAQ,IAC3B,IAAAF,QAAA,aAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEC,MAAM,MAAID,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,UAAU,EAAE;AAAA;AAE9E,IAAMC,cAA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H,OAAO,CAAC,EAAEsB,sBAAsB,CAACvI,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEiH,OAAO,CAAC;EAEnE,IAAIlH,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC,EAAEuI,uBAAuB,CAAC1I,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAEc,SAASyI,eAAeA,CAAC5I,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE6I,OAAO,GAAEpI,iBAAK,CAACC,QAAQ,CAACmI,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAC7I,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE8I,WAAW,GAAExI,cAAc,EAAE;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE+I,gBAAgB,GAAE,IAAAC,4BAAmB,GAAE;EAElD,IAAIjJ,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEkD,YAAY,CAAC,EAAEyF,kBAAkB,CAAC3I,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEkD,YAAY,CAAC;AAC3E"}
1
+ {"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_ramda","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","shouldNot","skip","_typeof2","shouldShowToastr","response","isNotEmpty","notice","noticeCode","setAuthHeaders","_document$querySelect","_axios$defaults$heade","axios","defaults","headers","_defineProperty2","HEADERS_KEYS","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","keysToCamelCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config$show","showToastr","matches","showThumbsUpToastr","Toastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","resetAuthTokens","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","toast","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","useErrorDisplayStore","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","evolve","omit","transformDataToSnakeCase","_request$transformReq","transformRequestCase","serializeKeysToSnakeCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer","setParamsSerializer"],"sources":["../../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const { showToastr = true } = response.config;\n if (!showToastr) return response;\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if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uBAAJA,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAEc,SAAS0I,eAAeA,CAAC7I,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE8I,OAAO,GAAEpI,iBAAK,CAACC,QAAQ,CAACmI,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAC9I,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE+I,WAAW,GAAExI,cAAc,EAAE;EAExC,IAAI,EAACP,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEgJ,gBAAgB,GAAE,IAAAC,4BAAmB,GAAE;EAElD,IAAIlJ,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEmD,YAAY,CAAC,EAAEyF,kBAAkB,CAAC5I,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEmD,YAAY,CAAC;AAC3E"}
@@ -10,10 +10,12 @@ function initializeMixpanel(skip) {
10
10
  var _globalProps$user, _globalProps$organiza;
11
11
  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);
12
12
  if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
13
- var _globalProps$user2, _globalProps$organiza2;
13
+ var _globalProps$user2, _globalProps$user3, _globalProps$user4, _globalProps$organiza2;
14
14
  _mixpanelBrowser["default"].init(globalProps.mixpanelProjectToken);
15
15
  _mixpanelBrowser["default"].people.set({
16
- user: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email,
16
+ $first_name: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.firstName,
17
+ $last_name: (_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.lastName,
18
+ user: (_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.email,
17
19
  subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
18
20
  });
19
21
  _mixpanelBrowser["default"].identify(analyticsId);
@@ -1 +1 @@
1
- {"version":3,"file":"mixpanel.js","names":["_mixpanelBrowser","_interopRequireDefault","require","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","mixpanel","_globalProps$user2","_globalProps$organiza2","init","people","set","identify"],"sources":["../../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEW,QAAQ,GAAE;IAAA,IAAAC,kBAAA,EAAAC,sBAAA;IACvDF,2BAAQ,CAACG,IAAI,CAACT,WAAW,CAACK,oBAAoB,CAAC;IAC/CC,2BAAQ,CAACI,MAAM,CAACC,GAAG,CAAC;MAClBV,IAAI,GAAAM,kBAAA,GAAEP,WAAW,CAACC,IAAI,cAAAM,kBAAA,uBAAhBA,kBAAA,CAAkBL,KAAK;MAC7BE,SAAS,GAAAI,sBAAA,GAAER,WAAW,CAACG,YAAY,cAAAK,sBAAA,uBAAxBA,sBAAA,CAA0BJ;IACvC,CAAC,CAAC;IACFE,2BAAQ,CAACM,QAAQ,CAACd,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIQ,2BAAQ,CAACG,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
1
+ {"version":3,"file":"mixpanel.js","names":["_mixpanelBrowser","_interopRequireDefault","require","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","mixpanel","_globalProps$user2","_globalProps$user3","_globalProps$user4","_globalProps$organiza2","init","people","set","$first_name","firstName","$last_name","lastName","identify"],"sources":["../../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n $first_name: globalProps.user?.firstName,\n $last_name: globalProps.user?.lastName,\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":";;;;;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RULES } = require("./constants");
2
+
1
3
  // eslint-disable-next-line @bigbinary/neeto/no-dangling-constants
2
4
  const VALID_ENVIRONMENTS = ["development", "test", "production"];
3
5
 
@@ -48,35 +50,7 @@ module.exports = function (api) {
48
50
  "babel-plugin-transform-react-remove-prop-types",
49
51
  { removeImport: true },
50
52
  ],
51
- [
52
- "transform-imports",
53
- {
54
- "@bigbinary/neetoui": {
55
- transform: "@bigbinary/neetoui/${member}",
56
- preventFullImport: true,
57
- },
58
- neetoui: {
59
- transform: "neetoui/${member}",
60
- preventFullImport: true,
61
- },
62
- "@bigbinary/neetoui/formik": {
63
- transform: "@bigbinary/neetoui/formik/${member}",
64
- preventFullImport: true,
65
- },
66
- "neetoui/formik": {
67
- transform: "neetoui/formik/${member}",
68
- preventFullImport: true,
69
- },
70
- "@bigbinary/neeto-thank-you-frontend": {
71
- transform: "@bigbinary/neeto-thank-you-frontend/${member}",
72
- preventFullImport: true,
73
- },
74
- neetothankyou: {
75
- transform: "neetothankyou/${member}",
76
- preventFullImport: true,
77
- },
78
- },
79
- ],
53
+ ...TRANSFORM_RULES,
80
54
  ].filter(Boolean),
81
55
  };
82
56
  };
@@ -0,0 +1,120 @@
1
+ const TRANSFORM_RULES = [
2
+ [
3
+ "transform-imports",
4
+ {
5
+ // neetoui
6
+ "@bigbinary/neetoui": {
7
+ transform: "@bigbinary/neetoui/${member}",
8
+ preventFullImport: true,
9
+ },
10
+ neetoui: {
11
+ transform: "neetoui/${member}",
12
+ preventFullImport: true,
13
+ },
14
+ "@bigbinary/neetoui/formik": {
15
+ transform: "@bigbinary/neetoui/formik/${member}",
16
+ preventFullImport: true,
17
+ },
18
+ "neetoui/formik": {
19
+ transform: "neetoui/formik/${member}",
20
+ preventFullImport: true,
21
+ },
22
+
23
+ // neeto-thank-you-frontend
24
+ "@bigbinary/neeto-thank-you-frontend": {
25
+ transform: "@bigbinary/neeto-thank-you-frontend/${member}",
26
+ preventFullImport: true,
27
+ },
28
+ neetothankyou: {
29
+ transform: "neetothankyou/${member}",
30
+ preventFullImport: true,
31
+ },
32
+
33
+ // neeto-payments-frontend
34
+ "@bigbinary/neeto-payments-frontend": {
35
+ transform: "@bigbinary/neeto-payments-frontend/${member}",
36
+ preventFullImport: true,
37
+ },
38
+ neetopayments: {
39
+ transform: "neetopayments/${member}",
40
+ preventFullImport: true,
41
+ },
42
+
43
+ // neeto-editor
44
+ "@bigbinary/neeto-editor": {
45
+ transform: importName => {
46
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
47
+ return `@bigbinary/neeto-editor/${importName}`;
48
+ }
49
+
50
+ return "@bigbinary/neeto-editor/utils";
51
+ },
52
+ preventFullImport: true,
53
+ skipDefaultConversion: true,
54
+ },
55
+ neetoeditor: {
56
+ transform: importName => {
57
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
58
+ return `neetoeditor/${importName}`;
59
+ }
60
+
61
+ return "neetoeditor/utils";
62
+ },
63
+ preventFullImport: true,
64
+ skipDefaultConversion: true,
65
+ },
66
+ "neetoeditor/([A-Z][a-zA-Z]+)$": {
67
+ transform: "neetoeditor/${member}",
68
+ preventFullImport: false,
69
+ },
70
+ "@bigbinary/neeto-editor/([A-Z][a-zA-Z]+)$": {
71
+ transform: "@bigbinary/neeto-editor/${member}",
72
+ preventFullImport: false,
73
+ },
74
+
75
+ // neeto-icons
76
+ "@bigbinary/neeto-icons": {
77
+ transform: "@bigbinary/neeto-icons/${member}",
78
+ preventFullImport: false,
79
+ },
80
+ neetoicons: {
81
+ transform: "neetoicons/${member}",
82
+ preventFullImport: false,
83
+ },
84
+ "@bigbinary/neeto-icons/typeface-logos": {
85
+ transform: "@bigbinary/neeto-icons/typeface-logos/${member}",
86
+ preventFullImport: false,
87
+ },
88
+ "neetoicons/typeface-logos": {
89
+ transform: "neetoicons/typeface-logos/${member}",
90
+ preventFullImport: false,
91
+ },
92
+ "@bigbinary/neeto-icons/app-icons": {
93
+ transform: "@bigbinary/neeto-icons/app-icons/${member}",
94
+ preventFullImport: false,
95
+ },
96
+ "neetoicons/app-icons": {
97
+ transform: "neetoicons/app-icons/${member}",
98
+ preventFullImport: false,
99
+ },
100
+ "@bigbinary/neeto-icons/neeto-logos": {
101
+ transform: "@bigbinary/neeto-icons/neeto-logos/${member}",
102
+ preventFullImport: false,
103
+ },
104
+ "neetoicons/neeto-logos": {
105
+ transform: "neetoicons/neeto-logos/${member}",
106
+ preventFullImport: false,
107
+ },
108
+ "@bigbinary/neeto-icons/misc": {
109
+ transform: "@bigbinary/neeto-icons/misc/${member}",
110
+ preventFullImport: false,
111
+ },
112
+ "neetoicons/misc": {
113
+ transform: "neetoicons/misc/${member}",
114
+ preventFullImport: false,
115
+ },
116
+ },
117
+ ],
118
+ ];
119
+
120
+ module.exports = { TRANSFORM_RULES };
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _typeof from "@babel/runtime/helpers/typeof";
3
3
  import axios from "axios";
4
4
  import i18next from "i18next";
5
- import { keysToCamelCase, matches, serializeKeysToSnakeCase } from "@bigbinary/neeto-cist";
5
+ import { isNotEmpty, keysToCamelCase, matches, serializeKeysToSnakeCase } from "@bigbinary/neeto-cist";
6
6
  import Toastr from "@bigbinary/neetoui/Toastr";
7
7
  import { evolve, omit } from "ramda";
8
8
  import { toast } from "react-toastify";
@@ -15,7 +15,7 @@ var shouldNot = function shouldNot(skip) {
15
15
  return _typeof(skip) === "object" || !skip;
16
16
  };
17
17
  var shouldShowToastr = function shouldShowToastr(response) {
18
- return typeof response === "string" || _typeof(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
18
+ return typeof response === "string" && isNotEmpty(response) || _typeof(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
19
19
  };
20
20
  var setAuthHeaders = function setAuthHeaders() {
21
21
  var _document$querySelect, _axios$defaults$heade;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["axios","i18next","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","evolve","omit","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","shouldNot","skip","_typeof","shouldShowToastr","response","notice","noticeCode","setAuthHeaders","_document$querySelect","_axios$defaults$heade","defaults","headers","_defineProperty","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config$show","showToastr","showThumbsUpToastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","transformDataToSnakeCase","_request$transformReq","transformRequestCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer"],"sources":["../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport { keysToCamelCase, matches, serializeKeysToSnakeCase } from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n typeof response === \"string\" ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const { showToastr = true } = response.config;\n if (!showToastr) return response;\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SAASC,eAAe,EAAEC,OAAO,EAAEC,wBAAwB;AAAoB,OAAAC,MAAA;AAE/E,SAASC,MAAM,EAAEC,IAAI,QAAQ,OAAO;AACpC,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,OAAOC,mBAAmB;AAE1B,SAASC,YAAY,EAAEC,wBAAwB;AAE/C,IAAIC,mBAAmB,GAAG,IAAI;AAE9B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAIC,OAAA,CAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC/B,OAAOA,QAAQ,KAAK,QAAQ,IAC3BF,OAAA,CAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEC,MAAM,MAAID,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,UAAU,EAAE;AAAA;AAE9E,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAA,EAAS;EAAA,IAAAC,qBAAA,EAAAC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,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC,EAAE0H,uBAAuB,CAAC7H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAED,eAAe,SAAS4H,eAAeA,CAAC/H,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEgI,OAAO,GAAEhJ,KAAK,CAACyB,QAAQ,CAACuH,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAChI,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEiI,WAAW,GAAE3H,cAAc,EAAE;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEkI,gBAAgB,GAAEvI,mBAAmB,EAAE;EAElD,IAAII,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC,EAAEiF,kBAAkB,CAAC9H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC;AAC3E"}
1
+ {"version":3,"file":"index.js","names":["axios","i18next","isNotEmpty","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","evolve","omit","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","shouldNot","skip","_typeof","shouldShowToastr","response","notice","noticeCode","setAuthHeaders","_document$querySelect","_axios$defaults$heade","defaults","headers","_defineProperty","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config$show","showToastr","showThumbsUpToastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","transformDataToSnakeCase","_request$transformReq","transformRequestCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer"],"sources":["../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const { showToastr = true } = response.config;\n if (!showToastr) return response;\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SACEC,UAAU,EACVC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,CAAEkI,gBAAgB,GAAEvI,mBAAmB,EAAE;EAElD,IAAII,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC,EAAEiF,kBAAkB,CAAC9H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC;AAC3E"}
@@ -3,10 +3,12 @@ export default function initializeMixpanel(skip) {
3
3
  var _globalProps$user, _globalProps$organiza;
4
4
  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);
5
5
  if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
6
- var _globalProps$user2, _globalProps$organiza2;
6
+ var _globalProps$user2, _globalProps$user3, _globalProps$user4, _globalProps$organiza2;
7
7
  mixpanel.init(globalProps.mixpanelProjectToken);
8
8
  mixpanel.people.set({
9
- user: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email,
9
+ $first_name: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.firstName,
10
+ $last_name: (_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.lastName,
11
+ user: (_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.email,
10
12
  subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
11
13
  });
12
14
  mixpanel.identify(analyticsId);
@@ -1 +1 @@
1
- {"version":3,"file":"mixpanel.js","names":["mixpanel","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","_globalProps$user2","_globalProps$organiza2","init","people","set","identify"],"sources":["../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAEvC,eAAe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEF,QAAQ,GAAE;IAAA,IAAAa,kBAAA,EAAAC,sBAAA;IACvDd,QAAQ,CAACe,IAAI,CAACR,WAAW,CAACK,oBAAoB,CAAC;IAC/CZ,QAAQ,CAACgB,MAAM,CAACC,GAAG,CAAC;MAClBT,IAAI,GAAAK,kBAAA,GAAEN,WAAW,CAACC,IAAI,cAAAK,kBAAA,uBAAhBA,kBAAA,CAAkBJ,KAAK;MAC7BE,SAAS,GAAAG,sBAAA,GAAEP,WAAW,CAACG,YAAY,cAAAI,sBAAA,uBAAxBA,sBAAA,CAA0BH;IACvC,CAAC,CAAC;IACFX,QAAQ,CAACkB,QAAQ,CAACb,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIL,QAAQ,CAACe,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
1
+ {"version":3,"file":"mixpanel.js","names":["mixpanel","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","_globalProps$user2","_globalProps$user3","_globalProps$user4","_globalProps$organiza2","init","people","set","$first_name","firstName","$last_name","lastName","identify"],"sources":["../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n $first_name: globalProps.user?.firstName,\n $last_name: globalProps.user?.lastName,\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAEvC,eAAe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEF,QAAQ,GAAE;IAAA,IAAAa,kBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,sBAAA;IACvDhB,QAAQ,CAACiB,IAAI,CAACV,WAAW,CAACK,oBAAoB,CAAC;IAC/CZ,QAAQ,CAACkB,MAAM,CAACC,GAAG,CAAC;MAClBC,WAAW,GAAAP,kBAAA,GAAEN,WAAW,CAACC,IAAI,cAAAK,kBAAA,uBAAhBA,kBAAA,CAAkBQ,SAAS;MACxCC,UAAU,GAAAR,kBAAA,GAAEP,WAAW,CAACC,IAAI,cAAAM,kBAAA,uBAAhBA,kBAAA,CAAkBS,QAAQ;MACtCf,IAAI,GAAAO,kBAAA,GAAER,WAAW,CAACC,IAAI,cAAAO,kBAAA,uBAAhBA,kBAAA,CAAkBN,KAAK;MAC7BE,SAAS,GAAAK,sBAAA,GAAET,WAAW,CAACG,YAAY,cAAAM,sBAAA,uBAAxBA,sBAAA,CAA0BL;IACvC,CAAC,CAAC;IACFX,QAAQ,CAACwB,QAAQ,CAACnB,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIL,QAAQ,CAACiB,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "3.6.0-beta3",
3
+ "version": "4.0.0",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -103,4 +103,4 @@
103
103
  "webpack": "^5.75.0",
104
104
  "yup": "^1.3.3"
105
105
  }
106
- }
106
+ }