@easyfunnel/react 0.1.1 → 0.1.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/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +28 -5
- package/dist/index.mjs +28 -5
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { EasyFunnelOptions, Tracker } from '@easyfunnel/sdk';
|
|
3
|
+
import { EasyFunnelOptions, EasyFunnelConfig, Tracker } from '@easyfunnel/sdk';
|
|
4
4
|
|
|
5
5
|
interface EasyFunnelProviderProps extends Omit<EasyFunnelOptions, 'autoPageView'> {
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
config?: EasyFunnelConfig;
|
|
7
8
|
}
|
|
8
|
-
declare function EasyFunnelProvider({ children, ...options }: EasyFunnelProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
declare function EasyFunnelProvider({ children, config, ...options }: EasyFunnelProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
10
|
declare function useEasyFunnel(): Tracker | null;
|
|
10
11
|
|
|
11
12
|
declare function useTrack(): (eventName: string, properties?: Record<string, any>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { EasyFunnelOptions, Tracker } from '@easyfunnel/sdk';
|
|
3
|
+
import { EasyFunnelOptions, EasyFunnelConfig, Tracker } from '@easyfunnel/sdk';
|
|
4
4
|
|
|
5
5
|
interface EasyFunnelProviderProps extends Omit<EasyFunnelOptions, 'autoPageView'> {
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
config?: EasyFunnelConfig;
|
|
7
8
|
}
|
|
8
|
-
declare function EasyFunnelProvider({ children, ...options }: EasyFunnelProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
declare function EasyFunnelProvider({ children, config, ...options }: EasyFunnelProviderProps): react_jsx_runtime.JSX.Element;
|
|
9
10
|
declare function useEasyFunnel(): Tracker | null;
|
|
10
11
|
|
|
11
12
|
declare function useTrack(): (eventName: string, properties?: Record<string, any>) => void;
|
package/dist/index.js
CHANGED
|
@@ -63,15 +63,24 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
63
63
|
var EasyFunnelContext = (0, import_react.createContext)(null);
|
|
64
64
|
function EasyFunnelProvider(_a) {
|
|
65
65
|
var _b = _a, {
|
|
66
|
-
children
|
|
66
|
+
children,
|
|
67
|
+
config
|
|
67
68
|
} = _b, options = __objRest(_b, [
|
|
68
|
-
"children"
|
|
69
|
+
"children",
|
|
70
|
+
"config"
|
|
69
71
|
]);
|
|
70
72
|
const trackerRef = (0, import_react.useRef)(null);
|
|
71
73
|
(0, import_react.useEffect)(() => {
|
|
74
|
+
if (!options.apiKey) {
|
|
75
|
+
console.error(
|
|
76
|
+
"[EasyFunnel] apiKey prop is missing on <EasyFunnelProvider>. Events will not be tracked. Check your environment variable is set and restart your dev server."
|
|
77
|
+
);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
72
80
|
if (!trackerRef.current) {
|
|
73
81
|
trackerRef.current = import_sdk.EasyFunnel.init(__spreadProps(__spreadValues({}, options), {
|
|
74
|
-
autoPageView: true
|
|
82
|
+
autoPageView: true,
|
|
83
|
+
rules: config == null ? void 0 : config.rules
|
|
75
84
|
}));
|
|
76
85
|
}
|
|
77
86
|
return () => {
|
|
@@ -92,7 +101,14 @@ function useTrack() {
|
|
|
92
101
|
const tracker = useEasyFunnel();
|
|
93
102
|
return (0, import_react2.useCallback)(
|
|
94
103
|
(eventName, properties) => {
|
|
95
|
-
|
|
104
|
+
var _a;
|
|
105
|
+
if (!tracker) {
|
|
106
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) === "development") {
|
|
107
|
+
console.warn(`[EasyFunnel] track("${eventName}") dropped \u2014 no provider found. Wrap your app with <EasyFunnelProvider>.`);
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
tracker.track(eventName, properties);
|
|
96
112
|
},
|
|
97
113
|
[tracker]
|
|
98
114
|
);
|
|
@@ -101,7 +117,14 @@ function useIdentify() {
|
|
|
101
117
|
const tracker = useEasyFunnel();
|
|
102
118
|
return (0, import_react2.useCallback)(
|
|
103
119
|
(userId) => {
|
|
104
|
-
|
|
120
|
+
var _a;
|
|
121
|
+
if (!tracker) {
|
|
122
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) === "development") {
|
|
123
|
+
console.warn(`[EasyFunnel] identify("${userId}") dropped \u2014 no provider found. Wrap your app with <EasyFunnelProvider>.`);
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
tracker.identify(userId);
|
|
105
128
|
},
|
|
106
129
|
[tracker]
|
|
107
130
|
);
|
package/dist/index.mjs
CHANGED
|
@@ -42,15 +42,24 @@ import { jsx } from "react/jsx-runtime";
|
|
|
42
42
|
var EasyFunnelContext = createContext(null);
|
|
43
43
|
function EasyFunnelProvider(_a) {
|
|
44
44
|
var _b = _a, {
|
|
45
|
-
children
|
|
45
|
+
children,
|
|
46
|
+
config
|
|
46
47
|
} = _b, options = __objRest(_b, [
|
|
47
|
-
"children"
|
|
48
|
+
"children",
|
|
49
|
+
"config"
|
|
48
50
|
]);
|
|
49
51
|
const trackerRef = useRef(null);
|
|
50
52
|
useEffect(() => {
|
|
53
|
+
if (!options.apiKey) {
|
|
54
|
+
console.error(
|
|
55
|
+
"[EasyFunnel] apiKey prop is missing on <EasyFunnelProvider>. Events will not be tracked. Check your environment variable is set and restart your dev server."
|
|
56
|
+
);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
51
59
|
if (!trackerRef.current) {
|
|
52
60
|
trackerRef.current = EasyFunnel.init(__spreadProps(__spreadValues({}, options), {
|
|
53
|
-
autoPageView: true
|
|
61
|
+
autoPageView: true,
|
|
62
|
+
rules: config == null ? void 0 : config.rules
|
|
54
63
|
}));
|
|
55
64
|
}
|
|
56
65
|
return () => {
|
|
@@ -71,7 +80,14 @@ function useTrack() {
|
|
|
71
80
|
const tracker = useEasyFunnel();
|
|
72
81
|
return useCallback(
|
|
73
82
|
(eventName, properties) => {
|
|
74
|
-
|
|
83
|
+
var _a;
|
|
84
|
+
if (!tracker) {
|
|
85
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) === "development") {
|
|
86
|
+
console.warn(`[EasyFunnel] track("${eventName}") dropped \u2014 no provider found. Wrap your app with <EasyFunnelProvider>.`);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
tracker.track(eventName, properties);
|
|
75
91
|
},
|
|
76
92
|
[tracker]
|
|
77
93
|
);
|
|
@@ -80,7 +96,14 @@ function useIdentify() {
|
|
|
80
96
|
const tracker = useEasyFunnel();
|
|
81
97
|
return useCallback(
|
|
82
98
|
(userId) => {
|
|
83
|
-
|
|
99
|
+
var _a;
|
|
100
|
+
if (!tracker) {
|
|
101
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) === "development") {
|
|
102
|
+
console.warn(`[EasyFunnel] identify("${userId}") dropped \u2014 no provider found. Wrap your app with <EasyFunnelProvider>.`);
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
tracker.identify(userId);
|
|
84
107
|
},
|
|
85
108
|
[tracker]
|
|
86
109
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easyfunnel/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "React/Next.js provider for easyfunnel.co analytics",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"dev": "tsup src/index.ts --format cjs,esm --dts --external react --watch"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@easyfunnel/sdk": "0.1.
|
|
16
|
+
"@easyfunnel/sdk": "^0.1.2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"next": ">=14.0.0",
|
|
20
|
+
"react": ">=18.0.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependenciesMeta": {
|
|
23
23
|
"next": {
|