@workleap/mixpanel 4.0.6 → 4.0.8

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @workleap/mixpanel
2
2
 
3
+ ## 4.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#133](https://github.com/workleap/wl-telemetry/pull/133) [`c1bd63a`](https://github.com/workleap/wl-telemetry/commit/c1bd63a18764ac34db9a1bafcc861fc87b5ce1f7) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped dependencies.
8
+
9
+ - Updated dependencies [[`c1bd63a`](https://github.com/workleap/wl-telemetry/commit/c1bd63a18764ac34db9a1bafcc861fc87b5ce1f7)]:
10
+ - @workleap/logrocket@2.1.8
11
+ - @workleap-telemetry/core@1.0.7
12
+
13
+ ## 4.0.7
14
+
15
+ ### Patch Changes
16
+
17
+ - [#129](https://github.com/workleap/wl-telemetry/pull/129) [`2b3bf24`](https://github.com/workleap/wl-telemetry/commit/2b3bf24e69abdcfe33c0bd3ce09350ec4f49d9ff) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Bumped dependency versions.
18
+
19
+ - Updated dependencies [[`2b3bf24`](https://github.com/workleap/wl-telemetry/commit/2b3bf24e69abdcfe33c0bd3ce09350ec4f49d9ff)]:
20
+ - @workleap/logrocket@2.1.7
21
+ - @workleap-telemetry/core@1.0.6
22
+
3
23
  ## 4.0.6
4
24
 
5
25
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"js/MixpanelClient.js","sources":["webpack://@workleap/mixpanel/./src/js/MixpanelClient.ts"],"sourcesContent":["import type { CreateMixpanelTrackingFunctionOptions, MixpanelTrackingFunction } from \"@workleap-telemetry/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport { getBaseProperties } from \"./properties.ts\";\n\nexport type MixpanelGlobalEventProperties = Map<string, unknown>;\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface MixpanelClient {\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n createTrackingFunction: (options: CreateMixpanelTrackingFunctionOptions) => MixpanelTrackingFunction;\n\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n setGlobalEventProperty: (key: string, value: unknown) => void;\n\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n setGlobalEventProperties: (values: Record<string, unknown>) => void;\n}\n\nexport class MixpanelClientImpl implements MixpanelClient {\n readonly #productId: string;\n readonly #endpoint: string;\n readonly #globalEventProperties: MixpanelGlobalEventProperties;\n readonly #logger: Logger;\n\n constructor(productId: string, endpoint: string, globalEventProperties: MixpanelGlobalEventProperties, logger: Logger) {\n this.#productId = productId;\n this.#endpoint = endpoint;\n this.#globalEventProperties = globalEventProperties;\n this.#logger = logger;\n }\n\n // IMPORTANT: If you update this method, make sure to update the MixpanelPartialClient\n // interface as well in @workleap-telemetry/core.\n createTrackingFunction(options: CreateMixpanelTrackingFunctionOptions = {}) {\n const {\n targetProductId\n } = options;\n\n const trackFunction: MixpanelTrackingFunction = async (eventName, properties, _options = {}) => {\n try {\n const {\n keepAlive = false\n } = _options;\n\n const baseProperties = getBaseProperties();\n\n const allProperties = {\n ...baseProperties,\n ...Object.fromEntries(this.#globalEventProperties),\n ...properties\n };\n\n await fetch(this.#endpoint, {\n method: \"POST\",\n credentials: \"include\",\n keepalive: keepAlive,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n eventName,\n productIdentifier: this.#productId,\n // Not sure why, but it seems important to send \"null\" if not target product identifier\n // are provided.\n targetProductIdentifier: targetProductId ?? null,\n properties: allProperties\n })\n });\n } catch (error: unknown) {\n this.#logger\n .withText(`[mixpanel] An error occurred while sending a tracking event to \"${this.#endpoint}\":`)\n .withError(error as Error)\n .error();\n }\n };\n\n return trackFunction;\n }\n\n setGlobalEventProperty(key: string, value: unknown) {\n this.#globalEventProperties.set(key, value);\n }\n\n setGlobalEventProperties(values: Record<string, unknown>) {\n Object.keys(values).forEach(x => {\n this.#globalEventProperties.set(x, values[x]);\n });\n }\n}\n"],"names":["getBaseProperties","MixpanelClientImpl","productId","endpoint","globalEventProperties","logger","options","targetProductId","trackFunction","eventName","properties","_options","keepAlive","baseProperties","allProperties","Object","fetch","JSON","error","key","value","values","x"],"mappings":";;;;;AAEoD;AAwB7C,MAAMC;IACA,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,sBAAsB,CAAgC;IACtD,OAAO,CAAS;IAEzB,YAAYC,SAAiB,EAAEC,QAAgB,EAAEC,qBAAoD,EAAEC,MAAc,CAAE;QACnH,IAAI,CAAC,UAAU,GAAGH;QAClB,IAAI,CAAC,SAAS,GAAGC;QACjB,IAAI,CAAC,sBAAsB,GAAGC;QAC9B,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,sFAAsF;IACtF,iDAAiD;IACjD,uBAAuBC,UAAiD,CAAC,CAAC,EAAE;QACxE,MAAM,EACFC,eAAe,EAClB,GAAGD;QAEJ,MAAME,gBAA0C,OAAOC,WAAWC,YAAYC,WAAW,CAAC,CAAC;YACvF,IAAI;gBACA,MAAM,EACFC,YAAY,KAAK,EACpB,GAAGD;gBAEJ,MAAME,iBAAiBb,iBAAiBA;gBAExC,MAAMc,gBAAgB;oBAClB,GAAGD,cAAc;oBACjB,GAAGE,OAAO,WAAW,CAAC,IAAI,CAAC,sBAAsB,CAAC;oBAClD,GAAGL,UAAU;gBACjB;gBAEA,MAAMM,MAAM,IAAI,CAAC,SAAS,EAAE;oBACxB,QAAQ;oBACR,aAAa;oBACb,WAAWJ;oBACX,SAAS;wBAAE,gBAAgB;oBAAmB;oBAC9C,MAAMK,KAAK,SAAS,CAAC;wBACjBR;wBACA,mBAAmB,IAAI,CAAC,UAAU;wBAClC,uFAAuF;wBACvF,gBAAgB;wBAChB,yBAAyBF,mBAAmB;wBAC5C,YAAYO;oBAChB;gBACJ;YACJ,EAAE,OAAOI,OAAgB;gBACrB,IAAI,CAAC,OAAO,CACP,QAAQ,CAAC,CAAC,gEAAgE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAC9F,SAAS,CAACA,OACV,KAAK;YACd;QACJ;QAEA,OAAOV;IACX;IAEA,uBAAuBW,GAAW,EAAEC,KAAc,EAAE;QAChD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACD,KAAKC;IACzC;IAEA,yBAAyBC,MAA+B,EAAE;QACtDN,OAAO,IAAI,CAACM,QAAQ,OAAO,CAACC,CAAAA;YACxB,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACA,GAAGD,MAAM,CAACC,EAAE;QAChD;IACJ;AACJ"}
1
+ {"version":3,"file":"js/MixpanelClient.js","sources":["../../src/js/MixpanelClient.ts"],"sourcesContent":["import type { CreateMixpanelTrackingFunctionOptions, MixpanelTrackingFunction } from \"@workleap-telemetry/core\";\nimport type { Logger } from \"@workleap/logging\";\nimport { getBaseProperties } from \"./properties.ts\";\n\nexport type MixpanelGlobalEventProperties = Map<string, unknown>;\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface MixpanelClient {\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n createTrackingFunction: (options: CreateMixpanelTrackingFunctionOptions) => MixpanelTrackingFunction;\n\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n setGlobalEventProperty: (key: string, value: unknown) => void;\n\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n setGlobalEventProperties: (values: Record<string, unknown>) => void;\n}\n\nexport class MixpanelClientImpl implements MixpanelClient {\n readonly #productId: string;\n readonly #endpoint: string;\n readonly #globalEventProperties: MixpanelGlobalEventProperties;\n readonly #logger: Logger;\n\n constructor(productId: string, endpoint: string, globalEventProperties: MixpanelGlobalEventProperties, logger: Logger) {\n this.#productId = productId;\n this.#endpoint = endpoint;\n this.#globalEventProperties = globalEventProperties;\n this.#logger = logger;\n }\n\n // IMPORTANT: If you update this method, make sure to update the MixpanelPartialClient\n // interface as well in @workleap-telemetry/core.\n createTrackingFunction(options: CreateMixpanelTrackingFunctionOptions = {}) {\n const {\n targetProductId\n } = options;\n\n const trackFunction: MixpanelTrackingFunction = async (eventName, properties, _options = {}) => {\n try {\n const {\n keepAlive = false\n } = _options;\n\n const baseProperties = getBaseProperties();\n\n const allProperties = {\n ...baseProperties,\n ...Object.fromEntries(this.#globalEventProperties),\n ...properties\n };\n\n await fetch(this.#endpoint, {\n method: \"POST\",\n credentials: \"include\",\n keepalive: keepAlive,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n eventName,\n productIdentifier: this.#productId,\n // Not sure why, but it seems important to send \"null\" if not target product identifier\n // are provided.\n targetProductIdentifier: targetProductId ?? null,\n properties: allProperties\n })\n });\n } catch (error: unknown) {\n this.#logger\n .withText(`[mixpanel] An error occurred while sending a tracking event to \"${this.#endpoint}\":`)\n .withError(error as Error)\n .error();\n }\n };\n\n return trackFunction;\n }\n\n setGlobalEventProperty(key: string, value: unknown) {\n this.#globalEventProperties.set(key, value);\n }\n\n setGlobalEventProperties(values: Record<string, unknown>) {\n Object.keys(values).forEach(x => {\n this.#globalEventProperties.set(x, values[x]);\n });\n }\n}\n"],"names":["getBaseProperties","MixpanelClientImpl","productId","endpoint","globalEventProperties","logger","options","targetProductId","trackFunction","eventName","properties","_options","keepAlive","baseProperties","allProperties","Object","fetch","JSON","error","key","value","values","x"],"mappings":";;;;;AAEoD;AAwB7C,MAAMC;IACA,UAAU,CAAS;IACnB,SAAS,CAAS;IAClB,sBAAsB,CAAgC;IACtD,OAAO,CAAS;IAEzB,YAAYC,SAAiB,EAAEC,QAAgB,EAAEC,qBAAoD,EAAEC,MAAc,CAAE;QACnH,IAAI,CAAC,UAAU,GAAGH;QAClB,IAAI,CAAC,SAAS,GAAGC;QACjB,IAAI,CAAC,sBAAsB,GAAGC;QAC9B,IAAI,CAAC,OAAO,GAAGC;IACnB;IAEA,sFAAsF;IACtF,iDAAiD;IACjD,uBAAuBC,UAAiD,CAAC,CAAC,EAAE;QACxE,MAAM,EACFC,eAAe,EAClB,GAAGD;QAEJ,MAAME,gBAA0C,OAAOC,WAAWC,YAAYC,WAAW,CAAC,CAAC;YACvF,IAAI;gBACA,MAAM,EACFC,YAAY,KAAK,EACpB,GAAGD;gBAEJ,MAAME,iBAAiBb,iBAAiBA;gBAExC,MAAMc,gBAAgB;oBAClB,GAAGD,cAAc;oBACjB,GAAGE,OAAO,WAAW,CAAC,IAAI,CAAC,sBAAsB,CAAC;oBAClD,GAAGL,UAAU;gBACjB;gBAEA,MAAMM,MAAM,IAAI,CAAC,SAAS,EAAE;oBACxB,QAAQ;oBACR,aAAa;oBACb,WAAWJ;oBACX,SAAS;wBAAE,gBAAgB;oBAAmB;oBAC9C,MAAMK,KAAK,SAAS,CAAC;wBACjBR;wBACA,mBAAmB,IAAI,CAAC,UAAU;wBAClC,uFAAuF;wBACvF,gBAAgB;wBAChB,yBAAyBF,mBAAmB;wBAC5C,YAAYO;oBAChB;gBACJ;YACJ,EAAE,OAAOI,OAAgB;gBACrB,IAAI,CAAC,OAAO,CACP,QAAQ,CAAC,CAAC,gEAAgE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAC9F,SAAS,CAACA,OACV,KAAK;YACd;QACJ;QAEA,OAAOV;IACX;IAEA,uBAAuBW,GAAW,EAAEC,KAAc,EAAE;QAChD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACD,KAAKC;IACzC;IAEA,yBAAyBC,MAA+B,EAAE;QACtDN,OAAO,IAAI,CAACM,QAAQ,OAAO,CAACC,CAAAA;YACxB,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACA,GAAGD,MAAM,CAACC,EAAE;QAChD;IACJ;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/NoopMixpanelClient.js","sources":["webpack://@workleap/mixpanel/./src/js/NoopMixpanelClient.ts"],"sourcesContent":["import type { MixpanelClient } from \"./MixpanelClient.ts\";\n\nexport class NoopMixpanelClient implements MixpanelClient {\n createTrackingFunction() {\n return () => Promise.resolve();\n }\n\n setGlobalEventProperty() {}\n setGlobalEventProperties() {}\n}\n"],"names":["NoopMixpanelClient","Promise"],"mappings":";;AAEO,MAAMA;IACT,yBAAyB;QACrB,OAAO,IAAMC,QAAQ,OAAO;IAChC;IAEA,yBAAyB,CAAC;IAC1B,2BAA2B,CAAC;AAChC"}
1
+ {"version":3,"file":"js/NoopMixpanelClient.js","sources":["../../src/js/NoopMixpanelClient.ts"],"sourcesContent":["import type { MixpanelClient } from \"./MixpanelClient.ts\";\n\nexport class NoopMixpanelClient implements MixpanelClient {\n createTrackingFunction() {\n return () => Promise.resolve();\n }\n\n setGlobalEventProperty() {}\n setGlobalEventProperties() {}\n}\n"],"names":["NoopMixpanelClient","Promise"],"mappings":";;AAEO,MAAMA;IACT,yBAAyB;QACrB,OAAO,IAAMC,QAAQ,OAAO;IAChC;IAEA,yBAAyB,CAAC;IAC1B,2BAA2B,CAAC;AAChC"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/context.js","sources":["webpack://@workleap/mixpanel/./src/js/context.ts"],"sourcesContent":["// DEPRECATED: Grace period ends on January 1th 2026.\n// Must keep this code until the end of the grace period because host applications using version 2.* of\n// this package would get runtime errors from the Platform Widgets CDN otherwise.\n\nimport type { Logger } from \"@workleap/logging\";\nimport type { MixpanelGlobalEventProperties } from \"./MixpanelClient.ts\";\n\nexport const MixpanelContextVariableName = \"__WLP_MIXPANEL_CONTEXT__\";\n\nexport interface MixpanelContext {\n productId: string;\n endpoint: string;\n globalEventProperties: MixpanelGlobalEventProperties;\n logger: Logger;\n}\n\nexport function setMixpanelContext(context: MixpanelContext) {\n // Will be used by the \"track\" function.\n // It's important to share the context with a global DOM object rather than\n // a singleton because projects like the platform widgets will use a distinct instance\n // of this package than the host application.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[MixpanelContextVariableName] = context;\n}\n\nexport function getMixpanelContext() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const context = globalThis[MixpanelContextVariableName] as MixpanelContext;\n\n if (!context) {\n throw new Error(\"[mixpanel] The Mixpanel context is not available. Did you initialize Mixpanel with the \\\"initializeMixpanel\\\" function?\");\n }\n\n return context;\n}\n\n"],"names":["MixpanelContextVariableName","setMixpanelContext","context","globalThis","getMixpanelContext","Error"],"mappings":";;AAAA,qDAAqD;AACrD,uGAAuG;AACvG,iFAAiF;AAK1E,MAAMA,8BAA8B,2BAA2B;AAS/D,SAASC,mBAAmBC,OAAwB;IACvD,wCAAwC;IACxC,2EAA2E;IAC3E,sFAAsF;IACtF,6CAA6C;IAC7C,6DAA6D;IAC7D,aAAa;IACbC,UAAU,CAACH,4BAA4B,GAAGE;AAC9C;AAEO,SAASE;IACZ,6DAA6D;IAC7D,aAAa;IACb,MAAMF,UAAUC,UAAU,CAACH,4BAA4B;IAEvD,IAAI,CAACE,SAAS;QACV,MAAM,IAAIG,MAAM;IACpB;IAEA,OAAOH;AACX"}
1
+ {"version":3,"file":"js/context.js","sources":["../../src/js/context.ts"],"sourcesContent":["// DEPRECATED: Grace period ends on January 1th 2026.\n// Must keep this code until the end of the grace period because host applications using version 2.* of\n// this package would get runtime errors from the Platform Widgets CDN otherwise.\n\nimport type { Logger } from \"@workleap/logging\";\nimport type { MixpanelGlobalEventProperties } from \"./MixpanelClient.ts\";\n\nexport const MixpanelContextVariableName = \"__WLP_MIXPANEL_CONTEXT__\";\n\nexport interface MixpanelContext {\n productId: string;\n endpoint: string;\n globalEventProperties: MixpanelGlobalEventProperties;\n logger: Logger;\n}\n\nexport function setMixpanelContext(context: MixpanelContext) {\n // Will be used by the \"track\" function.\n // It's important to share the context with a global DOM object rather than\n // a singleton because projects like the platform widgets will use a distinct instance\n // of this package than the host application.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[MixpanelContextVariableName] = context;\n}\n\nexport function getMixpanelContext() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const context = globalThis[MixpanelContextVariableName] as MixpanelContext;\n\n if (!context) {\n throw new Error(\"[mixpanel] The Mixpanel context is not available. Did you initialize Mixpanel with the \\\"initializeMixpanel\\\" function?\");\n }\n\n return context;\n}\n\n"],"names":["MixpanelContextVariableName","setMixpanelContext","context","globalThis","getMixpanelContext","Error"],"mappings":";;AAAA,qDAAqD;AACrD,uGAAuG;AACvG,iFAAiF;AAK1E,MAAMA,8BAA8B,2BAA2B;AAS/D,SAASC,mBAAmBC,OAAwB;IACvD,wCAAwC;IACxC,2EAA2E;IAC3E,sFAAsF;IACtF,6CAA6C;IAC7C,6DAA6D;IAC7D,aAAa;IACbC,UAAU,CAACH,4BAA4B,GAAGE;AAC9C;AAEO,SAASE;IACZ,6DAA6D;IAC7D,aAAa;IACb,MAAMF,UAAUC,UAAU,CAACH,4BAA4B;IAEvD,IAAI,CAACE,SAAS;QACV,MAAM,IAAIG,MAAM;IACpB;IAEA,OAAOH;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/createTrackingFunction.js","sources":["webpack://@workleap/mixpanel/./src/js/createTrackingFunction.ts"],"sourcesContent":["// DEPRECATED: Grace period ends on January 1th 2026.\n// Must keep this code until the end of the grace period because host applications using version 2.* of\n// this package would get runtime errors from the Platform Widgets CDN otherwise.\n\nimport type { CreateMixpanelTrackingFunctionOptions, MixpanelTrackingFunction } from \"@workleap-telemetry/core\";\nimport { getMixpanelContext } from \"./context.ts\";\nimport { getBaseProperties } from \"./properties.ts\";\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function createTrackingFunction(options: CreateMixpanelTrackingFunctionOptions = {}) {\n const {\n targetProductId\n } = options;\n\n const {\n productId,\n endpoint,\n globalEventProperties,\n logger\n } = getMixpanelContext();\n\n const trackFunction: MixpanelTrackingFunction = async (eventName, properties, _options = {}) => {\n try {\n const {\n keepAlive = false\n } = _options;\n\n const baseProperties = getBaseProperties();\n\n const allProperties = {\n ...baseProperties,\n ...Object.fromEntries(globalEventProperties),\n ...properties\n };\n\n await fetch(endpoint, {\n method: \"POST\",\n credentials: \"include\",\n keepalive: keepAlive,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n eventName,\n productIdentifier: productId,\n // Not sure why, but it seems important to send \"null\" if not target product identifier\n // are provided.\n targetProductIdentifier: targetProductId ?? null,\n properties: allProperties\n })\n });\n } catch (error: unknown) {\n logger\n .withText(`[mixpanel] An error occurred while sending a tracking event to \"${endpoint}\":`)\n .withError(error as Error)\n .error();\n }\n };\n\n return trackFunction;\n}\n"],"names":["getMixpanelContext","getBaseProperties","createTrackingFunction","options","targetProductId","productId","endpoint","globalEventProperties","logger","trackFunction","eventName","properties","_options","keepAlive","baseProperties","allProperties","Object","fetch","JSON","error"],"mappings":";;;;;;;;AAAA,qDAAqD;AACrD,uGAAuG;AACvG,iFAAiF;AAG/B;AACE;AAEpD;;CAEC,GACM,SAASE,uBAAuBC,UAAiD,CAAC,CAAC;IACtF,MAAM,EACFC,eAAe,EAClB,GAAGD;IAEJ,MAAM,EACFE,SAAS,EACTC,QAAQ,EACRC,qBAAqB,EACrBC,MAAM,EACT,GAAGR,kBAAkBA;IAEtB,MAAMS,gBAA0C,OAAOC,WAAWC,YAAYC,WAAW,CAAC,CAAC;QACvF,IAAI;YACA,MAAM,EACFC,YAAY,KAAK,EACpB,GAAGD;YAEJ,MAAME,iBAAiBb,iBAAiBA;YAExC,MAAMc,gBAAgB;gBAClB,GAAGD,cAAc;gBACjB,GAAGE,OAAO,WAAW,CAACT,sBAAsB;gBAC5C,GAAGI,UAAU;YACjB;YAEA,MAAMM,MAAMX,UAAU;gBAClB,QAAQ;gBACR,aAAa;gBACb,WAAWO;gBACX,SAAS;oBAAE,gBAAgB;gBAAmB;gBAC9C,MAAMK,KAAK,SAAS,CAAC;oBACjBR;oBACA,mBAAmBL;oBACnB,uFAAuF;oBACvF,gBAAgB;oBAChB,yBAAyBD,mBAAmB;oBAC5C,YAAYW;gBAChB;YACJ;QACJ,EAAE,OAAOI,OAAgB;YACrBX,OACK,QAAQ,CAAC,CAAC,gEAAgE,EAAEF,SAAS,EAAE,CAAC,EACxF,SAAS,CAACa,OACV,KAAK;QACd;IACJ;IAEA,OAAOV;AACX"}
1
+ {"version":3,"file":"js/createTrackingFunction.js","sources":["../../src/js/createTrackingFunction.ts"],"sourcesContent":["// DEPRECATED: Grace period ends on January 1th 2026.\n// Must keep this code until the end of the grace period because host applications using version 2.* of\n// this package would get runtime errors from the Platform Widgets CDN otherwise.\n\nimport type { CreateMixpanelTrackingFunctionOptions, MixpanelTrackingFunction } from \"@workleap-telemetry/core\";\nimport { getMixpanelContext } from \"./context.ts\";\nimport { getBaseProperties } from \"./properties.ts\";\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function createTrackingFunction(options: CreateMixpanelTrackingFunctionOptions = {}) {\n const {\n targetProductId\n } = options;\n\n const {\n productId,\n endpoint,\n globalEventProperties,\n logger\n } = getMixpanelContext();\n\n const trackFunction: MixpanelTrackingFunction = async (eventName, properties, _options = {}) => {\n try {\n const {\n keepAlive = false\n } = _options;\n\n const baseProperties = getBaseProperties();\n\n const allProperties = {\n ...baseProperties,\n ...Object.fromEntries(globalEventProperties),\n ...properties\n };\n\n await fetch(endpoint, {\n method: \"POST\",\n credentials: \"include\",\n keepalive: keepAlive,\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n eventName,\n productIdentifier: productId,\n // Not sure why, but it seems important to send \"null\" if not target product identifier\n // are provided.\n targetProductIdentifier: targetProductId ?? null,\n properties: allProperties\n })\n });\n } catch (error: unknown) {\n logger\n .withText(`[mixpanel] An error occurred while sending a tracking event to \"${endpoint}\":`)\n .withError(error as Error)\n .error();\n }\n };\n\n return trackFunction;\n}\n"],"names":["getMixpanelContext","getBaseProperties","createTrackingFunction","options","targetProductId","productId","endpoint","globalEventProperties","logger","trackFunction","eventName","properties","_options","keepAlive","baseProperties","allProperties","Object","fetch","JSON","error"],"mappings":";;;;;;;;AAAA,qDAAqD;AACrD,uGAAuG;AACvG,iFAAiF;AAG/B;AACE;AAEpD;;CAEC,GACM,SAASE,uBAAuBC,UAAiD,CAAC,CAAC;IACtF,MAAM,EACFC,eAAe,EAClB,GAAGD;IAEJ,MAAM,EACFE,SAAS,EACTC,QAAQ,EACRC,qBAAqB,EACrBC,MAAM,EACT,GAAGR,kBAAkBA;IAEtB,MAAMS,gBAA0C,OAAOC,WAAWC,YAAYC,WAAW,CAAC,CAAC;QACvF,IAAI;YACA,MAAM,EACFC,YAAY,KAAK,EACpB,GAAGD;YAEJ,MAAME,iBAAiBb,iBAAiBA;YAExC,MAAMc,gBAAgB;gBAClB,GAAGD,cAAc;gBACjB,GAAGE,OAAO,WAAW,CAACT,sBAAsB;gBAC5C,GAAGI,UAAU;YACjB;YAEA,MAAMM,MAAMX,UAAU;gBAClB,QAAQ;gBACR,aAAa;gBACb,WAAWO;gBACX,SAAS;oBAAE,gBAAgB;gBAAmB;gBAC9C,MAAMK,KAAK,SAAS,CAAC;oBACjBR;oBACA,mBAAmBL;oBACnB,uFAAuF;oBACvF,gBAAgB;oBAChB,yBAAyBD,mBAAmB;oBAC5C,YAAYW;gBAChB;YACJ;QACJ,EAAE,OAAOI,OAAgB;YACrBX,OACK,QAAQ,CAAC,CAAC,gEAAgE,EAAEF,SAAS,EAAE,CAAC,EACxF,SAAS,CAACa,OACV,KAAK;QACd;IACJ;IAEA,OAAOV;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/env.js","sources":["webpack://@workleap/mixpanel/./src/js/env.ts"],"sourcesContent":["const EnvironmentList = [\"development\", \"staging\", \"production\", \"local\", \"msw\"] as const;\n\nexport type MixpanelEnvironment = typeof EnvironmentList[number];\n\nconst NavigationApiBaseUrl: Record<MixpanelEnvironment, string> = {\n \"production\": \"https://api.platform.workleap.com/shell/navigation/\",\n \"staging\": \"https://api.platform.workleap-stg.com/shell/navigation/\",\n \"development\": \"https://api.platform.workleap-dev.com/shell/navigation/\",\n \"local\": \"https://api.platform.workleap-dev.com/shell/navigation/\",\n \"msw\": \"/api/shell/navigation/\"\n};\n\n// Cannot use URL() because it doesn't support relative base url: https://github.com/whatwg/url/issues/531.\nfunction resolveApiUrl(path: string, baseUrl: string | undefined): string {\n return `${baseUrl}${baseUrl!.endsWith(\"/\") ? \"\" : \"/\"}${path.startsWith(\"/\") ? path.substring(1) : path}`;\n}\n\nexport function getTrackingEndpoint(envOrTrackingApiBaseUrl: MixpanelEnvironment | (string & {}), trackingEndpoint = \"tracking/track\"): string {\n let baseUrl: string;\n\n if (EnvironmentList.includes(envOrTrackingApiBaseUrl as MixpanelEnvironment)) {\n baseUrl = NavigationApiBaseUrl[envOrTrackingApiBaseUrl as MixpanelEnvironment];\n } else {\n baseUrl = envOrTrackingApiBaseUrl;\n }\n\n return resolveApiUrl(trackingEndpoint, baseUrl);\n}\n"],"names":["EnvironmentList","NavigationApiBaseUrl","resolveApiUrl","path","baseUrl","getTrackingEndpoint","envOrTrackingApiBaseUrl","trackingEndpoint"],"mappings":";;AAAA,MAAMA,kBAAkB;IAAC;IAAe;IAAW;IAAc;IAAS;CAAM;AAIhF,MAAMC,uBAA4D;IAC9D,cAAc;IACd,WAAW;IACX,eAAe;IACf,SAAS;IACT,OAAO;AACX;AAEA,2GAA2G;AAC3G,SAASC,cAAcC,IAAY,EAAEC,OAA2B;IAC5D,OAAO,GAAGA,UAAUA,QAAS,QAAQ,CAAC,OAAO,KAAK,MAAMD,KAAK,UAAU,CAAC,OAAOA,KAAK,SAAS,CAAC,KAAKA,MAAM;AAC7G;AAEO,SAASE,oBAAoBC,uBAA4D,EAAEC,mBAAmB,gBAAgB;IACjI,IAAIH;IAEJ,IAAIJ,gBAAgB,QAAQ,CAACM,0BAAiD;QAC1EF,UAAUH,oBAAoB,CAACK,wBAA+C;IAClF,OAAO;QACHF,UAAUE;IACd;IAEA,OAAOJ,cAAcK,kBAAkBH;AAC3C"}
1
+ {"version":3,"file":"js/env.js","sources":["../../src/js/env.ts"],"sourcesContent":["const EnvironmentList = [\"development\", \"staging\", \"production\", \"local\", \"msw\"] as const;\n\nexport type MixpanelEnvironment = typeof EnvironmentList[number];\n\nconst NavigationApiBaseUrl: Record<MixpanelEnvironment, string> = {\n \"production\": \"https://api.platform.workleap.com/shell/navigation/\",\n \"staging\": \"https://api.platform.workleap-stg.com/shell/navigation/\",\n \"development\": \"https://api.platform.workleap-dev.com/shell/navigation/\",\n \"local\": \"https://api.platform.workleap-dev.com/shell/navigation/\",\n \"msw\": \"/api/shell/navigation/\"\n};\n\n// Cannot use URL() because it doesn't support relative base url: https://github.com/whatwg/url/issues/531.\nfunction resolveApiUrl(path: string, baseUrl: string | undefined): string {\n return `${baseUrl}${baseUrl!.endsWith(\"/\") ? \"\" : \"/\"}${path.startsWith(\"/\") ? path.substring(1) : path}`;\n}\n\nexport function getTrackingEndpoint(envOrTrackingApiBaseUrl: MixpanelEnvironment | (string & {}), trackingEndpoint = \"tracking/track\"): string {\n let baseUrl: string;\n\n if (EnvironmentList.includes(envOrTrackingApiBaseUrl as MixpanelEnvironment)) {\n baseUrl = NavigationApiBaseUrl[envOrTrackingApiBaseUrl as MixpanelEnvironment];\n } else {\n baseUrl = envOrTrackingApiBaseUrl;\n }\n\n return resolveApiUrl(trackingEndpoint, baseUrl);\n}\n"],"names":["EnvironmentList","NavigationApiBaseUrl","resolveApiUrl","path","baseUrl","getTrackingEndpoint","envOrTrackingApiBaseUrl","trackingEndpoint"],"mappings":";;AAAA,MAAMA,kBAAkB;IAAC;IAAe;IAAW;IAAc;IAAS;CAAM;AAIhF,MAAMC,uBAA4D;IAC9D,cAAc;IACd,WAAW;IACX,eAAe;IACf,SAAS;IACT,OAAO;AACX;AAEA,2GAA2G;AAC3G,SAASC,cAAcC,IAAY,EAAEC,OAA2B;IAC5D,OAAO,GAAGA,UAAUA,QAAS,QAAQ,CAAC,OAAO,KAAK,MAAMD,KAAK,UAAU,CAAC,OAAOA,KAAK,SAAS,CAAC,KAAKA,MAAM;AAC7G;AAEO,SAASE,oBAAoBC,uBAA4D,EAAEC,mBAAmB,gBAAgB;IACjI,IAAIH;IAEJ,IAAIJ,gBAAgB,QAAQ,CAACM,0BAAiD;QAC1EF,UAAUH,oBAAoB,CAACK,wBAA+C;IAClF,OAAO;QACHF,UAAUE;IACd;IAEA,OAAOJ,cAAcK,kBAAkBH;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/index.js","sources":["webpack://@workleap/mixpanel/./src/js/index.ts"],"sourcesContent":["export { createTelemetryContext, type CreateTelemetryContextOptions, type TelemetryContext } from \"@workleap-telemetry/core\";\nexport type { CreateMixpanelTrackingFunctionOptions, MixpanelEventProperties, MixpanelTrackingFunction, MixpanelTrackingFunctionOptions } from \"@workleap-telemetry/core\";\nexport { createTrackingFunction } from \"./createTrackingFunction.ts\";\nexport type { MixpanelEnvironment } from \"./env.ts\";\nexport { initializeMixpanel, type InitializeMixpanelOptions } from \"./initializeMixpanel.ts\";\nexport type { MixpanelClient, MixpanelGlobalEventProperties } from \"./MixpanelClient.ts\";\nexport { NoopMixpanelClient } from \"./NoopMixpanelClient.ts\";\n\n"],"names":["createTelemetryContext","createTrackingFunction","initializeMixpanel","NoopMixpanelClient"],"mappings":";;;;;;;;;;;;;;AAA6H;AAExD;AAEwB;AAEhC"}
1
+ {"version":3,"file":"js/index.js","sources":["../../src/js/index.ts"],"sourcesContent":["export { createTelemetryContext, type CreateTelemetryContextOptions, type TelemetryContext } from \"@workleap-telemetry/core\";\nexport type { CreateMixpanelTrackingFunctionOptions, MixpanelEventProperties, MixpanelTrackingFunction, MixpanelTrackingFunctionOptions } from \"@workleap-telemetry/core\";\nexport { createTrackingFunction } from \"./createTrackingFunction.ts\";\nexport type { MixpanelEnvironment } from \"./env.ts\";\nexport { initializeMixpanel, type InitializeMixpanelOptions } from \"./initializeMixpanel.ts\";\nexport type { MixpanelClient, MixpanelGlobalEventProperties } from \"./MixpanelClient.ts\";\nexport { NoopMixpanelClient } from \"./NoopMixpanelClient.ts\";\n\n"],"names":["createTelemetryContext","createTrackingFunction","initializeMixpanel","NoopMixpanelClient"],"mappings":";;;;;;;;;;;;;;AAA6H;AAExD;AAEwB;AAEhC"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/initializeMixpanel.js","sources":["webpack://@workleap/mixpanel/./src/js/initializeMixpanel.ts"],"sourcesContent":["import { HasExecutedGuard, type LogRocketInstrumentationPartialClient, type TelemetryContext } from \"@workleap-telemetry/core\";\nimport { createCompositeLogger, type Logger, type RootLogger } from \"@workleap/logging\";\nimport { setMixpanelContext } from \"./context.ts\";\nimport { getTrackingEndpoint, type MixpanelEnvironment } from \"./env.ts\";\nimport { type MixpanelClient, MixpanelClientImpl, type MixpanelGlobalEventProperties } from \"./MixpanelClient.ts\";\nimport { getTelemetryProperties, OtherProperties } from \"./properties.ts\";\n\n// DEPRECATED: Grace period ends on January 1th 2026.\n// Don't forget to remove the tests as well.\nexport const IsInitializedVariableName = \"__WLP_MIXPANEL_IS_INITIALIZED__\";\n\n// DEPRECATED: Grace period ends on January 1th 2026.\nfunction registerDeprecatedContextAndGlobalVariables(productId: string, endpoint: string, globalEventProperties: Map<string, unknown>, logger: Logger) {\n setMixpanelContext({\n productId,\n endpoint,\n globalEventProperties,\n logger\n });\n\n // Indicates to the host applications that Mixpanel has been initialized.\n // It's useful in cases where an \"add-on\", like the platform widgets needs\n // to know whether or not the host application is using Mixpanel.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[IsInitializedVariableName] = true;\n}\n\n///////////////////////////\n\nlet registrationGuardInstance: HasExecutedGuard | undefined;\n\n// It's important to use a lazy singleton instead of a singleton to avoid\n// any future probleme related to HMR, tree-shaking, SSR, etc..\nfunction getRegistrationGuard() {\n if (!registrationGuardInstance) {\n registrationGuardInstance = new HasExecutedGuard();\n }\n\n return registrationGuardInstance;\n}\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n if (registrationGuardInstance) {\n registrationGuardInstance.reset();\n }\n}\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface InitializeMixpanelOptions {\n /**\n * An optional tracking endpoint.\n * @default \"tracking/track\"\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n trackingEndpoint?: string;\n /**\n * Context including telemetry correlation ids.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n telemetryContext?: TelemetryContext;\n /**\n * An optional LogRocket client to automatically add the LogRocket\n * session URL to Mixpanel events once it's available.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n logRocketInstrumentationClient?: LogRocketInstrumentationPartialClient;\n /**\n * Whether or not debug information should be logged to the console.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n verbose?: boolean;\n /**\n * An array of RootLogger instances.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n loggers?: RootLogger[];\n}\n\nexport class MixpanelInitializer {\n readonly #globalEventProperties: MixpanelGlobalEventProperties;\n\n constructor(globalEventProperties: MixpanelGlobalEventProperties) {\n this.#globalEventProperties = globalEventProperties;\n }\n\n initialize(\n productId: string,\n envOrTrackingApiBaseUrl: MixpanelEnvironment | (string & {}),\n options: InitializeMixpanelOptions = {}\n ) {\n const {\n trackingEndpoint,\n telemetryContext,\n logRocketInstrumentationClient,\n verbose = false,\n loggers = []\n } = options;\n\n const logger = createCompositeLogger(verbose, loggers);\n const endpoint = getTrackingEndpoint(envOrTrackingApiBaseUrl, trackingEndpoint);\n\n // Set the telemetry correlation ids on every Mixpanel event.\n if (telemetryContext) {\n for (const [key, value] of Object.entries(getTelemetryProperties(telemetryContext))) {\n this.#globalEventProperties.set(key, value);\n }\n }\n\n // If a LogRocket client is already available, register a listener to get the LogRocket session url\n // once it's available to set it on every Mixpanel event.\n if (logRocketInstrumentationClient) {\n logRocketInstrumentationClient.registerGetSessionUrlListener((sessionUrl: string) => {\n logger\n .withText(\"[mixpanel] Received LogRocket session replay URL:\")\n .withText(sessionUrl)\n .debug();\n\n this.#globalEventProperties.set(OtherProperties.LogRocketSessionUrl, sessionUrl);\n });\n }\n\n registerDeprecatedContextAndGlobalVariables(productId, endpoint, this.#globalEventProperties, logger);\n\n logger.information(\"[mixpanel] Mixpanel is initialized.\");\n\n const client = new MixpanelClientImpl(productId, endpoint, this.#globalEventProperties, logger);\n\n // The cast is to normalize the inferred return type to the \"LogRocketInstrumentationClient\" type.\n return client as MixpanelClient;\n }\n}\n\n/**\n * Initialize Mixpanel telemetry.\n * @param productId The Mixpanel product identifier.\n * @param envOrTrackingApiBaseUrl The environment to get the navigation url from or a base URL.\n * @param options Mixpanel instrumentation options.\n * @returns {MixpanelClient} A Mixpanel client instance.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function initializeMixpanel(\n productId: string,\n envOrTrackingApiBaseUrl: MixpanelEnvironment | (string & {}),\n options?: InitializeMixpanelOptions\n) {\n getRegistrationGuard().throw(\"[mixpanel] Mixpanel has already been initialized. Did you call the \\\"initializeMixpanel\\\" function twice?\");\n\n return new MixpanelInitializer(\n new Map<string, unknown>()\n ).initialize(\n productId,\n envOrTrackingApiBaseUrl,\n options\n );\n}\n"],"names":["HasExecutedGuard","createCompositeLogger","setMixpanelContext","getTrackingEndpoint","MixpanelClientImpl","getTelemetryProperties","OtherProperties","IsInitializedVariableName","registerDeprecatedContextAndGlobalVariables","productId","endpoint","globalEventProperties","logger","globalThis","registrationGuardInstance","getRegistrationGuard","__resetRegistrationGuard","MixpanelInitializer","envOrTrackingApiBaseUrl","options","trackingEndpoint","telemetryContext","logRocketInstrumentationClient","verbose","loggers","key","value","Object","sessionUrl","client","initializeMixpanel","Map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAA+H;AACvC;AACtC;AACuB;AACyC;AACxC;AAE1E,qDAAqD;AACrD,4CAA4C;AACrC,MAAMO,4BAA4B,kCAAkC;AAE3E,qDAAqD;AACrD,SAASC,4CAA4CC,SAAiB,EAAEC,QAAgB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CC,WAAWC,UAAU,IAAI,CAAC,sBAAsB,EAAEE;QAE9FA,OAAO,WAAW,CAAC;QAEnB,MAAMiB,SAAS,IAAIzB,kBAAkBA,CAACK,WAAWC,UAAU,IAAI,CAAC,sBAAsB,EAAEE;QAExF,kGAAkG;QAClG,OAAOiB;IACX;AACJ;AAEA;;;;;;;CAOC,GACM,SAASC,mBACZrB,SAAiB,EACjBS,uBAA4D,EAC5DC,OAAmC;IAEnCJ,uBAAuB,KAAK,CAAC;IAE7B,OAAO,IAAIE,oBACP,IAAIc,OACN,UAAU,CACRtB,WACAS,yBACAC;AAER"}
1
+ {"version":3,"file":"js/initializeMixpanel.js","sources":["../../src/js/initializeMixpanel.ts"],"sourcesContent":["import { HasExecutedGuard, type LogRocketInstrumentationPartialClient, type TelemetryContext } from \"@workleap-telemetry/core\";\nimport { createCompositeLogger, type Logger, type RootLogger } from \"@workleap/logging\";\nimport { setMixpanelContext } from \"./context.ts\";\nimport { getTrackingEndpoint, type MixpanelEnvironment } from \"./env.ts\";\nimport { type MixpanelClient, MixpanelClientImpl, type MixpanelGlobalEventProperties } from \"./MixpanelClient.ts\";\nimport { getTelemetryProperties, OtherProperties } from \"./properties.ts\";\n\n// DEPRECATED: Grace period ends on January 1th 2026.\n// Don't forget to remove the tests as well.\nexport const IsInitializedVariableName = \"__WLP_MIXPANEL_IS_INITIALIZED__\";\n\n// DEPRECATED: Grace period ends on January 1th 2026.\nfunction registerDeprecatedContextAndGlobalVariables(productId: string, endpoint: string, globalEventProperties: Map<string, unknown>, logger: Logger) {\n setMixpanelContext({\n productId,\n endpoint,\n globalEventProperties,\n logger\n });\n\n // Indicates to the host applications that Mixpanel has been initialized.\n // It's useful in cases where an \"add-on\", like the platform widgets needs\n // to know whether or not the host application is using Mixpanel.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis[IsInitializedVariableName] = true;\n}\n\n///////////////////////////\n\nlet registrationGuardInstance: HasExecutedGuard | undefined;\n\n// It's important to use a lazy singleton instead of a singleton to avoid\n// any future probleme related to HMR, tree-shaking, SSR, etc..\nfunction getRegistrationGuard() {\n if (!registrationGuardInstance) {\n registrationGuardInstance = new HasExecutedGuard();\n }\n\n return registrationGuardInstance;\n}\n\n// This function should only be used by tests.\nexport function __resetRegistrationGuard() {\n if (registrationGuardInstance) {\n registrationGuardInstance.reset();\n }\n}\n\n///////////////////////////\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface InitializeMixpanelOptions {\n /**\n * An optional tracking endpoint.\n * @default \"tracking/track\"\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n trackingEndpoint?: string;\n /**\n * Context including telemetry correlation ids.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n telemetryContext?: TelemetryContext;\n /**\n * An optional LogRocket client to automatically add the LogRocket\n * session URL to Mixpanel events once it's available.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n logRocketInstrumentationClient?: LogRocketInstrumentationPartialClient;\n /**\n * Whether or not debug information should be logged to the console.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n verbose?: boolean;\n /**\n * An array of RootLogger instances.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n loggers?: RootLogger[];\n}\n\nexport class MixpanelInitializer {\n readonly #globalEventProperties: MixpanelGlobalEventProperties;\n\n constructor(globalEventProperties: MixpanelGlobalEventProperties) {\n this.#globalEventProperties = globalEventProperties;\n }\n\n initialize(\n productId: string,\n envOrTrackingApiBaseUrl: MixpanelEnvironment | (string & {}),\n options: InitializeMixpanelOptions = {}\n ) {\n const {\n trackingEndpoint,\n telemetryContext,\n logRocketInstrumentationClient,\n verbose = false,\n loggers = []\n } = options;\n\n const logger = createCompositeLogger(verbose, loggers);\n const endpoint = getTrackingEndpoint(envOrTrackingApiBaseUrl, trackingEndpoint);\n\n // Set the telemetry correlation ids on every Mixpanel event.\n if (telemetryContext) {\n for (const [key, value] of Object.entries(getTelemetryProperties(telemetryContext))) {\n this.#globalEventProperties.set(key, value);\n }\n }\n\n // If a LogRocket client is already available, register a listener to get the LogRocket session url\n // once it's available to set it on every Mixpanel event.\n if (logRocketInstrumentationClient) {\n logRocketInstrumentationClient.registerGetSessionUrlListener((sessionUrl: string) => {\n logger\n .withText(\"[mixpanel] Received LogRocket session replay URL:\")\n .withText(sessionUrl)\n .debug();\n\n this.#globalEventProperties.set(OtherProperties.LogRocketSessionUrl, sessionUrl);\n });\n }\n\n registerDeprecatedContextAndGlobalVariables(productId, endpoint, this.#globalEventProperties, logger);\n\n logger.information(\"[mixpanel] Mixpanel is initialized.\");\n\n const client = new MixpanelClientImpl(productId, endpoint, this.#globalEventProperties, logger);\n\n // The cast is to normalize the inferred return type to the \"LogRocketInstrumentationClient\" type.\n return client as MixpanelClient;\n }\n}\n\n/**\n * Initialize Mixpanel telemetry.\n * @param productId The Mixpanel product identifier.\n * @param envOrTrackingApiBaseUrl The environment to get the navigation url from or a base URL.\n * @param options Mixpanel instrumentation options.\n * @returns {MixpanelClient} A Mixpanel client instance.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function initializeMixpanel(\n productId: string,\n envOrTrackingApiBaseUrl: MixpanelEnvironment | (string & {}),\n options?: InitializeMixpanelOptions\n) {\n getRegistrationGuard().throw(\"[mixpanel] Mixpanel has already been initialized. Did you call the \\\"initializeMixpanel\\\" function twice?\");\n\n return new MixpanelInitializer(\n new Map<string, unknown>()\n ).initialize(\n productId,\n envOrTrackingApiBaseUrl,\n options\n );\n}\n"],"names":["HasExecutedGuard","createCompositeLogger","setMixpanelContext","getTrackingEndpoint","MixpanelClientImpl","getTelemetryProperties","OtherProperties","IsInitializedVariableName","registerDeprecatedContextAndGlobalVariables","productId","endpoint","globalEventProperties","logger","globalThis","registrationGuardInstance","getRegistrationGuard","__resetRegistrationGuard","MixpanelInitializer","envOrTrackingApiBaseUrl","options","trackingEndpoint","telemetryContext","logRocketInstrumentationClient","verbose","loggers","key","value","Object","sessionUrl","client","initializeMixpanel","Map"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;YAChCA,+BAA+B,6BAA6B,CAAC,CAACM;gBAC1DhB,OACK,QAAQ,CAAC,qDACT,QAAQ,CAACgB,YACT,KAAK;gBAEV,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACtB,mCAAmC,EAAEsB;YACzE;QACJ;QAEApB,4CAA4CC,WAAWC,UAAU,IAAI,CAAC,sBAAsB,EAAEE;QAE9FA,OAAO,WAAW,CAAC;QAEnB,MAAMiB,SAAS,IAAIzB,kBAAkBA,CAACK,WAAWC,UAAU,IAAI,CAAC,sBAAsB,EAAEE;QAExF,kGAAkG;QAClG,OAAOiB;IACX;AACJ;AAEA;;;;;;;CAOC,GACM,SAASC,mBACZrB,SAAiB,EACjBS,uBAA4D,EAC5DC,OAAmC;IAEnCJ,uBAAuB,KAAK,CAAC;IAE7B,OAAO,IAAIE,oBACP,IAAIc,OACN,UAAU,CACRtB,WACAS,yBACAC;AAER"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/properties.js","sources":["webpack://@workleap/mixpanel/./src/js/properties.ts"],"sourcesContent":["\nimport type { MixpanelEventProperties, TelemetryContext } from \"@workleap-telemetry/core\";\nimport { browserName, browserVersion, deviceType, osName, referringDomain } from \"./utils.ts\";\n\nexport const BaseProperties = {\n Browser: \"$browser\",\n BrowserVersion: \"$browser_version\",\n CurrentUrl: \"$current_url\",\n Device: \"$device\",\n IsMobile: \"Is Mobile\",\n Os: \"$os\",\n Referrer: \"$referrer\",\n ReferringDomain: \"$referring_domain\",\n ScreenHeight: \"$screen_height\",\n ScreenWidth: \"$screen_width\"\n} as const;\n\nexport function getBaseProperties() {\n const userAgent = navigator.userAgent;\n const device = deviceType(userAgent);\n\n return {\n [BaseProperties.Os]: osName(userAgent),\n [BaseProperties.Browser]: browserName(userAgent, navigator.vendor),\n [BaseProperties.Referrer]: document.referrer,\n [BaseProperties.ReferringDomain]: referringDomain(document.referrer),\n [BaseProperties.Device]: device,\n [BaseProperties.CurrentUrl]: window.location.href,\n [BaseProperties.BrowserVersion]: browserVersion(userAgent, navigator.vendor),\n [BaseProperties.ScreenHeight]: window.screen.height,\n [BaseProperties.ScreenWidth]: window.screen.width,\n [BaseProperties.IsMobile]: device.length > 0\n } satisfies MixpanelEventProperties;\n}\n\nexport const TelemetryProperties = {\n DeviceId: \"Device Id\",\n TelemetryId: \"Telemetry Id\"\n} as const;\n\nexport function getTelemetryProperties(context: TelemetryContext) {\n return {\n [TelemetryProperties.TelemetryId]: context.telemetryId,\n [TelemetryProperties.DeviceId]: context.deviceId\n } satisfies MixpanelEventProperties;\n}\n\nexport const OtherProperties = {\n LogRocketSessionUrl: \"LogRocket Session Url\"\n};\n"],"names":["browserName","browserVersion","deviceType","osName","referringDomain","BaseProperties","getBaseProperties","userAgent","navigator","device","document","window","TelemetryProperties","getTelemetryProperties","context","OtherProperties"],"mappings":";;;;;AAE8F;AAEvF,MAAMK,iBAAiB;IAC1B,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,UAAU;IACV,iBAAiB;IACjB,cAAc;IACd,aAAa;AACjB,EAAW;AAEJ,SAASC;IACZ,MAAMC,YAAYC,UAAU,SAAS;IACrC,MAAMC,SAASP,UAAUA,CAACK;IAE1B,OAAO;QACH,CAACF,eAAe,EAAE,CAAC,EAAEF,MAAMA,CAACI;QAC5B,CAACF,eAAe,OAAO,CAAC,EAAEL,WAAWA,CAACO,WAAWC,UAAU,MAAM;QACjE,CAACH,eAAe,QAAQ,CAAC,EAAEK,SAAS,QAAQ;QAC5C,CAACL,eAAe,eAAe,CAAC,EAAED,eAAeA,CAACM,SAAS,QAAQ;QACnE,CAACL,eAAe,MAAM,CAAC,EAAEI;QACzB,CAACJ,eAAe,UAAU,CAAC,EAAEM,OAAO,QAAQ,CAAC,IAAI;QACjD,CAACN,eAAe,cAAc,CAAC,EAAEJ,cAAcA,CAACM,WAAWC,UAAU,MAAM;QAC3E,CAACH,eAAe,YAAY,CAAC,EAAEM,OAAO,MAAM,CAAC,MAAM;QACnD,CAACN,eAAe,WAAW,CAAC,EAAEM,OAAO,MAAM,CAAC,KAAK;QACjD,CAACN,eAAe,QAAQ,CAAC,EAAEI,OAAO,MAAM,GAAG;IAC/C;AACJ;AAEO,MAAMG,sBAAsB;IAC/B,UAAU;IACV,aAAa;AACjB,EAAW;AAEJ,SAASC,uBAAuBC,OAAyB;IAC5D,OAAO;QACH,CAACF,oBAAoB,WAAW,CAAC,EAAEE,QAAQ,WAAW;QACtD,CAACF,oBAAoB,QAAQ,CAAC,EAAEE,QAAQ,QAAQ;IACpD;AACJ;AAEO,MAAMC,kBAAkB;IAC3B,qBAAqB;AACzB,EAAE"}
1
+ {"version":3,"file":"js/properties.js","sources":["../../src/js/properties.ts"],"sourcesContent":["\nimport type { MixpanelEventProperties, TelemetryContext } from \"@workleap-telemetry/core\";\nimport { browserName, browserVersion, deviceType, osName, referringDomain } from \"./utils.ts\";\n\nexport const BaseProperties = {\n Browser: \"$browser\",\n BrowserVersion: \"$browser_version\",\n CurrentUrl: \"$current_url\",\n Device: \"$device\",\n IsMobile: \"Is Mobile\",\n Os: \"$os\",\n Referrer: \"$referrer\",\n ReferringDomain: \"$referring_domain\",\n ScreenHeight: \"$screen_height\",\n ScreenWidth: \"$screen_width\"\n} as const;\n\nexport function getBaseProperties() {\n const userAgent = navigator.userAgent;\n const device = deviceType(userAgent);\n\n return {\n [BaseProperties.Os]: osName(userAgent),\n [BaseProperties.Browser]: browserName(userAgent, navigator.vendor),\n [BaseProperties.Referrer]: document.referrer,\n [BaseProperties.ReferringDomain]: referringDomain(document.referrer),\n [BaseProperties.Device]: device,\n [BaseProperties.CurrentUrl]: window.location.href,\n [BaseProperties.BrowserVersion]: browserVersion(userAgent, navigator.vendor),\n [BaseProperties.ScreenHeight]: window.screen.height,\n [BaseProperties.ScreenWidth]: window.screen.width,\n [BaseProperties.IsMobile]: device.length > 0\n } satisfies MixpanelEventProperties;\n}\n\nexport const TelemetryProperties = {\n DeviceId: \"Device Id\",\n TelemetryId: \"Telemetry Id\"\n} as const;\n\nexport function getTelemetryProperties(context: TelemetryContext) {\n return {\n [TelemetryProperties.TelemetryId]: context.telemetryId,\n [TelemetryProperties.DeviceId]: context.deviceId\n } satisfies MixpanelEventProperties;\n}\n\nexport const OtherProperties = {\n LogRocketSessionUrl: \"LogRocket Session Url\"\n};\n"],"names":["browserName","browserVersion","deviceType","osName","referringDomain","BaseProperties","getBaseProperties","userAgent","navigator","device","document","window","TelemetryProperties","getTelemetryProperties","context","OtherProperties"],"mappings":";;;;;AAE8F;AAEvF,MAAMK,iBAAiB;IAC1B,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,QAAQ;IACR,UAAU;IACV,IAAI;IACJ,UAAU;IACV,iBAAiB;IACjB,cAAc;IACd,aAAa;AACjB,EAAW;AAEJ,SAASC;IACZ,MAAMC,YAAYC,UAAU,SAAS;IACrC,MAAMC,SAASP,UAAUA,CAACK;IAE1B,OAAO;QACH,CAACF,eAAe,EAAE,CAAC,EAAEF,MAAMA,CAACI;QAC5B,CAACF,eAAe,OAAO,CAAC,EAAEL,WAAWA,CAACO,WAAWC,UAAU,MAAM;QACjE,CAACH,eAAe,QAAQ,CAAC,EAAEK,SAAS,QAAQ;QAC5C,CAACL,eAAe,eAAe,CAAC,EAAED,eAAeA,CAACM,SAAS,QAAQ;QACnE,CAACL,eAAe,MAAM,CAAC,EAAEI;QACzB,CAACJ,eAAe,UAAU,CAAC,EAAEM,OAAO,QAAQ,CAAC,IAAI;QACjD,CAACN,eAAe,cAAc,CAAC,EAAEJ,cAAcA,CAACM,WAAWC,UAAU,MAAM;QAC3E,CAACH,eAAe,YAAY,CAAC,EAAEM,OAAO,MAAM,CAAC,MAAM;QACnD,CAACN,eAAe,WAAW,CAAC,EAAEM,OAAO,MAAM,CAAC,KAAK;QACjD,CAACN,eAAe,QAAQ,CAAC,EAAEI,OAAO,MAAM,GAAG;IAC/C;AACJ;AAEO,MAAMG,sBAAsB;IAC/B,UAAU;IACV,aAAa;AACjB,EAAW;AAEJ,SAASC,uBAAuBC,OAAyB;IAC5D,OAAO;QACH,CAACF,oBAAoB,WAAW,CAAC,EAAEE,QAAQ,WAAW;QACtD,CAACF,oBAAoB,QAAQ,CAAC,EAAEE,QAAQ,QAAQ;IACpD;AACJ;AAEO,MAAMC,kBAAkB;IAC3B,qBAAqB;AACzB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"js/utils.js","sources":["webpack://@workleap/mixpanel/./src/js/utils.ts"],"sourcesContent":["// This code is adapted from https://github.com/mixpanel/mixpanel-js/blob/master/src/utils.js\nexport function browserName(userAgent: string, vendor?: string, opera?: object) {\n // vendor is undefined for at least IE9\n vendor = vendor || \"\"; // eslint-disable-line no-param-reassign\n\n if (opera || userAgent.includes(\" OPR/\")) {\n if (userAgent.includes(\"Mini\")) {\n return \"Opera Mini\";\n }\n\n return \"Opera\";\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {\n return \"BlackBerry\";\n } else if (userAgent.includes(\"IEMobile\") || userAgent.includes(\"WPDesktop\")) {\n return \"Internet Explorer Mobile\";\n } else if (userAgent.includes(\"Edge\")) {\n return \"Microsoft Edge\";\n } else if (userAgent.includes(\"FBIOS\")) {\n return \"Facebook Mobile\";\n } else if (userAgent.includes(\"Chrome\")) {\n return \"Chrome\";\n } else if (userAgent.includes(\"CriOS\")) {\n return \"Chrome iOS\";\n } else if (userAgent.includes(\"UCWEB\") || userAgent.includes(\"UCBrowser\")) {\n return \"UC Browser\";\n } else if (userAgent.includes(\"FxiOS\")) {\n return \"Firefox iOS\";\n } else if (vendor.includes(\"Apple\")) {\n if (userAgent.includes(\"Mobile\")) {\n return \"Mobile Safari\";\n }\n\n return \"Safari\";\n } else if (userAgent.includes(\"Android\")) {\n return \"Android Mobile\";\n } else if (userAgent.includes(\"Konqueror\")) {\n return \"Konqueror\";\n } else if (userAgent.includes(\"Firefox\")) {\n return \"Firefox\";\n } else if (userAgent.includes(\"MSIE\") || userAgent.includes(\"Trident/\")) {\n return \"Internet Explorer\";\n } else if (userAgent.includes(\"Gecko\")) {\n return \"Mozilla\";\n }\n\n return \"\";\n}\n\n/**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n */\nexport function browserVersion(userAgent: string, vendor?: string, opera?: object) {\n const browser = browserName(userAgent, vendor, opera);\n const versionRegexs: { [key: string]: RegExp } = {\n \"Internet Explorer Mobile\": /rv:(\\d+(\\.\\d+)?)/,\n \"Microsoft Edge\": /Edge\\/(\\d+(\\.\\d+)?)/,\n \"Chrome\": /Chrome\\/(\\d+(\\.\\d+)?)/,\n \"Chrome iOS\": /CriOS\\/(\\d+(\\.\\d+)?)/,\n \"UC Browser\": /(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)/,\n \"Safari\": /Version\\/(\\d+(\\.\\d+)?)/,\n \"Mobile Safari\": /Version\\/(\\d+(\\.\\d+)?)/,\n \"Opera\": /(Opera|OPR)\\/(\\d+(\\.\\d+)?)/,\n \"Firefox\": /Firefox\\/(\\d+(\\.\\d+)?)/,\n \"Firefox iOS\": /FxiOS\\/(\\d+(\\.\\d+)?)/,\n \"Konqueror\": /Konqueror:(\\d+(\\.\\d+)?)/,\n \"BlackBerry\": /BlackBerry (\\d+(\\.\\d+)?)/,\n \"Android Mobile\": /android\\s(\\d+(\\.\\d+)?)/,\n \"Internet Explorer\": /(rv:|MSIE )(\\d+(\\.\\d+)?)/,\n \"Mozilla\": /rv:(\\d+(\\.\\d+)?)/\n };\n const regex = versionRegexs[browser];\n if (regex === undefined) {\n return null;\n }\n const matches = userAgent.match(regex);\n if (!matches) {\n return null;\n }\n\n return parseFloat(matches[matches.length - 2]);\n}\n\nexport function osName(userAgent: string) {\n const a = userAgent;\n if (/Windows/i.test(a)) {\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n if (/Phone/.test(a) || /WPDesktop/.test(a)) {\n return \"Windows Phone\";\n }\n\n return \"Windows\";\n } else if (/(iPhone|iPad|iPod)/.test(a)) {\n return \"iOS\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/Android/.test(a)) {\n return \"Android\";\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {\n return \"BlackBerry\";\n } else if (/Mac/i.test(a)) {\n return \"Mac OS X\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/Linux/.test(a)) {\n return \"Linux\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/CrOS/.test(a)) {\n return \"Chrome OS\";\n }\n\n return \"\";\n}\n\nexport function deviceType(userAgent: string) {\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n if (/Windows Phone/i.test(userAgent) || /WPDesktop/.test(userAgent)) {\n return \"Windows Phone\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/iPad/.test(userAgent)) {\n return \"iPad\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/iPod/.test(userAgent)) {\n return \"iPod Touch\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/iPhone/.test(userAgent)) {\n return \"iPhone\";\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {\n return \"BlackBerry\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/Android/.test(userAgent)) {\n return \"Android\";\n }\n\n return \"\";\n}\n\nexport function referringDomain(referrer: string) {\n const split = referrer.split(\"/\");\n if (split.length >= 3) {\n return split[2];\n }\n\n return \"\";\n}\n"],"names":["browserName","userAgent","vendor","opera","browserVersion","browser","versionRegexs","regex","undefined","matches","parseFloat","osName","a","deviceType","referringDomain","referrer","split"],"mappings":";;AAAA,6FAA6F;AACtF,SAASA,YAAYC,SAAiB,EAAEC,MAAe,EAAEC,KAAc;IAC1E,uCAAuC;IACvCD,SAASA,UAAU,IAAI,wCAAwC;IAE/D,IAAIC,SAASF,UAAU,QAAQ,CAAC,UAAU;QACtC,IAAIA,UAAU,QAAQ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A,YAAY;QACtD,OAAO;IACX,8DAA8D;IAC9D,OAAO,IAAI,UAAU,IAAI,CAACA,YAAY;QAClC,OAAO;IACX;IAEA,OAAO;AACX;AAEO,SAASa,gBAAgBC,QAAgB;IAC5C,MAAMC,QAAQD,SAAS,KAAK,CAAC;IAC7B,IAAIC,MAAM,MAAM,IAAI,GAAG;QACnB,OAAOA,KAAK,CAAC,EAAE;IACnB;IAEA,OAAO;AACX"}
1
+ {"version":3,"file":"js/utils.js","sources":["../../src/js/utils.ts"],"sourcesContent":["// This code is adapted from https://github.com/mixpanel/mixpanel-js/blob/master/src/utils.js\nexport function browserName(userAgent: string, vendor?: string, opera?: object) {\n // vendor is undefined for at least IE9\n vendor = vendor || \"\"; // eslint-disable-line no-param-reassign\n\n if (opera || userAgent.includes(\" OPR/\")) {\n if (userAgent.includes(\"Mini\")) {\n return \"Opera Mini\";\n }\n\n return \"Opera\";\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {\n return \"BlackBerry\";\n } else if (userAgent.includes(\"IEMobile\") || userAgent.includes(\"WPDesktop\")) {\n return \"Internet Explorer Mobile\";\n } else if (userAgent.includes(\"Edge\")) {\n return \"Microsoft Edge\";\n } else if (userAgent.includes(\"FBIOS\")) {\n return \"Facebook Mobile\";\n } else if (userAgent.includes(\"Chrome\")) {\n return \"Chrome\";\n } else if (userAgent.includes(\"CriOS\")) {\n return \"Chrome iOS\";\n } else if (userAgent.includes(\"UCWEB\") || userAgent.includes(\"UCBrowser\")) {\n return \"UC Browser\";\n } else if (userAgent.includes(\"FxiOS\")) {\n return \"Firefox iOS\";\n } else if (vendor.includes(\"Apple\")) {\n if (userAgent.includes(\"Mobile\")) {\n return \"Mobile Safari\";\n }\n\n return \"Safari\";\n } else if (userAgent.includes(\"Android\")) {\n return \"Android Mobile\";\n } else if (userAgent.includes(\"Konqueror\")) {\n return \"Konqueror\";\n } else if (userAgent.includes(\"Firefox\")) {\n return \"Firefox\";\n } else if (userAgent.includes(\"MSIE\") || userAgent.includes(\"Trident/\")) {\n return \"Internet Explorer\";\n } else if (userAgent.includes(\"Gecko\")) {\n return \"Mozilla\";\n }\n\n return \"\";\n}\n\n/**\n * This function detects which browser version is running this script,\n * parsing major and minor version (e.g., 42.1). User agent strings from:\n * http://www.useragentstring.com/pages/useragentstring.php\n */\nexport function browserVersion(userAgent: string, vendor?: string, opera?: object) {\n const browser = browserName(userAgent, vendor, opera);\n const versionRegexs: { [key: string]: RegExp } = {\n \"Internet Explorer Mobile\": /rv:(\\d+(\\.\\d+)?)/,\n \"Microsoft Edge\": /Edge\\/(\\d+(\\.\\d+)?)/,\n \"Chrome\": /Chrome\\/(\\d+(\\.\\d+)?)/,\n \"Chrome iOS\": /CriOS\\/(\\d+(\\.\\d+)?)/,\n \"UC Browser\": /(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)/,\n \"Safari\": /Version\\/(\\d+(\\.\\d+)?)/,\n \"Mobile Safari\": /Version\\/(\\d+(\\.\\d+)?)/,\n \"Opera\": /(Opera|OPR)\\/(\\d+(\\.\\d+)?)/,\n \"Firefox\": /Firefox\\/(\\d+(\\.\\d+)?)/,\n \"Firefox iOS\": /FxiOS\\/(\\d+(\\.\\d+)?)/,\n \"Konqueror\": /Konqueror:(\\d+(\\.\\d+)?)/,\n \"BlackBerry\": /BlackBerry (\\d+(\\.\\d+)?)/,\n \"Android Mobile\": /android\\s(\\d+(\\.\\d+)?)/,\n \"Internet Explorer\": /(rv:|MSIE )(\\d+(\\.\\d+)?)/,\n \"Mozilla\": /rv:(\\d+(\\.\\d+)?)/\n };\n const regex = versionRegexs[browser];\n if (regex === undefined) {\n return null;\n }\n const matches = userAgent.match(regex);\n if (!matches) {\n return null;\n }\n\n return parseFloat(matches[matches.length - 2]);\n}\n\nexport function osName(userAgent: string) {\n const a = userAgent;\n if (/Windows/i.test(a)) {\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n if (/Phone/.test(a) || /WPDesktop/.test(a)) {\n return \"Windows Phone\";\n }\n\n return \"Windows\";\n } else if (/(iPhone|iPad|iPod)/.test(a)) {\n return \"iOS\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/Android/.test(a)) {\n return \"Android\";\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(a)) {\n return \"BlackBerry\";\n } else if (/Mac/i.test(a)) {\n return \"Mac OS X\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/Linux/.test(a)) {\n return \"Linux\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/CrOS/.test(a)) {\n return \"Chrome OS\";\n }\n\n return \"\";\n}\n\nexport function deviceType(userAgent: string) {\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n if (/Windows Phone/i.test(userAgent) || /WPDesktop/.test(userAgent)) {\n return \"Windows Phone\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/iPad/.test(userAgent)) {\n return \"iPad\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/iPod/.test(userAgent)) {\n return \"iPod Touch\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/iPhone/.test(userAgent)) {\n return \"iPhone\";\n } else if (/(BlackBerry|PlayBook|BB10)/i.test(userAgent)) {\n return \"BlackBerry\";\n // eslint-disable-next-line @typescript-eslint/prefer-includes\n } else if (/Android/.test(userAgent)) {\n return \"Android\";\n }\n\n return \"\";\n}\n\nexport function referringDomain(referrer: string) {\n const split = referrer.split(\"/\");\n if (split.length >= 3) {\n return split[2];\n }\n\n return \"\";\n}\n"],"names":["browserName","userAgent","vendor","opera","browserVersion","browser","versionRegexs","regex","undefined","matches","parseFloat","osName","a","deviceType","referringDomain","referrer","split"],"mappings":";;AAAA,6FAA6F;AACtF,SAASA,YAAYC,SAAiB,EAAEC,MAAe,EAAEC,KAAc;IAC1E,uCAAuC;IACvCD,SAASA,UAAU,IAAI,wCAAwC;IAE/D,IAAIC,SAASF,UAAU,QAAQ,CAAC,UAAU;QACtC,IAA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A8B,IAAI,CAACA,YAAY;QACtD,OAAO;IACX,8DAA8D;IAC9D,OAAO,IAAI,UAAU,IAAI,CAACA,YAAY;QAClC,OAAO;IACX;IAEA,OAAO;AACX;AAEO,SAASa,gBAAgBC,QAAgB;IAC5C,MAAMC,QAAQD,SAAS,KAAK,CAAC;IAC7B,IAAIC,MAAM,MAAM,IAAI,GAAG;QACnB,OAAOA,KAAK,CAAC,EAAE;IACnB;IAEA,OAAO;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"react/MixpanelContext.js","sources":["webpack://@workleap/mixpanel/./src/react/MixpanelContext.tsx"],"sourcesContent":["import { createContext, type PropsWithChildren, useContext } from \"react\";\nimport type { MixpanelClient } from \"../js/MixpanelClient.ts\";\n\nexport const MixpanelContext = createContext<MixpanelClient | undefined>(undefined);\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface MixpanelProviderProps extends PropsWithChildren {\n client: MixpanelClient;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function MixpanelProvider(props: MixpanelProviderProps) {\n const {\n client,\n children\n } = props;\n\n return (\n <MixpanelContext.Provider value={client}>\n {children}\n </MixpanelContext.Provider>\n );\n}\n\nexport interface UseMixpanelClientOptions {\n /**\n * Whether or not an exception should be thrown if the client hasn't been provided.\n */\n throwOnUndefined?: boolean;\n}\n\nexport function useMixpanelClient(options?: { throwOnUndefined?: true }): MixpanelClient;\nexport function useMixpanelClient(options: { throwOnUndefined: false }): MixpanelClient | undefined;\n\n/**\n * Retrieve the Mixpanel client.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useMixpanelClient(options: UseMixpanelClientOptions = {}) {\n const {\n throwOnUndefined = true\n } = options;\n\n const client = useContext(MixpanelContext);\n\n if (!client && throwOnUndefined) {\n throw new Error(\"[mixpanel] The useMixpanelClient function is called before a MixpanelClient instance has been provided.\");\n }\n\n return client;\n}\n"],"names":["createContext","useContext","MixpanelContext","undefined","MixpanelProvider","props","client","children","useMixpanelClient","options","throwOnUndefined","Error"],"mappings":";;;;;;;;;AAA0E;AAGnE,MAAME,gCAAkBF,aAAaA,CAA6BG,WAAW;AASpF;;CAEC,GACM,SAASC,iBAAiBC,KAA4B;IACzD,MAAM,EACFC,MAAM,EACNC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACH,gBAAgB,QAAQ;QAAC,OAAOI;kBAC5BC;;AAGb;AAYA;;;CAGC,GACM,SAASC,kBAAkBC,UAAoC,CAAC,CAAC;IACpE,MAAM,EACFC,mBAAmB,IAAI,EAC1B,GAAGD;IAEJ,MAAMH,SAASL,UAAUA,CAACC;IAE1B,IAAI,CAACI,UAAUI,kBAAkB;QAC7B,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOL;AACX"}
1
+ {"version":3,"file":"react/MixpanelContext.js","sources":["../../src/react/MixpanelContext.tsx"],"sourcesContent":["import { createContext, type PropsWithChildren, useContext } from \"react\";\nimport type { MixpanelClient } from \"../js/MixpanelClient.ts\";\n\nexport const MixpanelContext = createContext<MixpanelClient | undefined>(undefined);\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface MixpanelProviderProps extends PropsWithChildren {\n client: MixpanelClient;\n}\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function MixpanelProvider(props: MixpanelProviderProps) {\n const {\n client,\n children\n } = props;\n\n return (\n <MixpanelContext.Provider value={client}>\n {children}\n </MixpanelContext.Provider>\n );\n}\n\nexport interface UseMixpanelClientOptions {\n /**\n * Whether or not an exception should be thrown if the client hasn't been provided.\n */\n throwOnUndefined?: boolean;\n}\n\nexport function useMixpanelClient(options?: { throwOnUndefined?: true }): MixpanelClient;\nexport function useMixpanelClient(options: { throwOnUndefined: false }): MixpanelClient | undefined;\n\n/**\n * Retrieve the Mixpanel client.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useMixpanelClient(options: UseMixpanelClientOptions = {}) {\n const {\n throwOnUndefined = true\n } = options;\n\n const client = useContext(MixpanelContext);\n\n if (!client && throwOnUndefined) {\n throw new Error(\"[mixpanel] The useMixpanelClient function is called before a MixpanelClient instance has been provided.\");\n }\n\n return client;\n}\n"],"names":["createContext","useContext","MixpanelContext","undefined","MixpanelProvider","props","client","children","useMixpanelClient","options","throwOnUndefined","Error"],"mappings":";;;;;;;;;AAA0E;AAGnE,MAAME,gCAAkBF,aAAaA,CAA6BG,WAAW;AASpF;;CAEC,GACM,SAASC,iBAAiBC,KAA4B;IACzD,MAAM,EACFC,MAAM,EACNC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACH,gBAAgB,QAAQ;QAAC,OAAOI;kBAC5BC;;AAGb;AAYA;;;CAGC,GACM,SAASC,kBAAkBC,UAAoC,CAAC,CAAC;IACpE,MAAM,EACFC,mBAAmB,IAAI,EAC1B,GAAGD;IAEJ,MAAMH,SAASL,UAAUA,CAACC;IAE1B,IAAI,CAACI,UAAUI,kBAAkB;QAC7B,MAAM,IAAIC,MAAM;IACpB;IAEA,OAAOL;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"react/index.js","sources":["webpack://@workleap/mixpanel/./src/react/index.ts"],"sourcesContent":["export * from \"../js/index.ts\";\nexport { MixpanelProvider, useMixpanelClient, type UseMixpanelClientOptions } from \"./MixpanelContext.tsx\";\nexport { useTrackingFunction, type UseTrackingFunctionOptions } from \"./useTrackingFunction.ts\";\n\n"],"names":["MixpanelProvider","useMixpanelClient","useTrackingFunction"],"mappings":";;;;;;;;;AAA+B;AAC4E;AACX"}
1
+ {"version":3,"file":"react/index.js","sources":["../../src/react/index.ts"],"sourcesContent":["export * from \"../js/index.ts\";\nexport { MixpanelProvider, useMixpanelClient, type UseMixpanelClientOptions } from \"./MixpanelContext.tsx\";\nexport { useTrackingFunction, type UseTrackingFunctionOptions } from \"./useTrackingFunction.ts\";\n\n"],"names":["MixpanelProvider","useMixpanelClient","useTrackingFunction"],"mappings":";;;;;;;;;AAA+B;AAC4E;AACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"react/useTrackingFunction.js","sources":["webpack://@workleap/mixpanel/./src/react/useTrackingFunction.ts"],"sourcesContent":["import type { CreateMixpanelTrackingFunctionOptions } from \"@workleap-telemetry/core\";\nimport { useContext, useMemo } from \"react\";\nimport { createTrackingFunction } from \"../js/createTrackingFunction.ts\";\nimport { MixpanelContext } from \"./MixpanelContext.tsx\";\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type UseTrackingFunctionOptions = CreateMixpanelTrackingFunctionOptions;\n\n/**\n * Create a Mixpanel tracking function.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useTrackingFunction(options: UseTrackingFunctionOptions = {}) {\n const {\n targetProductId\n } = options;\n\n const client = useContext(MixpanelContext);\n\n return useMemo(() => {\n const trackOptions = {\n targetProductId\n } satisfies CreateMixpanelTrackingFunctionOptions;\n\n // DEPRECATED: Grace period ends on January 1th 2026.\n // After the grace period, only create the tracking function from the client, remove the fallback\n // and also use \"useMixpanelClient\" to retrieve the client rather than \"useContext\".\n return client\n ? client.createTrackingFunction(trackOptions)\n : createTrackingFunction(trackOptions);\n }, [client, targetProductId]);\n}\n"],"names":["useContext","useMemo","createTrackingFunction","MixpanelContext","useTrackingFunction","options","targetProductId","client","trackOptions"],"mappings":";;;;;;;;;;;AAC4C;AAC6B;AACjB;AAOxD;;;CAGC,GACM,SAASI,oBAAoBC,UAAsC,CAAC,CAAC;IACxE,MAAM,EACFC,eAAe,EAClB,GAAGD;IAEJ,MAAME,SAASP,UAAUA,CAACG,eAAeA;IAEzC,OAAOF,OAAOA,CAAC;QACX,MAAMO,eAAe;YACjBF;QACJ;QAEA,qDAAqD;QACrD,iGAAiG;QACjG,oFAAoF;QACpF,OAAOC,SACDA,OAAO,sBAAsB,CAACC,gBAC9BN,sBAAsBA,CAACM;IACjC,GAAG;QAACD;QAAQD;KAAgB;AAChC"}
1
+ {"version":3,"file":"react/useTrackingFunction.js","sources":["../../src/react/useTrackingFunction.ts"],"sourcesContent":["import type { CreateMixpanelTrackingFunctionOptions } from \"@workleap-telemetry/core\";\nimport { useContext, useMemo } from \"react\";\nimport { createTrackingFunction } from \"../js/createTrackingFunction.ts\";\nimport { MixpanelContext } from \"./MixpanelContext.tsx\";\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport type UseTrackingFunctionOptions = CreateMixpanelTrackingFunctionOptions;\n\n/**\n * Create a Mixpanel tracking function.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useTrackingFunction(options: UseTrackingFunctionOptions = {}) {\n const {\n targetProductId\n } = options;\n\n const client = useContext(MixpanelContext);\n\n return useMemo(() => {\n const trackOptions = {\n targetProductId\n } satisfies CreateMixpanelTrackingFunctionOptions;\n\n // DEPRECATED: Grace period ends on January 1th 2026.\n // After the grace period, only create the tracking function from the client, remove the fallback\n // and also use \"useMixpanelClient\" to retrieve the client rather than \"useContext\".\n return client\n ? client.createTrackingFunction(trackOptions)\n : createTrackingFunction(trackOptions);\n }, [client, targetProductId]);\n}\n"],"names":["useContext","useMemo","createTrackingFunction","MixpanelContext","useTrackingFunction","options","targetProductId","client","trackOptions"],"mappings":";;;;;;;;;;;AAC4C;AAC6B;AACjB;AAOxD;;;CAGC,GACM,SAASI,oBAAoBC,UAAsC,CAAC,CAAC;IACxE,MAAM,EACFC,eAAe,EAClB,GAAGD;IAEJ,MAAME,SAASP,UAAUA,CAACG,eAAeA;IAEzC,OAAOF,OAAOA,CAAC;QACX,MAAMO,eAAe;YACjBF;QACJ;QAEA,qDAAqD;QACrD,iGAAiG;QACjG,oFAAoF;QACpF,OAAOC,SACDA,OAAO,sBAAsB,CAACC,gBAC9BN,sBAAsBA,CAACM;IACjC,GAAG;QAACD;QAAQD;KAAgB;AAChC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workleap/mixpanel",
3
3
  "author": "Workleap",
4
- "version": "4.0.6",
4
+ "version": "4.0.8",
5
5
  "description": "A package containing utilities for Mixpanel telemetry.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",
36
36
  "react-dom": "^18.0.0 || ^19.0.0",
37
- "@workleap/logrocket": "2.1.6"
37
+ "@workleap/logrocket": "2.1.8"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@workleap/logrocket": {
@@ -48,23 +48,23 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "@workleap/logging": "^1.3.2",
52
- "@workleap-telemetry/core": "1.0.5"
51
+ "@workleap/logging": "^1.3.3",
52
+ "@workleap-telemetry/core": "1.0.7"
53
53
  },
54
54
  "devDependencies": {
55
- "@eslint/js": "9.38.0",
56
- "@rsbuild/core": "1.5.17",
57
- "@rslib/core": "0.16.1",
58
- "@types/react": "19.2.2",
59
- "@typescript-eslint/parser": "8.46.2",
60
- "@workleap/eslint-configs": "1.1.0",
61
- "@workleap/rslib-configs": "1.1.3",
55
+ "@eslint/js": "9.39.2",
56
+ "@rsbuild/core": "1.7.2",
57
+ "@rslib/core": "0.19.2",
58
+ "@types/react": "19.2.8",
59
+ "@typescript-eslint/parser": "8.53.0",
60
+ "@workleap/eslint-configs": "1.1.9",
61
+ "@workleap/rslib-configs": "1.1.5",
62
62
  "@workleap/typescript-configs": "3.0.7",
63
- "eslint": "9.38.0",
64
- "happy-dom": "20.0.10",
63
+ "eslint": "9.39.2",
64
+ "happy-dom": "20.1.0",
65
65
  "typescript": "5.9.3",
66
- "typescript-eslint": "8.46.2",
67
- "vitest": "4.0.4"
66
+ "typescript-eslint": "8.53.0",
67
+ "vitest": "4.0.17"
68
68
  },
69
69
  "sideEffects": false,
70
70
  "scripts": {