react-native-edgee 1.0.4 → 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/README.md +85 -2
- package/android/build.gradle +0 -4
- package/dist/api.d.ts +8 -1
- package/dist/api.js +146 -78
- package/dist/consent.d.ts +1 -45
- package/dist/consent.js +7 -89
- package/dist/core/context.d.ts +2 -1
- package/dist/core/context.js +4 -3
- package/dist/core/edgee-store.d.ts +6 -2
- package/dist/core/edgee-store.js +41 -12
- package/dist/core/queue.d.ts +1 -5
- package/dist/core/queue.js +11 -74
- package/dist/core/utils.d.ts +17 -0
- package/dist/core/utils.js +54 -0
- package/dist/index.d.ts +18 -12
- package/dist/index.js +61 -131
- package/dist/native-context.js +2 -1
- package/dist/react.d.ts +1 -16
- package/dist/react.js +0 -61
- package/expo-router.d.ts +1 -0
- package/expo-router.js +1 -0
- package/package.json +3 -1
- package/dist/core/query-builder.d.ts +0 -8
- package/dist/core/query-builder.js +0 -21
- package/dist/navigation/expo-router.d.ts +0 -4
- package/dist/navigation/expo-router.js +0 -21
- package/dist/navigation/index.d.ts +0 -2
- package/dist/navigation/index.js +0 -18
- package/dist/navigation/react-navigation.d.ts +0 -9
- package/dist/navigation/react-navigation.js +0 -36
package/dist/index.js
CHANGED
|
@@ -1,47 +1,15 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
3
|
+
exports.isNativeModuleAvailable = exports.getNativeContext = exports.clearContextCache = exports.useEdgee = exports.EdgeeProvider = exports.EdgeeClient = void 0;
|
|
37
4
|
const react_native_1 = require("react-native");
|
|
38
5
|
const api_1 = require("./api");
|
|
39
6
|
const consent_1 = require("./consent");
|
|
40
7
|
const context_1 = require("./core/context");
|
|
41
8
|
const edgee_store_1 = require("./core/edgee-store");
|
|
42
|
-
const query_builder_1 = require("./core/query-builder");
|
|
43
9
|
const queue_1 = require("./core/queue");
|
|
10
|
+
const utils_1 = require("./core/utils");
|
|
44
11
|
const native_context_1 = require("./native-context");
|
|
12
|
+
const DEFAULT_COOKIE_NAME = "edgee";
|
|
45
13
|
/**
|
|
46
14
|
* Extract native context properties to include in event data under a sub-object
|
|
47
15
|
*/
|
|
@@ -103,12 +71,6 @@ const extractNativeProperties = (nativeContext) => {
|
|
|
103
71
|
},
|
|
104
72
|
};
|
|
105
73
|
};
|
|
106
|
-
let initialized = false;
|
|
107
|
-
let config = null;
|
|
108
|
-
const STORAGE_KEYS = {
|
|
109
|
-
edgeeId: "_edgee",
|
|
110
|
-
userId: "_edgee_u",
|
|
111
|
-
};
|
|
112
74
|
class EdgeeClient {
|
|
113
75
|
constructor(config) {
|
|
114
76
|
// current app state
|
|
@@ -128,24 +90,26 @@ class EdgeeClient {
|
|
|
128
90
|
}
|
|
129
91
|
this.appState = nextAppState;
|
|
130
92
|
};
|
|
93
|
+
if (!config.cookieName) {
|
|
94
|
+
config.cookieName = DEFAULT_COOKIE_NAME;
|
|
95
|
+
}
|
|
96
|
+
// Initialize consent system
|
|
97
|
+
void consent_1.edgeeConsent.init();
|
|
98
|
+
void edgee_store_1.edgeeStore.init();
|
|
99
|
+
// Initialize queue
|
|
131
100
|
this.config = config;
|
|
132
|
-
this.
|
|
133
|
-
void this.store.init();
|
|
134
|
-
this.queryBuilder = new query_builder_1.QueryBuilder(config, this.store);
|
|
135
|
-
this.queue = new queue_1.EventQueue(this.store, config, this.queryBuilder);
|
|
101
|
+
this.queue = new queue_1.EventQueue(config);
|
|
136
102
|
this.appStateSubscription = react_native_1.AppState.addEventListener("change", this.handleAppStateChange);
|
|
137
|
-
//
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
async track(name, data, components) {
|
|
141
|
-
// Check consent before tracking
|
|
142
|
-
if (!consent_1.ConsentUtils.canTrack()) {
|
|
143
|
-
if (this.config.debug) {
|
|
144
|
-
console.log(`[Edgee] Event "${name}" not tracked - consent not granted`);
|
|
145
|
-
}
|
|
146
|
-
return;
|
|
103
|
+
// Log initialization (matching JS SDK)
|
|
104
|
+
if (this.config.debug) {
|
|
105
|
+
(0, utils_1.log)(this.config, "Edgee SDK initialized with debug mode");
|
|
147
106
|
}
|
|
148
|
-
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Track a screen view event
|
|
110
|
+
*/
|
|
111
|
+
async screen(screenName, data, components) {
|
|
112
|
+
const context = await (0, context_1.getContext)(this.config);
|
|
149
113
|
// Get native context properties if available and collectDeviceId is enabled
|
|
150
114
|
let nativeProperties = {};
|
|
151
115
|
if (this.config.collectDeviceId && (0, native_context_1.isNativeModuleAvailable)()) {
|
|
@@ -156,33 +120,28 @@ class EdgeeClient {
|
|
|
156
120
|
nativeProperties = extractNativeProperties(nativeContext);
|
|
157
121
|
}
|
|
158
122
|
catch (error) {
|
|
159
|
-
|
|
160
|
-
console.warn("[Edgee] Failed to get native context for event properties:", error);
|
|
161
|
-
}
|
|
123
|
+
(0, utils_1.logError)("Error collecting page event", error);
|
|
162
124
|
}
|
|
163
125
|
}
|
|
164
|
-
// Merge native properties with
|
|
126
|
+
// Merge native properties with screen data
|
|
165
127
|
const enhancedData = {
|
|
166
128
|
...data,
|
|
129
|
+
screen_name: screenName,
|
|
167
130
|
...nativeProperties,
|
|
168
131
|
};
|
|
169
132
|
const event = (0, api_1.createTrackEvent)({
|
|
170
|
-
name,
|
|
133
|
+
name: "screen",
|
|
171
134
|
data: enhancedData,
|
|
172
135
|
components,
|
|
173
136
|
context,
|
|
174
137
|
});
|
|
175
138
|
this.queue.enqueue(event);
|
|
176
139
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
const context = await (0, context_1.getContext)(this.config.collectDeviceId);
|
|
140
|
+
/**
|
|
141
|
+
* Track a custom event
|
|
142
|
+
*/
|
|
143
|
+
async track(name, data, components) {
|
|
144
|
+
const context = await (0, context_1.getContext)(this.config);
|
|
186
145
|
// Get native context properties if available and collectDeviceId is enabled
|
|
187
146
|
let nativeProperties = {};
|
|
188
147
|
if (this.config.collectDeviceId && (0, native_context_1.isNativeModuleAvailable)()) {
|
|
@@ -193,32 +152,27 @@ class EdgeeClient {
|
|
|
193
152
|
nativeProperties = extractNativeProperties(nativeContext);
|
|
194
153
|
}
|
|
195
154
|
catch (error) {
|
|
196
|
-
|
|
197
|
-
console.warn("[Edgee] Failed to get native context for user properties:", error);
|
|
198
|
-
}
|
|
155
|
+
(0, utils_1.logError)("Error collecting track event", error);
|
|
199
156
|
}
|
|
200
157
|
}
|
|
201
|
-
// Merge native properties with
|
|
158
|
+
// Merge native properties with event data
|
|
202
159
|
const enhancedData = {
|
|
203
160
|
...data,
|
|
204
161
|
...nativeProperties,
|
|
205
162
|
};
|
|
206
|
-
const event = (0, api_1.
|
|
163
|
+
const event = (0, api_1.createTrackEvent)({
|
|
164
|
+
name,
|
|
207
165
|
data: enhancedData,
|
|
208
166
|
components,
|
|
209
167
|
context,
|
|
210
168
|
});
|
|
211
169
|
this.queue.enqueue(event);
|
|
212
170
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
const context = await (0, context_1.getContext)(this.config.collectDeviceId);
|
|
171
|
+
/**
|
|
172
|
+
* Track a user event
|
|
173
|
+
*/
|
|
174
|
+
async user(data, components) {
|
|
175
|
+
const context = await (0, context_1.getContext)(this.config);
|
|
222
176
|
// Get native context properties if available and collectDeviceId is enabled
|
|
223
177
|
let nativeProperties = {};
|
|
224
178
|
if (this.config.collectDeviceId && (0, native_context_1.isNativeModuleAvailable)()) {
|
|
@@ -229,62 +183,32 @@ class EdgeeClient {
|
|
|
229
183
|
nativeProperties = extractNativeProperties(nativeContext);
|
|
230
184
|
}
|
|
231
185
|
catch (error) {
|
|
232
|
-
|
|
233
|
-
console.warn("[Edgee] Failed to get native context for screen properties:", error);
|
|
234
|
-
}
|
|
186
|
+
(0, utils_1.logError)("Error collecting user event", error);
|
|
235
187
|
}
|
|
236
188
|
}
|
|
237
|
-
// Merge native properties with
|
|
189
|
+
// Merge native properties with user data
|
|
238
190
|
const enhancedData = {
|
|
239
191
|
...data,
|
|
240
|
-
screen_name: screenName,
|
|
241
192
|
...nativeProperties,
|
|
242
193
|
};
|
|
243
|
-
const event = (0, api_1.
|
|
244
|
-
name: "screen",
|
|
194
|
+
const event = (0, api_1.createUserEvent)({
|
|
245
195
|
data: enhancedData,
|
|
246
196
|
components,
|
|
247
197
|
context,
|
|
248
198
|
});
|
|
249
199
|
this.queue.enqueue(event);
|
|
250
200
|
}
|
|
251
|
-
// Consent management methods
|
|
252
|
-
async setConsent(status) {
|
|
253
|
-
await consent_1.ConsentUtils.setConsent(status);
|
|
254
|
-
// Send consent event to server
|
|
255
|
-
await consent_1.ConsentUtils.sendConsentEvent(this, status);
|
|
256
|
-
if (this.config.debug) {
|
|
257
|
-
console.log(`[Edgee] Consent set to: ${status}`);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
getConsent() {
|
|
261
|
-
return consent_1.ConsentUtils.getConsent();
|
|
262
|
-
}
|
|
263
|
-
hasConsent() {
|
|
264
|
-
return consent_1.ConsentUtils.hasConsent();
|
|
265
|
-
}
|
|
266
|
-
canTrack() {
|
|
267
|
-
return consent_1.ConsentUtils.canTrack();
|
|
268
|
-
}
|
|
269
|
-
async resetConsent() {
|
|
270
|
-
await consent_1.ConsentUtils.reset();
|
|
271
|
-
if (this.config.debug) {
|
|
272
|
-
console.log(`[Edgee] Consent reset`);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
onConsentChange(callback) {
|
|
276
|
-
return consent_1.ConsentUtils.onChange(callback);
|
|
277
|
-
}
|
|
278
201
|
/**
|
|
279
202
|
* Send consent event directly to Edgee (matches web SDK format)
|
|
280
203
|
*/
|
|
281
204
|
async consent(status) {
|
|
282
205
|
// Validate consent status
|
|
283
206
|
if (!["granted", "denied", "pending"].includes(status)) {
|
|
207
|
+
(0, utils_1.logError)("- Consent not valid");
|
|
284
208
|
throw new Error(`Invalid consent: ${status}. Use 'granted', 'denied', or 'pending'`);
|
|
285
209
|
}
|
|
286
210
|
// Store consent locally
|
|
287
|
-
await consent_1.
|
|
211
|
+
await consent_1.edgeeConsent.setConsent(status);
|
|
288
212
|
// Send consent event using web SDK format
|
|
289
213
|
const payload = {
|
|
290
214
|
data_collection: {
|
|
@@ -293,29 +217,35 @@ class EdgeeClient {
|
|
|
293
217
|
};
|
|
294
218
|
try {
|
|
295
219
|
await this.queue.sendEvent(payload);
|
|
296
|
-
|
|
297
|
-
console.log(`[Edgee] Consent sent to server: ${status}`);
|
|
298
|
-
}
|
|
220
|
+
(0, utils_1.log)(this.config, "- Consent set to:", status);
|
|
299
221
|
}
|
|
300
222
|
catch (error) {
|
|
301
|
-
|
|
223
|
+
(0, utils_1.logError)("Error collecting consent event", error);
|
|
302
224
|
throw error;
|
|
303
225
|
}
|
|
304
226
|
}
|
|
227
|
+
// Consent management methods
|
|
228
|
+
async setConsent(status) {
|
|
229
|
+
await this.consent(status);
|
|
230
|
+
}
|
|
231
|
+
getConsent() {
|
|
232
|
+
return consent_1.edgeeConsent.getConsent();
|
|
233
|
+
}
|
|
234
|
+
hasConsent() {
|
|
235
|
+
return consent_1.edgeeConsent.hasConsent();
|
|
236
|
+
}
|
|
237
|
+
async resetConsent() {
|
|
238
|
+
await consent_1.edgeeConsent.reset();
|
|
239
|
+
}
|
|
240
|
+
onConsentChange(callback) {
|
|
241
|
+
return consent_1.edgeeConsent.onChange(callback);
|
|
242
|
+
}
|
|
305
243
|
}
|
|
306
244
|
exports.EdgeeClient = EdgeeClient;
|
|
307
|
-
exports.navigation = __importStar(require("./navigation"));
|
|
308
245
|
var react_1 = require("./react");
|
|
309
|
-
Object.defineProperty(exports, "EdgeeAutoTracker", { enumerable: true, get: function () { return react_1.EdgeeAutoTracker; } });
|
|
310
246
|
Object.defineProperty(exports, "EdgeeProvider", { enumerable: true, get: function () { return react_1.EdgeeProvider; } });
|
|
311
247
|
Object.defineProperty(exports, "useEdgee", { enumerable: true, get: function () { return react_1.useEdgee; } });
|
|
312
|
-
Object.defineProperty(exports, "useEdgeeConsent", { enumerable: true, get: function () { return react_1.useEdgeeConsent; } });
|
|
313
248
|
var native_context_2 = require("./native-context");
|
|
314
249
|
Object.defineProperty(exports, "clearContextCache", { enumerable: true, get: function () { return native_context_2.clearContextCache; } });
|
|
315
250
|
Object.defineProperty(exports, "getNativeContext", { enumerable: true, get: function () { return native_context_2.getNativeContext; } });
|
|
316
251
|
Object.defineProperty(exports, "isNativeModuleAvailable", { enumerable: true, get: function () { return native_context_2.isNativeModuleAvailable; } });
|
|
317
|
-
// Export consent functionality
|
|
318
|
-
var consent_2 = require("./consent");
|
|
319
|
-
Object.defineProperty(exports, "ConsentUtils", { enumerable: true, get: function () { return consent_2.ConsentUtils; } });
|
|
320
|
-
Object.defineProperty(exports, "EdgeeConsent", { enumerable: true, get: function () { return consent_2.EdgeeConsent; } });
|
|
321
|
-
Object.defineProperty(exports, "edgeeConsent", { enumerable: true, get: function () { return consent_2.edgeeConsent; } });
|
package/dist/native-context.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.getNativeContext = getNativeContext;
|
|
|
4
4
|
exports.clearContextCache = clearContextCache;
|
|
5
5
|
exports.isNativeModuleAvailable = isNativeModuleAvailable;
|
|
6
6
|
const react_native_1 = require("react-native");
|
|
7
|
+
const utils_1 = require("./core/utils");
|
|
7
8
|
const LINKING_ERROR = `The package 'react-native-edgee' doesn't seem to be linked. Make sure: \n\n` +
|
|
8
9
|
react_native_1.Platform.select({ ios: "- You have run 'pod install'\n", default: "" }) +
|
|
9
10
|
"- You rebuilt the app after installing the package\n" +
|
|
@@ -40,7 +41,7 @@ async function getNativeContext(config = {}) {
|
|
|
40
41
|
})
|
|
41
42
|
.catch((error) => {
|
|
42
43
|
contextPromise = null;
|
|
43
|
-
|
|
44
|
+
(0, utils_1.logError)("Failed to get native context", error);
|
|
44
45
|
// Return fallback context
|
|
45
46
|
return getFallbackContext();
|
|
46
47
|
});
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
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
|
-
}
|
package/expo-router.d.ts
ADDED
|
@@ -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.
|
|
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,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,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
|
-
}
|
package/dist/navigation/index.js
DELETED
|
@@ -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
|
-
}
|