react-native-edgee 1.0.5 → 1.0.6

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/react.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { ConsentStatus, EdgeeClient, EdgeeConfig } from ".";
2
+ import { EdgeeClient, EdgeeConfig } from ".";
3
3
  export declare function EdgeeProvider({ children, host, debug, collectDeviceId, }: {
4
4
  children: React.ReactNode;
5
5
  host: EdgeeConfig["host"];
@@ -7,18 +7,3 @@ export declare function EdgeeProvider({ children, host, debug, collectDeviceId,
7
7
  collectDeviceId?: EdgeeConfig["collectDeviceId"];
8
8
  }): React.JSX.Element;
9
9
  export declare function useEdgee(): EdgeeClient;
10
- export declare function EdgeeAutoTracker(): React.JSX.Element;
11
- /**
12
- * React hook for consent management
13
- */
14
- export declare function useEdgeeConsent(): {
15
- consentStatus: ConsentStatus | null;
16
- loading: boolean;
17
- hasConsent: boolean;
18
- isGranted: boolean;
19
- isDenied: boolean;
20
- isPending: boolean;
21
- canTrack: boolean;
22
- setConsent: (status: ConsentStatus) => Promise<void>;
23
- resetConsent: () => Promise<void>;
24
- };
package/dist/react.js CHANGED
@@ -35,12 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.EdgeeProvider = EdgeeProvider;
37
37
  exports.useEdgee = useEdgee;
38
- exports.EdgeeAutoTracker = EdgeeAutoTracker;
39
- exports.useEdgeeConsent = useEdgeeConsent;
40
38
  const react_1 = __importStar(require("react"));
41
39
  const _1 = require(".");
42
- const consent_1 = require("./consent");
43
- const expo_router_1 = require("./navigation/expo-router");
44
40
  const EdgeeContext = (0, react_1.createContext)(null);
45
41
  function EdgeeProvider({ children, host, debug, collectDeviceId, }) {
46
42
  const client = (0, react_1.useMemo)(() => new _1.EdgeeClient({ host, debug, collectDeviceId }), [host, debug, collectDeviceId]);
@@ -52,60 +48,3 @@ function useEdgee() {
52
48
  throw new Error("EdgeeProvider is missing in the tree");
53
49
  return ctx;
54
50
  }
55
- // Expo Router auto-tracker that pulls the client from context
56
- function EdgeeAutoTracker() {
57
- const edgee = useEdgee();
58
- return <expo_router_1.EdgeeExpoRouterTracker edgee={edgee}/>;
59
- }
60
- /**
61
- * React hook for consent management
62
- */
63
- function useEdgeeConsent() {
64
- const edgee = useEdgee();
65
- const [consentStatus, setConsentStatus] = (0, react_1.useState)(null);
66
- const [loading, setLoading] = (0, react_1.useState)(true);
67
- (0, react_1.useEffect)(() => {
68
- // Get current status (consent already initialized by EdgeeClient)
69
- setConsentStatus(consent_1.ConsentUtils.getConsent());
70
- setLoading(false);
71
- // Listen for consent changes
72
- const unsubscribe = consent_1.ConsentUtils.onChange((status) => {
73
- setConsentStatus(status);
74
- });
75
- return unsubscribe;
76
- }, []);
77
- const setConsent = (0, react_1.useCallback)(async (status) => {
78
- try {
79
- await consent_1.ConsentUtils.setConsent(status);
80
- // Send consent event to Edgee
81
- if (edgee) {
82
- await consent_1.ConsentUtils.sendConsentEvent(edgee, status);
83
- }
84
- }
85
- catch (error) {
86
- console.warn("[Edgee Consent] Failed to set consent:", error);
87
- }
88
- }, [edgee]);
89
- const resetConsent = (0, react_1.useCallback)(async () => {
90
- try {
91
- await consent_1.ConsentUtils.reset();
92
- }
93
- catch (error) {
94
- console.warn("[Edgee Consent] Failed to reset consent:", error);
95
- }
96
- }, []);
97
- return {
98
- // Status
99
- consentStatus,
100
- loading,
101
- // Checkers
102
- hasConsent: consent_1.ConsentUtils.hasConsent(),
103
- isGranted: consent_1.ConsentUtils.isGranted(),
104
- isDenied: consent_1.ConsentUtils.isDenied(),
105
- isPending: consent_1.ConsentUtils.isPending(),
106
- canTrack: consent_1.ConsentUtils.canTrack(),
107
- // Actions
108
- setConsent,
109
- resetConsent,
110
- };
111
- }
@@ -0,0 +1 @@
1
+ export * from "./dist/expo-router";
package/expo-router.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./dist/expo-router");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-edgee",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Lightweight Edgee data collection client for React Native with native context collection.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -10,6 +10,8 @@
10
10
  "dist",
11
11
  "android",
12
12
  "ios",
13
+ "expo-router.js",
14
+ "expo-router.d.ts",
13
15
  "react-native-edgee.podspec"
14
16
  ],
15
17
  "sideEffects": false,
@@ -1,8 +0,0 @@
1
- import { EdgeeConfig } from "..";
2
- import { EdgeeStore } from "./edgee-store";
3
- export declare class QueryBuilder {
4
- private config;
5
- private store;
6
- constructor(config: EdgeeConfig, store: EdgeeStore);
7
- getUrl(): Promise<string>;
8
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryBuilder = void 0;
4
- class QueryBuilder {
5
- constructor(config, store) {
6
- this.config = config;
7
- this.store = store;
8
- }
9
- async getUrl() {
10
- const { edgeeId, userId } = await this.store.getContext();
11
- const params = [];
12
- if (edgeeId)
13
- params.push(`e=${encodeURIComponent(edgeeId)}`);
14
- if (userId)
15
- params.push(`u=${encodeURIComponent(userId)}`);
16
- return params.length
17
- ? `${this.config.host}/_edgee/csevent?${params.join("&")}`
18
- : `${this.config.host}/_edgee/csevent`;
19
- }
20
- }
21
- exports.QueryBuilder = QueryBuilder;
@@ -1,4 +0,0 @@
1
- import type { EdgeeClient } from "../index";
2
- export declare function EdgeeExpoRouterTracker({ edgee, }: {
3
- edgee: Pick<EdgeeClient, "screen">;
4
- }): null;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- // Auto-pageview for Expo Router
3
- // Usage: mount <EdgeeExpoRouterTracker edgee={edgeeClient} /> once at the root
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.EdgeeExpoRouterTracker = EdgeeExpoRouterTracker;
6
- const expo_router_1 = require("expo-router");
7
- const react_1 = require("react");
8
- function EdgeeExpoRouterTracker({ edgee, }) {
9
- const pathname = (0, expo_router_1.usePathname)();
10
- const lastPathnameRef = (0, react_1.useRef)(null);
11
- (0, react_1.useEffect)(() => {
12
- if (!pathname)
13
- return;
14
- // Avoid duplicate fires on initial mount (e.g., React Strict Mode)
15
- if (lastPathnameRef.current === pathname)
16
- return;
17
- lastPathnameRef.current = pathname;
18
- edgee.screen(pathname, { path: pathname });
19
- }, [pathname]);
20
- return null;
21
- }
@@ -1,2 +0,0 @@
1
- export * from "./expo-router";
2
- export * from "./react-navigation";
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./expo-router"), exports);
18
- __exportStar(require("./react-navigation"), exports);
@@ -1,9 +0,0 @@
1
- import type { EdgeeClient } from "../index";
2
- type NavigationRef = {
3
- getCurrentRoute?: () => {
4
- name: string;
5
- } | undefined;
6
- addListener?: (event: string, callback: () => void) => () => void;
7
- };
8
- export declare function installAutoPageview(navigationRef: NavigationRef, edgee: Pick<EdgeeClient, "screen">): () => void;
9
- export {};
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.installAutoPageview = installAutoPageview;
4
- function installAutoPageview(navigationRef, edgee) {
5
- var _a;
6
- let previousRouteName;
7
- const report = () => {
8
- var _a;
9
- try {
10
- const route = (_a = navigationRef.getCurrentRoute) === null || _a === void 0 ? void 0 : _a.call(navigationRef);
11
- if (!route)
12
- return;
13
- const current = route.name;
14
- if (current !== previousRouteName) {
15
- // Fire a Page View as a track event
16
- edgee.screen(current, { path: `/${current}` });
17
- previousRouteName = current;
18
- }
19
- }
20
- catch {
21
- // no-op
22
- }
23
- };
24
- // initial fire
25
- report();
26
- // subscribe to changes
27
- const unsubscribe = (_a = navigationRef.addListener) === null || _a === void 0 ? void 0 : _a.call(navigationRef, "state", report);
28
- return () => {
29
- try {
30
- unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
31
- }
32
- catch {
33
- // no-op
34
- }
35
- };
36
- }