react-native-edgee 1.0.9 → 1.0.11
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 +2 -2
- package/dist/api.d.ts +14 -0
- package/dist/api.js +29 -1
- package/dist/core/edgee-store.d.ts +4 -4
- package/dist/core/queue.d.ts +2 -7
- package/dist/core/queue.js +8 -20
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -15
- package/ios/EdgeeReactNative.podspec +3 -3
- package/package.json +1 -1
- package/react-native-edgee.podspec +4 -5
package/README.md
CHANGED
|
@@ -248,7 +248,7 @@ services.
|
|
|
248
248
|
|
|
249
249
|
In the Services section, you will find guides on activating and customizing
|
|
250
250
|
features such as advanced analytics, A/B testing, security, and more:
|
|
251
|
-
https://www.edgee.
|
|
251
|
+
https://www.edgee.ai/docs/proxy/services/overview
|
|
252
252
|
|
|
253
253
|
For more details about the React Native SDK, visit:
|
|
254
|
-
https://github.com/edgee-
|
|
254
|
+
https://github.com/edgee-ai/react-native-edgee
|
package/dist/api.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export type EdgeeEvent = {
|
|
|
27
27
|
components: Record<string, boolean> | undefined;
|
|
28
28
|
context: EdgeeFullContext;
|
|
29
29
|
};
|
|
30
|
+
export type ConsentEvent = {
|
|
31
|
+
type: "consent";
|
|
32
|
+
status: "granted" | "denied" | "pending";
|
|
33
|
+
};
|
|
34
|
+
export type QueueItem = EdgeeEvent | ConsentEvent;
|
|
35
|
+
export declare const isConsentEvent: (item: QueueItem) => item is ConsentEvent;
|
|
30
36
|
export declare const createScreenEvent: (data: EdgeeScreenEvent, components: Record<string, boolean> | undefined, context: EdgeeFullContext) => EdgeeEvent;
|
|
31
37
|
export declare const createTrackEvent: (data: EdgeeTrackEvent, components: Record<string, boolean> | undefined, context: EdgeeFullContext) => EdgeeEvent;
|
|
32
38
|
export declare const createUserEvent: (data: EdgeeUserEvent, components: Record<string, boolean> | undefined, context: EdgeeFullContext) => EdgeeEvent;
|
|
@@ -38,4 +44,12 @@ export declare const sendPayload: (config: EdgeeConfig, payload: any) => Promise
|
|
|
38
44
|
* Sends an event to the Edgee API
|
|
39
45
|
*/
|
|
40
46
|
export declare const uploadEvent: (config: EdgeeConfig, event: EdgeeEvent) => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Sends a consent event to the Edgee API
|
|
49
|
+
*/
|
|
50
|
+
export declare const uploadConsent: (config: EdgeeConfig, consent: ConsentEvent) => Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a consent event
|
|
53
|
+
*/
|
|
54
|
+
export declare const createConsentEvent: (status: "granted" | "denied" | "pending") => ConsentEvent;
|
|
41
55
|
export {};
|
package/dist/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadEvent = exports.sendPayload = exports.createUserEvent = exports.createTrackEvent = exports.createScreenEvent = void 0;
|
|
3
|
+
exports.createConsentEvent = exports.uploadConsent = exports.uploadEvent = exports.sendPayload = exports.createUserEvent = exports.createTrackEvent = exports.createScreenEvent = exports.isConsentEvent = void 0;
|
|
4
4
|
const edgee_store_1 = require("./core/edgee-store");
|
|
5
5
|
const utils_1 = require("./core/utils");
|
|
6
6
|
var EventType;
|
|
@@ -9,6 +9,11 @@ var EventType;
|
|
|
9
9
|
EventType["User"] = "user";
|
|
10
10
|
EventType["Screen"] = "screen";
|
|
11
11
|
})(EventType || (EventType = {}));
|
|
12
|
+
// Type guard to check if item is a consent event
|
|
13
|
+
const isConsentEvent = (item) => {
|
|
14
|
+
return item.type === "consent";
|
|
15
|
+
};
|
|
16
|
+
exports.isConsentEvent = isConsentEvent;
|
|
12
17
|
const createScreenEvent = (data, components, context) => {
|
|
13
18
|
return {
|
|
14
19
|
type: EventType.Track,
|
|
@@ -129,6 +134,29 @@ const uploadEvent = async (config, event) => {
|
|
|
129
134
|
return;
|
|
130
135
|
};
|
|
131
136
|
exports.uploadEvent = uploadEvent;
|
|
137
|
+
/**
|
|
138
|
+
* Sends a consent event to the Edgee API
|
|
139
|
+
*/
|
|
140
|
+
const uploadConsent = async (config, consent) => {
|
|
141
|
+
const payload = {
|
|
142
|
+
data_collection: {
|
|
143
|
+
consent: consent.status,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
await (0, exports.sendPayload)(config, payload);
|
|
147
|
+
return;
|
|
148
|
+
};
|
|
149
|
+
exports.uploadConsent = uploadConsent;
|
|
150
|
+
/**
|
|
151
|
+
* Creates a consent event
|
|
152
|
+
*/
|
|
153
|
+
const createConsentEvent = (status) => {
|
|
154
|
+
return {
|
|
155
|
+
type: "consent",
|
|
156
|
+
status,
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
exports.createConsentEvent = createConsentEvent;
|
|
132
160
|
/**
|
|
133
161
|
* Handles response data: stores IDs, handles cookies, and logs events
|
|
134
162
|
* Similar to the JS SDK handleResponse function
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QueueItem } from "../api";
|
|
2
2
|
export declare class EdgeeStore {
|
|
3
3
|
edgeeId: string | null;
|
|
4
4
|
userId: string | null;
|
|
5
|
-
pendingEvents:
|
|
5
|
+
pendingEvents: QueueItem[];
|
|
6
6
|
initialized: boolean;
|
|
7
7
|
constructor();
|
|
8
8
|
init(): Promise<void>;
|
|
@@ -14,8 +14,8 @@ export declare class EdgeeStore {
|
|
|
14
14
|
edgeeId: string | null;
|
|
15
15
|
userId: string | null;
|
|
16
16
|
}>;
|
|
17
|
-
addEvent(event:
|
|
18
|
-
getPendingEvents(): Promise<
|
|
17
|
+
addEvent(event: QueueItem): Promise<void>;
|
|
18
|
+
getPendingEvents(): Promise<QueueItem[]>;
|
|
19
19
|
clearEvents(): Promise<void>;
|
|
20
20
|
reset(): Promise<void>;
|
|
21
21
|
}
|
package/dist/core/queue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EdgeeConfig } from "..";
|
|
2
|
-
import {
|
|
2
|
+
import { QueueItem } from "../api";
|
|
3
3
|
export declare class EventQueue {
|
|
4
4
|
private config;
|
|
5
5
|
private q;
|
|
@@ -10,12 +10,7 @@ export declare class EventQueue {
|
|
|
10
10
|
constructor(config: EdgeeConfig);
|
|
11
11
|
destroy(): void;
|
|
12
12
|
setReady(val: boolean): void;
|
|
13
|
-
enqueue(item:
|
|
14
|
-
/**
|
|
15
|
-
* Send a direct payload (used for consent events)
|
|
16
|
-
* This bypasses the normal event structure and sends raw payload
|
|
17
|
-
*/
|
|
18
|
-
sendEvent(payload: any): Promise<void>;
|
|
13
|
+
enqueue(item: QueueItem): void;
|
|
19
14
|
private shouldFlush;
|
|
20
15
|
flush(): Promise<void>;
|
|
21
16
|
}
|
package/dist/core/queue.js
CHANGED
|
@@ -51,24 +51,6 @@ class EventQueue {
|
|
|
51
51
|
void this.flush();
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Send a direct payload (used for consent events)
|
|
56
|
-
* This bypasses the normal event structure and sends raw payload
|
|
57
|
-
*/
|
|
58
|
-
async sendEvent(payload) {
|
|
59
|
-
if (!this.online) {
|
|
60
|
-
// For direct payloads, we can't easily queue them in the current structure
|
|
61
|
-
// So we'll send them when we come back online
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
await (0, api_1.sendPayload)(this.config, payload);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
(0, utils_1.logError)("[Queue] Error sending event.", error);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
54
|
shouldFlush() {
|
|
73
55
|
return this.ready && this.online && this.q.length > 0;
|
|
74
56
|
}
|
|
@@ -83,8 +65,14 @@ class EventQueue {
|
|
|
83
65
|
(0, utils_1.log)(this.config, `Flushing ${itemsToFlush.length} event(s)...`);
|
|
84
66
|
try {
|
|
85
67
|
for (const item of itemsToFlush) {
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
if ((0, api_1.isConsentEvent)(item)) {
|
|
69
|
+
await (0, api_1.uploadConsent)(this.config, item);
|
|
70
|
+
(0, utils_1.log)(this.config, `Consent sent: ${item.status}`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
await (0, api_1.uploadEvent)(this.config, item);
|
|
74
|
+
(0, utils_1.log)(this.config, `Event sent: ${item.type} - ${item.data.name || "user"}`);
|
|
75
|
+
}
|
|
88
76
|
}
|
|
89
77
|
// Only clear persisted events after successful send
|
|
90
78
|
await edgee_store_1.edgeeStore.clearEvents();
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class EdgeeClient {
|
|
|
27
27
|
*/
|
|
28
28
|
user(data: EdgeeUserEvent, components?: Components): Promise<void>;
|
|
29
29
|
/**
|
|
30
|
-
* Send consent event
|
|
30
|
+
* Send consent event to Edgee (queued like other events)
|
|
31
31
|
*/
|
|
32
32
|
consent(status: ConsentStatus): Promise<void>;
|
|
33
33
|
setConsent(status: ConsentStatus): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -96,7 +96,7 @@ class EdgeeClient {
|
|
|
96
96
|
(0, utils_1.log)(this.config, "USER event queued:", data.user_id || data.anonymous_id || "anonymous");
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* Send consent event
|
|
99
|
+
* Send consent event to Edgee (queued like other events)
|
|
100
100
|
*/
|
|
101
101
|
async consent(status) {
|
|
102
102
|
// Validate consent status
|
|
@@ -106,20 +106,10 @@ class EdgeeClient {
|
|
|
106
106
|
}
|
|
107
107
|
// Store consent locally
|
|
108
108
|
await consent_1.edgeeConsent.setConsent(status);
|
|
109
|
-
//
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
try {
|
|
116
|
-
await this.queue.sendEvent(payload);
|
|
117
|
-
(0, utils_1.log)(this.config, "- Consent set to:", status);
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
(0, utils_1.logError)("Error collecting consent event", error);
|
|
121
|
-
throw error;
|
|
122
|
-
}
|
|
109
|
+
// Queue consent event (will be sent when online)
|
|
110
|
+
const event = (0, api_1.createConsentEvent)(status);
|
|
111
|
+
this.queue.enqueue(event);
|
|
112
|
+
(0, utils_1.log)(this.config, "- Consent queued:", status);
|
|
123
113
|
}
|
|
124
114
|
// Consent management methods
|
|
125
115
|
async setConsent(status) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "../package.json")))
|
|
4
|
-
|
|
4
|
+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
5
5
|
|
|
6
6
|
Pod::Spec.new do |s|
|
|
7
7
|
s.name = "EdgeeReactNative"
|
|
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
|
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
14
|
s.platforms = { :ios => "11.0" }
|
|
15
|
-
s.source = { :git => "https://github.com/edgee-
|
|
15
|
+
s.source = { :git => "https://github.com/edgee-ai/react-native-edgee.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "*.{h,m,mm,swift}"
|
|
18
18
|
|
|
@@ -27,7 +27,7 @@ Pod::Spec.new do |s|
|
|
|
27
27
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
28
28
|
}
|
|
29
29
|
s.dependency "React-Codegen"
|
|
30
|
-
s.dependency "RCT-Folly"
|
|
30
|
+
s.dependency "RCT-Folly"
|
|
31
31
|
s.dependency "RCTRequired"
|
|
32
32
|
s.dependency "RCTTypeSafety"
|
|
33
33
|
s.dependency "ReactCommon/turbomodule/core"
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
folly_version = '2024.11.18.00'
|
|
5
4
|
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
|
|
6
5
|
|
|
7
6
|
Pod::Spec.new do |s|
|
|
8
7
|
s.name = "react-native-edgee"
|
|
9
8
|
s.version = package["version"]
|
|
10
9
|
s.summary = package["description"]
|
|
11
|
-
s.homepage = "https://github.com/edgee-
|
|
10
|
+
s.homepage = "https://github.com/edgee-ai/react-native-edgee"
|
|
12
11
|
s.license = package["license"]
|
|
13
|
-
s.authors = { "Edgee" => "hello@edgee.
|
|
12
|
+
s.authors = { "Edgee" => "hello@edgee.ai" }
|
|
14
13
|
|
|
15
14
|
s.platforms = { :ios => "11.0" }
|
|
16
|
-
s.source = { :git => "https://github.com/edgee-
|
|
15
|
+
s.source = { :git => "https://github.com/edgee-ai/react-native-edgee.git", :tag => "#{s.version}" }
|
|
17
16
|
|
|
18
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
19
18
|
|
|
@@ -28,7 +27,7 @@ Pod::Spec.new do |s|
|
|
|
28
27
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
29
28
|
}
|
|
30
29
|
s.dependency "React-Codegen"
|
|
31
|
-
s.dependency "RCT-Folly"
|
|
30
|
+
s.dependency "RCT-Folly"
|
|
32
31
|
s.dependency "RCTRequired"
|
|
33
32
|
s.dependency "RCTTypeSafety"
|
|
34
33
|
s.dependency "ReactCommon/turbomodule/core"
|