reactnative-plugin-appice 1.7.50 → 1.7.51
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/build.gradle +1 -1
- package/index.js +115 -5
- package/package.json +1 -1
- package/reactnative-plugin-appice.podspec +1 -1
- 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/android/build.gradle
CHANGED
|
@@ -97,7 +97,7 @@ dependencies {
|
|
|
97
97
|
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.3.1"
|
|
98
98
|
|
|
99
99
|
//appice
|
|
100
|
-
implementation "appice.io.android:sdk:2.6.
|
|
100
|
+
implementation "appice.io.android:sdk:2.6.47"
|
|
101
101
|
|
|
102
102
|
//glide
|
|
103
103
|
implementation "com.github.bumptech.glide:glide:4.11.0"
|
package/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
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';
|
|
3
5
|
import Campaign from './campaign';
|
|
4
6
|
|
|
5
7
|
const AppIceReactPlugin = NativeModules.AppIceReactPlugin;
|
|
@@ -11,6 +13,13 @@ else {
|
|
|
11
13
|
eventEmitter = new NativeEventEmitter(NativeModules.AppIceReactPlugin);
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
// export const appStorage = new MMKV({
|
|
17
|
+
// id: 'AppICE-storage',
|
|
18
|
+
// })
|
|
19
|
+
|
|
20
|
+
const EVENT_KEY = "lastEvent"
|
|
21
|
+
const LAST_EVENT_KEY = "event_"
|
|
22
|
+
|
|
14
23
|
export const CAMP_ID = AppIceReactPlugin.CAMP_ID;
|
|
15
24
|
export const ACTION_URL = AppIceReactPlugin.ACTION_URL;
|
|
16
25
|
export const ACTION_TYPE = AppIceReactPlugin.ACTION_TYPE;
|
|
@@ -169,10 +178,10 @@ var AppICEReact = {
|
|
|
169
178
|
AppState.addEventListener('change', (nextAppState) => {
|
|
170
179
|
if (nextAppState === 'active') {
|
|
171
180
|
AppIceReactPlugin.isDeviceReady(true);
|
|
172
|
-
AppIceReactPlugin.resumeInApp();
|
|
181
|
+
//AppIceReactPlugin.resumeInApp();
|
|
173
182
|
} else if (nextAppState === 'background') {
|
|
174
183
|
AppIceReactPlugin.isDeviceReady(false);
|
|
175
|
-
AppIceReactPlugin.discardInApp();
|
|
184
|
+
//AppIceReactPlugin.discardInApp();
|
|
176
185
|
}
|
|
177
186
|
});
|
|
178
187
|
},
|
|
@@ -191,13 +200,50 @@ var AppICEReact = {
|
|
|
191
200
|
* Record an event with optional event properties
|
|
192
201
|
* @param {string} eventName - the name of the event
|
|
193
202
|
* @param {object} props - the key-value properties of the event.
|
|
194
|
-
* @param {boolean}
|
|
203
|
+
* @param {boolean} flush - to use caching feature.
|
|
195
204
|
* keys are strings and values can be string, number or boolean.
|
|
196
205
|
*/
|
|
197
206
|
tagEvent: async function (eventName, props, flush) {
|
|
198
207
|
console.log("tagEvent : eventName " + eventName + ", prop " + props + ", flush " + flush);
|
|
199
|
-
|
|
200
|
-
|
|
208
|
+
|
|
209
|
+
if (flush == undefined || flush == null) {
|
|
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
|
+
}
|
|
201
247
|
},
|
|
202
248
|
|
|
203
249
|
|
|
@@ -560,5 +606,69 @@ function callWithCallback(method, args, callback) {
|
|
|
560
606
|
AppIceReactPlugin[method].apply(this, args);
|
|
561
607
|
}
|
|
562
608
|
|
|
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
|
+
|
|
563
673
|
|
|
564
674
|
module.exports = AppICEReact;
|
package/package.json
CHANGED
|
Binary file
|
|
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
|