@workleap/mixpanel 2.1.2 → 2.1.4

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,23 @@
1
1
  # @workleap/mixpanel
2
2
 
3
+ ## 2.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#60](https://github.com/workleap/wl-telemetry/pull/60) [`ed078b6`](https://github.com/workleap/wl-telemetry/commit/ed078b698cfb78e9299f53d0580bf5c5751b9294) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Improved debug vs information logs.
8
+
9
+ - Updated dependencies [[`ed078b6`](https://github.com/workleap/wl-telemetry/commit/ed078b698cfb78e9299f53d0580bf5c5751b9294)]:
10
+ - @workleap/telemetry@1.1.4
11
+
12
+ ## 2.1.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#58](https://github.com/workleap/wl-telemetry/pull/58) [`10d0c3f`](https://github.com/workleap/wl-telemetry/commit/10d0c3fe6e7565a2a95aeed9f3bc83274d90f1ad) Thanks [@patricklafrance](https://github.com/patricklafrance)! - LogRocketLogger object segment type is now unknown.
17
+
18
+ - Updated dependencies [[`10d0c3f`](https://github.com/workleap/wl-telemetry/commit/10d0c3fe6e7565a2a95aeed9f3bc83274d90f1ad)]:
19
+ - @workleap/telemetry@1.1.3
20
+
3
21
  ## 2.1.2
4
22
 
5
23
  ### Patch Changes
@@ -24,7 +24,7 @@ import { OtherProperties, getSuperProperties, getTelemetryProperties, setSuperPr
24
24
 
25
25
 
26
26
 
27
- function registerLogRocketSessionUrlListener(verbose = false) {
27
+ function registerLogRocketSessionUrlListener(logger) {
28
28
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
29
  // @ts-ignore
30
30
  if (globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__) {
@@ -32,13 +32,11 @@ function registerLogRocketSessionUrlListener(verbose = false) {
32
32
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
33
  // @ts-ignore
34
34
  globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__((sessionUrl)=>{
35
- if (verbose) {
36
- console.log("[mixpanel] Received LogRocket session replay URL:", sessionUrl);
37
- }
35
+ logger.withText("[mixpanel] Received LogRocket session replay URL:").withText(sessionUrl).debug();
38
36
  setSuperProperty(OtherProperties.LogRocketSessionUrl, sessionUrl);
39
37
  });
40
- } else if (verbose) {
41
- console.log("[mixpanel] Cannot integrate with LogRocket because \"globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\" is not available.");
38
+ } else {
39
+ logger.information("[mixpanel] Cannot integrate with LogRocket because \"globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\" is not available.");
42
40
  }
43
41
  }
44
42
  const initializationGuard = new HasExecutedGuard();
@@ -64,12 +62,12 @@ function __resetInitializationGuard() {
64
62
  // If LogRocket is already available, register the listener. Otherwise, subscribe to the bootstrapping store
65
63
  // and register the listener once a notification is received that LogRocket is registered.
66
64
  if (bootstrappingStore.state.isLogRocketReady) {
67
- registerLogRocketSessionUrlListener(verbose);
65
+ registerLogRocketSessionUrlListener(logger);
68
66
  } else {
69
67
  bootstrappingStore.subscribe((action, store, unsubscribe)=>{
70
68
  if (store.state.isLogRocketReady) {
71
69
  unsubscribe();
72
- registerLogRocketSessionUrlListener(verbose);
70
+ registerLogRocketSessionUrlListener(logger);
73
71
  }
74
72
  });
75
73
  }
@@ -79,7 +77,7 @@ function __resetInitializationGuard() {
79
77
  superProperties: getSuperProperties(),
80
78
  logger
81
79
  });
82
- logger.debug("[mixpanel] Mixpanel is initialized.");
80
+ logger.information("[mixpanel] Mixpanel is initialized.");
83
81
  }
84
82
 
85
83
  export { __resetInitializationGuard, initializeMixpanel };
@@ -1 +1 @@
1
- {"version":3,"file":"js/initializeMixpanel.js","sources":["webpack://@workleap/mixpanel/./src/js/initializeMixpanel.ts"],"sourcesContent":["import { createCompositeLogger, type RootLogger } from \"@workleap/logging\";\nimport { createBootstrappingStore, createTelemetryContext } from \"@workleap/telemetry\";\nimport { setMixpanelContext } from \"./context.ts\";\nimport { getTrackingEndpoint, type Environment } from \"./env.ts\";\nimport { HasExecutedGuard } from \"./HasExecutedGuard.ts\";\nimport { getSuperProperties, getTelemetryProperties, OtherProperties, setSuperProperties, setSuperProperty } from \"./properties.ts\";\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 */\n trackingEndpoint?: string;\n /**\n * Whether or not debug information should be logged to the console.\n */\n verbose?: boolean;\n /**\n * An array of RootLogger instances.\n */\n loggers?: RootLogger[];\n}\n\nfunction registerLogRocketSessionUrlListener(verbose = false) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__) {\n // Automatically add the LogRocket session URL to all Honeycomb traces as an attribute.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__((sessionUrl: string) => {\n if (verbose) {\n console.log(\"[mixpanel] Received LogRocket session replay URL:\", sessionUrl);\n }\n\n setSuperProperty(OtherProperties.LogRocketSessionUrl, sessionUrl);\n });\n } else if (verbose) {\n console.log(\"[mixpanel] Cannot integrate with LogRocket because \\\"globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\\\" is not available.\");\n }\n}\n\nconst initializationGuard = new HasExecutedGuard();\n\n// This function should only be used by tests.\nexport function __resetInitializationGuard() {\n initializationGuard.reset();\n}\n\n/**\n * Creates a function that sends tracking events to the tracking API.\n * @param productId Your product identifier.\n * @param envOrTrackingApiBaseUrl The environment to get the navigation url from or a base URL.\n * @param options Options for creating the tracking function.\n * @returns A function that sends tracking events to the tracking API.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function initializeMixpanel(productId: string, envOrTrackingApiBaseUrl: Environment | (string & {}), options: InitializeMixpanelOptions = {}) {\n const {\n trackingEndpoint,\n verbose = false,\n loggers = []\n } = options;\n\n initializationGuard.throw(\"[mixpanel] Mixpanel has already been initialized. Did you call the \\\"initializeMixpanel\\\" function twice?\");\n\n const logger = createCompositeLogger(verbose, loggers);\n const endpoint = getTrackingEndpoint(envOrTrackingApiBaseUrl, trackingEndpoint);\n const telemetryContext = createTelemetryContext(logger);\n\n setSuperProperties(getTelemetryProperties(telemetryContext));\n\n const bootstrappingStore = createBootstrappingStore(logger);\n\n // If LogRocket is already available, register the listener. Otherwise, subscribe to the bootstrapping store\n // and register the listener once a notification is received that LogRocket is registered.\n if (bootstrappingStore.state.isLogRocketReady) {\n registerLogRocketSessionUrlListener(verbose);\n } else {\n bootstrappingStore.subscribe((action, store, unsubscribe) => {\n if (store.state.isLogRocketReady) {\n unsubscribe();\n registerLogRocketSessionUrlListener(verbose);\n }\n });\n }\n\n setMixpanelContext({\n productId,\n endpoint,\n superProperties: getSuperProperties(),\n logger\n });\n\n logger.debug(\"[mixpanel] Mixpanel is initialized.\");\n}\n"],"names":["createCompositeLogger","createBootstrappingStore","createTelemetryContext","setMixpanelContext","getTrackingEndpoint","HasExecutedGuard","getSuperProperties","getTelemetryProperties","OtherProperties","setSuperProperties","setSuperProperty","registerLogRocketSessionUrlListener","verbose","globalThis","sessionUrl","console","initializationGuard","__resetInitializationGuard","initializeMixpanel","productId","envOrTrackingApiBaseUrl","options","trackingEndpoint","loggers","logger","endpoint","telemetryContext","bootstrappingStore","action","store","unsubscribe"],"mappings":";;;;;;;;;;;;;;;;;;;;AAA2E;AACY;AACrC;AACe;AACR;AAC2E;AAqBpI,SAASW,oCAAoCC,UAAU,KAAK;IACxD,6DAA6D;IAC7D,aAAa;IACb,IAAIC,WAAW,mEAAmE,EAAE;QAChF,uFAAuF;QACvF,6DAA6D;QAC7D,aAAa;QACbA,WAAW,mEAAmE,CAAC,CAACC;YAC5E,IAAIF,SAAS;gBACTG,QAAQ,GAAG,CAAC,qDAAqDD;YACrE;YAEAJ,gBAAgBA,CAACF,mCAAmC,EAAEM;QAC1D;IACJ,OAAO,IAAIF,SAAS;QAChBG,QAAQ,GAAG,CAAC;IAChB;AACJ;AAEA,MAAMC,sBAAsB,IAAIX,gBAAgBA;AAEhD,8CAA8C;AACvC,SAASY;IACZD,oBAAoB,KAAK;AAC7B;AAEA;;;;;;;CAOC,GACM,SAASE,mBAAmBC,SAAiB,EAAEC,uBAAoD,EAAEC,UAAqC,CAAC,CAAC;IAC/I,MAAM,EACFC,gBAAgB,EAChBV,UAAU,KAAK,EACfW,UAAU,EAAE,EACf,GAAGF;IAEJL,oBAAoB,KAAK,CAAC;IAE1B,MAAMQ,SAASxB,qBAAqBA,CAACY,SAASW;IAC9C,MAAME,WAAWrB,mBAAmBA,CAACgB,yBAAyBE;IAC9D,MAAMI,mBAAmBxB,sBAAsBA,CAACsB;IAEhDf,kBAAkBA,CAACF,sBAAsBA,CAACmB;IAE1C,MAAMC,qBAAqB1B,wBAAwBA,CAACuB;IAEpD,4GAA4G;IAC5G,0FAA0F;IAC1F,IAAIG,mBAAmB,KAAK,CAAC,gBAAgB,EAAE;QAC3ChB,oCAAoCC;IACxC,OAAO;QACHe,mBAAmB,SAAS,CAAC,CAACC,QAAQC,OAAOC;YACzC,IAAID,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBAC9BC;gBACAnB,oCAAoCC;YACxC;QACJ;IACJ;IAEAT,kBAAkBA,CAAC;QACfgB;QACAM;QACA,iBAAiBnB,kBAAkBA;QACnCkB;IACJ;IAEAA,OAAO,KAAK,CAAC;AACjB"}
1
+ {"version":3,"file":"js/initializeMixpanel.js","sources":["webpack://@workleap/mixpanel/./src/js/initializeMixpanel.ts"],"sourcesContent":["import { createCompositeLogger, type Logger, type RootLogger } from \"@workleap/logging\";\nimport { createBootstrappingStore, createTelemetryContext } from \"@workleap/telemetry\";\nimport { setMixpanelContext } from \"./context.ts\";\nimport { getTrackingEndpoint, type Environment } from \"./env.ts\";\nimport { HasExecutedGuard } from \"./HasExecutedGuard.ts\";\nimport { getSuperProperties, getTelemetryProperties, OtherProperties, setSuperProperties, setSuperProperty } from \"./properties.ts\";\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 */\n trackingEndpoint?: string;\n /**\n * Whether or not debug information should be logged to the console.\n */\n verbose?: boolean;\n /**\n * An array of RootLogger instances.\n */\n loggers?: RootLogger[];\n}\n\nfunction registerLogRocketSessionUrlListener(logger: Logger) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__) {\n // Automatically add the LogRocket session URL to all Honeycomb traces as an attribute.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__((sessionUrl: string) => {\n logger\n .withText(\"[mixpanel] Received LogRocket session replay URL:\")\n .withText(sessionUrl)\n .debug();\n\n setSuperProperty(OtherProperties.LogRocketSessionUrl, sessionUrl);\n });\n } else {\n logger.information(\"[mixpanel] Cannot integrate with LogRocket because \\\"globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\\\" is not available.\");\n }\n}\n\nconst initializationGuard = new HasExecutedGuard();\n\n// This function should only be used by tests.\nexport function __resetInitializationGuard() {\n initializationGuard.reset();\n}\n\n/**\n * Creates a function that sends tracking events to the tracking API.\n * @param productId Your product identifier.\n * @param envOrTrackingApiBaseUrl The environment to get the navigation url from or a base URL.\n * @param options Options for creating the tracking function.\n * @returns A function that sends tracking events to the tracking API.\n * @see {@link https://workleap.github.io/wl-telemetry}\n */\nexport function initializeMixpanel(productId: string, envOrTrackingApiBaseUrl: Environment | (string & {}), options: InitializeMixpanelOptions = {}) {\n const {\n trackingEndpoint,\n verbose = false,\n loggers = []\n } = options;\n\n initializationGuard.throw(\"[mixpanel] Mixpanel has already been initialized. Did you call the \\\"initializeMixpanel\\\" function twice?\");\n\n const logger = createCompositeLogger(verbose, loggers);\n const endpoint = getTrackingEndpoint(envOrTrackingApiBaseUrl, trackingEndpoint);\n const telemetryContext = createTelemetryContext(logger);\n\n setSuperProperties(getTelemetryProperties(telemetryContext));\n\n const bootstrappingStore = createBootstrappingStore(logger);\n\n // If LogRocket is already available, register the listener. Otherwise, subscribe to the bootstrapping store\n // and register the listener once a notification is received that LogRocket is registered.\n if (bootstrappingStore.state.isLogRocketReady) {\n registerLogRocketSessionUrlListener(logger);\n } else {\n bootstrappingStore.subscribe((action, store, unsubscribe) => {\n if (store.state.isLogRocketReady) {\n unsubscribe();\n registerLogRocketSessionUrlListener(logger);\n }\n });\n }\n\n setMixpanelContext({\n productId,\n endpoint,\n superProperties: getSuperProperties(),\n logger\n });\n\n logger.information(\"[mixpanel] Mixpanel is initialized.\");\n}\n"],"names":["createCompositeLogger","createBootstrappingStore","createTelemetryContext","setMixpanelContext","getTrackingEndpoint","HasExecutedGuard","getSuperProperties","getTelemetryProperties","OtherProperties","setSuperProperties","setSuperProperty","registerLogRocketSessionUrlListener","logger","globalThis","sessionUrl","initializationGuard","__resetInitializationGuard","initializeMixpanel","productId","envOrTrackingApiBaseUrl","options","trackingEndpoint","verbose","loggers","endpoint","telemetryContext","bootstrappingStore","action","store","unsubscribe"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAwF;AACD;AACrC;AACe;AACR;AAC2E;AAqBpI,SAASW,oCAAoCC,MAAc;IACvD,6DAA6D;IAC7D,aAAa;IACb,IAAIC,WAAW,mEAAmE,EAAE;QAChF,uFAAuF;QACvF,6DAA6D;QAC7D,aAAa;QACbA,WAAW,mEAAmE,CAAC,CAACC;YAC5EF,OACK,QAAQ,CAAC,qDACT,QAAQ,CAACE,YACT,KAAK;YAEVJ,gBAAgBA,CAACF,mCAAmC,EAAEM;QAC1D;IACJ,OAAO;QACHF,OAAO,WAAW,CAAC;IACvB;AACJ;AAEA,MAAMG,sBAAsB,IAAIV,gBAAgBA;AAEhD,8CAA8C;AACvC,SAASW;IACZD,oBAAoB,KAAK;AAC7B;AAEA;;;;;;;CAOC,GACM,SAASE,mBAAmBC,SAAiB,EAAEC,uBAAoD,EAAEC,UAAqC,CAAC,CAAC;IAC/I,MAAM,EACFC,gBAAgB,EAChBC,UAAU,KAAK,EACfC,UAAU,EAAE,EACf,GAAGH;IAEJL,oBAAoB,KAAK,CAAC;IAE1B,MAAMH,SAASZ,qBAAqBA,CAACsB,SAASC;IAC9C,MAAMC,WAAWpB,mBAAmBA,CAACe,yBAAyBE;IAC9D,MAAMI,mBAAmBvB,sBAAsBA,CAACU;IAEhDH,kBAAkBA,CAACF,sBAAsBA,CAACkB;IAE1C,MAAMC,qBAAqBzB,wBAAwBA,CAACW;IAEpD,4GAA4G;IAC5G,0FAA0F;IAC1F,IAAIc,mBAAmB,KAAK,CAAC,gBAAgB,EAAE;QAC3Cf,oCAAoCC;IACxC,OAAO;QACHc,mBAAmB,SAAS,CAAC,CAACC,QAAQC,OAAOC;YACzC,IAAID,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBAC9BC;gBACAlB,oCAAoCC;YACxC;QACJ;IACJ;IAEAT,kBAAkBA,CAAC;QACfe;QACAM;QACA,iBAAiBlB,kBAAkBA;QACnCM;IACJ;IAEAA,OAAO,WAAW,CAAC;AACvB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workleap/mixpanel",
3
3
  "author": "Workleap",
4
- "version": "2.1.2",
4
+ "version": "2.1.4",
5
5
  "description": "A package containing utilities for Mixpanel telemetry.",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -45,8 +45,8 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@workleap/logging": "^1.2.1",
49
- "@workleap/telemetry": "1.1.2"
48
+ "@workleap/logging": "^1.2.2",
49
+ "@workleap/telemetry": "1.1.4"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@rsbuild/core": "1.4.6",
@@ -1,4 +1,4 @@
1
- import { createCompositeLogger, type RootLogger } from "@workleap/logging";
1
+ import { createCompositeLogger, type Logger, type RootLogger } from "@workleap/logging";
2
2
  import { createBootstrappingStore, createTelemetryContext } from "@workleap/telemetry";
3
3
  import { setMixpanelContext } from "./context.ts";
4
4
  import { getTrackingEndpoint, type Environment } from "./env.ts";
@@ -24,7 +24,7 @@ export interface InitializeMixpanelOptions {
24
24
  loggers?: RootLogger[];
25
25
  }
26
26
 
27
- function registerLogRocketSessionUrlListener(verbose = false) {
27
+ function registerLogRocketSessionUrlListener(logger: Logger) {
28
28
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
29
29
  // @ts-ignore
30
30
  if (globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__) {
@@ -32,14 +32,15 @@ function registerLogRocketSessionUrlListener(verbose = false) {
32
32
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
33
33
  // @ts-ignore
34
34
  globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__((sessionUrl: string) => {
35
- if (verbose) {
36
- console.log("[mixpanel] Received LogRocket session replay URL:", sessionUrl);
37
- }
35
+ logger
36
+ .withText("[mixpanel] Received LogRocket session replay URL:")
37
+ .withText(sessionUrl)
38
+ .debug();
38
39
 
39
40
  setSuperProperty(OtherProperties.LogRocketSessionUrl, sessionUrl);
40
41
  });
41
- } else if (verbose) {
42
- console.log("[mixpanel] Cannot integrate with LogRocket because \"globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\" is not available.");
42
+ } else {
43
+ logger.information("[mixpanel] Cannot integrate with LogRocket because \"globalThis.__WLP_LOGROCKET_INSTRUMENTATION_REGISTER_GET_SESSION_URL_LISTENER__\" is not available.");
43
44
  }
44
45
  }
45
46
 
@@ -78,12 +79,12 @@ export function initializeMixpanel(productId: string, envOrTrackingApiBaseUrl: E
78
79
  // If LogRocket is already available, register the listener. Otherwise, subscribe to the bootstrapping store
79
80
  // and register the listener once a notification is received that LogRocket is registered.
80
81
  if (bootstrappingStore.state.isLogRocketReady) {
81
- registerLogRocketSessionUrlListener(verbose);
82
+ registerLogRocketSessionUrlListener(logger);
82
83
  } else {
83
84
  bootstrappingStore.subscribe((action, store, unsubscribe) => {
84
85
  if (store.state.isLogRocketReady) {
85
86
  unsubscribe();
86
- registerLogRocketSessionUrlListener(verbose);
87
+ registerLogRocketSessionUrlListener(logger);
87
88
  }
88
89
  });
89
90
  }
@@ -95,5 +96,5 @@ export function initializeMixpanel(productId: string, envOrTrackingApiBaseUrl: E
95
96
  logger
96
97
  });
97
98
 
98
- logger.debug("[mixpanel] Mixpanel is initialized.");
99
+ logger.information("[mixpanel] Mixpanel is initialized.");
99
100
  }