clevertap-react-native 3.1.1 → 3.2.0

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +2 -2
  3. package/android/.gradle/8.5/checksums/checksums.lock +0 -0
  4. package/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
  5. package/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
  6. package/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
  7. package/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
  8. package/android/.gradle/8.5/gc.properties +0 -0
  9. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  10. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  11. package/android/.gradle/nb-cache/trust/78DD44AAC81C568A008B13ED64740D37310990B04E1F70028E68455541C79400 +1 -0
  12. package/android/.gradle/vcs-1/gc.properties +0 -0
  13. package/android/build.gradle +3 -3
  14. package/android/src/main/java/com/clevertap/react/CleverTapEventEmitter.kt +5 -3
  15. package/android/src/main/java/com/clevertap/react/CleverTapModuleImpl.java +104 -0
  16. package/android/src/newarch/CleverTapModule.kt +21 -0
  17. package/android/src/oldarch/CleverTapModule.kt +25 -0
  18. package/clevertap-react-native.podspec +1 -1
  19. package/docs/install.md +2 -2
  20. package/docs/integration.md +4 -4
  21. package/docs/usage.md +3 -3
  22. package/ios/CleverTapReact/CleverTapReact.mm +60 -0
  23. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  24. package/ios/CleverTapReact.xcodeproj/project.xcworkspace/xcuserdata/kushagra.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  25. package/ios/CleverTapReact.xcodeproj/xcuserdata/kushagra.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  26. package/package.json +1 -1
  27. package/src/NativeCleverTapModule.ts +11 -0
  28. package/src/index.d.ts +49 -2
  29. package/src/index.js +49 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,37 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ Version 3.2.0 *(5 February 2025)*
5
+ -------------------------------------------
6
+ **What's new**
7
+
8
+ * **[Android Platform]**
9
+ * Supports [CleverTap Android SDK v7.1.2](https://github.com/CleverTap/clevertap-android-sdk/blob/master/docs/CTCORECHANGELOG.md#version-712-january-29-2025).
10
+ * Adds support to hide large icon in android notifications by sending `wzrk_hide_large_icon` key in notification payload.
11
+
12
+ * **[iOS Platform]**
13
+ * Supports [CleverTap iOS SDK v7.1.0](https://github.com/CleverTap/clevertap-ios-sdk/blob/master/CHANGELOG.md#version-710-january-21-2024).
14
+
15
+ * **[Android and iOS Platform]**
16
+ - Adds support for triggering InApps based on first-time event filtering in multiple triggers. Now you can create campaign triggers that combine recurring and first-time events. For example: Trigger a campaign when "Charged" occurs (every time) OR "App Launched" occurs (first time only).
17
+ - Adds new user-level event log tracking system to store and manage user event history. New APIs include:
18
+ - `getUserEventLog(<eventName>)`: Get details about a specific event
19
+ - `getUserEventLogCount(<eventName>)`: Get count of times an event occurred
20
+ - `getUserLastVisitTs()`: Get timestamp of user's last app visit
21
+ - `getUserAppLaunchCount()`: Get total number of times user has launched the app
22
+ - `getUserEventLogHistory()`: Get full event history for current user
23
+
24
+ #### API Changes
25
+
26
+ - **Deprecates:** The old event tracking APIs tracked events at the device level rather than the user level, making it difficult to maintain accurate user-specific event histories, especially in multi-user scenarios. The following methods have been deprecated in favor of new user-specific event tracking APIs that provide more accurate, user-level analytics. These deprecated methods will be removed in future versions with prior notice:
27
+ - `eventGetDetail()`: Use `getUserEventLog()` instead for user-specific event details
28
+ - `eventGetOccurrences()`: Use `getUserEventLogCount()` instead for user-specific event counts
29
+ - `eventGetFirstTime()`: Use `getUserEventLog()` instead for user-specific first occurrence timestamp
30
+ - `eventGetLastTime()`: Use `getUserEventLog()` instead for user-specific last occurrence timestamp
31
+ - `sessionGetPreviousVisitTime()`: Use `getUserLastVisitTs()` instead for user-specific last visit timestamp
32
+ - `sessionGetTotalVisits()`: Use `getUserAppLaunchCount()` instead for user-specific app launch count
33
+ - `getEventHistory()`: Use `getUserEventLogHistory()` instead for user-specific event history
34
+
4
35
  Version 3.1.1 *(6 November 2024)*
5
36
  -------------------------------------------
6
37
  **Bug Fixes**
package/README.md CHANGED
@@ -22,8 +22,8 @@ To get started, sign up [here](https://clevertap.com/live-product-demo/).
22
22
  3. Follow the [integration instructions](./docs/integration.md)
23
23
 
24
24
  ## 📚 Additional Resources
25
- - [CleverTap iOS SDK Integration guide](https://support.clevertap.com/docs/ios/getting-started.html)
26
- - [CleverTap Android SDK Integration guide](https://support.clevertap.com/docs/android/getting-started.html)
25
+ - [CleverTap iOS SDK Integration guide](https://developer.clevertap.com/docs/ios)
26
+ - [CleverTap Android SDK Integration guide](https://developer.clevertap.com/docs/android)
27
27
 
28
28
  ## 📲 CleverTap iOS Push Templates SDK
29
29
 
File without changes
@@ -0,0 +1,2 @@
1
+ #Tue Feb 04 15:23:26 IST 2025
2
+ gradle.version=8.5
@@ -0,0 +1 @@
1
+ DCC73873EEDDA3B877B3B1661F94F060C0B645A5A1CEFC1A3367BF88075D1DE9
File without changes
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 19
37
37
  targetSdkVersion 34
38
- versionCode 311
39
- versionName "3.1.1"
38
+ versionCode 320
39
+ versionName "3.2.0"
40
40
  buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
41
41
  }
42
42
 
@@ -54,7 +54,7 @@ android {
54
54
  }
55
55
 
56
56
  dependencies {
57
- api 'com.clevertap.android:clevertap-android-sdk:7.0.2'
57
+ api 'com.clevertap.android:clevertap-android-sdk:7.1.2'
58
58
  implementation 'com.android.installreferrer:installreferrer:2.2'
59
59
  //compile 'com.android.support:appcompat-v7:28.0.0'
60
60
  implementation 'com.facebook.react:react-native:+'
@@ -57,9 +57,11 @@ object CleverTapEventEmitter {
57
57
  */
58
58
  fun flushBuffer(event: CleverTapEvent) {
59
59
  val buffer = eventsBuffers[event] ?: return
60
- while (buffer.size() > 0) {
61
- val params = buffer.remove()
62
- sendEvent(event, params)
60
+ synchronized(buffer) {
61
+ while (buffer.size() > 0) {
62
+ val params = buffer.remove()
63
+ sendEvent(event, params)
64
+ }
63
65
  }
64
66
  }
65
67
 
@@ -32,6 +32,7 @@ import com.clevertap.android.sdk.inapp.customtemplates.CustomTemplateContext;
32
32
  import com.clevertap.android.sdk.inbox.CTInboxMessage;
33
33
  import com.clevertap.android.sdk.interfaces.OnInitCleverTapIDListener;
34
34
  import com.clevertap.android.sdk.product_config.CTProductConfigController;
35
+ import com.clevertap.android.sdk.usereventlogs.UserEventLog;
35
36
  import com.clevertap.android.sdk.variables.CTVariableUtils;
36
37
  import com.clevertap.android.sdk.variables.Var;
37
38
  import com.clevertap.android.sdk.variables.callbacks.FetchVariablesCallback;
@@ -295,6 +296,75 @@ public class CleverTapModuleImpl {
295
296
  clevertap.enablePersonalization();
296
297
  }
297
298
 
299
+
300
+ public void getUserEventLog(String eventName, Callback callback) {
301
+ String error = null;
302
+ WritableMap result = null;
303
+
304
+ CleverTapAPI clevertap = getCleverTapAPI();
305
+ if (clevertap != null) {
306
+ UserEventLog eventLog = clevertap.getUserEventLog(eventName);
307
+ result = eventLogToWritableMap(eventLog);
308
+ } else {
309
+ error = "CleverTap not initialized";
310
+ }
311
+ callbackWithErrorAndResult(callback, error, result);
312
+ }
313
+
314
+ public void getUserEventLogCount(String eventName, Callback callback) {
315
+ String error = null;
316
+ int result = -1;
317
+
318
+ CleverTapAPI clevertap = getCleverTapAPI();
319
+ if (clevertap != null) {
320
+ result = clevertap.getUserEventLogCount(eventName);
321
+ } else {
322
+ error = "CleverTap not initialized";
323
+ }
324
+ callbackWithErrorAndResult(callback, error, result);
325
+ }
326
+
327
+ public void getUserLastVisitTs(Callback callback) {
328
+ String error = null;
329
+ double result = -1;
330
+
331
+ CleverTapAPI clevertap = getCleverTapAPI();
332
+ if (clevertap != null) {
333
+ result = clevertap.getUserLastVisitTs();
334
+ } else {
335
+ error = "CleverTap not initialized";
336
+ }
337
+ callbackWithErrorAndResult(callback, error, result);
338
+ }
339
+
340
+ public void getUserAppLaunchCount(Callback callback) {
341
+ String error = null;
342
+ int result = -1;
343
+
344
+ CleverTapAPI clevertap = getCleverTapAPI();
345
+ if (clevertap != null) {
346
+ result = clevertap.getUserAppLaunchCount();
347
+ } else {
348
+ error = "CleverTap not initialized";
349
+ }
350
+ callbackWithErrorAndResult(callback, error, result);
351
+ }
352
+
353
+ public void getUserEventLogHistory(Callback callback) {
354
+ String error = null;
355
+ WritableMap result = null;
356
+
357
+ CleverTapAPI clevertap = getCleverTapAPI();
358
+ if (clevertap != null) {
359
+ Map<String, UserEventLog> history = clevertap.getUserEventLogHistory();
360
+ result = eventLogHistoryToWritableMap(history);
361
+ } else {
362
+ error = "CleverTap not initialized";
363
+ }
364
+ callbackWithErrorAndResult(callback, error, result);
365
+ }
366
+
367
+ @Deprecated(since = "3.2.0")
298
368
  public void eventGetDetail(String eventName, Callback callback) {
299
369
  String error = null;
300
370
  WritableMap result = null;
@@ -309,6 +379,8 @@ public class CleverTapModuleImpl {
309
379
  callbackWithErrorAndResult(callback, error, result);
310
380
  }
311
381
 
382
+
383
+ @Deprecated(since = "3.2.0")
312
384
  public void eventGetFirstTime(String eventName, Callback callback) {
313
385
  String error = null;
314
386
  int result = -1;
@@ -322,6 +394,7 @@ public class CleverTapModuleImpl {
322
394
  callbackWithErrorAndResult(callback, error, result);
323
395
  }
324
396
 
397
+ @Deprecated(since = "3.2.0")
325
398
  public void eventGetLastTime(String eventName, Callback callback) {
326
399
  String error = null;
327
400
  int result = -1;
@@ -335,6 +408,7 @@ public class CleverTapModuleImpl {
335
408
  callbackWithErrorAndResult(callback, error, result);
336
409
  }
337
410
 
411
+ @Deprecated(since = "3.2.0")
338
412
  public void eventGetOccurrences(String eventName, Callback callback) {
339
413
  String error = null;
340
414
  int result = -1;
@@ -440,6 +514,7 @@ public class CleverTapModuleImpl {
440
514
  callbackWithErrorAndResult(callback, error, result);
441
515
  }
442
516
 
517
+ @Deprecated(since = "3.2.0")
443
518
  public void getEventHistory(Callback callback) {
444
519
  String error = null;
445
520
  WritableMap result = null;
@@ -890,6 +965,7 @@ public class CleverTapModuleImpl {
890
965
  productConfigController.reset();
891
966
  }
892
967
 
968
+ @Deprecated(since = "3.2.0")
893
969
  public void sessionGetPreviousVisitTime(Callback callback) {
894
970
  String error = null;
895
971
  int result = -1;
@@ -929,6 +1005,7 @@ public class CleverTapModuleImpl {
929
1005
  callbackWithErrorAndResult(callback, error, result);
930
1006
  }
931
1007
 
1008
+ @Deprecated(since = "3.2.0")
932
1009
  public void sessionGetTotalVisits(Callback callback) {
933
1010
  String error = null;
934
1011
  int result = -1;
@@ -1866,6 +1943,32 @@ public class CleverTapModuleImpl {
1866
1943
  return array;
1867
1944
  }
1868
1945
 
1946
+ private static WritableMap eventLogToWritableMap(UserEventLog eventLog) {
1947
+ WritableMap ret = Arguments.createMap();
1948
+
1949
+ if (eventLog != null) {
1950
+ ret.putString("eventName", eventLog.getEventName());
1951
+ ret.putString("normalizedEventName", eventLog.getNormalizedEventName());
1952
+ ret.putDouble("firstTime", eventLog.getFirstTs());
1953
+ ret.putDouble("lastTime", eventLog.getLastTs());
1954
+ ret.putInt("count", eventLog.getCountOfEvents());
1955
+ ret.putString("deviceID", eventLog.getDeviceID());
1956
+ }
1957
+ return ret;
1958
+ }
1959
+
1960
+ private static WritableMap eventLogHistoryToWritableMap(Map<String, UserEventLog> history) {
1961
+ WritableMap ret = Arguments.createMap();
1962
+
1963
+ if (history != null) {
1964
+ for (String key : history.keySet()) {
1965
+ ret.putMap(key, eventLogToWritableMap(history.get(key)));
1966
+ }
1967
+ }
1968
+ return ret;
1969
+ }
1970
+
1971
+ @Deprecated(since = "3.2.0")
1869
1972
  private static WritableMap eventDetailToWritableMap(EventDetail details) {
1870
1973
  WritableMap ret = Arguments.createMap();
1871
1974
 
@@ -1878,6 +1981,7 @@ public class CleverTapModuleImpl {
1878
1981
  return ret;
1879
1982
  }
1880
1983
 
1984
+ @Deprecated(since = "3.2.0")
1881
1985
  private static WritableMap eventHistoryToWritableMap(Map<String, EventDetail> history) {
1882
1986
  WritableMap ret = Arguments.createMap();
1883
1987
 
@@ -587,6 +587,27 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
587
587
  return
588
588
  }
589
589
 
590
+ override fun getUserEventLog(eventName: String, callback: Callback?) {
591
+ cleverTapModuleImpl.getUserEventLog(eventName, callback)
592
+ }
593
+
594
+ override fun getUserEventLogCount(eventName: String, callback: Callback?) {
595
+ cleverTapModuleImpl.getUserEventLogCount(eventName, callback)
596
+ }
597
+
598
+ override fun getUserLastVisitTs(callback: Callback?) {
599
+ cleverTapModuleImpl.getUserLastVisitTs(callback)
600
+ }
601
+
602
+ override fun getUserAppLaunchCount(callback: Callback?) {
603
+ cleverTapModuleImpl.getUserAppLaunchCount(callback)
604
+ }
605
+
606
+ override fun getUserEventLogHistory(callback: Callback?) {
607
+ cleverTapModuleImpl.getUserEventLogHistory(callback)
608
+ }
609
+
610
+
590
611
  override fun getTypedExportedConstants(): Map<String, Any> {
591
612
  return cleverTapModuleImpl.getClevertapConstants()
592
613
  }
@@ -675,6 +675,31 @@ class CleverTapModule(reactContext: ReactApplicationContext?) :
675
675
  cleverTapModuleImpl.onEventListenerAdded(eventName)
676
676
  }
677
677
 
678
+ @ReactMethod
679
+ fun getUserEventLog(eventName: String, callback: Callback) {
680
+ cleverTapModuleImpl.getUserEventLog(eventName, callback)
681
+ }
682
+
683
+ @ReactMethod
684
+ fun getUserEventLogCount(eventName: String, callback: Callback) {
685
+ cleverTapModuleImpl.getUserEventLogCount(eventName, callback)
686
+ }
687
+
688
+ @ReactMethod
689
+ fun getUserLastVisitTs(callback: Callback) {
690
+ cleverTapModuleImpl.getUserLastVisitTs(callback)
691
+ }
692
+
693
+ @ReactMethod
694
+ fun getUserAppLaunchCount(callback: Callback) {
695
+ cleverTapModuleImpl.getUserAppLaunchCount(callback)
696
+ }
697
+
698
+ @ReactMethod
699
+ fun getUserEventLogHistory(callback: Callback) {
700
+ cleverTapModuleImpl.getUserEventLogHistory(callback)
701
+ }
702
+
678
703
  override fun getConstants(): Map<String, Any> {
679
704
  return cleverTapModuleImpl.getClevertapConstants()
680
705
  }
@@ -24,7 +24,7 @@ Pod::Spec.new do |s|
24
24
  s.dependency 'React-Core'
25
25
  end
26
26
 
27
- s.dependency 'CleverTap-iOS-SDK', '7.0.2'
27
+ s.dependency 'CleverTap-iOS-SDK', '7.1.0'
28
28
 
29
29
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
30
30
  s.pod_target_xcconfig = {
package/docs/install.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Link CleverTap for React Native 0.59 or below & Not Using Cocoapods
6
6
 
7
- 2. `react-native link clevertap-react-native` **or** [follow the manual linking instructions below](#manual-linking).
7
+ 2. `react-native link clevertap-react-native` **or** [follow the manual linking instructions below](install.md#manual-linking).
8
8
 
9
9
  **Note:**
10
10
 
@@ -143,7 +143,7 @@ maven {
143
143
  }
144
144
  ```
145
145
 
146
- ## Manual Linking ##
146
+ ## Manual Linking
147
147
 
148
148
  #### iOS:
149
149
  - Drag and Drop node_modules/clevertap-react-native/ios/CleverTapReact.xcodeproj into the Libraries folder of your project in XCode ([see Step 1 here](http://facebook.github.io/react-native/docs/linking-libraries-ios.html#manual-linking)).
@@ -8,7 +8,7 @@ Clevertap supports the [ReactNative New Architecture](https://reactnative.dev/do
8
8
 
9
9
 
10
10
  ### iOS
11
- 1. Follow the integration instructions [starting with Step 2 here](https://support.clevertap.com/docs/ios/getting-started.html).
11
+ 1. Follow the integration instructions [here](https://developer.clevertap.com/docs/react-native-quick-start-guide#ios-integration).
12
12
  2. In your `AppDelegate didFinishLaunchingWithOptions:` notify the CleverTap React SDK of application launch:
13
13
  ```objc
14
14
  [CleverTap autoIntegrate]; // integrate CleverTap SDK using the autoIntegrate option
@@ -22,10 +22,10 @@ NOTE: Don't forget to add the CleverTap imports at the top of the file.
22
22
 
23
23
  Note: Need to use **@import CleverTapSDK;** instead of **#import <CleverTap-iOS-SDK/CleverTap.h>** and **@import CleverTapReact;** instead of **#import <clevertap-react-native/CleverTapReactManager.h>** in the AppDelegate class in case if using ```use_modular_headers!``` in the podfile.
24
24
 
25
- [See the Example Project](/Example/ios/Example/AppDelegate.m).
25
+ [See the Example Project](/Example/ios/Example/AppDelegate.mm).
26
26
 
27
27
  ### Android
28
- 1. Follow the integration instructions [starting with Step 2 here](https://support.clevertap.com/docs/android/getting-started.html).
28
+ 1. Follow the integration instructions [here](https://developer.clevertap.com/docs/react-native-quick-start-guide#android-integration).
29
29
 
30
30
  2. Add CleverTapPackage to the packages list in MainApplication.java (`android/app/src/[...]/MainApplication.java`)
31
31
  ```java
@@ -118,5 +118,5 @@ Note: Need to use **@import CleverTapSDK;** instead of **#import <CleverTap-iOS-
118
118
  }
119
119
  ```
120
120
 
121
- [See the Example Project](/Example/App.js)
121
+ [See the Example Project](/Example/app/App.js)
122
122
 
package/docs/usage.md CHANGED
@@ -500,6 +500,6 @@ CleverTap.resumeInAppNotifications();
500
500
 
501
501
 
502
502
  ### For more information,
503
- - [See included Example Application](/Example/App.js)
504
- - [See CleverTap JS interface](/index.js)
505
- - [See CleverTap TS interface](/index.d.ts)
503
+ - [See included Example Application](/Example/app/App.js)
504
+ - [See CleverTap JS interface](/src/index.js)
505
+ - [See CleverTap TS interface](/src/index.d.ts)
@@ -264,6 +264,43 @@ RCT_EXPORT_METHOD(getEventHistory:(RCTResponseSenderBlock)callback) {
264
264
  [self returnResult:result withCallback:callback andError:nil];
265
265
  }
266
266
 
267
+ RCT_EXPORT_METHOD(getUserEventLog:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
268
+ RCTLogInfo(@"[CleverTap getUserEventLog: %@]", eventName);
269
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
270
+ CleverTapEventDetail *detail = [[self cleverTapInstance] getUserEventLog:eventName];
271
+ NSDictionary *result = [self _eventDetailToDict:detail];
272
+ dispatch_async(dispatch_get_main_queue(), ^{
273
+ [self returnResult:result withCallback:callback andError:nil];
274
+ });
275
+ });
276
+ }
277
+
278
+ RCT_EXPORT_METHOD(getUserEventLogCount:(NSString*)eventName callback:(RCTResponseSenderBlock)callback) {
279
+ RCTLogInfo(@"[CleverTap getUserEventLogCount: %@]", eventName);
280
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
281
+ int result = [[self cleverTapInstance] getUserEventLogCount:eventName];
282
+ dispatch_async(dispatch_get_main_queue(), ^{
283
+ [self returnResult:@(result) withCallback:callback andError:nil];
284
+ });
285
+ });
286
+ }
287
+
288
+ RCT_EXPORT_METHOD(getUserEventLogHistory:(RCTResponseSenderBlock)callback) {
289
+ RCTLogInfo(@"[CleverTap getUserEventLogHistory]");
290
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
291
+ NSDictionary *history = [[self cleverTapInstance] getUserEventLogHistory];
292
+ NSMutableDictionary *result = [NSMutableDictionary new];
293
+
294
+ for (NSString *eventName in [history keyEnumerator]) {
295
+ CleverTapEventDetail *detail = history[eventName];
296
+ NSDictionary * _inner = [self _eventDetailToDict:detail];
297
+ result[eventName] = _inner;
298
+ }
299
+ dispatch_async(dispatch_get_main_queue(), ^{
300
+ [self returnResult:result withCallback:callback andError:nil];
301
+ });
302
+ });
303
+ }
267
304
 
268
305
  #pragma mark - Profile API
269
306
 
@@ -387,6 +424,21 @@ RCT_EXPORT_METHOD(sessionGetUTMDetails:(RCTResponseSenderBlock)callback) {
387
424
  [self returnResult:result withCallback:callback andError:nil];
388
425
  }
389
426
 
427
+ RCT_EXPORT_METHOD(getUserLastVisitTs:(RCTResponseSenderBlock)callback) {
428
+ RCTLogInfo(@"[CleverTap getUserLastVisitTs]");
429
+ NSTimeInterval result = [[self cleverTapInstance] getUserLastVisitTs];
430
+ [self returnResult:@(result) withCallback:callback andError:nil];
431
+ }
432
+
433
+ RCT_EXPORT_METHOD(getUserAppLaunchCount:(RCTResponseSenderBlock)callback) {
434
+ RCTLogInfo(@"[CleverTap getUserAppLaunchCount]");
435
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
436
+ int result = [[self cleverTapInstance] getUserAppLaunchCount];
437
+ dispatch_async(dispatch_get_main_queue(), ^{
438
+ [self returnResult:@(result) withCallback:callback andError:nil];
439
+ });
440
+ });
441
+ }
390
442
 
391
443
  #pragma mark - no-op Android O methods
392
444
 
@@ -451,6 +503,10 @@ RCT_EXPORT_METHOD(setDebugLevel:(double)level) {
451
503
  [_dict setObject:detail.eventName forKey:@"eventName"];
452
504
  }
453
505
 
506
+ if(detail.normalizedEventName){
507
+ [_dict setObject:detail.normalizedEventName forKey:@"normalizedEventName"];
508
+ }
509
+
454
510
  if(detail.firstTime){
455
511
  [_dict setObject:@(detail.firstTime) forKey:@"firstTime"];
456
512
  }
@@ -462,6 +518,10 @@ RCT_EXPORT_METHOD(setDebugLevel:(double)level) {
462
518
  if(detail.count){
463
519
  [_dict setObject:@(detail.count) forKey:@"count"];
464
520
  }
521
+
522
+ if(detail.deviceID){
523
+ [_dict setObject:detail.deviceID forKey:@"deviceID"];
524
+ }
465
525
  }
466
526
 
467
527
  return _dict;
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>CleverTapReact.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>0</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clevertap-react-native",
3
- "version": "3.1.1",
3
+ "version": "3.2.0",
4
4
  "description": "CleverTap React Native SDK.",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -70,7 +70,16 @@ export interface Spec extends TurboModule {
70
70
  eventName: string,
71
71
  callback: ((error: Object, result: boolean) => void) | null
72
72
  ): void;
73
+ getUserEventLog(
74
+ eventName: string,
75
+ callback: ((error: Object, result: boolean) => void) | null
76
+ ): void;
77
+ getUserEventLogCount(
78
+ eventName: string,
79
+ callback: ((error: Object, result: boolean) => void) | null
80
+ ): void;
73
81
  getEventHistory(callback: ((error: Object, result: boolean) => void) | null): void;
82
+ getUserEventLogHistory(callback: ((error: Object, result: boolean) => void) | null): void;
74
83
  setLocation(location: number, longitude: number): void;
75
84
  profileGetCleverTapAttributionIdentifier(callback: ((error: Object, result: boolean) => void) | null): void;
76
85
  profileGetCleverTapID(callback: ((error: Object, result: boolean) => void) | null): void;
@@ -104,6 +113,8 @@ export interface Spec extends TurboModule {
104
113
  sessionGetScreenCount(callback: ((error: Object, result: boolean) => void) | null): void;
105
114
  sessionGetPreviousVisitTime(callback: ((error: Object, result: boolean) => void) | null): void;
106
115
  sessionGetUTMDetails(callback: ((error: Object, result: boolean) => void) | null): void;
116
+ getUserLastVisitTs(callback: ((error: Object, result: boolean) => void) | null): void;
117
+ getUserAppLaunchCount(callback: ((error: Object, result: boolean) => void) | null): void;
107
118
  createNotificationChannel(
108
119
  channelId: string,
109
120
  withChannelName: string,
package/src/index.d.ts CHANGED
@@ -224,6 +224,8 @@ export function isPushPermissionGranted(callback: CallbackString): void;
224
224
  ): void;
225
225
 
226
226
  /**
227
+ * @deprecated
228
+ * Since version 3.2.0. Use `getUserEventLog()` instead.
227
229
  * Get Event First Time
228
230
  * @param eventName {string}
229
231
  * callback returns epoch seconds or -1
@@ -231,6 +233,8 @@ export function isPushPermissionGranted(callback: CallbackString): void;
231
233
  export function eventGetFirstTime(eventName: string, callback: Callback): void;
232
234
 
233
235
  /**
236
+ * @deprecated
237
+ * Since version 3.2.0. Use `getUserEventLog()` instead.
234
238
  * Get Event Last Time
235
239
  * @param eventName {string}
236
240
  * callback returns epoch seconds or -1
@@ -238,6 +242,8 @@ export function isPushPermissionGranted(callback: CallbackString): void;
238
242
  export function eventGetLastTime(eventName: string, callback: Callback): void;
239
243
 
240
244
  /**
245
+ * @deprecated
246
+ * Since version 3.2.0. Use `getUserEventLogCount()` instead.
241
247
  * Get Event Number of Occurrences
242
248
  * @param eventName {string}
243
249
  * calls back with int or -1
@@ -245,6 +251,9 @@ export function isPushPermissionGranted(callback: CallbackString): void;
245
251
  export function eventGetOccurrences(eventName: string, callback: Callback): void;
246
252
 
247
253
  /**
254
+ * @deprecated
255
+ * Since version 3.2.0. Use `getUserEventLog()` instead.
256
+ *
248
257
  * Get Event Details
249
258
  * @param eventName {string}
250
259
  * calls back with object {"eventName": <string>, "firstTime":<epoch seconds>, "lastTime": <epoch seconds>, "count": <int>} or empty object
@@ -252,10 +261,32 @@ export function isPushPermissionGranted(callback: CallbackString): void;
252
261
  export function eventGetDetail(eventName: string, callback: Callback): void;
253
262
 
254
263
  /**
264
+ * @deprecated
265
+ * Since version 3.2.0. Use `getUserEventLogHistory()` instead.
255
266
  * Get Event History
256
267
  * calls back with object {"eventName1":<event1 details object>, "eventName2":<event2 details object>}
257
268
  */
258
269
  export function getEventHistory(callback: Callback): void;
270
+ /**
271
+ *
272
+ * Get Event Details
273
+ * @param eventName {string}
274
+ * calls back with object {"eventName": <string>, "firstTime":<epoch seconds>, "lastTime": <epoch seconds>, "count": <int>, "deviceID": <string>, "normalizedEventName": <string>} or empty object
275
+ */
276
+ export function getUserEventLog(eventName: string, callback: Callback): void;
277
+
278
+ /**
279
+ * Get count of times an event occured
280
+ * @param eventName {string}
281
+ * calls back with int or -1
282
+ */
283
+ export function getUserEventLogCount(eventName: string, callback: Callback): void;
284
+
285
+ /**
286
+ * Get Event History
287
+ * calls back with object {"eventName1":<event1 details object>, "eventName2":<event2 details object>}
288
+ */
289
+ export function getUserEventLogHistory(callback: Callback): void;
259
290
 
260
291
  /**
261
292
  * Set location
@@ -395,11 +426,25 @@ export function isPushPermissionGranted(callback: CallbackString): void;
395
426
  export function sessionGetTimeElapsed(callback: Callback): void;
396
427
 
397
428
  /**
398
- * Get Session Total Visits
429
+ * Get timestamp of user's last app visit
430
+ * calls back with epoch seconds or -1
431
+ */
432
+ export function getUserLastVisitTs(callback: Callback): void;
433
+
434
+ /**
435
+ * Get total number of times user has lanched the app
399
436
  * calls back with int or -1
400
437
  */
401
- export function sessionGetTotalVisits(callback: Callback): void;
438
+ export function getUserAppLaunchCount(callback: Callback): void;
402
439
 
440
+ /**
441
+ * @deprecated
442
+ * Since version 3.2.0. Use `getUserAppLaunchCount()` instead.
443
+ * Get Session Total Visits
444
+ * calls back with int or -1
445
+ */
446
+ export function sessionGetTotalVisits(callback: Callback): void;
447
+
403
448
  /**
404
449
  * Get Session Screen Count
405
450
  * calls back with with int
@@ -407,6 +452,8 @@ export function isPushPermissionGranted(callback: CallbackString): void;
407
452
  export function sessionGetScreenCount(callback: Callback): void;
408
453
 
409
454
  /**
455
+ * @deprecated
456
+ * Since version 3.2.0. Use `getUserLastVisits()` instead.
410
457
  * Get Session Previous Visit Time
411
458
  * calls back with epoch seconds or -1
412
459
  */
package/src/index.js CHANGED
@@ -12,7 +12,7 @@ const EventEmitter = Platform.select({
12
12
  * @param {int} libVersion - The updated library version. If current version is 1.1.0 then pass as 10100
13
13
  */
14
14
  const libName = 'React-Native';
15
- const libVersion = 30101;
15
+ const libVersion = 30200;
16
16
  CleverTapReact.setLibrary(libName,libVersion);
17
17
 
18
18
  function defaultCallback(method, err, res) {
@@ -338,6 +338,7 @@ var CleverTap = {
338
338
 
339
339
  /**
340
340
  * Get the time of the first occurrence of an event
341
+ * @deprecated - Since version 3.2.0. Use getUserEventLog() instead
341
342
  * @param {string} eventName - the name of the event
342
343
  * @param {function(err, res)} callback that returns a res of epoch seconds or -1
343
344
  */
@@ -347,6 +348,7 @@ var CleverTap = {
347
348
 
348
349
  /**
349
350
  * Get the time of the most recent occurrence of an event
351
+ * @deprecated - Since version 3.2.0. Use getUserEventLog() instead
350
352
  * @param {string} eventName - the name of the event
351
353
  * @param {function(err, res)} callback that returns a res of epoch seconds or -1
352
354
  */
@@ -356,6 +358,7 @@ var CleverTap = {
356
358
 
357
359
  /**
358
360
  * Get the number of occurrences of an event
361
+ * @deprecated - Since version 3.2.0. Use getUserEventLogCount() instead
359
362
  * @param {string} eventName - the name of the event
360
363
  * @param {function(err, res)} callback that returns a res of int
361
364
  */
@@ -365,6 +368,7 @@ var CleverTap = {
365
368
 
366
369
  /**
367
370
  * Get the summary details of an event
371
+ * @deprecated - Since version 3.2.0. Use getUserEventLog() instead
368
372
  * @param {string} eventName - the name of the event
369
373
  * @param {function(err, res)} callback that returns a res of object {"eventName": <string>, "firstTime":<epoch seconds>, "lastTime": <epoch seconds>, "count": <int>} or empty object
370
374
  */
@@ -374,11 +378,37 @@ var CleverTap = {
374
378
 
375
379
  /**
376
380
  * Get the user's event history
381
+ * @deprecated - Since version 3.2.0. Use getUserEventLogHistory() instead
377
382
  * @param {function(err, res)} callback that returns a res of object {"eventName1":<event1 details object>, "eventName2":<event2 details object>}
378
383
  */
379
384
  getEventHistory: function (callback) {
380
385
  callWithCallback('getEventHistory', null, callback);
381
386
  },
387
+ /**
388
+ * Get the details of a specific event
389
+ * @param {string} eventName - the name of the event
390
+ * @param {function(err, res)} callback that returns a res of object {"eventName": <string>, "firstTime":<epoch seconds>, "lastTime": <epoch seconds>, "count": <int>, "deviceID": <string>, "normalizedEventName": <string>} or empty object
391
+ */
392
+ getUserEventLog: function (eventName, callback) {
393
+ callWithCallback('getUserEventLog', [eventName], callback);
394
+ },
395
+
396
+ /**
397
+ * Get the count of times an event occured
398
+ * @param {string} eventName - the name of the event
399
+ * @param {function(err, res)} callback that returns a res of int
400
+ */
401
+ getUserEventLogCount: function (eventName, callback) {
402
+ callWithCallback('getUserEventLogCount', [eventName], callback);
403
+ },
404
+
405
+ /**
406
+ * Get full event hostory for current user
407
+ * @param {function(err, res)} callback that returns a res of object {"eventName1":<event1 details object>, "eventName2":<event2 details object>}
408
+ */
409
+ getUserEventLogHistory: function (callback) {
410
+ callWithCallback('getUserEventLogHistory', null, callback);
411
+ },
382
412
 
383
413
  /**
384
414
  * Set the user's location as a latitude,longitude coordinate
@@ -539,12 +569,29 @@ var CleverTap = {
539
569
 
540
570
  /**
541
571
  * Get the total number of vists by the user
572
+ * @deprecated - Since version 3.2.0. Use getUserAppLaunchCount() instead
542
573
  * @param {function(err, res)} callback that returns a res of int
543
574
  */
544
575
  sessionGetTotalVisits: function (callback) {
545
576
  callWithCallback('sessionGetTotalVisits', null, callback);
546
577
  },
547
578
 
579
+ /**
580
+ * Get timestamp of user's last app visit
581
+ * @param {function(err, res)} callback that returns a res of epoch seconds or -1
582
+ */
583
+ getUserLastVisitTs: function (callback) {
584
+ callWithCallback('getUserLastVisitTs', null, callback);
585
+ },
586
+
587
+ /**
588
+ * Get the total number of times user has launched the app
589
+ * @param {function(err, res)} callback that returns a res of int
590
+ */
591
+ getUserAppLaunchCount: function (callback) {
592
+ callWithCallback('getUserAppLaunchCount', null, callback);
593
+ },
594
+
548
595
  /**
549
596
  * Get the number of screens viewed by the user during the session
550
597
  * @param {function(err, res)} callback that returns a res of int
@@ -555,6 +602,7 @@ var CleverTap = {
555
602
 
556
603
  /**
557
604
  * Get the most recent previous visit time of the user
605
+ * @deprecated - Since version 3.2.0. Use getUserLastVisits() instead
558
606
  * @param {function(err, res)} callback that returns a res of epoch seconds or -1
559
607
  */
560
608
  sessionGetPreviousVisitTime: function (callback) {