@workleap/mixpanel 4.0.3 → 4.0.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,14 @@
|
|
|
1
1
|
# @workleap/mixpanel
|
|
2
2
|
|
|
3
|
+
## 4.0.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#115](https://github.com/workleap/wl-telemetry/pull/115) [`97f3f76`](https://github.com/workleap/wl-telemetry/commit/97f3f76199231d43a56d78209e8193a781df490d) Thanks [@patricklafrance](https://github.com/patricklafrance)! - Renamed `dontThrowOnUndefined` to `throwOnUndefined` for the hooks to retrieve the telemetry clients.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`97f3f76`](https://github.com/workleap/wl-telemetry/commit/97f3f76199231d43a56d78209e8193a781df490d)]:
|
|
10
|
+
- @workleap/logrocket@2.1.4
|
|
11
|
+
|
|
3
12
|
## 4.0.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -15,11 +15,11 @@ export interface UseMixpanelClientOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Whether or not an exception should be thrown if the client hasn't been provided.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
throwOnUndefined?: boolean;
|
|
19
19
|
}
|
|
20
20
|
export declare function useMixpanelClient(options?: {
|
|
21
|
-
|
|
21
|
+
throwOnUndefined?: true;
|
|
22
22
|
}): MixpanelClient;
|
|
23
23
|
export declare function useMixpanelClient(options: {
|
|
24
|
-
|
|
24
|
+
throwOnUndefined: false;
|
|
25
25
|
}): MixpanelClient | undefined;
|
|
@@ -22,9 +22,9 @@ const MixpanelContext = /*#__PURE__*/ createContext(undefined);
|
|
|
22
22
|
* Retrieve the Mixpanel client.
|
|
23
23
|
* @see {@link https://workleap.github.io/wl-telemetry}
|
|
24
24
|
*/ function useMixpanelClient(options = {}) {
|
|
25
|
-
const {
|
|
25
|
+
const { throwOnUndefined = true } = options;
|
|
26
26
|
const client = useContext(MixpanelContext);
|
|
27
|
-
if (!client &&
|
|
27
|
+
if (!client && throwOnUndefined) {
|
|
28
28
|
throw new Error("[mixpanel] The useMixpanelClient function is called before a MixpanelClient instance has been provided.");
|
|
29
29
|
}
|
|
30
30
|
return client;
|
|
@@ -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
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workleap/mixpanel",
|
|
3
3
|
"author": "Workleap",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.4",
|
|
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.
|
|
38
|
+
"@workleap/logrocket": "2.1.4"
|
|
39
39
|
},
|
|
40
40
|
"peerDependenciesMeta": {
|
|
41
41
|
"@workleap/logrocket": {
|
|
@@ -30,11 +30,11 @@ export interface UseMixpanelClientOptions {
|
|
|
30
30
|
/**
|
|
31
31
|
* Whether or not an exception should be thrown if the client hasn't been provided.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
throwOnUndefined?: boolean;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function useMixpanelClient(options?: {
|
|
37
|
-
export function useMixpanelClient(options: {
|
|
36
|
+
export function useMixpanelClient(options?: { throwOnUndefined?: true }): MixpanelClient;
|
|
37
|
+
export function useMixpanelClient(options: { throwOnUndefined: false }): MixpanelClient | undefined;
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Retrieve the Mixpanel client.
|
|
@@ -42,12 +42,12 @@ export function useMixpanelClient(options: { dontThrowOnUndefined: true }): Mixp
|
|
|
42
42
|
*/
|
|
43
43
|
export function useMixpanelClient(options: UseMixpanelClientOptions = {}) {
|
|
44
44
|
const {
|
|
45
|
-
|
|
45
|
+
throwOnUndefined = true
|
|
46
46
|
} = options;
|
|
47
47
|
|
|
48
48
|
const client = useContext(MixpanelContext);
|
|
49
49
|
|
|
50
|
-
if (!client &&
|
|
50
|
+
if (!client && throwOnUndefined) {
|
|
51
51
|
throw new Error("[mixpanel] The useMixpanelClient function is called before a MixpanelClient instance has been provided.");
|
|
52
52
|
}
|
|
53
53
|
|