@bugfender/rn-bugfender 1.1.3 → 2.0.0-alpha.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 (166) hide show
  1. package/README.md +110 -86
  2. package/RnBugfender.podspec +21 -0
  3. package/android/.gradle/7.1/dependencies-accessors/dependencies-accessors.lock +0 -0
  4. package/android/.gradle/{5.6.4 → 7.1/dependencies-accessors}/gc.properties +0 -0
  5. package/android/.gradle/7.1/executionHistory/executionHistory.bin +0 -0
  6. package/android/.gradle/7.1/executionHistory/executionHistory.lock +0 -0
  7. package/android/.gradle/{5.6.4 → 7.1}/fileChanges/last-build.bin +0 -0
  8. package/android/.gradle/7.1/fileHashes/fileHashes.bin +0 -0
  9. package/android/.gradle/7.1/fileHashes/fileHashes.lock +0 -0
  10. package/android/.gradle/7.1/gc.properties +0 -0
  11. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/.gradle/buildOutputCleanup/cache.properties +2 -2
  13. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/android/.gradle/checksums/checksums.lock +0 -0
  15. package/android/.gradle/{5.6.4/fileHashes/fileHashes.bin → checksums/md5-checksums.bin} +0 -0
  16. package/android/.gradle/checksums/sha1-checksums.bin +0 -0
  17. package/android/.idea/compiler.xml +6 -0
  18. package/android/.idea/gradle.xml +1 -2
  19. package/android/.idea/jarRepositories.xml +40 -0
  20. package/android/.idea/misc.xml +4 -110
  21. package/android/.idea/runConfigurations.xml +1 -3
  22. package/android/.idea/uiDesigner.xml +124 -0
  23. package/android/build.gradle +47 -24
  24. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  25. package/android/gradle/wrapper/gradle-wrapper.properties +1 -2
  26. package/android/gradlew +34 -21
  27. package/android/gradlew.bat +24 -19
  28. package/android/src/main/AndroidManifest.xml +4 -3
  29. package/android/src/main/java/com/bugfender/react/{RNBugfenderModule.java → RnBugfenderModule.java} +88 -13
  30. package/android/src/main/java/com/bugfender/react/RnBugfenderPackage.java +28 -0
  31. package/ios/RnBugfender.h +5 -0
  32. package/ios/{RNBugfender.m → RnBugfender.m} +67 -8
  33. package/ios/{RNBugfender.xcodeproj → RnBugfender.xcodeproj}/project.pbxproj +42 -37
  34. package/ios/{RNBugfender.xcodeproj → RnBugfender.xcodeproj}/project.xcworkspace/contents.xcworkspacedata +0 -3
  35. package/ios/{RNBugfender.xcodeproj → RnBugfender.xcodeproj}/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
  36. package/ios/RnBugfender.xcodeproj/project.xcworkspace/xcuserdata/fj.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  37. package/ios/{RNBugfender.xcodeproj/xcuserdata/rubenvot.xcuserdatad → RnBugfender.xcodeproj/xcuserdata/fj.xcuserdatad}/xcschemes/xcschememanagement.plist +1 -6
  38. package/lib/commonjs/bugfender.js +338 -0
  39. package/lib/commonjs/bugfender.js.map +1 -0
  40. package/lib/commonjs/index.js +28 -0
  41. package/lib/commonjs/index.js.map +1 -0
  42. package/lib/commonjs/index.web.js +30 -0
  43. package/lib/commonjs/index.web.js.map +1 -0
  44. package/lib/commonjs/override-console-methods.js +91 -0
  45. package/lib/commonjs/override-console-methods.js.map +1 -0
  46. package/lib/commonjs/print-to-console.js +78 -0
  47. package/lib/commonjs/print-to-console.js.map +1 -0
  48. package/lib/commonjs/sdk-options.js +81 -0
  49. package/lib/commonjs/sdk-options.js.map +1 -0
  50. package/lib/commonjs/string-formatter.js +55 -0
  51. package/lib/commonjs/string-formatter.js.map +1 -0
  52. package/lib/commonjs/types/device.js +2 -0
  53. package/lib/commonjs/types/device.js.map +1 -0
  54. package/lib/commonjs/types/log.js +35 -0
  55. package/lib/commonjs/types/log.js.map +1 -0
  56. package/lib/commonjs/types/sdk-options.js +55 -0
  57. package/lib/commonjs/types/sdk-options.js.map +1 -0
  58. package/lib/commonjs/user-feedback.js +31 -0
  59. package/lib/commonjs/user-feedback.js.map +1 -0
  60. package/lib/module/bugfender.js +323 -0
  61. package/lib/module/bugfender.js.map +1 -0
  62. package/lib/module/index.js +6 -0
  63. package/lib/module/index.js.map +1 -0
  64. package/lib/module/index.web.js +5 -0
  65. package/lib/module/index.web.js.map +1 -0
  66. package/lib/module/override-console-methods.js +75 -0
  67. package/lib/module/override-console-methods.js.map +1 -0
  68. package/lib/module/print-to-console.js +67 -0
  69. package/lib/module/print-to-console.js.map +1 -0
  70. package/lib/module/sdk-options.js +72 -0
  71. package/lib/module/sdk-options.js.map +1 -0
  72. package/lib/module/string-formatter.js +45 -0
  73. package/lib/module/string-formatter.js.map +1 -0
  74. package/lib/module/types/device.js +2 -0
  75. package/lib/module/types/device.js.map +1 -0
  76. package/lib/module/types/log.js +24 -0
  77. package/lib/module/types/log.js.map +1 -0
  78. package/lib/module/types/sdk-options.js +46 -0
  79. package/lib/module/types/sdk-options.js.map +1 -0
  80. package/lib/module/user-feedback.js +22 -0
  81. package/lib/module/user-feedback.js.map +1 -0
  82. package/lib/typescript/bugfender.d.ts +163 -0
  83. package/lib/typescript/index.d.ts +5 -0
  84. package/lib/typescript/index.web.d.ts +4 -0
  85. package/lib/typescript/override-console-methods.d.ts +10 -0
  86. package/lib/typescript/print-to-console.d.ts +14 -0
  87. package/lib/typescript/sdk-options.d.ts +16 -0
  88. package/lib/typescript/string-formatter.d.ts +4 -0
  89. package/lib/typescript/types/device.d.ts +4 -0
  90. package/lib/typescript/types/log.d.ts +59 -0
  91. package/lib/typescript/types/sdk-options.d.ts +40 -0
  92. package/lib/typescript/user-feedback.d.ts +31 -0
  93. package/package.json +146 -12
  94. package/src/bugfender.ts +360 -0
  95. package/src/index.tsx +7 -0
  96. package/src/index.web.tsx +5 -0
  97. package/src/override-console-methods.ts +53 -0
  98. package/src/print-to-console.ts +67 -0
  99. package/src/sdk-options.ts +68 -0
  100. package/src/string-formatter.ts +44 -0
  101. package/src/types/device.ts +4 -0
  102. package/src/types/log.ts +75 -0
  103. package/src/types/sdk-options.ts +81 -0
  104. package/src/user-feedback.ts +33 -0
  105. package/.idea/codeStyles/Project.xml +0 -116
  106. package/.idea/modules.xml +0 -8
  107. package/.idea/rn-bugfender.iml +0 -9
  108. package/.idea/vcs.xml +0 -6
  109. package/RNBugfender.podspec +0 -26
  110. package/android/.gradle/5.6.4/fileHashes/fileHashes.lock +0 -0
  111. package/android/.idea/caches/build_file_checksums.ser +0 -0
  112. package/android/.idea/codeStyles/Project.xml +0 -116
  113. package/android/.idea/libraries/Gradle__com_android_support_appcompat_v7_23_0_1_aar.xml +0 -15
  114. package/android/.idea/libraries/Gradle__com_android_support_recyclerview_v7_23_0_1_aar.xml +0 -12
  115. package/android/.idea/libraries/Gradle__com_android_support_support_annotations_23_0_1_jar.xml +0 -11
  116. package/android/.idea/libraries/Gradle__com_android_support_support_v4_23_0_1_aar.xml +0 -16
  117. package/android/.idea/libraries/Gradle__com_bugfender_sdk_android_3_0_5_aar.xml +0 -12
  118. package/android/.idea/libraries/Gradle__com_facebook_fresco_drawee_0_8_1_aar.xml +0 -12
  119. package/android/.idea/libraries/Gradle__com_facebook_fresco_fbcore_0_8_1_aar.xml +0 -12
  120. package/android/.idea/libraries/Gradle__com_facebook_fresco_fresco_0_8_1_aar.xml +0 -12
  121. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_0_8_1_aar.xml +0 -12
  122. package/android/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp_0_8_1_aar.xml +0 -12
  123. package/android/.idea/libraries/Gradle__com_facebook_react_react_native_0_20_1_aar.xml +0 -16
  124. package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_2_0_jar.xml +0 -11
  125. package/android/.idea/libraries/Gradle__com_facebook_stetho_stetho_okhttp_1_2_0_jar.xml +0 -11
  126. package/android/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_2_3_jar.xml +0 -11
  127. package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_0_jar.xml +0 -11
  128. package/android/.idea/libraries/Gradle__com_nineoldandroids_library_2_4_0_jar.xml +0 -11
  129. package/android/.idea/libraries/Gradle__com_parse_bolts_bolts_android_1_1_4_jar.xml +0 -11
  130. package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_2_5_0_jar.xml +0 -11
  131. package/android/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_ws_2_5_0_jar.xml +0 -11
  132. package/android/.idea/libraries/Gradle__com_squareup_okio_okio_1_6_0_jar.xml +0 -11
  133. package/android/.idea/libraries/Gradle__commons_cli_commons_cli_1_2_jar.xml +0 -13
  134. package/android/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +0 -10
  135. package/android/.idea/modules.xml +0 -8
  136. package/android/android.iml +0 -116
  137. package/android/build/generated/source/buildConfig/debug/com/bugfender/react/BuildConfig.java +0 -13
  138. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +0 -11
  139. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output.json +0 -1
  140. package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +0 -1
  141. package/android/build/intermediates/compile_library_classes/debug/classes.jar +0 -0
  142. package/android/build/intermediates/compile_only_not_namespaced_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  143. package/android/build/intermediates/incremental/debug-mergeJniLibs/merge-state +0 -0
  144. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  145. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  146. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  147. package/android/build/intermediates/incremental/packageDebugResources/compile-file-map.properties +0 -1
  148. package/android/build/intermediates/incremental/packageDebugResources/merger.xml +0 -2
  149. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/bugfender/react/BuildConfig.class +0 -0
  150. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/bugfender/react/RNBugfenderModule.class +0 -0
  151. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/bugfender/react/RNBugfenderPackage.class +0 -0
  152. package/android/build/intermediates/library_java_res/debug/res.jar +0 -0
  153. package/android/build/intermediates/library_manifest/debug/AndroidManifest.xml +0 -11
  154. package/android/build/intermediates/merged_manifests/debug/output.json +0 -1
  155. package/android/build/intermediates/res/symbol-table-with-package/debug/package-aware-r.txt +0 -1309
  156. package/android/build/intermediates/runtime_library_classes/debug/classes.jar +0 -0
  157. package/android/build/intermediates/symbols/debug/R.txt +0 -1783
  158. package/android/build/intermediates/transforms/mergeJniLibs/debug/__content__.json +0 -1
  159. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -37
  160. package/android/local.properties +0 -8
  161. package/android/src/main/java/com/bugfender/react/RNBugfenderPackage.java +0 -29
  162. package/bugfender.js +0 -188
  163. package/example/.babelrc +0 -3
  164. package/example/.watchmanconfig +0 -1
  165. package/example/App.js +0 -121
  166. package/ios/RNBugfender.h +0 -7
@@ -0,0 +1,338 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RnBugfender = exports.BugfenderClass = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ var _userFeedback = require("./user-feedback");
11
+
12
+ var _stringFormatter = require("./string-formatter");
13
+
14
+ var _log = require("./types/log");
15
+
16
+ var _overrideConsoleMethods = require("./override-console-methods");
17
+
18
+ var _printToConsole = require("./print-to-console");
19
+
20
+ var _sdkOptions = require("./sdk-options");
21
+
22
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+
24
+ const LINKING_ERROR = `The package '@bugfender/rn-bugfender' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
25
+ ios: "- You have run 'pod install'\n",
26
+ default: ''
27
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
28
+ const RnBugfender = _reactNative.NativeModules.RnBugfender ? _reactNative.NativeModules.RnBugfender : new Proxy({}, {
29
+ get() {
30
+ throw new Error(LINKING_ERROR);
31
+ }
32
+
33
+ });
34
+ exports.RnBugfender = RnBugfender;
35
+
36
+ class BugfenderClass {
37
+ constructor() {
38
+ _defineProperty(this, "stringFormatter", new _stringFormatter.StringFormatter());
39
+
40
+ _defineProperty(this, "overrideConsoleMethods", new _overrideConsoleMethods.OverrideConsoleMethods(window));
41
+
42
+ _defineProperty(this, "printToConsole", new _printToConsole.PrintToConsole(global.console));
43
+
44
+ _defineProperty(this, "sdkOptions", new _sdkOptions.SDKOptions());
45
+
46
+ _defineProperty(this, "initialized", false);
47
+ }
48
+
49
+ async init(options) {
50
+ if (!this.initialized) {
51
+ var _validatedOptions$pri;
52
+
53
+ const validatedOptions = this.sdkOptions.init(options); // Needs to be executed prior initialization
54
+
55
+ if (typeof options.deviceName !== 'undefined') {
56
+ RnBugfender.overrideDeviceName(options.deviceName);
57
+ } // Library initialization
58
+
59
+
60
+ _reactNative.Platform.OS === 'ios' ? RnBugfender.activateLogger(validatedOptions.appKey) : RnBugfender.init(validatedOptions.appKey, false);
61
+
62
+ if (typeof validatedOptions.apiURL !== 'undefined') {
63
+ RnBugfender.setApiUrl(validatedOptions.apiURL);
64
+ }
65
+
66
+ if (typeof validatedOptions.baseURL !== 'undefined') {
67
+ RnBugfender.setBaseUrl(validatedOptions.baseURL);
68
+ }
69
+
70
+ if (validatedOptions.enableLogcatLogging) {
71
+ RnBugfender.enableLogcatLogging();
72
+ }
73
+
74
+ if (validatedOptions.logUIEvents) {
75
+ RnBugfender.enableUIEventLogging();
76
+ }
77
+
78
+ if (validatedOptions.registerErrorHandler) {
79
+ RnBugfender.enableCrashReporting();
80
+ }
81
+
82
+ if (validatedOptions.overrideConsoleMethods) {
83
+ this.overrideConsoleMethods.init(this.stringFormatter);
84
+ }
85
+
86
+ this.printToConsole.init((_validatedOptions$pri = validatedOptions.printToConsole) !== null && _validatedOptions$pri !== void 0 ? _validatedOptions$pri : true);
87
+ this.initialized = true;
88
+ }
89
+ }
90
+ /**
91
+ * @returns Bugfender dashboard URL for the device
92
+ */
93
+
94
+
95
+ getDeviceURL() {
96
+ return RnBugfender.getDeviceUrl();
97
+ }
98
+ /**
99
+ * @returns Bugfender dashboard URL for the current session
100
+ */
101
+
102
+
103
+ getSessionURL() {
104
+ return RnBugfender.getSessionUrl();
105
+ }
106
+ /**
107
+ * Show a modal which asks for feedback. Once the user closes the modal or sends the feedback
108
+ * the returned promise resolves with the result.
109
+ *
110
+ * ```typescript
111
+ * Bugfender.getUserFeedback().then((result) => {
112
+ * if (result.isSent) {
113
+ * // User sent the feedback
114
+ * // `result.feedbackURL` contains the Bugfender feedback URL
115
+ * } else {
116
+ * // User closed the modal without sending the feedback
117
+ * }
118
+ * });
119
+ * ```
120
+ *
121
+ * @param options Options object to configure modal strings
122
+ * @returns Promise which resolves once the user closes the modal or sends the feedback
123
+ */
124
+
125
+
126
+ async getUserFeedback(options) {
127
+ return new Promise(resolve => {
128
+ var _options;
129
+
130
+ options = { ...new _userFeedback.DefaultUserFeedbackOptions(),
131
+ ...((_options = options) !== null && _options !== void 0 ? _options : {})
132
+ };
133
+ return RnBugfender.showUserFeedback(options.title, options.hint, options.subjectPlaceholder, options.feedbackPlaceholder, options.submitLabel, options.closeLabel).then(value => {
134
+ resolve({
135
+ isSent: true,
136
+ feedbackURL: value
137
+ });
138
+ }, _ => {
139
+ resolve({
140
+ isSent: false
141
+ });
142
+ });
143
+ });
144
+ }
145
+ /**
146
+ * @param obj A JavaScript value to output
147
+ * @param objs List of optional JavaScript values to output
148
+ */
149
+
150
+
151
+ log() {
152
+ for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
153
+ parameters[_key] = arguments[_key];
154
+ }
155
+
156
+ this.printToConsole.log(...parameters);
157
+ let message = this.stringFormatter.format([...parameters]);
158
+ RnBugfender.debug('', message);
159
+ }
160
+ /**
161
+ * @param obj A JavaScript value to output
162
+ * @param objs List of optional JavaScript values to output
163
+ */
164
+
165
+
166
+ warn() {
167
+ for (var _len2 = arguments.length, parameters = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
168
+ parameters[_key2] = arguments[_key2];
169
+ }
170
+
171
+ this.printToConsole.warn(...parameters);
172
+ let message = this.stringFormatter.format([...parameters]);
173
+ RnBugfender.warning('', message);
174
+ }
175
+ /**
176
+ * @param obj A JavaScript value to output
177
+ * @param objs List of optional JavaScript values to output
178
+ */
179
+
180
+
181
+ error() {
182
+ for (var _len3 = arguments.length, parameters = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
183
+ parameters[_key3] = arguments[_key3];
184
+ }
185
+
186
+ this.printToConsole.error(...parameters);
187
+ let message = this.stringFormatter.format([...parameters]);
188
+ RnBugfender.error('', message);
189
+ }
190
+ /**
191
+ * @param obj A JavaScript value to output
192
+ * @param objs List of optional JavaScript values to output
193
+ */
194
+
195
+
196
+ trace() {
197
+ for (var _len4 = arguments.length, parameters = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
198
+ parameters[_key4] = arguments[_key4];
199
+ }
200
+
201
+ this.printToConsole.trace(...parameters);
202
+ let message = this.stringFormatter.format([...parameters]);
203
+ RnBugfender.trace('', message);
204
+ }
205
+ /**
206
+ * @param obj A JavaScript value to output
207
+ * @param objs List of optional JavaScript values to output
208
+ */
209
+
210
+
211
+ info() {
212
+ for (var _len5 = arguments.length, parameters = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
213
+ parameters[_key5] = arguments[_key5];
214
+ }
215
+
216
+ this.printToConsole.info(...parameters);
217
+ let message = this.stringFormatter.format([...parameters]);
218
+ RnBugfender.info('', message);
219
+ }
220
+ /**
221
+ * @param obj A JavaScript value to output
222
+ * @param objs List of optional JavaScript values to output
223
+ */
224
+
225
+
226
+ fatal() {
227
+ for (var _len6 = arguments.length, parameters = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
228
+ parameters[_key6] = arguments[_key6];
229
+ }
230
+
231
+ this.printToConsole.error(...parameters);
232
+ let message = this.stringFormatter.format([...parameters]);
233
+ RnBugfender.fatal('', message);
234
+ }
235
+ /**
236
+ * Remove a device associated key-value pair. [Learn more](https://bugfender.com/blog/associated-device-information/).
237
+ *
238
+ * @param key Key identifier
239
+ */
240
+
241
+
242
+ removeDeviceKey(key) {
243
+ RnBugfender.removeDeviceKey(key);
244
+ this.printToConsole.info(`Device key "${key}" removed`);
245
+ }
246
+ /**
247
+ * Use this method if you need more control over the data sent while logging. See `ILogEntry` interface reference to see all the accepted properties.
248
+ *
249
+ * @param log Log object that complies with `ILogEntry` interface.
250
+ */
251
+
252
+
253
+ sendLog(log) {
254
+ var _log$line, _log$method, _log$file, _log$level, _log$tag, _log$text;
255
+
256
+ this.printToConsole.printLog(log);
257
+ RnBugfender.log((_log$line = log.line) !== null && _log$line !== void 0 ? _log$line : 0, (_log$method = log.method) !== null && _log$method !== void 0 ? _log$method : '', (_log$file = log.file) !== null && _log$file !== void 0 ? _log$file : '', (_log$level = log.level) !== null && _log$level !== void 0 ? _log$level : _log.LogLevel.Debug, (_log$tag = log.tag) !== null && _log$tag !== void 0 ? _log$tag : '', (_log$text = log.text) !== null && _log$text !== void 0 ? _log$text : '');
258
+ }
259
+ /**
260
+ * Send an issue.
261
+ *
262
+ * @param title - Title
263
+ * @param text - Text content
264
+ * @returns Bugfender dashboard URL for the issue.
265
+ */
266
+
267
+
268
+ sendIssue(title, text) {
269
+ this.printToConsole.warn(`Issue: ${title}.\n${text}`);
270
+ return RnBugfender.sendIssue(title, text);
271
+ }
272
+ /**
273
+ * Send a crash report.
274
+ *
275
+ * @param title - Title
276
+ * @param text - Text content
277
+ * @returns Bugfender dashboard URL for the crash.
278
+ */
279
+
280
+
281
+ sendCrash(title, text) {
282
+ this.printToConsole.error(`Crash: ${title}.\n${text}`);
283
+ return RnBugfender.sendCrash(title, text);
284
+ }
285
+ /**
286
+ * Send an user feedback.
287
+ *
288
+ * @param title - Title/Subject
289
+ * @param text - Feedback text
290
+ * @returns Bugfender dashboard URL for the feedback.
291
+ */
292
+
293
+
294
+ sendUserFeedback(title, text) {
295
+ this.printToConsole.info(`User Feedback: ${title}.\n${text}`);
296
+ return RnBugfender.sendUserFeedback(title, text);
297
+ }
298
+ /**
299
+ * Set a device associated key-value pair. [Learn more](https://bugfender.com/blog/associated-device-information/).
300
+ *
301
+ * @param key Key identifier.
302
+ * @param value Value.
303
+ */
304
+
305
+
306
+ setDeviceKey(key, value) {
307
+ this.printToConsole.info(`Device key "${key}" set to "${value}"`);
308
+
309
+ if (typeof value === 'boolean') {
310
+ RnBugfender.setDeviceBoolean(key, value);
311
+ } else if (typeof value === 'string') {
312
+ RnBugfender.setDeviceString(key, value);
313
+ } else {
314
+ // typeof value === 'number'
315
+ if (Number.isInteger(value)) {
316
+ RnBugfender.setDeviceInteger(key, value);
317
+ } else {
318
+ RnBugfender.setDeviceFloat(key, value);
319
+ }
320
+ }
321
+ }
322
+ /**
323
+ * Synchronizes all logs and issues with the server once, regardless if this device is enabled or not.
324
+ *
325
+ * Logs and issues are synchronized only once. After that, the logs are again sent according to the enabled flag
326
+ * in the Bugfender Console.
327
+ */
328
+
329
+
330
+ forceSendOnce() {
331
+ this.printToConsole.info(`Force send once`);
332
+ RnBugfender.forceSendOnce();
333
+ }
334
+
335
+ }
336
+
337
+ exports.BugfenderClass = BugfenderClass;
338
+ //# sourceMappingURL=bugfender.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["bugfender.ts"],"names":["LINKING_ERROR","Platform","select","ios","default","RnBugfender","NativeModules","Proxy","get","Error","BugfenderClass","StringFormatter","OverrideConsoleMethods","window","PrintToConsole","global","console","SDKOptions","init","options","initialized","validatedOptions","sdkOptions","deviceName","overrideDeviceName","OS","activateLogger","appKey","apiURL","setApiUrl","baseURL","setBaseUrl","enableLogcatLogging","logUIEvents","enableUIEventLogging","registerErrorHandler","enableCrashReporting","overrideConsoleMethods","stringFormatter","printToConsole","getDeviceURL","getDeviceUrl","getSessionURL","getSessionUrl","getUserFeedback","Promise","resolve","DefaultUserFeedbackOptions","showUserFeedback","title","hint","subjectPlaceholder","feedbackPlaceholder","submitLabel","closeLabel","then","value","isSent","feedbackURL","_","log","parameters","message","format","debug","warn","warning","error","trace","info","fatal","removeDeviceKey","key","sendLog","printLog","line","method","file","level","LogLevel","Debug","tag","text","sendIssue","sendCrash","sendUserFeedback","setDeviceKey","setDeviceBoolean","setDeviceString","Number","isInteger","setDeviceInteger","setDeviceFloat","forceSendOnce"],"mappings":";;;;;;;AAAA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAChB,kFAAD,GACAC,sBAASC,MAAT,CAAgB;AAAEC,EAAAA,GAAG,EAAE,gCAAP;AAAyCC,EAAAA,OAAO,EAAE;AAAlD,CAAhB,CADA,GAEA,sDAFA,GAGA,6CAJF;AAMA,MAAMC,WAAW,GAAGC,2BAAcD,WAAd,GAChBC,2BAAcD,WADE,GAEhB,IAAIE,KAAJ,CACA,EADA,EAEA;AACEC,EAAAA,GAAG,GAAG;AACJ,UAAM,IAAIC,KAAJ,CAAUT,aAAV,CAAN;AACD;;AAHH,CAFA,CAFJ;;;AAWA,MAAMU,cAAN,CAAqB;AAAA;AAAA,6CACO,IAAIC,gCAAJ,EADP;;AAAA,oDAEc,IAAIC,8CAAJ,CAA2BC,MAA3B,CAFd;;AAAA,4CAGM,IAAIC,8BAAJ,CAAmBC,MAAM,CAACC,OAA1B,CAHN;;AAAA,wCAIc,IAAIC,sBAAJ,EAJd;;AAAA,yCAKG,KALH;AAAA;;AAOF,QAAJC,IAAI,CAACC,OAAD,EAAsC;AACrD,QAAI,CAAC,KAAKC,WAAV,EAAuB;AAAA;;AACrB,YAAMC,gBAAgB,GAAG,KAAKC,UAAL,CAAgBJ,IAAhB,CAAqBC,OAArB,CAAzB,CADqB,CAGrB;;AACA,UAAI,OAAOA,OAAO,CAACI,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 'react-native';\nimport type { ISDKOptions } from './types/sdk-options';\nimport type { UserFeedbackOptions, UserFeedbackResult } from './user-feedback';\nimport { DefaultUserFeedbackOptions } from './user-feedback';\nimport type { DeviceKeyValue } from './types/device';\nimport type { ILogEntry } from './types/log';\nimport { StringFormatter } from './string-formatter';\nimport { LogLevel } from \"./types/log\";\nimport { OverrideConsoleMethods } from \"./override-console-methods\";\nimport { PrintToConsole } from \"./print-to-console\";\nimport { SDKOptions } from \"./sdk-options\";\n\nconst LINKING_ERROR =\n `The package '@bugfender/rn-bugfender' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo managed workflow\\n';\n\nconst RnBugfender = NativeModules.RnBugfender\n ? NativeModules.RnBugfender\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\nclass BugfenderClass {\n private stringFormatter = new StringFormatter();\n private overrideConsoleMethods = new OverrideConsoleMethods(window);\n private printToConsole = new PrintToConsole(global.console);\n private sdkOptions: SDKOptions = new SDKOptions();\n private initialized = false;\n\n public async init(options: ISDKOptions): Promise<void> {\n if (!this.initialized) {\n const validatedOptions = this.sdkOptions.init(options);\n\n // Needs to be executed prior initialization\n if (typeof options.deviceName !== 'undefined') {\n RnBugfender.overrideDeviceName(options.deviceName);\n }\n\n // Library initialization\n Platform.OS === 'ios'\n ? RnBugfender.activateLogger(validatedOptions.appKey)\n : RnBugfender.init(validatedOptions.appKey, false);\n\n if (typeof validatedOptions.apiURL !== 'undefined') {\n RnBugfender.setApiUrl(validatedOptions.apiURL);\n }\n\n if (typeof validatedOptions.baseURL !== 'undefined') {\n RnBugfender.setBaseUrl(validatedOptions.baseURL);\n }\n\n if (validatedOptions.enableLogcatLogging) {\n RnBugfender.enableLogcatLogging();\n }\n\n if (validatedOptions.logUIEvents) {\n RnBugfender.enableUIEventLogging();\n }\n\n if (validatedOptions.registerErrorHandler) {\n RnBugfender.enableCrashReporting();\n }\n\n if (validatedOptions.overrideConsoleMethods) {\n this.overrideConsoleMethods.init(this.stringFormatter);\n }\n\n this.printToConsole.init(validatedOptions.printToConsole ?? true);\n\n this.initialized = true;\n }\n }\n\n /**\n * @returns Bugfender dashboard URL for the device\n */\n public getDeviceURL(): Promise<string> {\n return RnBugfender.getDeviceUrl();\n }\n\n /**\n * @returns Bugfender dashboard URL for the current session\n */\n public getSessionURL(): Promise<string> {\n return RnBugfender.getSessionUrl();\n }\n\n /**\n * Show a modal which asks for feedback. Once the user closes the modal or sends the feedback\n * the returned promise resolves with the result.\n *\n * ```typescript\n * Bugfender.getUserFeedback().then((result) => {\n * if (result.isSent) {\n * // User sent the feedback\n * // `result.feedbackURL` contains the Bugfender feedback URL\n * } else {\n * // User closed the modal without sending the feedback\n * }\n * });\n * ```\n *\n * @param options Options object to configure modal strings\n * @returns Promise which resolves once the user closes the modal or sends the feedback\n */\n public async getUserFeedback(\n options?: UserFeedbackOptions\n ): Promise<UserFeedbackResult> {\n return new Promise<UserFeedbackResult>((resolve) => {\n options = {\n ...new DefaultUserFeedbackOptions(),\n ...(options ?? {}),\n };\n\n return RnBugfender.showUserFeedback(\n options.title,\n options.hint,\n options.subjectPlaceholder,\n options.feedbackPlaceholder,\n options.submitLabel,\n options.closeLabel\n ).then(\n (value: string) => {\n resolve({\n isSent: true,\n feedbackURL: value,\n });\n },\n (_: any) => {\n resolve({\n isSent: false,\n });\n }\n );\n });\n }\n\n /**\n * @param obj A JavaScript value to output\n * @param objs List of optional JavaScript values to output\n */\n public log(obj: unknown, ...objs: unknown[]): void;\n /**\n * String message with optional substitutions. This mimicks que the `window.console` template messages. [Learn more in MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).\n *\n * @param msg Message with optional `%` placeholders\n * @param subst Optional substitutions list\n */\n public log(msg: string, ...subst: unknown[]): void;\n public log(...parameters: unknown[]): void {\n this.printToConsole.log(...parameters);\n\n let message = this.stringFormatter.format([...parameters]);\n RnBugfender.debug('', message);\n }\n\n /**\n * @param obj A JavaScript value to output\n * @param objs List of optional JavaScript values to output\n */\n public warn(obj: unknown, ...objs: unknown[]): void;\n /**\n * String message with optional substitutions. This mimicks que the `window.console` template messages. [Learn more in MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).\n *\n * @param msg Message with optional `%` placeholders\n * @param subst Optional substitutions list\n */\n public warn(msg: string, ...subst: unknown[]): void;\n public warn(...parameters: unknown[]): void {\n this.printToConsole.warn(...parameters);\n\n let message = this.stringFormatter.format([...parameters]);\n RnBugfender.warning('', message);\n }\n\n /**\n * @param obj A JavaScript value to output\n * @param objs List of optional JavaScript values to output\n */\n public error(obj: unknown, ...objs: unknown[]): void;\n /**\n * String message with optional substitutions. This mimicks que the `window.console` template messages. [Learn more in MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).\n *\n * @param msg Message with optional `%` placeholders\n * @param subst Optional substitutions list\n */\n public error(msg: string, ...subst: unknown[]): void;\n public error(...parameters: unknown[]): void {\n this.printToConsole.error(...parameters);\n\n let message = this.stringFormatter.format([...parameters]);\n RnBugfender.error('', message);\n }\n\n /**\n * @param obj A JavaScript value to output\n * @param objs List of optional JavaScript values to output\n */\n public trace(obj: unknown, ...objs: unknown[]): void;\n /**\n * String message with optional substitutions. This mimicks que the `window.console` template messages. [Learn more in MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).\n *\n * @param msg Message with optional `%` placeholders\n * @param subst Optional substitutions list\n */\n public trace(msg: string, ...subst: unknown[]): void;\n public trace(...parameters: unknown[]): void {\n this.printToConsole.trace(...parameters);\n\n let message = this.stringFormatter.format([...parameters]);\n RnBugfender.trace('', message);\n }\n\n /**\n * @param obj A JavaScript value to output\n * @param objs List of optional JavaScript values to output\n */\n public info(obj: unknown, ...objs: unknown[]): void;\n /**\n * String message with optional substitutions. This mimicks que the `window.console` template messages. [Learn more in MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).\n *\n * @param msg Message with optional `%` placeholders\n * @param subst Optional substitutions list\n */\n public info(msg: string, ...subst: unknown[]): void;\n public info(...parameters: unknown[]): void {\n this.printToConsole.info(...parameters);\n\n let message = this.stringFormatter.format([...parameters]);\n RnBugfender.info('', message);\n }\n\n /**\n * @param obj A JavaScript value to output\n * @param objs List of optional JavaScript values to output\n */\n public fatal(obj: unknown, ...objs: unknown[]): void;\n /**\n * String message with optional substitutions. This mimicks que the `window.console` template messages. [Learn more in MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions).\n *\n * @param msg Message with optional `%` placeholders\n * @param subst Optional substitutions list\n */\n public fatal(msg: string, ...subst: unknown[]): void;\n public fatal(...parameters: unknown[]): void {\n this.printToConsole.error(...parameters);\n\n let message = this.stringFormatter.format([...parameters]);\n RnBugfender.fatal('', message);\n }\n\n /**\n * Remove a device associated key-value pair. [Learn more](https://bugfender.com/blog/associated-device-information/).\n *\n * @param key Key identifier\n */\n public removeDeviceKey(key: string): void {\n RnBugfender.removeDeviceKey(key);\n this.printToConsole.info(`Device key \"${key}\" removed`);\n }\n\n /**\n * Use this method if you need more control over the data sent while logging. See `ILogEntry` interface reference to see all the accepted properties.\n *\n * @param log Log object that complies with `ILogEntry` interface.\n */\n public sendLog(log: ILogEntry): void {\n this.printToConsole.printLog(log);\n\n RnBugfender.log(\n log.line ?? 0,\n log.method ?? '',\n log.file ?? '',\n log.level ?? LogLevel.Debug,\n log.tag ?? '',\n log.text ?? ''\n );\n }\n\n /**\n * Send an issue.\n *\n * @param title - Title\n * @param text - Text content\n * @returns Bugfender dashboard URL for the issue.\n */\n public sendIssue(title: string, text: string): Promise<string> {\n this.printToConsole.warn(`Issue: ${title}.\\n${text}`);\n return RnBugfender.sendIssue(title, text);\n }\n\n /**\n * Send a crash report.\n *\n * @param title - Title\n * @param text - Text content\n * @returns Bugfender dashboard URL for the crash.\n */\n public sendCrash(title: string, text: string): Promise<string> {\n this.printToConsole.error(`Crash: ${title}.\\n${text}`);\n return RnBugfender.sendCrash(title, text);\n }\n\n /**\n * Send an user feedback.\n *\n * @param title - Title/Subject\n * @param text - Feedback text\n * @returns Bugfender dashboard URL for the feedback.\n */\n public sendUserFeedback(title: string, text: string): Promise<string> {\n this.printToConsole.info(`User Feedback: ${title}.\\n${text}`);\n return RnBugfender.sendUserFeedback(title, text);\n }\n\n /**\n * Set a device associated key-value pair. [Learn more](https://bugfender.com/blog/associated-device-information/).\n *\n * @param key Key identifier.\n * @param value Value.\n */\n public setDeviceKey(key: string, value: DeviceKeyValue): void {\n this.printToConsole.info(`Device key \"${key}\" set to \"${value}\"`);\n\n if (typeof value === 'boolean') {\n RnBugfender.setDeviceBoolean(key, value);\n } else if (typeof value === 'string') {\n RnBugfender.setDeviceString(key, value);\n } else {\n // typeof value === 'number'\n if (Number.isInteger(value)) {\n RnBugfender.setDeviceInteger(key, value);\n } else {\n RnBugfender.setDeviceFloat(key, value);\n }\n }\n }\n\n /**\n * Synchronizes all logs and issues with the server once, regardless if this device is enabled or not.\n *\n * Logs and issues are synchronized only once. After that, the logs are again sent according to the enabled flag\n * in the Bugfender Console.\n */\n public forceSendOnce(): void {\n this.printToConsole.info(`Force send once`);\n RnBugfender.forceSendOnce();\n }\n}\n\nexport {\n BugfenderClass, RnBugfender\n}\n"]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Bugfender = void 0;
7
+ Object.defineProperty(exports, "LogLevel", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _log.LogLevel;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "SDKOptionsBuilder", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _sdkOptions.SDKOptionsBuilder;
17
+ }
18
+ });
19
+
20
+ var _log = require("./types/log");
21
+
22
+ var _sdkOptions = require("./types/sdk-options");
23
+
24
+ var _bugfender = require("./bugfender");
25
+
26
+ const Bugfender = new _bugfender.BugfenderClass();
27
+ exports.Bugfender = Bugfender;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.tsx"],"names":["Bugfender","BugfenderClass"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,MAAMA,SAAS,GAAG,IAAIC,yBAAJ,EAAlB","sourcesContent":["import { LogLevel } from './types/log';\nimport { SDKOptionsBuilder } from './types/sdk-options';\nimport { BugfenderClass } from './bugfender';\n\nconst Bugfender = new BugfenderClass();\n\nexport { Bugfender, LogLevel, SDKOptionsBuilder };\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Bugfender", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _sdk.Bugfender;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "LogLevel", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _log.LogLevel;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "SDKOptionsBuilder", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _sdkOptions.SDKOptionsBuilder;
22
+ }
23
+ });
24
+
25
+ var _log = require("./types/log");
26
+
27
+ var _sdkOptions = require("./types/sdk-options");
28
+
29
+ var _sdk = require("@bugfender/sdk");
30
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.web.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA","sourcesContent":["import { LogLevel } from './types/log';\nimport { SDKOptionsBuilder } from './types/sdk-options';\nimport { Bugfender } from '@bugfender/sdk';\n\nexport { Bugfender, LogLevel, SDKOptionsBuilder };\n"]}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.OverrideConsoleMethods = void 0;
7
+
8
+ var _bugfender = require("./bugfender");
9
+
10
+ /* eslint-disable @typescript-eslint/no-explicit-any */
11
+
12
+ /**
13
+ * Overrides the `window.console` methods in order to execute the Bugfender equivalent logging
14
+ * methods while keeping the original browser functionality.
15
+ */
16
+ class OverrideConsoleMethods {
17
+ constructor(window) {
18
+ this.window = window;
19
+ }
20
+
21
+ init(stringFormatter) {
22
+ this.window.console = function (console) {
23
+ return { ...console,
24
+ log: function () {
25
+ for (var _len = arguments.length, parameters = new Array(_len), _key = 0; _key < _len; _key++) {
26
+ parameters[_key] = arguments[_key];
27
+ }
28
+
29
+ console.log(...parameters);
30
+ let message = stringFormatter.format([...parameters]);
31
+
32
+ _bugfender.RnBugfender.debug('', message);
33
+ },
34
+ debug: function () {
35
+ for (var _len2 = arguments.length, parameters = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
36
+ parameters[_key2] = arguments[_key2];
37
+ }
38
+
39
+ console.debug(...parameters);
40
+ let message = stringFormatter.format([...parameters]);
41
+
42
+ _bugfender.RnBugfender.debug('', message);
43
+ },
44
+ trace: function () {
45
+ for (var _len3 = arguments.length, parameters = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
46
+ parameters[_key3] = arguments[_key3];
47
+ }
48
+
49
+ console.trace(...parameters);
50
+ let message = stringFormatter.format([...parameters]);
51
+
52
+ _bugfender.RnBugfender.trace('', message);
53
+ },
54
+ info: function () {
55
+ for (var _len4 = arguments.length, parameters = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
56
+ parameters[_key4] = arguments[_key4];
57
+ }
58
+
59
+ console.info(...parameters);
60
+ let message = stringFormatter.format([...parameters]);
61
+
62
+ _bugfender.RnBugfender.info('', message);
63
+ },
64
+ warn: function () {
65
+ for (var _len5 = arguments.length, parameters = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
66
+ parameters[_key5] = arguments[_key5];
67
+ }
68
+
69
+ console.warn(...parameters);
70
+ let message = stringFormatter.format([...parameters]);
71
+
72
+ _bugfender.RnBugfender.warning('', message);
73
+ },
74
+ error: function () {
75
+ for (var _len6 = arguments.length, parameters = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
76
+ parameters[_key6] = arguments[_key6];
77
+ }
78
+
79
+ console.error(...parameters);
80
+ let message = stringFormatter.format([...parameters]);
81
+
82
+ _bugfender.RnBugfender.error('', message);
83
+ }
84
+ };
85
+ }(this.window.console);
86
+ }
87
+
88
+ }
89
+
90
+ exports.OverrideConsoleMethods = OverrideConsoleMethods;
91
+ //# sourceMappingURL=override-console-methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["override-console-methods.ts"],"names":["OverrideConsoleMethods","constructor","window","init","stringFormatter","console","log","parameters","message","format","RnBugfender","debug","trace","info","warn","warning","error"],"mappings":";;;;;;;AACA;;AADA;;AAIA;AACA;AACA;AACA;AACO,MAAMA,sBAAN,CAA6B;AAClCC,EAAAA,WAAW,CACCC,MADD,EAET;AAAA,SADUA,MACV,GADUA,MACV;AACD;;AAEMC,EAAAA,IAAI,CAACC,eAAD,EAAyC;AAEjD,SAAKF,MAAN,CAAqBG,OAArB,GAA+B,UAAUA,OAAV,EAA4B;AACzD,aAAO,EACL,GAAGA,OADE;AAELC,QAAAA,GAAG,EAAE,YAAoC;AAAA,4CAAvBC,UAAuB;AAAvBA,YAAAA,UAAuB;AAAA;;AACvCF,UAAAA,OAAO,CAACC,GAAR,CAAY,GAAGC,UAAf;AACA,cAAIC,OAAO,GAAGJ,eAAe,CAACK,MAAhB,CAAuB,CAAC,GAAGF,UAAJ,CAAvB,CAAd;;AACAG,iCAAYC,KAAZ,CAAkB,EAAlB,EAAsBH,OAAtB;AACD,SANI;AAOLG,QAAAA,KAAK,EAAE,YAAoC;AAAA,6CAAvBJ,UAAuB;AAAvBA,YAAAA,UAAuB;AAAA;;AACzCF,UAAAA,OAAO,CAACM,KAAR,CAAc,GAAGJ,UAAjB;AACA,cAAIC,OAAO,GAAGJ,eAAe,CAACK,MAAhB,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AAkB,EAAlB,EAAsBR,OAAtB;AACD;AA/BI,OAAP;AAiCD,KAlC8B,CAkC5B,KAAKN,MAAN,CAAqBG,OAlCQ,CAA/B;AAmCD;;AA3CiC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {RnBugfender} from \"./bugfender\";\nimport type {StringFormatter} from \"./string-formatter\";\n\n/**\n * Overrides the `window.console` methods in order to execute the Bugfender equivalent logging\n * methods while keeping the original browser functionality.\n */\nexport class OverrideConsoleMethods {\n constructor(\n protected window: Window,\n ) {\n }\n\n public init(stringFormatter: StringFormatter): void {\n\n (this.window as any).console = function (console: Console) {\n return {\n ...console,\n log: function (...parameters: unknown[]) {\n console.log(...parameters);\n let message = stringFormatter.format([...parameters]);\n RnBugfender.debug('', message);\n },\n debug: function (...parameters: unknown[]) {\n console.debug(...parameters);\n let message = stringFormatter.format([...parameters]);\n RnBugfender.debug('', message);\n },\n trace: function (...parameters: unknown[]) {\n console.trace(...parameters);\n let message = stringFormatter.format([...parameters]);\n RnBugfender.trace('', message);\n },\n info: function (...parameters: unknown[]) {\n console.info(...parameters);\n let message = stringFormatter.format([...parameters]);\n RnBugfender.info('', message);\n },\n warn: function (...parameters: unknown[]) {\n console.warn(...parameters);\n let message = stringFormatter.format([...parameters]);\n RnBugfender.warning('', message);\n },\n error: function (...parameters: unknown[]) {\n console.error(...parameters);\n let message = stringFormatter.format([...parameters]);\n RnBugfender.error('', message);\n },\n };\n }((this.window as any).console);\n }\n}\n"]}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PrintToConsole = void 0;
7
+
8
+ var _util = require("util");
9
+
10
+ var _log = require("./types/log");
11
+
12
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
13
+
14
+ class PrintToConsole {
15
+ constructor(console) {
16
+ _defineProperty(this, "printToConsole", false);
17
+
18
+ this.console = console;
19
+ }
20
+
21
+ init(printToConsole) {
22
+ this.printToConsole = printToConsole;
23
+ }
24
+
25
+ error() {
26
+ if (this.printToConsole) {
27
+ this.console.error(...arguments);
28
+ }
29
+ }
30
+
31
+ info() {
32
+ if (this.printToConsole) {
33
+ this.console.info(...arguments);
34
+ }
35
+ }
36
+
37
+ log() {
38
+ if (this.printToConsole) {
39
+ this.console.log(...arguments);
40
+ }
41
+ }
42
+
43
+ debug() {
44
+ if (this.printToConsole) {
45
+ this.console.debug(...arguments);
46
+ }
47
+ }
48
+
49
+ trace() {
50
+ if (this.printToConsole) {
51
+ this.console.trace(...arguments);
52
+ }
53
+ }
54
+
55
+ warn() {
56
+ if (this.printToConsole) {
57
+ this.console.warn(...arguments);
58
+ }
59
+ }
60
+
61
+ printLog(log) {
62
+ if (this.printToConsole) {
63
+ // Log to browser console
64
+ // debug, warning, error, trace, info, fatal
65
+ const levelToMethod = ['log', 'warn', 'error', 'trace', 'info', 'error'];
66
+ const method = levelToMethod[log.level || _log.LogLevel.Debug];
67
+ const tag = log.tag ? `[${log.tag}] ` : '';
68
+ const location = [log.file || '', log.method || '', log.line || ''].filter(p => p !== '').join(':');
69
+ const message = `${tag}${(0, _util.format)(log.text)} ${location}`; // @ts-ignore
70
+
71
+ this.console[method](message);
72
+ }
73
+ }
74
+
75
+ }
76
+
77
+ exports.PrintToConsole = PrintToConsole;
78
+ //# sourceMappingURL=print-to-console.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["print-to-console.ts"],"names":["PrintToConsole","constructor","console","init","printToConsole","error","info","log","debug","trace","warn","printLog","levelToMethod","method","level","LogLevel","Debug","tag","location","file","line","filter","p","join","message","text"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAEO,MAAMA,cAAN,CAAqB;AAG1BC,EAAAA,WAAW,CACUC,OADV,EAET;AAAA,4CAJkC,KAIlC;;AAAA,SADmBA,OACnB,GADmBA,OACnB;AACD;;AAEMC,EAA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AAiBZ,GAAG,CAACM,MAAJ,IAAc,EAA/B,EAAmCN,GAAG,CAACa,IAAJ,IAAY,EAA/C,EAAmDC,MAAnD,CAA0DC,CAAC,IAAIA,CAAC,KAAK,EAArE,EAAyEC,IAAzE,CAA8E,GAA9E,CAAjB;AACA,YAAMC,OAAO,GAAI,GAAEP,GAAI,GAAE,kBAAOV,GAAG,CAACkB,IAAX,CAAiB,IAAGP,QAAS,EAAtD,CAPuB,CASvB;;AACA,WAAKhB,OAAL,CAAaW,MAAb,EAAqBW,OAArB;AACD;AACF;;AA7DyB","sourcesContent":["import {format} from 'util';\nimport type {ILogEntry} from \"./types/log\";\nimport {LogLevel} from \"./types/log\";\n\nexport class PrintToConsole {\n protected printToConsole: boolean = false;\n\n constructor(\n protected readonly console: Console,\n ) {\n }\n\n public init(printToConsole: boolean): void {\n this.printToConsole = printToConsole;\n }\n\n public error(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.error(...parameters);\n }\n }\n\n public info(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.info(...parameters);\n }\n }\n\n public log(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.log(...parameters);\n }\n }\n\n public debug(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.debug(...parameters);\n }\n }\n\n public trace(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.trace(...parameters);\n }\n }\n\n public warn(...parameters: unknown[]): void {\n if (this.printToConsole) {\n this.console.warn(...parameters);\n }\n }\n\n public printLog(log: ILogEntry): void {\n if (this.printToConsole) {\n // Log to browser console\n // debug, warning, error, trace, info, fatal\n const levelToMethod = ['log', 'warn', 'error', 'trace', 'info', 'error'];\n const method = levelToMethod[log.level || LogLevel.Debug];\n const tag = log.tag ? `[${log.tag}] ` : '';\n const location = [log.file || '', log.method || '', log.line || ''].filter(p => p !== '').join(':');\n const message = `${tag}${format(log.text)} ${location}`;\n\n // @ts-ignore\n this.console[method](message);\n }\n }\n}\n"]}