plotline-engage 5.5.9 → 5.6.1

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.
@@ -40,6 +40,6 @@ repositories {
40
40
 
41
41
  dependencies {
42
42
  implementation 'com.facebook.react:react-native:+'
43
- implementation 'com.gitlab.plotline:plotline-android-sdk:5.1.7'
43
+ implementation 'com.gitlab.plotline:plotline-android-sdk:5.1.9'
44
44
  }
45
45
 
@@ -58,6 +58,10 @@ public class RNPlotline extends ReactContextBaseJavaModule {
58
58
  final Activity activity = getCurrentActivity();
59
59
  Plotline.setFramework("REACT_NATIVE");
60
60
  Plotline.init(activity, apiKey, userId, endpoint);
61
+ registerPlotlineListeners();
62
+ }
63
+
64
+ private void registerPlotlineListeners() {
61
65
  Plotline.setPlotlineEventsListener((eventName, eventProperties) -> {
62
66
  try {
63
67
  WritableMap writableMap = Arguments.createMap();
@@ -110,6 +114,14 @@ public class RNPlotline extends ReactContextBaseJavaModule {
110
114
  });
111
115
  }
112
116
 
117
+ @ReactMethod
118
+ public void initAnonymousUser(String apiKey, String deviceId) {
119
+ final Activity activity = getCurrentActivity();
120
+ Plotline.setFramework("REACT_NATIVE");
121
+ Plotline.initAnonymousUser(activity != null ? activity : getReactApplicationContext(), apiKey, deviceId == null ? "" : deviceId);
122
+ registerPlotlineListeners();
123
+ }
124
+
113
125
  public JSONObject getJSONObjectFromReadableMap(ReadableMap object) {
114
126
  JSONObject jsonObject = new JSONObject();
115
127
  if (object != null) {
@@ -294,4 +306,4 @@ public class RNPlotline extends ReactContextBaseJavaModule {
294
306
  }
295
307
  });
296
308
  }
297
- }
309
+ }
package/index.d.ts CHANGED
@@ -4,6 +4,8 @@ import { NavigationContainer as RNNavigationContainer } from '@react-navigation/
4
4
  declare class plotline {
5
5
  track(eventName: string, properties: {[key: string]: any}): void;
6
6
  init(apiKey: string, refId?: string, endpoint?: string): void;
7
+ /** deviceId maps to the native Plotline device ID. An empty value preserves the existing device ID. */
8
+ initAnonymousUser(apiKey: string, deviceId?: string): void;
7
9
  identify(attributes: {[key: string]: any}): void;
8
10
  setLocale(locale: string): void;
9
11
  showMockStudy(): void;
package/index.js CHANGED
@@ -86,6 +86,10 @@ class plotline {
86
86
  RNPlotline.init(apiKey, refId, endpoint);
87
87
  }
88
88
 
89
+ initAnonymousUser (apiKey, deviceId = "") {
90
+ RNPlotline.initAnonymousUser(apiKey, deviceId ?? "");
91
+ }
92
+
89
93
  identify (obj) {
90
94
  RNPlotline.identify(convertToStringValues(obj));
91
95
  }
package/ios/RNPlotline.m CHANGED
@@ -17,6 +17,11 @@ RCT_EXPORT_METHOD(init:(NSString *)apiKey userId:(NSString *)userId endpoint:(NS
17
17
  } else {
18
18
  [Plotline initializeWithApiKey:apiKey userId:userId];
19
19
  }
20
+ [self registerPlotlineListeners];
21
+ }
22
+
23
+ - (void)registerPlotlineListeners
24
+ {
20
25
  [Plotline setPlotlineEventsListenerWithListener:^(NSString *eventName, NSDictionary *eventProperties) {
21
26
  NSDictionary *event = @{
22
27
  @"eventName": eventName,
@@ -29,6 +34,13 @@ RCT_EXPORT_METHOD(init:(NSString *)apiKey userId:(NSString *)userId endpoint:(NS
29
34
  }];
30
35
  }
31
36
 
37
+ RCT_EXPORT_METHOD(initAnonymousUser:(NSString *)apiKey deviceId:(NSString *)deviceId)
38
+ {
39
+ [Plotline setPlotlineFrameworkWithFramework:@"REACT_NATIVE"];
40
+ [Plotline initializeAnonymousUserWithApiKey:apiKey deviceId:deviceId ?: @""];
41
+ [self registerPlotlineListeners];
42
+ }
43
+
32
44
  RCT_EXPORT_METHOD(track:(NSString *)eventName properties: (NSDictionary *) properties)
33
45
  {
34
46
  if(properties != nil) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotline-engage",
3
- "version": "5.5.9",
3
+ "version": "5.6.1",
4
4
  "description": "React Native plugin for Plotline",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"