@dynatrace/react-native-plugin 2.337.3 → 2.341.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 (57) hide show
  1. package/README.md +122 -21
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +0 -1
  4. package/files/default.config.js +2 -0
  5. package/files/plugin.gradle +1 -1
  6. package/instrumentation/BabelPluginDynatrace.js +1 -1
  7. package/instrumentation/DynatraceInstrumentation.js +1 -1
  8. package/instrumentation/jsx/CreateElement.js +5 -9
  9. package/instrumentation/jsx/ElementHelper.js +5 -6
  10. package/instrumentation/jsx/JsxDevRuntime.js +33 -31
  11. package/instrumentation/jsx/JsxRuntime.js +30 -30
  12. package/instrumentation/jsx/JsxRuntimeHelpers.js +14 -0
  13. package/instrumentation/jsx/components/ClassComponent.js +6 -9
  14. package/instrumentation/jsx/components/ComponentUtil.js +24 -25
  15. package/instrumentation/libs/UserInteraction.js +27 -24
  16. package/instrumentation/libs/react-native/RefreshControl.js +5 -9
  17. package/instrumentation/libs/react-navigation/ReactNavigation.js +7 -4
  18. package/instrumentation/libs/withOnPressMonitoring.js +67 -55
  19. package/lib/core/Application.js +5 -2
  20. package/lib/core/Dynatrace.js +113 -44
  21. package/lib/core/DynatraceAction.js +78 -23
  22. package/lib/core/DynatraceInternal.js +39 -26
  23. package/lib/core/DynatraceRootAction.js +6 -3
  24. package/lib/core/DynatraceWebRequestTiming.js +25 -4
  25. package/lib/core/ErrorHandler.js +46 -19
  26. package/lib/core/NullAction.js +1 -3
  27. package/lib/core/logging/ConsoleLogger.js +17 -6
  28. package/lib/core/logging/LogMessages.js +764 -0
  29. package/lib/core/logging/LogType.js +9 -0
  30. package/lib/core/util/JsonUtils.js +6 -0
  31. package/lib/features/ui-interaction/IUserInteractionEvent.js +1 -1
  32. package/lib/features/ui-interaction/Runtime.js +7 -3
  33. package/lib/features/ui-interaction/TouchMetaResolver.js +4 -3
  34. package/lib/next/Dynatrace.js +42 -22
  35. package/lib/next/appstart/AppStartObserver.js +7 -2
  36. package/lib/next/events/EventPipeline.js +12 -5
  37. package/lib/next/events/EventTimestamp.js +5 -1
  38. package/lib/next/events/ExceptionEventData.js +1 -1
  39. package/lib/next/events/HttpRequestEventData.js +18 -9
  40. package/lib/next/events/interface/HttpRequestEventDataTypes.js +2 -0
  41. package/lib/next/events/modifier/BaseDataEventModifier.js +4 -1
  42. package/lib/next/events/modifier/EventModifierUtil.js +12 -5
  43. package/lib/next/events/modifier/ModifyEventValidation.js +99 -58
  44. package/lib/next/events/modifier/SendEventValidation.js +10 -4
  45. package/lib/next/events/modifier/StringLengthEventModifier.js +4 -1
  46. package/lib/next/events/modifier/ValueRestrictionModifier.js +5 -1
  47. package/lib/next/events/spec/EventSpecContstants.js +6 -2
  48. package/lib/next/util/TraceContextUtils.js +4 -3
  49. package/package.json +7 -5
  50. package/react-native-dynatrace.podspec +1 -1
  51. package/scripts/Config.js +7 -3
  52. package/scripts/DebugFlag.js +20 -0
  53. package/scripts/FileOperationHelper.js +15 -39
  54. package/scripts/Logger.js +2 -3
  55. package/scripts/core/InstrumentCall.js +101 -80
  56. package/scripts/util/CustomArgumentUtil.js +8 -6
  57. package/types.d.ts +159 -8
@@ -18,6 +18,7 @@ const DynatraceBridge_1 = require("./DynatraceBridge");
18
18
  const DataCollectionLevel_1 = require("./model/DataCollectionLevel");
19
19
  const UserPrivacyOptions_1 = require("./UserPrivacyOptions");
20
20
  const ConsoleLogger_1 = require("./logging/ConsoleLogger");
21
+ const LogMessages_1 = require("./logging/LogMessages");
21
22
  const ConfigurationHandler_1 = require("./configuration/ConfigurationHandler");
22
23
  const DynatraceRootAction_1 = require("./DynatraceRootAction");
23
24
  const NullRootAction_1 = require("./NullRootAction");
@@ -36,7 +37,7 @@ exports.Dynatrace = {
36
37
  (0, ErrorHandler_1.startErrorHandler)(configuration.reportFatalErrorAsCrash);
37
38
  }
38
39
  else {
39
- logger.debug('Dynatrace error handler will not be enabled as errorHandler was set to false!');
40
+ logger.debug(LogMessages_1.LogMessage.ERROR_HANDLER_DISABLED);
40
41
  }
41
42
  Application_1.ApplicationHandler.startup(configuration);
42
43
  }
@@ -45,7 +46,7 @@ exports.Dynatrace = {
45
46
  }
46
47
  }
47
48
  else {
48
- logger.debug('Configuration is already available! Duplicated startup blocked.');
49
+ logger.debug(LogMessages_1.LogMessage.CONFIGURATION_DUPLICATE_STARTUP);
49
50
  }
50
51
  }),
51
52
  withMonitoring: (Component, name) => {
@@ -80,17 +81,20 @@ exports.Dynatrace = {
80
81
  key = 'DEFAULT_' + DynatraceInternal_1.DynatraceInternal.getCounter();
81
82
  }
82
83
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(name)) {
83
- logger.debug(`enterManualAction(${name})`);
84
+ logger.debug(LogMessages_1.LogMessage.ENTER_MANUAL_ACTION, { name });
84
85
  DynatraceBridge_1.DynatraceNative.enterManualAction(name, key, platform === null || platform === void 0 ? void 0 : platform.toString());
85
86
  return new DynatraceRootAction_1.DynatraceRootAction(key, name);
86
87
  }
87
88
  else {
88
- logger.debug('Action Name was empty or null! Action will have no effect.');
89
+ logger.debug(LogMessages_1.LogMessage.ACTION_NAME_EMPTY);
89
90
  return new NullRootAction_1.NullRootAction();
90
91
  }
91
92
  }
92
93
  else {
93
- logger.info(`enterManualAction(${name}): React Native plugin has not been started yet! Action can't be created!`);
94
+ logger.info(LogMessages_1.LogMessage.ACTION_NOT_STARTED, {
95
+ name,
96
+ actionType: 'enterManualAction',
97
+ });
94
98
  return new NullRootAction_1.NullRootAction();
95
99
  }
96
100
  },
@@ -107,28 +111,34 @@ exports.Dynatrace = {
107
111
  key = 'DEFAULT_' + DynatraceInternal_1.DynatraceInternal.getCounter();
108
112
  }
109
113
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(name)) {
110
- logger.debug(`enterAutoAction(${name})`);
114
+ logger.debug(LogMessages_1.LogMessage.ENTER_AUTO_ACTION, { name });
111
115
  DynatraceBridge_1.DynatraceNative.enterAction(name, key, platform === null || platform === void 0 ? void 0 : platform.toString());
112
116
  return new DynatraceAction_1.DynatraceAction(key, name, false);
113
117
  }
114
118
  else {
115
- logger.debug('Action Name was empty or null! Action will have no effect.');
119
+ logger.debug(LogMessages_1.LogMessage.ACTION_NAME_EMPTY);
116
120
  return new NullAction_1.NullAction();
117
121
  }
118
122
  }
119
123
  else {
120
- logger.info(`enterAutoAction(${name}): React Native plugin has not been started yet! Action can't be created!`);
124
+ logger.info(LogMessages_1.LogMessage.ACTION_NOT_STARTED, {
125
+ name,
126
+ actionType: 'enterAutoAction',
127
+ });
121
128
  return new NullAction_1.NullAction();
122
129
  }
123
130
  },
124
131
  reportError: (errorName, errorCode, platform) => {
125
132
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
126
- logger.debug(`reportError(${errorName}, ${errorCode})`);
133
+ logger.debug(LogMessages_1.LogMessage.REPORT_ERROR, { errorName, errorCode });
127
134
  DynatraceBridge_1.DynatraceNative.reportErrorWithoutStacktrace(errorName, errorCode, platform === null || platform === void 0 ? void 0 : platform.toString());
128
135
  DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportError(errorName, errorCode);
129
136
  }
130
137
  else {
131
- logger.info(`reportError(${errorName}, ${errorCode}): React Native plugin has not been started yet! Error will not be reported!`);
138
+ logger.info(LogMessages_1.LogMessage.REPORT_ERROR_NOT_STARTED, {
139
+ errorName,
140
+ errorCode,
141
+ });
132
142
  }
133
143
  },
134
144
  reportErrorWithStacktrace: (errorName, reason, stacktrace, platform) => {
@@ -139,12 +149,20 @@ exports.Dynatrace = {
139
149
  reason = reason.substring(0, reasonNewLineIndex);
140
150
  }
141
151
  }
142
- logger.debug(`reportErrorStacktrace(${errorName}, ${reason}, ${stacktrace})`);
152
+ logger.debug(LogMessages_1.LogMessage.REPORT_ERROR_WITH_STACKTRACE, {
153
+ errorName,
154
+ reason,
155
+ stacktrace,
156
+ });
143
157
  DynatraceBridge_1.DynatraceNative.reportError(errorName, '-', reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
144
158
  DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportErrorWithStacktrace(errorName, reason, stacktrace);
145
159
  }
146
160
  else {
147
- logger.info(`reportErrorStacktrace(${errorName}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Error will not be reported!`);
161
+ logger.info(LogMessages_1.LogMessage.REPORT_ERROR_WITH_STACKTRACE_NOT_STARTED, {
162
+ errorName,
163
+ reason,
164
+ stacktrace,
165
+ });
148
166
  }
149
167
  },
150
168
  reportErrorStacktrace: (errorName, errorValue, reason, stacktrace, platform) => {
@@ -155,12 +173,22 @@ exports.Dynatrace = {
155
173
  reason = reason.substring(0, reasonNewLineIndex);
156
174
  }
157
175
  }
158
- logger.debug(`reportErrorStacktrace(${errorName}, ${errorValue}, ${reason}, ${stacktrace})`);
176
+ logger.debug(LogMessages_1.LogMessage.REPORT_ERROR_STACKTRACE, {
177
+ errorName,
178
+ errorValue,
179
+ reason,
180
+ stacktrace,
181
+ });
159
182
  DynatraceBridge_1.DynatraceNative.reportError(errorName, errorValue, reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
160
183
  DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportErrorStacktrace(errorName, errorValue, reason, stacktrace);
161
184
  }
162
185
  else {
163
- logger.info(`reportErrorStacktrace(${errorName}, ${errorValue}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Error will not be reported!`);
186
+ logger.info(LogMessages_1.LogMessage.REPORT_ERROR_STACKTRACE_NOT_STARTED, {
187
+ errorName,
188
+ errorValue,
189
+ reason,
190
+ stacktrace,
191
+ });
164
192
  }
165
193
  },
166
194
  reportCrash: (crashName, reason, stacktrace, platform) => {
@@ -172,13 +200,21 @@ exports.Dynatrace = {
172
200
  reason = reason.substring(0, reasonNewLineIndex);
173
201
  }
174
202
  }
175
- logger.debug(`reportCrash(${crashName}, ${reason}, ${stacktrace})`);
203
+ logger.debug(LogMessages_1.LogMessage.REPORT_CRASH, {
204
+ crashName,
205
+ reason,
206
+ stacktrace,
207
+ });
176
208
  DynatraceBridge_1.DynatraceNative.reportCrash(crashName, reason, stacktrace, false, platform === null || platform === void 0 ? void 0 : platform.toString());
177
209
  DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportCrash(crashName, reason, stacktrace);
178
210
  }
179
211
  }
180
212
  else {
181
- logger.info(`reportCrash(${crashName}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Crash will not be reported!`);
213
+ logger.info(LogMessages_1.LogMessage.REPORT_CRASH_NOT_STARTED, {
214
+ crashName,
215
+ reason,
216
+ stacktrace,
217
+ });
182
218
  }
183
219
  },
184
220
  reportCrashWithException: (crashName, crash, platform) => {
@@ -192,110 +228,139 @@ exports.Dynatrace = {
192
228
  crashReason = crashReason.substring(0, reasonNewLineIndex);
193
229
  }
194
230
  }
195
- logger.debug(`reportCrashWithException(${crashName}, ${crash.stack})`);
231
+ logger.debug(LogMessages_1.LogMessage.REPORT_CRASH_WITH_EXCEPTION, {
232
+ crashName,
233
+ stack: crash.stack,
234
+ });
196
235
  DynatraceBridge_1.DynatraceNative.reportCrash(crashName, crashReason, crash.stack, true, platform === null || platform === void 0 ? void 0 : platform.toString());
197
236
  DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportCrashWithException(crashName, crash);
198
237
  }
199
238
  }
200
239
  else {
201
- logger.info(`reportCrashWithException(${crashName}, ${crash}): React Native plugin has not been started yet! Crash will not be reported!`);
240
+ logger.info(LogMessages_1.LogMessage.REPORT_CRASH_WITH_EXCEPTION_NOT_STARTED, {
241
+ crashName,
242
+ crash: String(crash),
243
+ });
202
244
  }
203
245
  },
204
246
  sendBizEvent: (type, attributes = {}, platform) => {
205
247
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
206
248
  if (StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(type)) {
207
- logger.debug(`sendBizEvent(${type}, ${attributes})): Type must be a non empty string`);
249
+ logger.debug(LogMessages_1.LogMessage.SEND_BIZ_EVENT_TYPE_EMPTY, {
250
+ type,
251
+ attributes: 'attributes',
252
+ });
208
253
  return;
209
254
  }
210
255
  if (typeof attributes !== 'object' ||
211
256
  attributes === null ||
212
257
  Array.isArray(attributes)) {
213
- logger.debug(`sendBizEvent(${type}, ${attributes})): Payload toplevel must be an object`);
258
+ logger.debug(LogMessages_1.LogMessage.SEND_BIZ_EVENT_PAYLOAD_INVALID, {
259
+ type,
260
+ attributes: String(attributes),
261
+ });
214
262
  return;
215
263
  }
216
264
  const internalAttributes = Object.assign({}, attributes);
217
- logger.debug(`sendBizEvent(${type}, ${internalAttributes})`);
265
+ logger.debug(LogMessages_1.LogMessage.SEND_BIZ_EVENT, {
266
+ type,
267
+ attributes: JSON.stringify(internalAttributes),
268
+ });
218
269
  DynatraceBridge_1.DynatraceNative.sendBizEvent(type, internalAttributes, platform === null || platform === void 0 ? void 0 : platform.toString());
219
270
  }
220
271
  else {
221
- logger.info(`sendBizEvent(${type}, ${attributes}): React Native plugin has not been started yet! Biz Event will not be reported!`);
272
+ logger.info(LogMessages_1.LogMessage.SEND_BIZ_EVENT_NOT_STARTED, {
273
+ type,
274
+ attributes: 'attributes',
275
+ });
222
276
  }
223
277
  },
224
278
  endSession: (platform) => {
225
279
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
226
- logger.debug('Dynatrace endSession()');
280
+ logger.debug(LogMessages_1.LogMessage.END_SESSION);
227
281
  DynatraceBridge_1.DynatraceNative.endVisit(platform === null || platform === void 0 ? void 0 : platform.toString());
228
282
  }
229
283
  else {
230
- logger.info('endSession(): React Native plugin has not been started yet! Session will not be ended!');
284
+ logger.info(LogMessages_1.LogMessage.END_SESSION_NOT_STARTED);
231
285
  }
232
286
  },
233
287
  identifyUser: (user, platform) => {
234
288
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
235
- logger.debug(`Dynatrace identifyUser(${user})`);
289
+ logger.debug(LogMessages_1.LogMessage.IDENTIFY_USER, { user });
236
290
  DynatraceBridge_1.DynatraceNative.identifyUser(user, platform === null || platform === void 0 ? void 0 : platform.toString());
237
291
  }
238
292
  else {
239
- logger.info(`identifyUser(${user}): React Native plugin has not been started yet! Session will not be tagged!`);
293
+ logger.info(LogMessages_1.LogMessage.IDENTIFY_USER_NOT_STARTED, { user });
240
294
  }
241
295
  },
242
296
  setGPSLocation: (latitude, longitude, platform) => {
243
297
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
244
- logger.debug(`setGPSLocation(${latitude}, ${longitude})`);
298
+ logger.debug(LogMessages_1.LogMessage.SET_GPS_LOCATION, { latitude, longitude });
245
299
  DynatraceBridge_1.DynatraceNative.setGPSLocation(latitude, longitude, platform === null || platform === void 0 ? void 0 : platform.toString());
246
300
  }
247
301
  else {
248
- logger.info(`setGPSLocation(${latitude}, ${longitude}): React Native plugin has not been started yet! GPS Position will not be set!`);
302
+ logger.info(LogMessages_1.LogMessage.SET_GPS_LOCATION_NOT_STARTED, {
303
+ latitude,
304
+ longitude,
305
+ });
249
306
  }
250
307
  },
251
308
  isCrashReportingOptedIn: (platform) => __awaiter(void 0, void 0, void 0, function* () {
252
309
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
253
- logger.debug('Dynatrace isCrashReportingOptedIn()');
310
+ logger.debug(LogMessages_1.LogMessage.IS_CRASH_REPORTING_OPTED_IN);
254
311
  return DynatraceBridge_1.DynatraceNative.isCrashReportingOptedIn(platform === null || platform === void 0 ? void 0 : platform.toString());
255
312
  }
256
313
  else {
257
- logger.info('isCrashReportingOptedIn(): React Native plugin has not been started yet! Crash reporting value not available!');
314
+ logger.info(LogMessages_1.LogMessage.IS_CRASH_REPORTING_OPTED_IN_NOT_STARTED);
258
315
  return false;
259
316
  }
260
317
  }),
261
318
  setCrashReportingOptedIn: (crashReporting, platform) => {
262
319
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
263
- logger.debug(`setCrashReportingOptedIn(${crashReporting})`);
320
+ logger.debug(LogMessages_1.LogMessage.SET_CRASH_REPORTING_OPTED_IN, {
321
+ crashReporting,
322
+ });
264
323
  DynatraceBridge_1.DynatraceNative.setCrashReportingOptedIn(crashReporting, platform === null || platform === void 0 ? void 0 : platform.toString());
265
324
  }
266
325
  else {
267
- logger.info(`setCrashReportingOptedIn(${crashReporting}): React Native plugin has not been started yet! Crash reporting value will not be set!`);
326
+ logger.info(LogMessages_1.LogMessage.SET_CRASH_REPORTING_OPTED_IN_NOT_STARTED, {
327
+ crashReporting,
328
+ });
268
329
  }
269
330
  },
270
331
  getDataCollectionLevel: (platform) => __awaiter(void 0, void 0, void 0, function* () {
271
332
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
272
- logger.debug('getDataCollectionLevel()');
333
+ logger.debug(LogMessages_1.LogMessage.GET_DATA_COLLECTION_LEVEL);
273
334
  return (0, DataCollectionLevel_1.StringToDataCollectionLevel)(yield DynatraceBridge_1.DynatraceNative.getDataCollectionLevel(platform === null || platform === void 0 ? void 0 : platform.toString()));
274
335
  }
275
336
  else {
276
- logger.info('getDataCollectionLevel(): React Native plugin has not been started yet! Data Collection level not available!');
337
+ logger.info(LogMessages_1.LogMessage.GET_DATA_COLLECTION_LEVEL_NOT_STARTED);
277
338
  return DataCollectionLevel_1.DataCollectionLevel.Off;
278
339
  }
279
340
  }),
280
341
  setDataCollectionLevel: (dataCollectionLevel, platform) => {
281
342
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
282
- logger.debug(`setDataCollectionLevel(${dataCollectionLevel})`);
343
+ logger.debug(LogMessages_1.LogMessage.SET_DATA_COLLECTION_LEVEL, {
344
+ dataCollectionLevel: String(dataCollectionLevel),
345
+ });
283
346
  DynatraceBridge_1.DynatraceNative.setDataCollectionLevel(dataCollectionLevel.toString(), platform === null || platform === void 0 ? void 0 : platform.toString());
284
347
  }
285
348
  else {
286
- logger.info(`setDataCollectionLevel(${dataCollectionLevel}): React Native plugin has not been started yet! Data Collection level will not be set!`);
349
+ logger.info(LogMessages_1.LogMessage.SET_DATA_COLLECTION_LEVEL_NOT_STARTED, {
350
+ dataCollectionLevel: String(dataCollectionLevel),
351
+ });
287
352
  }
288
353
  },
289
354
  getUserPrivacyOptions: (platform) => __awaiter(void 0, void 0, void 0, function* () {
290
355
  var _a;
291
356
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
292
- logger.debug('getUserPrivacyOptions()');
357
+ logger.debug(LogMessages_1.LogMessage.GET_USER_PRIVACY_OPTIONS);
293
358
  const options = yield DynatraceBridge_1.DynatraceNative.getUserPrivacyOptions(platform === null || platform === void 0 ? void 0 : platform.toString());
294
359
  const currentOptions = new UserPrivacyOptions_1.UserPrivacyOptions((0, DataCollectionLevel_1.StringToDataCollectionLevel)(options.dataCollectionLevel), options.crashReportingOptedIn, (_a = options.screenRecordOptedIn) !== null && _a !== void 0 ? _a : false);
295
360
  return currentOptions;
296
361
  }
297
362
  else {
298
- logger.info('getUserPrivacyOptions(): React Native plugin has not been started yet! User Privacy Options are not available!');
363
+ logger.info(LogMessages_1.LogMessage.GET_USER_PRIVACY_OPTIONS_NOT_STARTED);
299
364
  return new UserPrivacyOptions_1.UserPrivacyOptions(DataCollectionLevel_1.DataCollectionLevel.Off, false);
300
365
  }
301
366
  }),
@@ -304,26 +369,30 @@ exports.Dynatrace = {
304
369
  if ((userPrivacyOptions.crashReportingOptedIn === true ||
305
370
  userPrivacyOptions.crashReportingOptedIn === false) &&
306
371
  userPrivacyOptions.dataCollectionLevel in DataCollectionLevel_1.DataCollectionLevel) {
307
- logger.debug(`applyUserPrivacyOptions(${JSON.stringify(userPrivacyOptions)})`);
372
+ logger.debug(LogMessages_1.LogMessage.APPLY_USER_PRIVACY_OPTIONS, {
373
+ userPrivacyOptions: JSON.stringify(userPrivacyOptions),
374
+ });
308
375
  DynatraceBridge_1.DynatraceNative.applyUserPrivacyOptions(userPrivacyOptions, platform === null || platform === void 0 ? void 0 : platform.toString());
309
376
  }
310
377
  }
311
378
  else {
312
- logger.info(`applyUserPrivacyOptions(${JSON.stringify(userPrivacyOptions)}): React Native plugin has not been started yet! User Privacy Options can't be applied!`);
379
+ logger.info(LogMessages_1.LogMessage.APPLY_USER_PRIVACY_OPTIONS_NOT_STARTED, {
380
+ userPrivacyOptions: JSON.stringify(userPrivacyOptions),
381
+ });
313
382
  }
314
383
  },
315
384
  flushEvents: (platform) => {
316
385
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
317
- logger.debug('flushEvents()');
386
+ logger.debug(LogMessages_1.LogMessage.FLUSH_EVENTS);
318
387
  DynatraceBridge_1.DynatraceNative.flushEvents(platform === null || platform === void 0 ? void 0 : platform.toString());
319
388
  }
320
389
  else {
321
- logger.info('flushEvents(): React Native plugin has not been started yet! Flushing Event not possible!');
390
+ logger.info(LogMessages_1.LogMessage.FLUSH_EVENTS_NOT_STARTED);
322
391
  }
323
392
  },
324
393
  setBeaconHeaders: (headers, platform) => {
325
394
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
326
- logger.debug('setBeaconHeaders(headers)');
395
+ logger.debug(LogMessages_1.LogMessage.SET_BEACON_HEADERS);
327
396
  if (headers && headers.size > 0) {
328
397
  const obj = {};
329
398
  headers.forEach((value, key) => (obj[key] = value));
@@ -334,7 +403,7 @@ exports.Dynatrace = {
334
403
  }
335
404
  }
336
405
  else {
337
- logger.info('setBeaconHeaders(headers): React Native plugin has not been started yet! Setting Beacon Headers is not possible!');
406
+ logger.info(LogMessages_1.LogMessage.SET_BEACON_HEADERS_NOT_STARTED);
338
407
  }
339
408
  },
340
409
  addEventModifier: (eventModifier) => Dynatrace_1.Dynatrace.addEventModifier(eventModifier),
@@ -4,6 +4,7 @@ exports.DynatraceAction = void 0;
4
4
  const StringUtils_1 = require("./util/StringUtils");
5
5
  const DynatraceBridge_1 = require("./DynatraceBridge");
6
6
  const ConsoleLogger_1 = require("./logging/ConsoleLogger");
7
+ const LogMessages_1 = require("./logging/LogMessages");
7
8
  class DynatraceAction {
8
9
  constructor(key, name, manual) {
9
10
  this.key = key;
@@ -14,96 +15,150 @@ class DynatraceAction {
14
15
  }
15
16
  reportError(errorName, errorCode, platform) {
16
17
  if (this.closed) {
17
- this.logger.debug(`reportError(${errorName}, ${errorCode}): Action was closed already!`);
18
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_ERROR_CLOSED, {
19
+ errorName,
20
+ errorCode,
21
+ });
18
22
  return;
19
23
  }
20
24
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(errorName)) {
21
25
  DynatraceBridge_1.DynatraceNative.reportErrorInAction(this.key, errorName, errorCode, platform === null || platform === void 0 ? void 0 : platform.toString());
22
- this.logger.debug(`reportError(${errorName}, ${errorCode}): in Action - ${this.name}`);
26
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_ERROR, {
27
+ errorName,
28
+ errorCode,
29
+ name: this.name,
30
+ });
23
31
  }
24
32
  else {
25
- this.logger.debug(`reportError(errorName, errorCode): Error will not be reported because errorName is invalid! errorName: ${errorName}, errorCode: ${errorCode}`);
33
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_ERROR_INVALID, {
34
+ errorName,
35
+ errorCode,
36
+ });
26
37
  }
27
38
  }
28
39
  reportEvent(eventName, platform) {
29
40
  if (this.closed) {
30
- this.logger.debug(`reportEvent(${eventName}): Action was closed already!`);
41
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_EVENT_CLOSED, {
42
+ eventName,
43
+ });
31
44
  return;
32
45
  }
33
46
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(eventName)) {
34
47
  DynatraceBridge_1.DynatraceNative.reportEventInAction(this.key, eventName, platform === null || platform === void 0 ? void 0 : platform.toString());
35
- this.logger.debug(`reportEvent(${eventName}): in Action - ${this.name}`);
48
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_EVENT, {
49
+ eventName,
50
+ name: this.name,
51
+ });
36
52
  }
37
53
  else {
38
- this.logger.debug(`reportEvent(eventName): Event will not be reported because eventName is invalid! eventName: ${eventName} in Action - ${this.name}`);
54
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_EVENT_INVALID, {
55
+ eventName,
56
+ name: this.name,
57
+ });
39
58
  }
40
59
  }
41
60
  reportStringValue(valueName, value, platform) {
42
61
  if (this.closed) {
43
- this.logger.debug(`reportStringValue(${valueName}, ${value}): Action was closed already!`);
62
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_STRING_VALUE_CLOSED, {
63
+ valueName,
64
+ value,
65
+ });
44
66
  return;
45
67
  }
46
68
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(valueName) &&
47
69
  !StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(value)) {
48
70
  DynatraceBridge_1.DynatraceNative.reportStringValueInAction(this.key, valueName, value, platform === null || platform === void 0 ? void 0 : platform.toString());
49
- this.logger.debug(`reportStringValue(${valueName}, ${value}): in Action - ${this.name}`);
71
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_STRING_VALUE, {
72
+ valueName,
73
+ value,
74
+ name: this.name,
75
+ });
50
76
  }
51
77
  else {
52
- this.logger.debug(`reportStringValue(valueName, value): String value will not be reported because valueName or value is invalid! valueName: ${valueName}, value: ${value} in Action - ${this.name}`);
78
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_STRING_VALUE_INVALID, {
79
+ valueName,
80
+ value,
81
+ name: this.name,
82
+ });
53
83
  }
54
84
  }
55
85
  reportIntValue(valueName, value, platform) {
56
86
  if (this.closed) {
57
- this.logger.debug(`reportIntValue(${valueName}, ${value}): Action was closed already!`);
87
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_INT_VALUE_CLOSED, {
88
+ valueName,
89
+ value,
90
+ });
58
91
  return;
59
92
  }
60
93
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(valueName)) {
61
94
  DynatraceBridge_1.DynatraceNative.reportIntValueInAction(this.key, valueName, value, platform === null || platform === void 0 ? void 0 : platform.toString());
62
- this.logger.debug(`reportIntValue(${valueName}, ${value}): in Action - ${this.name}`);
95
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_INT_VALUE, {
96
+ valueName,
97
+ value,
98
+ name: this.name,
99
+ });
63
100
  }
64
101
  else {
65
- this.logger.debug(`reportIntValue(valueName, value): Int value will not be reported because valueName is invalid! valueName: ${valueName}, value: ${value} in Action - ${this.name}`);
102
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_INT_VALUE_INVALID, {
103
+ valueName,
104
+ value,
105
+ name: this.name,
106
+ });
66
107
  }
67
108
  }
68
109
  reportDoubleValue(valueName, value, platform) {
69
110
  if (this.closed) {
70
- this.logger.debug(`reportDoubleValue(${valueName}, ${value}): Action was closed already!`);
111
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_DOUBLE_VALUE_CLOSED, {
112
+ valueName,
113
+ value,
114
+ });
71
115
  return;
72
116
  }
73
117
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(valueName)) {
74
118
  DynatraceBridge_1.DynatraceNative.reportDoubleValueInAction(this.key, valueName, value, platform === null || platform === void 0 ? void 0 : platform.toString());
75
- this.logger.debug(`reportDoubleValue(${valueName}, ${value}): in Action - ${this.name}`);
119
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_DOUBLE_VALUE, {
120
+ valueName,
121
+ value,
122
+ name: this.name,
123
+ });
76
124
  }
77
125
  else {
78
- this.logger.debug(`reportDoubleValue(valueName, value): Double value will not be reported because valueName is invalid! valueName: ${valueName}, value: ${value} in Action - ${this.name}`);
126
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_REPORT_DOUBLE_VALUE_INVALID, {
127
+ valueName,
128
+ value,
129
+ name: this.name,
130
+ });
79
131
  }
80
132
  }
81
133
  leaveAction(platform) {
82
134
  if (this.closed) {
83
- this.logger.debug('leaveAction(): Action was closed already!');
135
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_LEAVE_CLOSED);
84
136
  return;
85
137
  }
86
138
  this.closed = true;
87
- this.logger.debug(`leaveAction(): ${this.name}`);
139
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_LEAVE, { name: this.name });
88
140
  DynatraceBridge_1.DynatraceNative.leaveAction(this.key, this.manual, platform === null || platform === void 0 ? void 0 : platform.toString());
89
141
  }
90
142
  cancel(platform) {
91
143
  if (this.closed) {
92
- this.logger.debug('cancelAction(): Action was closed already!');
144
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_CANCEL_CLOSED);
93
145
  return;
94
146
  }
95
147
  this.closed = true;
96
- this.logger.debug(`cancelAction(): ${this.name}`);
148
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_CANCEL, { name: this.name });
97
149
  DynatraceBridge_1.DynatraceNative.cancelAction(this.key, platform === null || platform === void 0 ? void 0 : platform.toString());
98
150
  }
99
151
  getRequestTag(url) {
100
152
  if (this.closed) {
101
- this.logger.debug(`getRequestTag(${url}): Action was closed already!`);
102
- return new Promise((resolve) => {
103
- resolve('');
153
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_GET_REQUEST_TAG_CLOSED, {
154
+ url,
104
155
  });
156
+ return Promise.resolve('');
105
157
  }
106
- this.logger.debug(`getRequestTag(${url}): in Action - ${this.name}`);
158
+ this.logger.debug(LogMessages_1.LogMessage.ACTION_GET_REQUEST_TAG, {
159
+ url,
160
+ name: this.name,
161
+ });
107
162
  return DynatraceBridge_1.DynatraceNative.getRequestTag(this.key, url);
108
163
  }
109
164
  getRequestTagHeader() {
@@ -6,41 +6,54 @@ const Dynatrace_1 = require("../next/Dynatrace");
6
6
  const DynatraceBridge_1 = require("./DynatraceBridge");
7
7
  const StringUtils_1 = require("./util/StringUtils");
8
8
  const ConsoleLogger_1 = require("./logging/ConsoleLogger");
9
+ const LogMessages_1 = require("./logging/LogMessages");
9
10
  let counter = 0;
10
11
  const logger = new ConsoleLogger_1.ConsoleLogger('DyntraceInt');
11
12
  exports.DynatraceInternal = {
12
- reportErrorFromHandler: (isFatal, errorName, reason, stacktrace, isReportFatalErrorAsCrash, platform) => {
13
- if (isFatal && isReportFatalErrorAsCrash) {
14
- if (react_native_1.Platform.OS === 'ios') {
15
- logger.debug(`storeCrash(${errorName}, ${reason}, ${stacktrace})`);
16
- DynatraceBridge_1.DynatraceNative.storeCrash(errorName, reason, stacktrace);
17
- }
18
- else {
19
- logger.debug(`reportCrash(${errorName}, ${reason}, ${stacktrace})`);
20
- DynatraceBridge_1.DynatraceNative.reportCrash(errorName, reason, stacktrace, true, platform === null || platform === void 0 ? void 0 : platform.toString());
21
- }
22
- Dynatrace_1.Dynatrace.reportCrash({
13
+ reportErrorFromHandler: (_isFatal, errorName, reason, stacktrace, isLegacyApiReported = false, platform) => {
14
+ if (StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(stacktrace)) {
15
+ logger.debug(LogMessages_1.LogMessage.INTERNAL_REPORT_ERROR_SIMPLE, {
16
+ errorName,
17
+ });
18
+ DynatraceBridge_1.DynatraceNative.reportErrorWithoutStacktrace(errorName, -1);
19
+ Dynatrace_1.Dynatrace.reportErrorCode(errorName, -1, isLegacyApiReported);
20
+ }
21
+ else {
22
+ logger.debug(LogMessages_1.LogMessage.INTERNAL_REPORT_ERROR, {
23
+ errorName,
24
+ reason,
25
+ stacktrace,
26
+ });
27
+ DynatraceBridge_1.DynatraceNative.reportError(errorName, '-', reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
28
+ Dynatrace_1.Dynatrace.reportError({
23
29
  name: errorName,
24
30
  message: reason,
25
31
  stack: stacktrace,
26
- }, false, isFatal);
32
+ }, isLegacyApiReported);
33
+ }
34
+ },
35
+ reportFatalErrorAsCrashFromHandler: (isFatal, errorName, reason, stacktrace, platform) => {
36
+ if (react_native_1.Platform.OS === 'ios') {
37
+ logger.debug(LogMessages_1.LogMessage.STORE_CRASH, {
38
+ errorName,
39
+ reason,
40
+ stacktrace,
41
+ });
42
+ DynatraceBridge_1.DynatraceNative.storeCrash(errorName, reason, stacktrace);
27
43
  }
28
44
  else {
29
- if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(stacktrace)) {
30
- logger.debug(`reportError(${errorName}, ${reason}, ${stacktrace})`);
31
- DynatraceBridge_1.DynatraceNative.reportError(errorName, '-', reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
32
- Dynatrace_1.Dynatrace.reportError({
33
- name: errorName,
34
- message: reason,
35
- stack: stacktrace,
36
- }, false);
37
- }
38
- else {
39
- logger.debug(`reportError(${errorName})`);
40
- DynatraceBridge_1.DynatraceNative.reportErrorWithoutStacktrace(errorName, -1);
41
- Dynatrace_1.Dynatrace.reportErrorCode(errorName, -1, false);
42
- }
45
+ logger.debug(LogMessages_1.LogMessage.REPORT_CRASH, {
46
+ crashName: errorName,
47
+ reason,
48
+ stacktrace,
49
+ });
50
+ DynatraceBridge_1.DynatraceNative.reportCrash(errorName, reason, stacktrace, true, platform === null || platform === void 0 ? void 0 : platform.toString());
43
51
  }
52
+ Dynatrace_1.Dynatrace.reportCrash({
53
+ name: errorName,
54
+ message: reason,
55
+ stack: stacktrace,
56
+ }, false, isFatal);
44
57
  },
45
58
  getCounter: () => counter++,
46
59
  };