reactnative-plugin-appice 1.7.49 → 1.7.50
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/android/.gradle/8.5/checksums/checksums.lock +0 -0
- package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.5/gc.properties +0 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/example/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
- package/example/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
- package/example/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
- package/example/android/.gradle/7.3.3/gc.properties +0 -0
- package/example/android/.gradle/vcs-1/gc.properties +0 -0
- package/index.js +5 -115
- package/package.json +1 -1
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
package/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { DeviceEventEmitter, NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
2
|
import { Platform, Component, AppState } from 'react-native';
|
|
3
|
-
// import { MMKV } from 'react-native-mmkv'
|
|
4
|
-
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
5
3
|
import Campaign from './campaign';
|
|
6
4
|
|
|
7
5
|
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
@@ -13,13 +11,6 @@ else {
|
|
|
13
11
|
eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
// export const appStorage = new MMKV({
|
|
17
|
-
// id: 'AppICE-storage',
|
|
18
|
-
// })
|
|
19
|
-
|
|
20
|
-
const EVENT_KEY = "lastEvent"
|
|
21
|
-
const LAST_EVENT_KEY = "event_"
|
|
22
|
-
|
|
23
14
|
export const CAMP_ID = AppIceReactPlugin.CAMP_ID;
|
|
24
15
|
export const ACTION_URL = AppIceReactPlugin.ACTION_URL;
|
|
25
16
|
export const ACTION_TYPE = AppIceReactPlugin.ACTION_TYPE;
|
|
@@ -178,10 +169,10 @@ var AppICEReact = {
|
|
|
178
169
|
AppState.addEventListener('change', (nextAppState) => {
|
|
179
170
|
if (nextAppState === 'active') {
|
|
180
171
|
AppIceReactPlugin.isDeviceReady(true);
|
|
181
|
-
|
|
172
|
+
AppIceReactPlugin.resumeInApp();
|
|
182
173
|
} else if (nextAppState === 'background') {
|
|
183
174
|
AppIceReactPlugin.isDeviceReady(false);
|
|
184
|
-
|
|
175
|
+
AppIceReactPlugin.discardInApp();
|
|
185
176
|
}
|
|
186
177
|
});
|
|
187
178
|
},
|
|
@@ -200,50 +191,13 @@ var AppICEReact = {
|
|
|
200
191
|
* Record an event with optional event properties
|
|
201
192
|
* @param {string} eventName - the name of the event
|
|
202
193
|
* @param {object} props - the key-value properties of the event.
|
|
203
|
-
* @param {boolean} flush -
|
|
194
|
+
* @param {boolean} [flush] - retained for backward compatibility; ignored.
|
|
204
195
|
* keys are strings and values can be string, number or boolean.
|
|
205
196
|
*/
|
|
206
197
|
tagEvent: async function (eventName, props, flush) {
|
|
207
198
|
console.log("tagEvent : eventName " + eventName + ", prop " + props + ", flush " + flush);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
211
|
-
} else {
|
|
212
|
-
const lastEventData = await getEventData(LAST_EVENT_KEY)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
if (lastEventData != undefined && lastEventData !== eventName) {
|
|
216
|
-
try {
|
|
217
|
-
const storedEvents = await getEventData(EVENT_KEY + lastEventData)
|
|
218
|
-
|
|
219
|
-
console.log("tagEvent : storedEvents " + storedEvents);
|
|
220
|
-
|
|
221
|
-
if (storedEvents != null && storedEvents.length > 0) {
|
|
222
|
-
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
223
|
-
|
|
224
|
-
const lastPropsData = events.reduce((acc, event) => {
|
|
225
|
-
return { ...acc, ...event.props };
|
|
226
|
-
}, {});
|
|
227
|
-
|
|
228
|
-
await AppIceReactPlugin.tagEvent(lastEventData, lastPropsData);
|
|
229
|
-
|
|
230
|
-
await deleteData(EVENT_KEY + lastEventData)
|
|
231
|
-
await deleteData(LAST_EVENT_KEY)
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
} catch (error) {
|
|
235
|
-
console.error('Failed to flush events:', error);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
await handleStoredEvents(eventName, props);
|
|
239
|
-
} else {
|
|
240
|
-
if (flush) {
|
|
241
|
-
await handleFlushEvent(eventName, props);
|
|
242
|
-
} else {
|
|
243
|
-
await handleStoredEvents(eventName, props);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
199
|
+
// Always forward events immediately, whether flush is supplied or omitted.
|
|
200
|
+
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
247
201
|
},
|
|
248
202
|
|
|
249
203
|
|
|
@@ -606,69 +560,5 @@ function callWithCallback(method, args, callback) {
|
|
|
606
560
|
AppIceReactPlugin[method].apply(this, args);
|
|
607
561
|
}
|
|
608
562
|
|
|
609
|
-
const handleStoredEvents = async (eventName, props) => {
|
|
610
|
-
try {
|
|
611
|
-
const storedEvents = await getEventData(EVENT_KEY + eventName);
|
|
612
|
-
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
613
|
-
|
|
614
|
-
// Add the current event
|
|
615
|
-
events.push({ eventName, props });
|
|
616
|
-
|
|
617
|
-
// Save the updated events list
|
|
618
|
-
// appStorage.set(EVENT_KEY + eventName, JSON.stringify(events));
|
|
619
|
-
// appStorage.set(LAST_EVENT_KEY, eventName);
|
|
620
|
-
|
|
621
|
-
// async Storage
|
|
622
|
-
await AsyncStorage.setItem(EVENT_KEY + eventName, JSON.stringify(events))
|
|
623
|
-
await AsyncStorage.setItem(LAST_EVENT_KEY, eventName)
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
} catch (error) {
|
|
627
|
-
console.error('Failed to store event:', error);
|
|
628
|
-
}
|
|
629
|
-
};
|
|
630
|
-
|
|
631
|
-
const handleFlushEvent = async (eventName, props) => {
|
|
632
|
-
try {
|
|
633
|
-
const storedEvents = await getEventData(EVENT_KEY + eventName);
|
|
634
|
-
let events = storedEvents ? JSON.parse(storedEvents) : [];
|
|
635
|
-
|
|
636
|
-
events.forEach(event => {
|
|
637
|
-
Object.assign(props, event.props);
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
await AppIceReactPlugin.tagEvent(eventName, props);
|
|
641
|
-
|
|
642
|
-
await deleteData(EVENT_KEY + eventName)
|
|
643
|
-
await deleteData(LAST_EVENT_KEY)
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
} catch (error) {
|
|
647
|
-
console.error('Failed to flush events:', error);
|
|
648
|
-
}
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
const deleteData = async (eventName) => {
|
|
652
|
-
try {
|
|
653
|
-
//appStorage.delete(EVENT_KEY + eventName);
|
|
654
|
-
//appStorage.delete(LAST_EVENT_KEY);
|
|
655
|
-
|
|
656
|
-
await AsyncStorage.removeItem(eventName)
|
|
657
|
-
} catch (error) {
|
|
658
|
-
console.error('Failed to delete events:', error);
|
|
659
|
-
}
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
const getEventData = async (eventName) => {
|
|
663
|
-
try {
|
|
664
|
-
|
|
665
|
-
// const storedEvents1 = appStorage.getString(EVENT_KEY + lastEventData);
|
|
666
|
-
|
|
667
|
-
return await AsyncStorage.getItem(eventName)
|
|
668
|
-
} catch (error) {
|
|
669
|
-
console.error('Failed to fetch events:', error);
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
|
|
673
563
|
|
|
674
564
|
module.exports = AppICEReact;
|