react-native-gleapsdk 6.4.8 → 7.0.2

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.
@@ -3,7 +3,6 @@ buildscript {
3
3
  repositories {
4
4
  google()
5
5
  mavenCentral()
6
- jcenter()
7
6
  }
8
7
 
9
8
  dependencies {
@@ -19,10 +18,10 @@ def safeExtGet(prop, fallback) {
19
18
  }
20
19
 
21
20
  android {
22
- compileSdkVersion safeExtGet('Gleapsdk_compileSdkVersion', 29)
21
+ compileSdkVersion safeExtGet('Gleapsdk_compileSdkVersion', 31)
23
22
  defaultConfig {
24
23
  minSdkVersion safeExtGet('Gleapsdk_minSdkVersion', 16)
25
- targetSdkVersion safeExtGet('Gleapsdk_targetSdkVersion', 29)
24
+ targetSdkVersion safeExtGet('Gleapsdk_targetSdkVersion', 31)
26
25
  versionCode 1
27
26
  versionName "1.0"
28
27
 
@@ -54,7 +53,7 @@ repositories {
54
53
 
55
54
  dependencies {
56
55
  //noinspection GradleDynamicVersion
57
- implementation "com.facebook.react:react-native:+" // From node_modules
58
- // https://mvnrepository.com/artifact/io.gleap/gleap-android-sdk
59
- implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '6.4.12'
56
+ implementation "com.facebook.react:react-native:+"
57
+ implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '7.0.19'
58
+ implementation 'com.google.android.material:material:1.6.1'
60
59
  }
@@ -8,10 +8,8 @@ import androidx.annotation.NonNull;
8
8
  import androidx.annotation.RequiresApi;
9
9
 
10
10
  import com.facebook.react.ReactApplication;
11
- import com.facebook.react.ReactInstanceManager;
12
11
  import com.facebook.react.bridge.LifecycleEventListener;
13
12
  import com.facebook.react.bridge.ReactApplicationContext;
14
- import com.facebook.react.bridge.ReactContext;
15
13
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
16
14
  import com.facebook.react.bridge.ReactMethod;
17
15
  import com.facebook.react.bridge.ReadableArray;
@@ -33,16 +31,21 @@ import java.util.regex.Matcher;
33
31
  import java.util.regex.Pattern;
34
32
 
35
33
  import io.gleap.APPLICATIONTYPE;
36
- import io.gleap.ConfigLoadedCallback;
37
- import io.gleap.CustomActionCallback;
38
- import io.gleap.FeedbackSentCallback;
39
- import io.gleap.FeedbackSentWithDataCallback;
40
- import io.gleap.FeedbackWillBeSentCallback;
41
- import io.gleap.GetActivityCallback;
42
34
  import io.gleap.Gleap;
43
35
  import io.gleap.GleapActivationMethod;
36
+ import io.gleap.GleapLogLevel;
44
37
  import io.gleap.GleapUserProperties;
38
+ import io.gleap.PrefillHelper;
45
39
  import io.gleap.RequestType;
40
+ import io.gleap.UserSessionController;
41
+ import io.gleap.callbacks.ConfigLoadedCallback;
42
+ import io.gleap.callbacks.CustomActionCallback;
43
+ import io.gleap.callbacks.FeedbackFlowStartedCallback;
44
+ import io.gleap.callbacks.FeedbackSendingFailedCallback;
45
+ import io.gleap.callbacks.FeedbackSentCallback;
46
+ import io.gleap.callbacks.GetActivityCallback;
47
+ import io.gleap.callbacks.WidgetClosedCallback;
48
+ import io.gleap.callbacks.WidgetOpenedCallback;
46
49
 
47
50
  @ReactModule(name = GleapsdkModule.NAME)
48
51
  public class GleapsdkModule extends ReactContextBaseJavaModule implements LifecycleEventListener {
@@ -85,17 +88,24 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
85
88
  .getCurrentActivity();
86
89
  if (activity != null && !invalidated) {
87
90
  Gleap.getInstance().setApplicationType(APPLICATIONTYPE.REACTNATIVE);
88
- Gleap.getInstance().setFeedbackWillBeSentCallback(new FeedbackWillBeSentCallback() {
91
+ Gleap.initialize(sdkKey, activity.getApplication());
92
+
93
+ Gleap.getInstance().setWidgetOpenedCallback(new WidgetOpenedCallback() {
89
94
  @Override
90
- public void flowInvoced() {
91
- if (!invalidated) {
92
- getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
93
- .emit("feedbackWillBeSent", null);
94
- }
95
+ public void invoke() {
96
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
97
+ .emit("widgetOpened", null);
98
+ }
99
+ });
100
+
101
+ Gleap.getInstance().setWidgetClosedCallback(new WidgetClosedCallback() {
102
+ @Override
103
+ public void invoke() {
104
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
105
+ .emit("widgetClosed", null);
95
106
  }
96
107
  });
97
108
 
98
- Gleap.initialize(sdkKey, activity.getApplication());
99
109
  Gleap.getInstance().setConfigLoadedCallback(new ConfigLoadedCallback() {
100
110
  @Override
101
111
  public void configLoaded(JSONObject jsonObject) {
@@ -103,6 +113,23 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
103
113
  getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
104
114
  .emit("configLoaded", jsonObject.toString());
105
115
  }
116
+
117
+ }
118
+ });
119
+
120
+ Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
121
+ @Override
122
+ public void invoke(String message) {
123
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
124
+ .emit("feedbackSent", message);
125
+ }
126
+ });
127
+
128
+ Gleap.getInstance().setFeedbackSendingFailedCallback(new FeedbackSendingFailedCallback() {
129
+ @Override
130
+ public void invoke(String message) {
131
+ getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
132
+ .emit("feedbackSendingFailed", message);
106
133
  }
107
134
  });
108
135
 
@@ -122,33 +149,11 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
122
149
  }
123
150
  });
124
151
 
125
- Gleap.getInstance().setFeedbackSentWithDataCallback(new FeedbackSentWithDataCallback() {
152
+ Gleap.getInstance().setFeedbackFlowStartedCallback(new FeedbackFlowStartedCallback() {
126
153
  @Override
127
- public void close(JSONObject jsonObject) {
154
+ public void invoke(String message) {
128
155
  getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
129
- .emit("feedbackSent", jsonObject.toString());
130
- new java.util.Timer().schedule(
131
- new java.util.TimerTask() {
132
- @Override
133
- public void run() {
134
- showDevMenu();
135
- }
136
- },
137
- 500);
138
- }
139
- });
140
-
141
- Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
142
- @Override
143
- public void close() {
144
- new java.util.Timer().schedule(
145
- new java.util.TimerTask() {
146
- @Override
147
- public void run() {
148
- showDevMenu();
149
- }
150
- },
151
- 500);
156
+ .emit("feedbackFlowStarted", message);
152
157
  }
153
158
  });
154
159
  }
@@ -183,10 +188,10 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
183
188
  @Override
184
189
  public void run() {
185
190
  try {
186
- Gleap.getInstance().startFeedbackFlow();
191
+ Gleap.getInstance().open();
187
192
  Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
188
193
  @Override
189
- public void close() {
194
+ public void invoke(String message) {
190
195
  new java.util.Timer().schedule(
191
196
  new java.util.TimerTask() {
192
197
  @Override
@@ -211,21 +216,53 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
211
216
  }
212
217
  }
213
218
 
219
+ @ReactMethod
220
+ public void close() {
221
+ try {
222
+ getActivitySafe().runOnUiThread(
223
+ new Runnable() {
224
+ @Override
225
+ public void run() {
226
+ try {
227
+ Gleap.getInstance().close();
228
+ }catch (Exception ex) {}
229
+ }
230
+ });
231
+ } catch (NoUiThreadException e) {
232
+ System.err.println(e.getMessage());
233
+ }
234
+ }
235
+
236
+ @ReactMethod
237
+ public void isOpened() {
238
+ try {
239
+ getActivitySafe().runOnUiThread(
240
+ new Runnable() {
241
+ @Override
242
+ public void run() {
243
+ Gleap.getInstance().isOpened();
244
+ }
245
+ });
246
+ } catch (NoUiThreadException e) {
247
+ System.err.println(e.getMessage());
248
+ }
249
+ }
250
+
214
251
  /**
215
252
  * Start bug report manually by calling this function.
216
253
  */
217
254
  @ReactMethod
218
- public void startFeedbackFlow(String feedbackFlow){
255
+ public void startFeedbackFlow(String feedbackFlow, boolean showBackButton) {
219
256
  try {
220
257
  getActivitySafe().runOnUiThread(
221
258
  new Runnable() {
222
259
  @Override
223
260
  public void run() {
224
261
  try {
225
- Gleap.getInstance().startFeedbackFlow(feedbackFlow);
262
+ Gleap.getInstance().startFeedbackFlow(feedbackFlow, showBackButton);
226
263
  Gleap.getInstance().setFeedbackSentCallback(new FeedbackSentCallback() {
227
264
  @Override
228
- public void close() {
265
+ public void invoke(String message) {
229
266
  new java.util.Timer().schedule(
230
267
  new java.util.TimerTask() {
231
268
  @Override
@@ -254,7 +291,7 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
254
291
  * Manually start a silent bug reporting workflow.
255
292
  */
256
293
  @ReactMethod
257
- public void sendSilentBugReport(
294
+ public void sendSilentCrashReport(
258
295
  String description,
259
296
  String priority) {
260
297
  try {
@@ -270,7 +307,7 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
270
307
  if (priority == "HIGH") {
271
308
  severity = Gleap.SEVERITY.HIGH;
272
309
  }
273
- Gleap.getInstance().sendSilentBugReport(description, severity);
310
+ Gleap.getInstance().sendSilentCrashReport(description, severity);
274
311
  }
275
312
  });
276
313
  } catch (NoUiThreadException e) {
@@ -282,15 +319,21 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
282
319
  * Manually start a silent bug reporting workflow.
283
320
  */
284
321
  @ReactMethod
285
- public void sendSilentBugReportWithType(
322
+ public void sendSilentCrashReportWithExcludeData(
286
323
  String description,
287
324
  String priority,
288
- String type) {
325
+ ReadableMap data) {
289
326
  try {
290
327
  getActivitySafe().runOnUiThread(
291
328
  new Runnable() {
292
329
  @Override
293
330
  public void run() {
331
+ JSONObject jsonObject = new JSONObject();
332
+ try {
333
+ jsonObject = GleapUtil.convertMapToJson(data);
334
+ } catch (Exception ex) {
335
+ }
336
+
294
337
  isSilentBugReport = true;
295
338
  Gleap.SEVERITY severity = Gleap.SEVERITY.LOW;
296
339
  if (priority == "MEDIUM") {
@@ -299,7 +342,28 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
299
342
  if (priority == "HIGH") {
300
343
  severity = Gleap.SEVERITY.HIGH;
301
344
  }
302
- Gleap.getInstance().sendSilentBugReport(description, severity, type);
345
+ Gleap.getInstance().sendSilentCrashReport(description, severity, jsonObject);
346
+ }
347
+ });
348
+ } catch (NoUiThreadException e) {
349
+ System.err.println(e.getMessage());
350
+ }
351
+ }
352
+
353
+ @ReactMethod
354
+ public void preFillForm(
355
+ ReadableMap data) {
356
+ try {
357
+ getActivitySafe().runOnUiThread(
358
+ new Runnable() {
359
+ @Override
360
+ public void run() {
361
+ JSONObject jsonObject = new JSONObject();
362
+ try {
363
+ jsonObject = GleapUtil.convertMapToJson(data);
364
+ } catch (Exception ex) {
365
+ }
366
+ PrefillHelper.getInstancen().setPrefillData(jsonObject);
303
367
  }
304
368
  });
305
369
  } catch (NoUiThreadException e) {
@@ -307,6 +371,7 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
307
371
  }
308
372
  }
309
373
 
374
+
310
375
  @ReactMethod
311
376
  public void setLanguage(String language) {
312
377
  Gleap.getInstance().setLanguage(language);
@@ -314,6 +379,7 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
314
379
 
315
380
  @ReactMethod
316
381
  public void enableDebugConsoleLog() {
382
+
317
383
  }
318
384
 
319
385
  @ReactMethod
@@ -338,7 +404,7 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
338
404
  e.printStackTrace();
339
405
  }
340
406
  GleapUserProperties gleapUserSession = new GleapUserProperties(name, email);
341
- if(Gleap.getInstance() == null) {
407
+ if (Gleap.getInstance() == null) {
342
408
  return;
343
409
  }
344
410
  Gleap.getInstance().identifyUser(userid, gleapUserSession);
@@ -349,9 +415,56 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
349
415
  }
350
416
  }
351
417
 
418
+ @ReactMethod
419
+ public void identifyWithUserHash(String userid, ReadableMap data, String hash) {
420
+ try {
421
+ getActivitySafe().runOnUiThread(
422
+ new Runnable() {
423
+ @Override
424
+ public void run() {
425
+ JSONObject jsonObject = null;
426
+ String name = "";
427
+ String email = "";
428
+ try {
429
+ jsonObject = GleapUtil.convertMapToJson(data);
430
+ if (jsonObject.has("name")) {
431
+ name = jsonObject.getString("name");
432
+ }
433
+ if (jsonObject.has("email")) {
434
+ email = jsonObject.getString("email");
435
+ }
436
+ } catch (JSONException e) {
437
+ e.printStackTrace();
438
+ }
439
+ GleapUserProperties gleapUserSession = new GleapUserProperties(name, email);
440
+ gleapUserSession.setHash(hash);
441
+ if (Gleap.getInstance() == null) {
442
+ return;
443
+ }
444
+
445
+ if (UserSessionController.getInstance() != null) {
446
+ Gleap.getInstance().identifyUser(userid, gleapUserSession);
447
+ }
448
+ }
449
+ });
450
+ } catch (NoUiThreadException e) {
451
+ System.err.println(e.getMessage());
452
+ }
453
+ }
454
+
352
455
  @ReactMethod
353
456
  public void clearIdentity() {
354
- Gleap.getInstance().clearIdentity();
457
+ try {
458
+ getActivitySafe().runOnUiThread(
459
+ new Runnable() {
460
+ @Override
461
+ public void run() {
462
+ Gleap.getInstance().clearIdentity();
463
+ }
464
+ });
465
+ } catch (NoUiThreadException e) {
466
+ System.err.println(e.getMessage());
467
+ }
355
468
  }
356
469
 
357
470
  /**
@@ -365,10 +478,10 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
365
478
  public void attachCustomData(ReadableMap customData) {
366
479
  try {
367
480
  JSONObject jsonObject = GleapUtil.convertMapToJson(customData);
368
- if(Gleap.getInstance() == null) {
481
+ if (Gleap.getInstance() == null) {
369
482
  return;
370
483
  }
371
- Gleap.getInstance().appendCustomData(jsonObject);
484
+ Gleap.getInstance().attachCustomData(jsonObject);
372
485
  } catch (Exception e) {
373
486
  System.out.println(e);
374
487
  }
@@ -390,31 +503,15 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
390
503
  }
391
504
 
392
505
  /**
393
- * Used for dedicated server. Set the url, where the widget is loaded from.
394
- *
395
- * @param widgetUrl Url to the dedicated server.
396
- */
397
- @ReactMethod
398
- public void setWidgetUrl(String widgetUrl) {
399
- try {
400
- Gleap.getInstance().setApiUrl(widgetUrl);
401
- } catch (Exception e) {
402
- System.out.println(e);
403
- }
404
- }
405
-
406
- /**
407
- * Attaches custom data, which can be viewed in the Gleap dashboard. New data
408
- * will be merged with existing custom data.
506
+ * Frame url
507
+ * 330,.
409
508
  *
410
- * @param customData The data to attach to a bug report.
411
- * @author Gleap
509
+ * @param frameUrl Url to the dedicated server.
412
510
  */
413
511
  @ReactMethod
414
- public void appendCustomData(ReadableMap customData) {
512
+ public void setFrameUrl(String frameUrl) {
415
513
  try {
416
- JSONObject jsonObject = GleapUtil.convertMapToJson(customData);
417
- Gleap.getInstance().appendCustomData(jsonObject);
514
+ Gleap.getInstance().setFrameUrl(frameUrl);
418
515
  } catch (Exception e) {
419
516
  System.out.println(e);
420
517
  }
@@ -460,8 +557,10 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
460
557
  internalActivationMethods.add(GleapActivationMethod.SCREENSHOT);
461
558
  }
462
559
  }
463
- Gleap.getInstance().setActivationMethods(
464
- internalActivationMethods.toArray(new GleapActivationMethod[internalActivationMethods.size()]));
560
+ if(Gleap.getInstance() != null) {
561
+ Gleap.getInstance().setActivationMethods(
562
+ internalActivationMethods.toArray(new GleapActivationMethod[internalActivationMethods.size()]));
563
+ }
465
564
  }
466
565
 
467
566
  /**
@@ -603,7 +702,32 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
603
702
  Gleap.getInstance().setConfigLoadedCallback(configLoadedCallback);
604
703
  }
605
704
 
606
- ;
705
+ @ReactMethod
706
+ public void disableConsoleLog() {
707
+ Gleap.getInstance().disableConsoleLog();
708
+ }
709
+
710
+
711
+ @ReactMethod
712
+ public void log(String msg) {
713
+ Gleap.getInstance().log(msg);
714
+ }
715
+
716
+ @ReactMethod
717
+ public void logWithLogLevel(String msg, String logLevel) {
718
+ GleapLogLevel ll;
719
+ switch (logLevel) {
720
+ case "WARNING":
721
+ ll = GleapLogLevel.WARNING;
722
+ break;
723
+ case "ERROR":
724
+ ll = GleapLogLevel.ERROR;
725
+ break;
726
+ default:
727
+ ll = GleapLogLevel.INFO;
728
+ }
729
+ Gleap.getInstance().log(msg, ll);
730
+ }
607
731
 
608
732
  private boolean checkAllowedEndings(String fileName) {
609
733
  String[] fileType = fileName.split("\\.");
@@ -680,9 +804,11 @@ public class GleapsdkModule extends ReactContextBaseJavaModule implements Lifecy
680
804
  super.invalidate();
681
805
  }
682
806
 
807
+
808
+
683
809
  private Activity getActivitySafe() throws NoUiThreadException {
684
810
  Activity activity = getCurrentActivity();
685
- if(activity == null) {
811
+ if (activity == null) {
686
812
  throw new NoUiThreadException();
687
813
  }
688
814
  return activity;