@easyfunnel/react 0.1.4 → 0.2.1
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/index.js +9 -11
- package/dist/index.mjs +12 -14
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ function EasyFunnelProvider(_a) {
|
|
|
70
70
|
"children",
|
|
71
71
|
"config"
|
|
72
72
|
]);
|
|
73
|
-
const
|
|
73
|
+
const [tracker, setTracker] = (0, import_react.useState)(null);
|
|
74
74
|
(0, import_react.useEffect)(() => {
|
|
75
75
|
if (!options.apiKey) {
|
|
76
76
|
console.error(
|
|
@@ -78,19 +78,17 @@ function EasyFunnelProvider(_a) {
|
|
|
78
78
|
);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
81
|
+
const instance = import_sdk.EasyFunnel.init(__spreadProps(__spreadValues({}, options), {
|
|
82
|
+
autoPageView: true,
|
|
83
|
+
rules: config == null ? void 0 : config.rules
|
|
84
|
+
}));
|
|
85
|
+
setTracker(instance);
|
|
87
86
|
return () => {
|
|
88
|
-
|
|
89
|
-
(
|
|
90
|
-
trackerRef.current = null;
|
|
87
|
+
instance.destroy();
|
|
88
|
+
setTracker(null);
|
|
91
89
|
};
|
|
92
90
|
}, [options.apiKey]);
|
|
93
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EasyFunnelContext.Provider, { value:
|
|
91
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EasyFunnelContext.Provider, { value: tracker, children });
|
|
94
92
|
}
|
|
95
93
|
function useEasyFunnel() {
|
|
96
94
|
return (0, import_react.useContext)(EasyFunnelContext);
|
package/dist/index.mjs
CHANGED
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
createContext,
|
|
36
36
|
useContext,
|
|
37
37
|
useEffect,
|
|
38
|
-
|
|
38
|
+
useState
|
|
39
39
|
} from "react";
|
|
40
40
|
import { EasyFunnel } from "@easyfunnel/sdk";
|
|
41
41
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -48,7 +48,7 @@ function EasyFunnelProvider(_a) {
|
|
|
48
48
|
"children",
|
|
49
49
|
"config"
|
|
50
50
|
]);
|
|
51
|
-
const
|
|
51
|
+
const [tracker, setTracker] = useState(null);
|
|
52
52
|
useEffect(() => {
|
|
53
53
|
if (!options.apiKey) {
|
|
54
54
|
console.error(
|
|
@@ -56,26 +56,24 @@ function EasyFunnelProvider(_a) {
|
|
|
56
56
|
);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
59
|
+
const instance = EasyFunnel.init(__spreadProps(__spreadValues({}, options), {
|
|
60
|
+
autoPageView: true,
|
|
61
|
+
rules: config == null ? void 0 : config.rules
|
|
62
|
+
}));
|
|
63
|
+
setTracker(instance);
|
|
65
64
|
return () => {
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
trackerRef.current = null;
|
|
65
|
+
instance.destroy();
|
|
66
|
+
setTracker(null);
|
|
69
67
|
};
|
|
70
68
|
}, [options.apiKey]);
|
|
71
|
-
return /* @__PURE__ */ jsx(EasyFunnelContext.Provider, { value:
|
|
69
|
+
return /* @__PURE__ */ jsx(EasyFunnelContext.Provider, { value: tracker, children });
|
|
72
70
|
}
|
|
73
71
|
function useEasyFunnel() {
|
|
74
72
|
return useContext(EasyFunnelContext);
|
|
75
73
|
}
|
|
76
74
|
|
|
77
75
|
// src/hooks.ts
|
|
78
|
-
import { useCallback, useEffect as useEffect2, useRef
|
|
76
|
+
import { useCallback, useEffect as useEffect2, useRef } from "react";
|
|
79
77
|
function useTrack() {
|
|
80
78
|
const tracker = useEasyFunnel();
|
|
81
79
|
return useCallback(
|
|
@@ -109,7 +107,7 @@ function useIdentify() {
|
|
|
109
107
|
);
|
|
110
108
|
}
|
|
111
109
|
function useSectionRef(sectionName) {
|
|
112
|
-
const ref =
|
|
110
|
+
const ref = useRef(null);
|
|
113
111
|
useEffect2(() => {
|
|
114
112
|
const el = ref.current;
|
|
115
113
|
if (el) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyfunnel/react",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "React/Next.js provider for easyfunnel.co analytics",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dev": "tsup src/index.ts --format cjs,esm --dts --external react --watch"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@easyfunnel/sdk": "^0.
|
|
16
|
+
"@easyfunnel/sdk": "^0.2.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"next": ">=14.0.0",
|