@workleap/mixpanel 4.0.0 → 4.0.2

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,24 @@
1
1
  # @workleap/mixpanel
2
2
 
3
+ ## 4.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#112](https://github.com/workleap/wl-telemetry/pull/112) [`5d70e28`](https://github.com/workleap/wl-telemetry/commit/5d70e286d428ee5ffcd3466924662274f97232c8) Thanks [@alexasselin008](https://github.com/alexasselin008)! - Bump versions to test OIDC publishing
8
+
9
+ - Updated dependencies [[`5d70e28`](https://github.com/workleap/wl-telemetry/commit/5d70e286d428ee5ffcd3466924662274f97232c8)]:
10
+ - @workleap-telemetry/core@1.0.3
11
+ - @workleap/logrocket@2.1.2
12
+
13
+ ## 4.0.1
14
+
15
+ ### Patch Changes
16
+
17
+ - [#109](https://github.com/workleap/wl-telemetry/pull/109) [`0a423ff`](https://github.com/workleap/wl-telemetry/commit/0a423ffc47baea121607283fc23aacdad43e36f9) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Fix a typing issues with the React context providers.
18
+
19
+ - Updated dependencies [[`0a423ff`](https://github.com/workleap/wl-telemetry/commit/0a423ffc47baea121607283fc23aacdad43e36f9)]:
20
+ - @workleap/logrocket@2.1.1
21
+
3
22
  ## 4.0.0
4
23
 
5
24
  ### Minor Changes
@@ -1,10 +1,10 @@
1
- import type { CreateMixpanelTrackingFunctionOptions, MixpanelTrackingFunction } from "@workleap-telemetry/core";
1
+ import type { CreateMixpanelTrackingFunctionOptions, MixpanelPartialClient, MixpanelTrackingFunction } from "@workleap-telemetry/core";
2
2
  import type { Logger } from "@workleap/logging";
3
3
  export type MixpanelGlobalEventProperties = Map<string, unknown>;
4
4
  /**
5
5
  * @see {@link https://workleap.github.io/wl-telemetry}
6
6
  */
7
- export declare class MixpanelClient {
7
+ export declare class MixpanelClient implements MixpanelPartialClient {
8
8
  #private;
9
9
  constructor(productId: string, endpoint: string, globalEventProperties: MixpanelGlobalEventProperties, logger: Logger);
10
10
  /**
@@ -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 class 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 /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\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 /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n setGlobalEventProperty(key: string, value: unknown) {\n this.#globalEventProperties.set(key, value);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\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","MixpanelClient","productId","endpoint","globalEventProperties","logger","options","targetProductId","trackFunction","eventName","properties","_options","keepAlive","baseProperties","allProperties","Object","fetch","JSON","error","key","value","values","x"],"mappings":";;;;;AAEoD;AAIpD;;CAEC,GACM,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;;KAEC,GACD,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,yBAA0BF,mBAAmB;wBAC7C,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;;KAEC,GACD,uBAAuBW,GAAW,EAAEC,KAAc,EAAE;QAChD,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAACD,KAAKC;IACzC;IAEA;;KAEC,GACD,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":["webpack://@workleap/mixpanel/./src/js/MixpanelClient.ts"],"sourcesContent":["import type { CreateMixpanelTrackingFunctionOptions, MixpanelPartialClient, 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 class MixpanelClient implements MixpanelPartialClient {\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 /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\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 /**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\n setGlobalEventProperty(key: string, value: unknown) {\n this.#globalEventProperties.set(key, value);\n }\n\n /**\n * @see {@link https://workleap.github.io/wl-telemetry}\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","MixpanelClient","productId","endpoint","globalEventProperties","logger","options","targetProductId","trackFunction","eventName","properties","_options","keepAlive","baseProperties","allProperties","Object","fetch","JSON","error","key","value","values","x"],"mappings":";;;;;AAEoD;AAIpD;;CAEC,GACM,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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;IACJ;AACJ"}
@@ -1,11 +1,11 @@
1
+ import type { MixpanelPartialClient } from "@workleap-telemetry/core";
1
2
  import { type PropsWithChildren } from "react";
2
- import type { MixpanelClient } from "../js/MixpanelClient.ts";
3
- export declare const MixpanelContext: import("react").Context<MixpanelClient | undefined>;
3
+ export declare const MixpanelContext: import("react").Context<MixpanelPartialClient | undefined>;
4
4
  /**
5
5
  * @see {@link https://workleap.github.io/wl-telemetry}
6
6
  */
7
7
  export interface MixpanelProviderProps extends PropsWithChildren {
8
- client: MixpanelClient;
8
+ client: MixpanelPartialClient;
9
9
  }
10
10
  /**
11
11
  * @see {@link https://workleap.github.io/wl-telemetry}
@@ -15,4 +15,4 @@ export declare function MixpanelProvider(props: MixpanelProviderProps): import("
15
15
  * Retrieve the Mixpanel client.
16
16
  * @see {@link https://workleap.github.io/wl-telemetry}
17
17
  */
18
- export declare function useMixpanelClient(): MixpanelClient;
18
+ export declare function useMixpanelClient(): MixpanelPartialClient;
@@ -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\n/**\n * Retrieve the Mixpanel client.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useMixpanelClient() {\n const client = useContext(MixpanelContext);\n\n if (!client) {\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","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;AAEA;;;CAGC,GACM,SAASC;IACZ,MAAMF,SAASL,UAAUA,CAACC;IAE1B,IAAI,CAACI,QAAQ;QACT,MAAM,IAAIG,MAAM;IACpB;IAEA,OAAOH;AACX"}
1
+ {"version":3,"file":"react/MixpanelContext.js","sources":["webpack://@workleap/mixpanel/./src/react/MixpanelContext.tsx"],"sourcesContent":["import type { MixpanelPartialClient } from \"@workleap-telemetry/core\";\nimport { createContext, type PropsWithChildren, useContext } from \"react\";\n\nexport const MixpanelContext = createContext<MixpanelPartialClient | undefined>(undefined);\n\n/**\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport interface MixpanelProviderProps extends PropsWithChildren {\n client: MixpanelPartialClient;\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\n/**\n * Retrieve the Mixpanel client.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function useMixpanelClient() {\n const client = useContext(MixpanelContext);\n\n if (!client) {\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","Error"],"mappings":";;;;;;;;;AAC0E;AAEnE,MAAME,gCAAkBF,aAAaA,CAAoCG,WAAW;AAS3F;;CAEC,GACM,SAASC,iBAAiBC,KAA4B;IACzD,MAAM,EACFC,MAAM,EACNC,QAAQ,EACX,GAAGF;IAEJ,qBACI,IAACH,gBAAgB,QAAQ;QAAC,OAAOI;kBAC5BC;;AAGb;AAEA;;;CAGC,GACM,SAASC;IACZ,MAAMF,SAASL,UAAUA,CAACC;IAE1B,IAAI,CAACI,QAAQ;QACT,MAAM,IAAIG,MAAM;IACpB;IAEA,OAAOH;AACX"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workleap/mixpanel",
3
3
  "author": "Workleap",
4
- "version": "4.0.0",
4
+ "version": "4.0.2",
5
5
  "description": "A package containing utilities for Mixpanel telemetry.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "peerDependencies": {
36
36
  "react": "^18.0.0 || ^19.0.0",
37
37
  "react-dom": "^18.0.0 || ^19.0.0",
38
- "@workleap/logrocket": "2.1.0"
38
+ "@workleap/logrocket": "2.1.2"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@workleap/logrocket": {
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@workleap/logging": "^1.3.0",
53
- "@workleap-telemetry/core": "1.0.2"
53
+ "@workleap-telemetry/core": "1.0.3"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@rsbuild/core": "1.5.13",
@@ -1,4 +1,4 @@
1
- import type { CreateMixpanelTrackingFunctionOptions, MixpanelTrackingFunction } from "@workleap-telemetry/core";
1
+ import type { CreateMixpanelTrackingFunctionOptions, MixpanelPartialClient, MixpanelTrackingFunction } from "@workleap-telemetry/core";
2
2
  import type { Logger } from "@workleap/logging";
3
3
  import { getBaseProperties } from "./properties.ts";
4
4
 
@@ -7,7 +7,7 @@ export type MixpanelGlobalEventProperties = Map<string, unknown>;
7
7
  /**
8
8
  * @see {@link https://workleap.github.io/wl-telemetry}
9
9
  */
10
- export class MixpanelClient {
10
+ export class MixpanelClient implements MixpanelPartialClient {
11
11
  readonly #productId: string;
12
12
  readonly #endpoint: string;
13
13
  readonly #globalEventProperties: MixpanelGlobalEventProperties;
@@ -1,13 +1,13 @@
1
+ import type { MixpanelPartialClient } from "@workleap-telemetry/core";
1
2
  import { createContext, type PropsWithChildren, useContext } from "react";
2
- import type { MixpanelClient } from "../js/MixpanelClient.ts";
3
3
 
4
- export const MixpanelContext = createContext<MixpanelClient | undefined>(undefined);
4
+ export const MixpanelContext = createContext<MixpanelPartialClient | undefined>(undefined);
5
5
 
6
6
  /**
7
7
  * @see {@link https://workleap.github.io/wl-telemetry}
8
8
  */
9
9
  export interface MixpanelProviderProps extends PropsWithChildren {
10
- client: MixpanelClient;
10
+ client: MixpanelPartialClient;
11
11
  }
12
12
 
13
13
  /**