capacitor-gleap-plugin 18.1.0 → 19.0.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.
Files changed (43) hide show
  1. package/CapacitorGleapPlugin.podspec +7 -2
  2. package/Package.swift +31 -0
  3. package/README.md +298 -759
  4. package/android/build.gradle +1 -1
  5. package/android/src/main/java/io/gleapplugins/capacitor/GleapPlugin.java +202 -37
  6. package/dist/docs.json +288 -3893
  7. package/dist/esm/definitions.d.ts +162 -3
  8. package/dist/esm/definitions.js.map +1 -1
  9. package/dist/esm/index.js +9 -1
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/logs/body.d.ts +58 -0
  12. package/dist/esm/logs/body.js +303 -0
  13. package/dist/esm/logs/body.js.map +1 -0
  14. package/dist/esm/logs/consoleCapture.d.ts +29 -0
  15. package/dist/esm/logs/consoleCapture.js +189 -0
  16. package/dist/esm/logs/consoleCapture.js.map +1 -0
  17. package/dist/esm/logs/format.d.ts +16 -0
  18. package/dist/esm/logs/format.js +394 -0
  19. package/dist/esm/logs/format.js.map +1 -0
  20. package/dist/esm/logs/networkCapture.d.ts +65 -0
  21. package/dist/esm/logs/networkCapture.js +654 -0
  22. package/dist/esm/logs/networkCapture.js.map +1 -0
  23. package/dist/esm/logs/redaction.d.ts +54 -0
  24. package/dist/esm/logs/redaction.js +388 -0
  25. package/dist/esm/logs/redaction.js.map +1 -0
  26. package/dist/esm/logs/webViewLogs.d.ts +70 -0
  27. package/dist/esm/logs/webViewLogs.js +297 -0
  28. package/dist/esm/logs/webViewLogs.js.map +1 -0
  29. package/dist/esm/logs/zone.d.ts +5 -0
  30. package/dist/esm/logs/zone.js +15 -0
  31. package/dist/esm/logs/zone.js.map +1 -0
  32. package/dist/esm/web.d.ts +42 -2
  33. package/dist/esm/web.js +38 -0
  34. package/dist/esm/web.js.map +1 -1
  35. package/dist/plugin.cjs.js +2258 -1
  36. package/dist/plugin.cjs.js.map +1 -1
  37. package/dist/plugin.js +2258 -1
  38. package/dist/plugin.js.map +1 -1
  39. package/ios/{Plugin → Sources/GleapPlugin}/GleapPlugin.swift +219 -12
  40. package/package.json +18 -4
  41. package/ios/Plugin/GleapPlugin.h +0 -10
  42. package/ios/Plugin/GleapPlugin.m +0 -68
  43. package/ios/Plugin/Info.plist +0 -24
@@ -55,5 +55,5 @@ dependencies {
55
55
  testImplementation "junit:junit:$junitVersion"
56
56
  androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
57
57
  androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
58
- implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '18.1.0'
58
+ implementation group: 'io.gleap', name: 'gleap-android-sdk', version: '19.0.0'
59
59
  }
@@ -58,10 +58,49 @@ public class GleapPlugin extends Plugin {
58
58
 
59
59
  private Gleap implementation;
60
60
  private final Map<String, GleapAgentToolResultCallback> pendingAgentToolExecutions = new ConcurrentHashMap<>();
61
+ // Network log settings from the last loaded config, for the WebView log capture.
62
+ private volatile JSObject lastLogConfig;
63
+ // Set by disableConsoleLogOverwrite: WebView console logs are no longer attached.
64
+ private volatile boolean webViewConsoleLogsDisabled = false;
61
65
 
62
66
  @Override
63
67
  public void load() {
64
68
  implementation = Gleap.getInstance();
69
+ // The loaded config only feeds the WebView log capture; like on iOS, setEventCallback gets no event for it.
70
+ implementation.setConfigLoadedCallback(
71
+ new ConfigLoadedCallback() {
72
+ @Override
73
+ public void configLoaded(JSONObject jsonObject) {
74
+ notifyLogConfig(jsonObject);
75
+ }
76
+ }
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Sends the network log settings of the loaded config to the WebView log capture.
82
+ */
83
+ private void notifyLogConfig(JSONObject config) {
84
+ JSObject logConfig = new JSObject();
85
+ logConfig.put("enableNetworkLogs", config != null && config.optBoolean("enableNetworkLogs", false));
86
+ logConfig.put("networkLogPropsToIgnore", stringArray(config, "networkLogPropsToIgnore"));
87
+ logConfig.put("networkLogBlacklist", stringArray(config, "networkLogBlacklist"));
88
+ lastLogConfig = logConfig;
89
+ notifyListeners("logConfigLoaded", logConfig, true);
90
+ }
91
+
92
+ private static JSONArray stringArray(JSONObject config, String key) {
93
+ JSONArray result = new JSONArray();
94
+ JSONArray values = config != null ? config.optJSONArray(key) : null;
95
+ if (values != null) {
96
+ for (int i = 0; i < values.length(); i++) {
97
+ Object value = values.opt(i);
98
+ if (value instanceof String) {
99
+ result.put(value);
100
+ }
101
+ }
102
+ }
103
+ return result;
65
104
  }
66
105
 
67
106
  @PluginMethod
@@ -80,6 +119,12 @@ public class GleapPlugin extends Plugin {
80
119
  // Set the application type
81
120
  Gleap.getInstance().setApplicationType(APPLICATIONTYPE.CAPACITOR);
82
121
 
122
+ // A reloaded WebView calls initialize again: hand it the config that was already loaded.
123
+ JSObject logConfig = lastLogConfig;
124
+ if (logConfig != null) {
125
+ notifyListeners("logConfigLoaded", logConfig, true);
126
+ }
127
+
83
128
  // Build Json object and resolve success
84
129
  JSObject ret = new JSObject();
85
130
  ret.put("initialized", true);
@@ -251,6 +296,48 @@ public class GleapPlugin extends Plugin {
251
296
  call.resolve(ret);
252
297
  }
253
298
 
299
+ @PluginMethod
300
+ public void updateContact(PluginCall call) {
301
+ GleapSessionProperties sessionProperties = new GleapSessionProperties();
302
+ if (call.getData().has("email")) {
303
+ sessionProperties.setEmail(call.getString("email"));
304
+ }
305
+ if (call.getData().has("name")) {
306
+ sessionProperties.setName(call.getString("name"));
307
+ }
308
+ if (call.getData().has("phone")) {
309
+ sessionProperties.setPhone(call.getString("phone"));
310
+ }
311
+ if (call.getData().has("plan")) {
312
+ sessionProperties.setPlan(call.getString("plan"));
313
+ }
314
+ if (call.getData().has("companyName")) {
315
+ sessionProperties.setCompanyName(call.getString("companyName"));
316
+ }
317
+ if (call.getData().has("avatar")) {
318
+ sessionProperties.setAvatar(call.getString("avatar"));
319
+ }
320
+ if (call.getData().has("sla")) {
321
+ sessionProperties.setSla(call.getDouble("sla"));
322
+ }
323
+ if (call.getData().has("companyId")) {
324
+ sessionProperties.setCompanyId(call.getString("companyId"));
325
+ }
326
+ if (call.getData().has("value")) {
327
+ sessionProperties.setValue(call.getDouble("value"));
328
+ }
329
+ if (call.getData().has("customData")) {
330
+ sessionProperties.setCustomData(call.getObject("customData"));
331
+ }
332
+
333
+ implementation.updateContact(sessionProperties);
334
+
335
+ // Build Json object and resolve success
336
+ JSObject ret = new JSObject();
337
+ ret.put("identify", true);
338
+ call.resolve(ret);
339
+ }
340
+
254
341
  @PluginMethod
255
342
  public void clearIdentity(PluginCall call) {
256
343
  // Clear User Identity in Gleap
@@ -616,9 +703,9 @@ public class GleapPlugin extends Plugin {
616
703
  String message = call.getString("message");
617
704
  String logLevel = call.getString("logLevel", "INFO");
618
705
  GleapLogLevel logLevelObj = GleapLogLevel.INFO;
619
- if (logLevel == "ERROR") {
706
+ if ("ERROR".equals(logLevel)) {
620
707
  logLevelObj = GleapLogLevel.ERROR;
621
- } else if (logLevel == "WARNING") {
708
+ } else if ("WARNING".equals(logLevel)) {
622
709
  logLevelObj = GleapLogLevel.WARNING;
623
710
  }
624
711
 
@@ -674,7 +761,7 @@ public class GleapPlugin extends Plugin {
674
761
 
675
762
  // Build Json object and resolve success
676
763
  JSObject ret = new JSObject();
677
- ret.put("trackedEvent", true);
764
+ ret.put("loggedEvent", true);
678
765
  call.resolve(ret);
679
766
  }
680
767
 
@@ -774,7 +861,7 @@ public class GleapPlugin extends Plugin {
774
861
 
775
862
  @PluginMethod
776
863
  public void setDisableInAppNotifications(PluginCall call) {
777
- boolean disableInAppNotifications = call.getBoolean("disableInAppNotifications");
864
+ boolean disableInAppNotifications = call.getBoolean("disableInAppNotifications", false);
778
865
 
779
866
  implementation.setDisableInAppNotifications(disableInAppNotifications);
780
867
 
@@ -796,9 +883,32 @@ public class GleapPlugin extends Plugin {
796
883
  call.resolve(ret);
797
884
  }
798
885
 
886
+ /**
887
+ * Sets the color scheme of the widget ("auto", "light" or "dark").
888
+ *
889
+ * @since 19.0.0
890
+ */
891
+ @PluginMethod
892
+ public void setColorScheme(PluginCall call) {
893
+ if (!call.getData().has("colorScheme")) {
894
+ call.reject("No colorScheme provided");
895
+ return;
896
+ }
897
+
898
+ String colorScheme = call.getString("colorScheme");
899
+
900
+ // Missing colors fall back to the dashboard setting / the SDK defaults
901
+ implementation.setColorScheme(colorScheme, call.getString("lightBackgroundColor"), call.getString("darkBackgroundColor"));
902
+
903
+ // Build Json object and resolve success
904
+ JSObject ret = new JSObject();
905
+ ret.put("colorScheme", colorScheme);
906
+ call.resolve(ret);
907
+ }
908
+
799
909
  @PluginMethod
800
910
  public void showFeedbackButton(PluginCall call) {
801
- boolean show = call.getBoolean("show");
911
+ boolean show = call.getBoolean("show", false);
802
912
 
803
913
  implementation.showFeedbackButton(show);
804
914
 
@@ -820,12 +930,54 @@ public class GleapPlugin extends Plugin {
820
930
 
821
931
  @PluginMethod
822
932
  public void disableConsoleLogOverwrite(PluginCall call) {
933
+ // The plugin's JavaScript restores the WebView console; drop what it attached so far.
934
+ webViewConsoleLogsDisabled = true;
935
+ implementation.attachConsoleLogs(new JSONArray());
936
+
823
937
  // Build Json object and resolve success
824
938
  JSObject ret = new JSObject();
825
939
  ret.put("consoleLogDisabled", true);
826
940
  call.resolve(ret);
827
941
  }
828
942
 
943
+ /**
944
+ * Network requests made inside the WebView (fetch / XMLHttpRequest), recorded by the plugin's
945
+ * JavaScript. Each call replaces the previous list; the SDK merges and sanitizes them.
946
+ *
947
+ * @since 19.0.0
948
+ */
949
+ @PluginMethod
950
+ public void attachNetworkLogs(PluginCall call) {
951
+ JSONArray logs = call.getArray("logs", new JSArray());
952
+ implementation.attachNetworkLogs(logs);
953
+
954
+ JSObject ret = new JSObject();
955
+ ret.put("networkLogsAttached", true);
956
+ call.resolve(ret);
957
+ }
958
+
959
+ /**
960
+ * Console output of the WebView, recorded by the plugin's JavaScript. Each call replaces the
961
+ * previous list.
962
+ *
963
+ * @since 19.0.0
964
+ */
965
+ @PluginMethod
966
+ public void attachConsoleLogs(PluginCall call) {
967
+ JSObject ret = new JSObject();
968
+ if (webViewConsoleLogsDisabled) {
969
+ ret.put("consoleLogsAttached", false);
970
+ call.resolve(ret);
971
+ return;
972
+ }
973
+
974
+ JSONArray logs = call.getArray("logs", new JSArray());
975
+ implementation.attachConsoleLogs(logs);
976
+
977
+ ret.put("consoleLogsAttached", true);
978
+ call.resolve(ret);
979
+ }
980
+
829
981
  @PluginMethod
830
982
  public void enableDebugConsoleLog(PluginCall call) {
831
983
  // Build Json object and resolve success
@@ -845,9 +997,9 @@ public class GleapPlugin extends Plugin {
845
997
  String severity = call.getString("severity");
846
998
 
847
999
  Gleap.SEVERITY severityObj = Gleap.SEVERITY.HIGH;
848
- if (severity == "high") {
1000
+ if ("HIGH".equalsIgnoreCase(severity)) {
849
1001
  severityObj = Gleap.SEVERITY.HIGH;
850
- } else if (severity == "medium") {
1002
+ } else if ("MEDIUM".equalsIgnoreCase(severity)) {
851
1003
  severityObj = Gleap.SEVERITY.MEDIUM;
852
1004
  } else {
853
1005
  severityObj = Gleap.SEVERITY.LOW;
@@ -887,7 +1039,7 @@ public class GleapPlugin extends Plugin {
887
1039
 
888
1040
  @PluginMethod
889
1041
  public void openChecklists(PluginCall call) throws GleapNotInitialisedException {
890
- boolean showBackButton = call.getBoolean("showBackButton");
1042
+ boolean showBackButton = call.getBoolean("showBackButton", true);
891
1043
 
892
1044
  implementation.openChecklists(showBackButton);
893
1045
 
@@ -900,7 +1052,7 @@ public class GleapPlugin extends Plugin {
900
1052
  @PluginMethod
901
1053
  public void openChecklist(PluginCall call) throws GleapNotInitialisedException {
902
1054
  String checklistId = call.getString("checklistId");
903
- boolean showBackButton = call.getBoolean("showBackButton");
1055
+ boolean showBackButton = call.getBoolean("showBackButton", true);
904
1056
 
905
1057
  implementation.openChecklist(checklistId, showBackButton);
906
1058
 
@@ -913,9 +1065,9 @@ public class GleapPlugin extends Plugin {
913
1065
  @PluginMethod
914
1066
  public void startChecklist(PluginCall call) throws GleapNotInitialisedException {
915
1067
  String outboundId = call.getString("outboundId");
916
- boolean showBackButton = call.getBoolean("showBackButton");
1068
+ boolean showBackButton = call.getBoolean("showBackButton", true);
917
1069
 
918
- implementation.openChecklist(outboundId, showBackButton);
1070
+ implementation.startChecklist(outboundId, showBackButton);
919
1071
 
920
1072
  // Build Json object and resolve success
921
1073
  JSObject ret = new JSObject();
@@ -925,20 +1077,20 @@ public class GleapPlugin extends Plugin {
925
1077
 
926
1078
  @PluginMethod
927
1079
  public void openNews(PluginCall call) throws GleapNotInitialisedException {
928
- boolean showBackButton = call.getBoolean("showBackButton");
1080
+ boolean showBackButton = call.getBoolean("showBackButton", true);
929
1081
 
930
1082
  implementation.openNews(showBackButton);
931
1083
 
932
1084
  // Build Json object and resolve success
933
1085
  JSObject ret = new JSObject();
934
- ret.put("opened", true);
1086
+ ret.put("openedNews", true);
935
1087
  call.resolve(ret);
936
1088
  }
937
1089
 
938
1090
  @PluginMethod
939
1091
  public void openNewsArticle(PluginCall call) throws GleapNotInitialisedException {
940
1092
  String articleId = call.getString("articleId");
941
- boolean showBackButton = call.getBoolean("showBackButton");
1093
+ boolean showBackButton = call.getBoolean("showBackButton", true);
942
1094
 
943
1095
  implementation.openNewsArticle(articleId, showBackButton);
944
1096
 
@@ -950,7 +1102,7 @@ public class GleapPlugin extends Plugin {
950
1102
 
951
1103
  @PluginMethod
952
1104
  public void openHelpCenter(PluginCall call) throws GleapNotInitialisedException {
953
- boolean showBackButton = call.getBoolean("showBackButton");
1105
+ boolean showBackButton = call.getBoolean("showBackButton", true);
954
1106
 
955
1107
  implementation.openHelpCenter(showBackButton);
956
1108
 
@@ -964,7 +1116,7 @@ public class GleapPlugin extends Plugin {
964
1116
  public void askAI(PluginCall call) throws GleapNotInitialisedException {
965
1117
  // Open news
966
1118
  String question = call.getString("question");
967
- boolean showBackButton = call.getBoolean("showBackButton");
1119
+ boolean showBackButton = call.getBoolean("showBackButton", true);
968
1120
 
969
1121
  implementation.askAI(question, showBackButton);
970
1122
 
@@ -978,7 +1130,7 @@ public class GleapPlugin extends Plugin {
978
1130
  public void openHelpCenterArticle(PluginCall call) throws GleapNotInitialisedException {
979
1131
  // Open news
980
1132
  String articleId = call.getString("articleId");
981
- boolean showBackButton = call.getBoolean("showBackButton");
1133
+ boolean showBackButton = call.getBoolean("showBackButton", true);
982
1134
 
983
1135
  implementation.openHelpCenterArticle(articleId, showBackButton);
984
1136
 
@@ -992,7 +1144,7 @@ public class GleapPlugin extends Plugin {
992
1144
  public void openHelpCenterCollection(PluginCall call) throws GleapNotInitialisedException {
993
1145
  // Open news
994
1146
  String collectionId = call.getString("collectionId");
995
- boolean showBackButton = call.getBoolean("showBackButton");
1147
+ boolean showBackButton = call.getBoolean("showBackButton", true);
996
1148
 
997
1149
  implementation.openHelpCenterCollection(collectionId, showBackButton);
998
1150
 
@@ -1006,7 +1158,7 @@ public class GleapPlugin extends Plugin {
1006
1158
  public void searchHelpCenter(PluginCall call) throws GleapNotInitialisedException {
1007
1159
  // Open news
1008
1160
  String term = call.getString("term");
1009
- boolean showBackButton = call.getBoolean("showBackButton");
1161
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1010
1162
 
1011
1163
  implementation.searchHelpCenter(term, showBackButton);
1012
1164
 
@@ -1018,7 +1170,7 @@ public class GleapPlugin extends Plugin {
1018
1170
 
1019
1171
  @PluginMethod
1020
1172
  public void openFeatureRequests(PluginCall call) throws GleapNotInitialisedException {
1021
- boolean showBackButton = call.getBoolean("showBackButton");
1173
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1022
1174
 
1023
1175
  // Open feature requests
1024
1176
  implementation.openFeatureRequests(showBackButton);
@@ -1049,7 +1201,7 @@ public class GleapPlugin extends Plugin {
1049
1201
 
1050
1202
  // Start bot
1051
1203
  String botId = call.getString("botId");
1052
- boolean showBackButton = call.getBoolean("showBackButton");
1204
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1053
1205
  implementation.startBot(botId, showBackButton);
1054
1206
 
1055
1207
  // Build Json object and resolve success
@@ -1067,7 +1219,8 @@ public class GleapPlugin extends Plugin {
1067
1219
 
1068
1220
  // Start feedback flow
1069
1221
  String feedbackFlow = call.getString("feedbackFlow");
1070
- implementation.startFeedbackFlow(feedbackFlow);
1222
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1223
+ implementation.startFeedbackFlow(feedbackFlow, showBackButton);
1071
1224
 
1072
1225
  // Build Json object and resolve success
1073
1226
  JSObject ret = new JSObject();
@@ -1077,7 +1230,7 @@ public class GleapPlugin extends Plugin {
1077
1230
 
1078
1231
  @PluginMethod
1079
1232
  public void startConversation(PluginCall call) throws GleapNotInitialisedException {
1080
- boolean showBackButton = call.getBoolean("showBackButton");
1233
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1081
1234
 
1082
1235
  // Start conversation
1083
1236
  implementation.startConversation(showBackButton);
@@ -1090,7 +1243,7 @@ public class GleapPlugin extends Plugin {
1090
1243
 
1091
1244
  @PluginMethod
1092
1245
  public void openConversations(PluginCall call) throws GleapNotInitialisedException {
1093
- boolean showBackButton = call.getBoolean("showBackButton");
1246
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1094
1247
 
1095
1248
  // Start conversation
1096
1249
  implementation.openConversations(showBackButton);
@@ -1101,6 +1254,30 @@ public class GleapPlugin extends Plugin {
1101
1254
  call.resolve(ret);
1102
1255
  }
1103
1256
 
1257
+ // The name the plugin's TypeScript API uses for opening the conversations tab.
1258
+ @PluginMethod
1259
+ public void openConversation(PluginCall call) throws GleapNotInitialisedException {
1260
+ openConversations(call);
1261
+ }
1262
+
1263
+ // Emailed protected file link (gleapFile query parameter). The SDK opens the conversation
1264
+ // once a verified identify (user hash) gave the session file access.
1265
+ @PluginMethod
1266
+ public void openProtectedFileFromUrl(PluginCall call) {
1267
+ String url = call.getString("url");
1268
+ if (url == null) {
1269
+ call.reject("No url provided");
1270
+ return;
1271
+ }
1272
+
1273
+ boolean opened = implementation.openProtectedFileFromUrl(url);
1274
+
1275
+ // Build Json object and resolve success
1276
+ JSObject ret = new JSObject();
1277
+ ret.put("opened", opened);
1278
+ call.resolve(ret);
1279
+ }
1280
+
1104
1281
  @PluginMethod
1105
1282
  public void startClassicForm(PluginCall call) throws GleapNotInitialisedException {
1106
1283
  if (!call.getData().has("formId")) {
@@ -1109,7 +1286,7 @@ public class GleapPlugin extends Plugin {
1109
1286
  }
1110
1287
 
1111
1288
  // Start feedback flow
1112
- boolean showBackButton = call.getBoolean("showBackButton");
1289
+ boolean showBackButton = call.getBoolean("showBackButton", true);
1113
1290
  String formId = call.getString("formId");
1114
1291
  implementation.startClassicForm(formId, showBackButton);
1115
1292
 
@@ -1186,18 +1363,6 @@ public class GleapPlugin extends Plugin {
1186
1363
  }
1187
1364
  );
1188
1365
 
1189
- implementation.setConfigLoadedCallback(
1190
- new ConfigLoadedCallback() {
1191
- @Override
1192
- public void configLoaded(JSONObject jsonObject) {
1193
- JSObject data = new JSObject();
1194
- data.put("name", "widget-opened");
1195
- data.put("data", jsonObject);
1196
- call.resolve(data);
1197
- }
1198
- }
1199
- );
1200
-
1201
1366
  implementation.setFeedbackSentCallback(
1202
1367
  new FeedbackSentCallback() {
1203
1368
  @Override