@jitsu/jitsu-react 1.9.9-canary.990.20241015090416 → 1.9.10
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/dist/JitsuContext.d.ts +6 -7
- package/dist/JitsuProvider.d.ts +7 -7
- package/dist/index.d.ts +3 -3
- package/dist/index.js +28 -4
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +10 -5
- package/dist/index.modern.js.map +1 -1
- package/dist/useJitsu.d.ts +22 -22
- package/package.json +4 -4
package/dist/JitsuContext.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default JitsuContext;
|
|
1
|
+
import { AnalyticsInterface } from "@jitsu/js";
|
|
2
|
+
export type JitsuInstance = {
|
|
3
|
+
analytics: AnalyticsInterface;
|
|
4
|
+
};
|
|
5
|
+
declare const JitsuContext: import("react").Context<JitsuInstance | null>;
|
|
6
|
+
export default JitsuContext;
|
package/dist/JitsuProvider.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { PropsWithChildren } from "react";
|
|
3
|
-
import { ExtendedJitsuOptions } from "./useJitsu";
|
|
4
|
-
declare const JitsuProvider: React.FC<PropsWithChildren<{
|
|
5
|
-
options: ExtendedJitsuOptions;
|
|
6
|
-
}>>;
|
|
7
|
-
export default JitsuProvider;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
import { ExtendedJitsuOptions } from "./useJitsu";
|
|
4
|
+
declare const JitsuProvider: React.FC<PropsWithChildren<{
|
|
5
|
+
options: ExtendedJitsuOptions;
|
|
6
|
+
}>>;
|
|
7
|
+
export default JitsuProvider;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as JitsuContext } from "./JitsuContext";
|
|
2
|
-
export { default as JitsuProvider } from "./JitsuProvider";
|
|
3
|
-
export { default as useJitsu } from "./useJitsu";
|
|
1
|
+
export { default as JitsuContext } from "./JitsuContext";
|
|
2
|
+
export { default as JitsuProvider } from "./JitsuProvider";
|
|
3
|
+
export { default as useJitsu } from "./useJitsu";
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
var React = require('react');
|
|
2
2
|
var js = require('@jitsu/js');
|
|
3
3
|
|
|
4
|
+
function _interopNamespace(e) {
|
|
5
|
+
if (e && e.__esModule) return e;
|
|
6
|
+
var n = Object.create(null);
|
|
7
|
+
if (e) {
|
|
8
|
+
Object.keys(e).forEach(function (k) {
|
|
9
|
+
if (k !== 'default') {
|
|
10
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return e[k]; }
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
n["default"] = e;
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
23
|
+
|
|
4
24
|
var JitsuContext = React.createContext(null);
|
|
5
25
|
|
|
6
26
|
var JitsuProvider = function JitsuProvider(props) {
|
|
@@ -21,20 +41,23 @@ var JitsuProvider = function JitsuProvider(props) {
|
|
|
21
41
|
};
|
|
22
42
|
}
|
|
23
43
|
}, [props.options.disabled, props.options.host]);
|
|
24
|
-
return
|
|
44
|
+
return React__namespace.createElement(JitsuContext.Provider, {
|
|
25
45
|
value: instance
|
|
26
46
|
}, props.children);
|
|
27
47
|
};
|
|
28
48
|
|
|
49
|
+
/**
|
|
50
|
+
* See for details http://jitsu.com/docs/sending-data/js-sdk/react
|
|
51
|
+
*/
|
|
29
52
|
function useJitsu(opts) {
|
|
30
53
|
var jitsuInstance = React.useContext(JitsuContext);
|
|
31
|
-
if (opts
|
|
54
|
+
if (opts != null && opts.disabled) {
|
|
32
55
|
return {
|
|
33
56
|
analytics: js.emptyAnalytics
|
|
34
57
|
};
|
|
35
58
|
}
|
|
36
59
|
if (!jitsuInstance) {
|
|
37
|
-
if (opts
|
|
60
|
+
if (opts != null && opts.host || opts != null && opts.echoEvents) {
|
|
38
61
|
return {
|
|
39
62
|
analytics: js.jitsuAnalytics(opts)
|
|
40
63
|
};
|
|
@@ -45,8 +68,9 @@ function useJitsu(opts) {
|
|
|
45
68
|
analytics: js.emptyAnalytics
|
|
46
69
|
};
|
|
47
70
|
}
|
|
48
|
-
} else if (opts
|
|
71
|
+
} else if (opts != null && opts.host || opts != null && opts.echoEvents) {
|
|
49
72
|
throw new Error("Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react");
|
|
73
|
+
//Jitsu analytics is initialized inside provider
|
|
50
74
|
} else if (jitsuInstance.analytics) {
|
|
51
75
|
return jitsuInstance;
|
|
52
76
|
} else {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/js\";\n\nexport type JitsuInstance = { analytics: AnalyticsInterface };\n\nconst JitsuContext = createContext<JitsuInstance | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren, useMemo } from \"react\";\nimport JitsuContext, { JitsuInstance } from \"./JitsuContext\";\nimport { emptyAnalytics, jitsuAnalytics } from \"@jitsu/js\";\nimport { ExtendedJitsuOptions } from \"./useJitsu\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: ExtendedJitsuOptions }>> = props => {\n const instance: JitsuInstance = useMemo(() => {\n if (props.options.disabled) {\n return { analytics: emptyAnalytics };\n } else if (!props.options.host) {\n const msg = \"<JitsuProvider />. Jitsu host is not defined. Jitsu will not be initialized\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n } else {\n return { analytics: jitsuAnalytics(props.options) };\n }\n }, [props.options.disabled, props.options.host]);\n return <JitsuContext.Provider value={instance}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\n\nimport { AnalyticsInterface, jitsuAnalytics, JitsuOptions, emptyAnalytics } from \"@jitsu/js\";\n\nexport interface BeforeEffect {\n effect: (analytics: AnalyticsInterface) => any;\n deps: any[];\n}\n\nexport type ExtendedJitsuOptions =\n | (Omit<JitsuOptions, \"host\"> & { host: string } & {\n disabled?: false | undefined;\n echoEvents?: boolean;\n })\n | { disabled: true; host?: undefined };\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let jitsuInstance = useContext(JitsuContext);\n if (opts?.disabled) {\n return { analytics: emptyAnalytics };\n }\n if (!jitsuInstance) {\n if (opts?.host || opts?.echoEvents) {\n return { analytics: jitsuAnalytics(opts) };\n } else {\n const msg =\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n }\n } else if (opts?.host || opts?.echoEvents) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n //Jitsu analytics is initialized inside provider\n } else if (jitsuInstance.analytics) {\n return jitsuInstance;\n } else {\n throw new Error(`<JitsuProvider /> is not initialized with undefined analytics instance`);\n }\n}\n\nexport default useJitsu;\nexport { AnalyticsInterface, JitsuOptions };\n"],"names":["JitsuContext","createContext","JitsuProvider","props","instance","useMemo","options","disabled","analytics","emptyAnalytics","host","msg","console","error","jitsuAnalytics","React","Provider","value","children","useJitsu","opts","jitsuInstance","useContext","echoEvents","Error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/js\";\n\nexport type JitsuInstance = { analytics: AnalyticsInterface };\n\nconst JitsuContext = createContext<JitsuInstance | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren, useMemo } from \"react\";\nimport JitsuContext, { JitsuInstance } from \"./JitsuContext\";\nimport { emptyAnalytics, jitsuAnalytics } from \"@jitsu/js\";\nimport { ExtendedJitsuOptions } from \"./useJitsu\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: ExtendedJitsuOptions }>> = props => {\n const instance: JitsuInstance = useMemo(() => {\n if (props.options.disabled) {\n return { analytics: emptyAnalytics };\n } else if (!props.options.host) {\n const msg = \"<JitsuProvider />. Jitsu host is not defined. Jitsu will not be initialized\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n } else {\n return { analytics: jitsuAnalytics(props.options) };\n }\n }, [props.options.disabled, props.options.host]);\n return <JitsuContext.Provider value={instance}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\n\nimport { AnalyticsInterface, jitsuAnalytics, JitsuOptions, emptyAnalytics } from \"@jitsu/js\";\n\nexport interface BeforeEffect {\n effect: (analytics: AnalyticsInterface) => any;\n deps: any[];\n}\n\nexport type ExtendedJitsuOptions =\n | (Omit<JitsuOptions, \"host\"> & { host: string } & {\n disabled?: false | undefined;\n echoEvents?: boolean;\n })\n | { disabled: true; host?: undefined };\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let jitsuInstance = useContext(JitsuContext);\n if (opts?.disabled) {\n return { analytics: emptyAnalytics };\n }\n if (!jitsuInstance) {\n if (opts?.host || opts?.echoEvents) {\n return { analytics: jitsuAnalytics(opts) };\n } else {\n const msg =\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n }\n } else if (opts?.host || opts?.echoEvents) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n //Jitsu analytics is initialized inside provider\n } else if (jitsuInstance.analytics) {\n return jitsuInstance;\n } else {\n throw new Error(`<JitsuProvider /> is not initialized with undefined analytics instance`);\n }\n}\n\nexport default useJitsu;\nexport { AnalyticsInterface, JitsuOptions };\n"],"names":["JitsuContext","createContext","JitsuProvider","props","instance","useMemo","options","disabled","analytics","emptyAnalytics","host","msg","console","error","jitsuAnalytics","React","createElement","Provider","value","children","useJitsu","opts","jitsuInstance","useContext","echoEvents","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAMA,YAAY,GAAGC,mBAAa,CAAuB,IAAI;;ACC7D,IAAMC,aAAa,GAAmE,SAAhFA,aAAaA,CAAmEC,KAAK,EAAG;AAC5F,EAAA,IAAMC,QAAQ,GAAkBC,aAAO,CAAC,YAAK;AAC3C,IAAA,IAAIF,KAAK,CAACG,OAAO,CAACC,QAAQ,EAAE;MAC1B,OAAO;AAAEC,QAAAA,SAAS,EAAEC,iBAAAA;OAAgB,CAAA;KACrC,MAAM,IAAI,CAACN,KAAK,CAACG,OAAO,CAACI,IAAI,EAAE;MAC9B,IAAMC,GAAG,GAAG,6EAA6E,CAAA;AACzFC,MAAAA,OAAO,CAACC,KAAK,CAAA,IAAA,GAAMF,GAAG,EAAI,gCAAgC,CAAC,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,IAAIW,IAAI,IAAA,IAAA,IAAJA,IAAI,CAAEG,UAAU,EAAE;AACzC,IAAA,MAAM,IAAIC,KAAK,CACb,2IAA2I,CAC5I,CAAA;AACD;AACF,GAAC,MAAM,IAAIH,aAAa,CAACd,SAAS,EAAE;AAClC,IAAA,OAAOc,aAAa,CAAA;AACtB,GAAC,MAAM;IACL,MAAM,IAAIG,KAAK,CAAA,wEAAyE,CAAC,CAAA;AAC3F,GAAA;AACF;;;;;;"}
|
package/dist/index.modern.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createContext, useMemo, useContext } from 'react';
|
|
2
3
|
import { emptyAnalytics, jitsuAnalytics } from '@jitsu/js';
|
|
3
4
|
|
|
4
5
|
var JitsuContext = createContext(null);
|
|
@@ -21,20 +22,23 @@ var JitsuProvider = function JitsuProvider(props) {
|
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
}, [props.options.disabled, props.options.host]);
|
|
24
|
-
return createElement(JitsuContext.Provider, {
|
|
25
|
+
return React.createElement(JitsuContext.Provider, {
|
|
25
26
|
value: instance
|
|
26
27
|
}, props.children);
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* See for details http://jitsu.com/docs/sending-data/js-sdk/react
|
|
32
|
+
*/
|
|
29
33
|
function useJitsu(opts) {
|
|
30
34
|
var jitsuInstance = useContext(JitsuContext);
|
|
31
|
-
if (opts
|
|
35
|
+
if (opts != null && opts.disabled) {
|
|
32
36
|
return {
|
|
33
37
|
analytics: emptyAnalytics
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
if (!jitsuInstance) {
|
|
37
|
-
if (opts
|
|
41
|
+
if (opts != null && opts.host || opts != null && opts.echoEvents) {
|
|
38
42
|
return {
|
|
39
43
|
analytics: jitsuAnalytics(opts)
|
|
40
44
|
};
|
|
@@ -45,8 +49,9 @@ function useJitsu(opts) {
|
|
|
45
49
|
analytics: emptyAnalytics
|
|
46
50
|
};
|
|
47
51
|
}
|
|
48
|
-
} else if (opts
|
|
52
|
+
} else if (opts != null && opts.host || opts != null && opts.echoEvents) {
|
|
49
53
|
throw new Error("Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react");
|
|
54
|
+
//Jitsu analytics is initialized inside provider
|
|
50
55
|
} else if (jitsuInstance.analytics) {
|
|
51
56
|
return jitsuInstance;
|
|
52
57
|
} else {
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/js\";\n\nexport type JitsuInstance = { analytics: AnalyticsInterface };\n\nconst JitsuContext = createContext<JitsuInstance | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren, useMemo } from \"react\";\nimport JitsuContext, { JitsuInstance } from \"./JitsuContext\";\nimport { emptyAnalytics, jitsuAnalytics } from \"@jitsu/js\";\nimport { ExtendedJitsuOptions } from \"./useJitsu\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: ExtendedJitsuOptions }>> = props => {\n const instance: JitsuInstance = useMemo(() => {\n if (props.options.disabled) {\n return { analytics: emptyAnalytics };\n } else if (!props.options.host) {\n const msg = \"<JitsuProvider />. Jitsu host is not defined. Jitsu will not be initialized\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n } else {\n return { analytics: jitsuAnalytics(props.options) };\n }\n }, [props.options.disabled, props.options.host]);\n return <JitsuContext.Provider value={instance}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\n\nimport { AnalyticsInterface, jitsuAnalytics, JitsuOptions, emptyAnalytics } from \"@jitsu/js\";\n\nexport interface BeforeEffect {\n effect: (analytics: AnalyticsInterface) => any;\n deps: any[];\n}\n\nexport type ExtendedJitsuOptions =\n | (Omit<JitsuOptions, \"host\"> & { host: string } & {\n disabled?: false | undefined;\n echoEvents?: boolean;\n })\n | { disabled: true; host?: undefined };\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let jitsuInstance = useContext(JitsuContext);\n if (opts?.disabled) {\n return { analytics: emptyAnalytics };\n }\n if (!jitsuInstance) {\n if (opts?.host || opts?.echoEvents) {\n return { analytics: jitsuAnalytics(opts) };\n } else {\n const msg =\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n }\n } else if (opts?.host || opts?.echoEvents) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n //Jitsu analytics is initialized inside provider\n } else if (jitsuInstance.analytics) {\n return jitsuInstance;\n } else {\n throw new Error(`<JitsuProvider /> is not initialized with undefined analytics instance`);\n }\n}\n\nexport default useJitsu;\nexport { AnalyticsInterface, JitsuOptions };\n"],"names":["JitsuContext","createContext","JitsuProvider","props","instance","useMemo","options","disabled","analytics","emptyAnalytics","host","msg","console","error","jitsuAnalytics","React","Provider","value","children","useJitsu","opts","jitsuInstance","useContext","echoEvents","Error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/JitsuContext.tsx","../src/JitsuProvider.tsx","../src/useJitsu.ts"],"sourcesContent":["import { createContext } from \"react\";\nimport { AnalyticsInterface } from \"@jitsu/js\";\n\nexport type JitsuInstance = { analytics: AnalyticsInterface };\n\nconst JitsuContext = createContext<JitsuInstance | null>(null);\n\nexport default JitsuContext;\n","import * as React from \"react\";\nimport { PropsWithChildren, useMemo } from \"react\";\nimport JitsuContext, { JitsuInstance } from \"./JitsuContext\";\nimport { emptyAnalytics, jitsuAnalytics } from \"@jitsu/js\";\nimport { ExtendedJitsuOptions } from \"./useJitsu\";\n\nconst JitsuProvider: React.FC<PropsWithChildren<{ options: ExtendedJitsuOptions }>> = props => {\n const instance: JitsuInstance = useMemo(() => {\n if (props.options.disabled) {\n return { analytics: emptyAnalytics };\n } else if (!props.options.host) {\n const msg = \"<JitsuProvider />. Jitsu host is not defined. Jitsu will not be initialized\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n } else {\n return { analytics: jitsuAnalytics(props.options) };\n }\n }, [props.options.disabled, props.options.host]);\n return <JitsuContext.Provider value={instance}>{props.children}</JitsuContext.Provider>;\n};\n\nexport default JitsuProvider;\n","import { useContext } from \"react\";\nimport JitsuContext from \"./JitsuContext\";\n\nimport { AnalyticsInterface, jitsuAnalytics, JitsuOptions, emptyAnalytics } from \"@jitsu/js\";\n\nexport interface BeforeEffect {\n effect: (analytics: AnalyticsInterface) => any;\n deps: any[];\n}\n\nexport type ExtendedJitsuOptions =\n | (Omit<JitsuOptions, \"host\"> & { host: string } & {\n disabled?: false | undefined;\n echoEvents?: boolean;\n })\n | { disabled: true; host?: undefined };\n\n/**\n * See for details http://jitsu.com/docs/sending-data/js-sdk/react\n */\nfunction useJitsu(opts?: ExtendedJitsuOptions): { analytics: AnalyticsInterface } {\n let jitsuInstance = useContext(JitsuContext);\n if (opts?.disabled) {\n return { analytics: emptyAnalytics };\n }\n if (!jitsuInstance) {\n if (opts?.host || opts?.echoEvents) {\n return { analytics: jitsuAnalytics(opts) };\n } else {\n const msg =\n \"Before calling useJitsu() hook, please wrap your component into <JitsuProvider />. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\";\n console.error(`%c${msg}`, \"color: red; font-weight: bold;\");\n return { analytics: emptyAnalytics };\n }\n } else if (opts?.host || opts?.echoEvents) {\n throw new Error(\n \"Jitsu client already set up with <JitsuProvider /> and cannot be overridden. Read more in http://jitsu.com/docs/sending-data/js-sdk/react\"\n );\n //Jitsu analytics is initialized inside provider\n } else if (jitsuInstance.analytics) {\n return jitsuInstance;\n } else {\n throw new Error(`<JitsuProvider /> is not initialized with undefined analytics instance`);\n }\n}\n\nexport default useJitsu;\nexport { AnalyticsInterface, JitsuOptions };\n"],"names":["JitsuContext","createContext","JitsuProvider","props","instance","useMemo","options","disabled","analytics","emptyAnalytics","host","msg","console","error","jitsuAnalytics","React","createElement","Provider","value","children","useJitsu","opts","jitsuInstance","useContext","echoEvents","Error"],"mappings":";;;;AAKA,IAAMA,YAAY,GAAGC,aAAa,CAAuB,IAAI;;ACC7D,IAAMC,aAAa,GAAmE,SAAhFA,aAAaA,CAAmEC,KAAK,EAAG;AAC5F,EAAA,IAAMC,QAAQ,GAAkBC,OAAO,CAAC,YAAK;AAC3C,IAAA,IAAIF,KAAK,CAACG,OAAO,CAACC,QAAQ,EAAE;MAC1B,OAAO;AAAEC,QAAAA,SAAS,EAAEC,cAAAA;OAAgB,CAAA;KACrC,MAAM,IAAI,CAACN,KAAK,CAACG,OAAO,CAACI,IAAI,EAAE;MAC9B,IAAMC,GAAG,GAAG,6EAA6E,CAAA;AACzFC,MAAAA,OAAO,CAACC,KAAK,CAAA,IAAA,GAAMF,GAAG,EAAI,gCAAgC,CAAC,CAAA;MAC3D,OAAO;AAAEH,QAAAA,SAAS,EAAEC,cAAAA;OAAgB,CAAA;AACtC,KAAC,MAAM;MACL,OAAO;AAAED,QAAAA,SAAS,EAAEM,cAAc,CAACX,KAAK,CAACG,OAAO,CAAA;OAAG,CAAA;AACrD,KAAA;AACF,GAAC,EAAE,CAACH,KAAK,CAACG,OAAO,CAACC,QAAQ,EAAEJ,KAAK,CAACG,OAAO,CAACI,IAAI,CAAC,CAAC,CAAA;AAChD,EAAA,OAAOK,KAAC,CAAAC,aAAA,CAAAhB,YAAY,CAACiB,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AnalyticsInterface, JitsuOptions } from "@jitsu/js";
|
|
2
|
-
export interface BeforeEffect {
|
|
3
|
-
effect: (analytics: AnalyticsInterface) => any;
|
|
4
|
-
deps: any[];
|
|
5
|
-
}
|
|
6
|
-
export
|
|
7
|
-
host: string;
|
|
8
|
-
} & {
|
|
9
|
-
disabled?: false | undefined;
|
|
10
|
-
echoEvents?: boolean;
|
|
11
|
-
}) | {
|
|
12
|
-
disabled: true;
|
|
13
|
-
host?: undefined;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* See for details http://jitsu.com/docs/sending-data/js-sdk/react
|
|
17
|
-
*/
|
|
18
|
-
declare function useJitsu(opts?: ExtendedJitsuOptions): {
|
|
19
|
-
analytics: AnalyticsInterface;
|
|
20
|
-
};
|
|
21
|
-
export default useJitsu;
|
|
22
|
-
export { AnalyticsInterface, JitsuOptions };
|
|
1
|
+
import { AnalyticsInterface, JitsuOptions } from "@jitsu/js";
|
|
2
|
+
export interface BeforeEffect {
|
|
3
|
+
effect: (analytics: AnalyticsInterface) => any;
|
|
4
|
+
deps: any[];
|
|
5
|
+
}
|
|
6
|
+
export type ExtendedJitsuOptions = (Omit<JitsuOptions, "host"> & {
|
|
7
|
+
host: string;
|
|
8
|
+
} & {
|
|
9
|
+
disabled?: false | undefined;
|
|
10
|
+
echoEvents?: boolean;
|
|
11
|
+
}) | {
|
|
12
|
+
disabled: true;
|
|
13
|
+
host?: undefined;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* See for details http://jitsu.com/docs/sending-data/js-sdk/react
|
|
17
|
+
*/
|
|
18
|
+
declare function useJitsu(opts?: ExtendedJitsuOptions): {
|
|
19
|
+
analytics: AnalyticsInterface;
|
|
20
|
+
};
|
|
21
|
+
export default useJitsu;
|
|
22
|
+
export { AnalyticsInterface, JitsuOptions };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jitsu/jitsu-react",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"node": ">=10"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@jitsu/js": "1.9.
|
|
14
|
+
"@jitsu/js": "1.9.10"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "15.x || 16.x || 17.x || 18.x",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@testing-library/user-event": "^14.4.3",
|
|
31
31
|
"@types/jest": "^29.2.3",
|
|
32
32
|
"@types/node": "^18.15.3",
|
|
33
|
-
"microbundle
|
|
33
|
+
"microbundle": "^0.15.1",
|
|
34
34
|
"typescript": "^5.6.3",
|
|
35
35
|
"@babel/plugin-transform-regenerator": "^7.22.10"
|
|
36
36
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
|
-
"build": "pnpm compile && microbundle
|
|
41
|
+
"build": "pnpm compile && microbundle build --jsx React.createElement --no-compress --format es,cjs",
|
|
42
42
|
"compile": "tsc -p .",
|
|
43
43
|
"clean": "rm -rf dist"
|
|
44
44
|
}
|