react-native-edgee 1.0.0 → 1.0.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/README.md +1 -2
- package/dist/api.d.ts +32 -0
- package/dist/api.js +111 -0
- package/dist/consent.d.ts +96 -0
- package/dist/consent.js +220 -0
- package/dist/core/context.d.ts +41 -0
- package/dist/core/context.js +90 -0
- package/dist/core/edgee-store.d.ts +21 -0
- package/dist/core/edgee-store.js +53 -0
- package/dist/core/query-builder.d.ts +8 -0
- package/dist/core/query-builder.js +21 -0
- package/dist/core/queue.d.ts +25 -0
- package/dist/core/queue.js +155 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +321 -0
- package/dist/native-context.d.ts +13 -0
- package/dist/native-context.js +106 -0
- package/dist/navigation/expo-router.d.ts +4 -0
- package/dist/navigation/expo-router.js +21 -0
- package/dist/navigation/index.d.ts +2 -0
- package/dist/navigation/index.js +18 -0
- package/dist/navigation/react-navigation.d.ts +9 -0
- package/dist/navigation/react-navigation.js +36 -0
- package/dist/react.d.ts +24 -0
- package/dist/react.js +111 -0
- package/dist/types.d.ts +64 -0
- package/dist/types.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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);
|
|
@@ -0,0 +1,9 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ConsentStatus, EdgeeClient, EdgeeConfig } from ".";
|
|
3
|
+
export declare function EdgeeProvider({ children, host, debug, collectDeviceId, }: {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
host: EdgeeConfig["host"];
|
|
6
|
+
debug?: EdgeeConfig["debug"];
|
|
7
|
+
collectDeviceId?: EdgeeConfig["collectDeviceId"];
|
|
8
|
+
}): React.JSX.Element;
|
|
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
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.EdgeeProvider = EdgeeProvider;
|
|
37
|
+
exports.useEdgee = useEdgee;
|
|
38
|
+
exports.EdgeeAutoTracker = EdgeeAutoTracker;
|
|
39
|
+
exports.useEdgeeConsent = useEdgeeConsent;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const _1 = require(".");
|
|
42
|
+
const consent_1 = require("./consent");
|
|
43
|
+
const expo_router_1 = require("./navigation/expo-router");
|
|
44
|
+
const EdgeeContext = (0, react_1.createContext)(null);
|
|
45
|
+
function EdgeeProvider({ children, host, debug, collectDeviceId, }) {
|
|
46
|
+
const client = (0, react_1.useMemo)(() => new _1.EdgeeClient({ host, debug, collectDeviceId }), [host, debug, collectDeviceId]);
|
|
47
|
+
return (<EdgeeContext.Provider value={client}>{children}</EdgeeContext.Provider>);
|
|
48
|
+
}
|
|
49
|
+
function useEdgee() {
|
|
50
|
+
const ctx = (0, react_1.useContext)(EdgeeContext);
|
|
51
|
+
if (!ctx)
|
|
52
|
+
throw new Error("EdgeeProvider is missing in the tree");
|
|
53
|
+
return ctx;
|
|
54
|
+
}
|
|
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
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { NativeModule } from "react-native";
|
|
2
|
+
export interface EdgeeNativeContextConfig {
|
|
3
|
+
collectDeviceId?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface EdgeeNativeContext {
|
|
6
|
+
appName: string;
|
|
7
|
+
appVersion: string;
|
|
8
|
+
buildNumber: string;
|
|
9
|
+
bundleId: string;
|
|
10
|
+
deviceId?: string;
|
|
11
|
+
deviceName: string;
|
|
12
|
+
deviceType: "ios" | "android";
|
|
13
|
+
manufacturer: string;
|
|
14
|
+
model: string;
|
|
15
|
+
brand?: string;
|
|
16
|
+
product?: string;
|
|
17
|
+
systemName?: string;
|
|
18
|
+
osName: string;
|
|
19
|
+
osVersion: string;
|
|
20
|
+
sdkVersion?: number;
|
|
21
|
+
kernelVersion?: string;
|
|
22
|
+
locale: string;
|
|
23
|
+
language: string;
|
|
24
|
+
country: string;
|
|
25
|
+
timezone: string;
|
|
26
|
+
screenWidth: number;
|
|
27
|
+
screenHeight: number;
|
|
28
|
+
screenDensity: number;
|
|
29
|
+
screenScale?: number;
|
|
30
|
+
networkType: "wifi" | "cellular" | "ethernet" | "unknown";
|
|
31
|
+
carrierName?: string;
|
|
32
|
+
carrierCode?: string;
|
|
33
|
+
mobileCountryCode?: string;
|
|
34
|
+
mobileNetworkCode?: string;
|
|
35
|
+
isoCountryCode?: string;
|
|
36
|
+
radioTechnology?: string;
|
|
37
|
+
isTablet: boolean;
|
|
38
|
+
isSimulator?: boolean;
|
|
39
|
+
isEmulator?: boolean;
|
|
40
|
+
isJailbroken?: boolean;
|
|
41
|
+
isRooted?: boolean;
|
|
42
|
+
architecture?: string;
|
|
43
|
+
systemUptime?: number;
|
|
44
|
+
lowPowerMode?: boolean;
|
|
45
|
+
totalMemoryMB: number;
|
|
46
|
+
freeMemoryMB?: number;
|
|
47
|
+
maxMemoryMB?: number;
|
|
48
|
+
usedMemoryMB?: number;
|
|
49
|
+
availableMemoryMB?: number;
|
|
50
|
+
freeStorageMB?: number;
|
|
51
|
+
totalStorageMB?: number;
|
|
52
|
+
usedStorageMB?: number;
|
|
53
|
+
batteryLevel?: number;
|
|
54
|
+
batteryState?: "unplugged" | "charging" | "full" | "unknown";
|
|
55
|
+
advertisingId?: string;
|
|
56
|
+
adTrackingEnabled?: boolean;
|
|
57
|
+
trackingStatus?: "authorized" | "denied" | "restricted" | "notDetermined" | "unknown";
|
|
58
|
+
userAgent?: string;
|
|
59
|
+
firstInstallTime?: number;
|
|
60
|
+
lastUpdateTime?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface EdgeeReactNativeModule extends NativeModule {
|
|
63
|
+
getContextInfo(config: EdgeeNativeContextConfig): Promise<EdgeeNativeContext>;
|
|
64
|
+
}
|
package/dist/types.js
ADDED