@dynatrace/react-native-plugin 2.307.1 → 2.309.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 (130) hide show
  1. package/README.md +7 -3
  2. package/android/build.gradle +3 -1
  3. package/android/src/main/java/com/dynatrace/android/agent/DynatraceAppStartModule.kt +128 -0
  4. package/android/src/main/java/com/dynatrace/android/agent/DynatraceInternalModule.kt +22 -0
  5. package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +411 -0
  6. package/android/src/main/java/com/dynatrace/android/agent/DynatraceReactPackage.kt +54 -0
  7. package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.kt +86 -0
  8. package/android/src/main/java/com/dynatrace/android/agent/model/AppStartMeasurement.kt +15 -0
  9. package/android/src/main/java/com/dynatrace/android/agent/model/AppStartMeasurementType.kt +18 -0
  10. package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +228 -0
  11. package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +258 -0
  12. package/files/plugin.gradle +1 -1
  13. package/index.js +10 -10
  14. package/instrumentation/DynatraceInstrumentation.js +1 -0
  15. package/{lib → instrumentation/jsx}/CreateElement.js +6 -5
  16. package/{lib/instrumentor/base → instrumentation/jsx}/ElementHelper.js +14 -12
  17. package/{lib/jsx-dev-runtime.js → instrumentation/jsx/JsxDevRuntime.js} +10 -19
  18. package/instrumentation/jsx/JsxRuntime.js +63 -0
  19. package/instrumentation/jsx/JsxRuntimeUtil.js +31 -0
  20. package/instrumentation/jsx/components/ClassComponent.js +49 -0
  21. package/instrumentation/jsx/components/ComponentUtil.js +33 -0
  22. package/instrumentation/jsx/components/FunctionalComponent.js +20 -0
  23. package/{lib/instrumentor/base → instrumentation/jsx/components}/Picker.js +1 -1
  24. package/{lib/instrumentor/base → instrumentation/jsx/components}/RefreshControl.js +1 -1
  25. package/{lib/instrumentor/base → instrumentation/jsx/components}/Switch.js +1 -1
  26. package/{lib/instrumentor/base → instrumentation/jsx/components}/Touchable.js +5 -5
  27. package/instrumentation/libs/community/Picker.InstrInfo.js +20 -0
  28. package/{lib → instrumentation/libs}/community/Picker.js +1 -1
  29. package/instrumentation/libs/community/gesture-handler/Touchables.InstrInfo.js +23 -0
  30. package/{lib → instrumentation/libs}/community/gesture-handler/Touchables.js +1 -1
  31. package/{lib → instrumentation/libs}/react-native/RefreshControl.InstrInfo.js +2 -2
  32. package/{lib → instrumentation/libs}/react-native/RefreshControl.js +5 -5
  33. package/{lib → instrumentation/libs}/react-native/Switch.InstrInfo.js +2 -2
  34. package/{lib → instrumentation/libs}/react-native/Switch.js +5 -5
  35. package/instrumentation/libs/react-native/Touchables.InstrInfo.js +25 -0
  36. package/{lib → instrumentation/libs}/react-native/Touchables.js +1 -1
  37. package/{lib → instrumentation/libs}/react-navigation/ReactNavigation.js +6 -5
  38. package/{lib/instrumentor → instrumentation}/model/Types.js +1 -14
  39. package/instrumentation/model/TypesUtil.js +17 -0
  40. package/ios/DynatraceRNBridge.h +10 -1
  41. package/ios/DynatraceRNBridge.mm +152 -0
  42. package/jsx-dev-runtime.js +1 -1
  43. package/jsx-runtime.js +1 -1
  44. package/lib/core/Application.js +20 -0
  45. package/lib/{instrumentor/base → core}/Dynatrace.js +57 -48
  46. package/lib/{instrumentor/base → core}/DynatraceAction.js +23 -22
  47. package/lib/core/DynatraceInternal.js +46 -0
  48. package/lib/{instrumentor/base → core}/DynatraceRootAction.js +5 -4
  49. package/lib/{instrumentor/base → core}/DynatraceWebRequestTiming.js +6 -5
  50. package/lib/{instrumentor/base → core}/ErrorHandler.js +6 -5
  51. package/lib/{instrumentor/base → core}/configuration/Configuration.js +1 -1
  52. package/lib/{instrumentor/base → core}/configuration/ConfigurationDefaults.js +1 -2
  53. package/lib/{instrumentor/base → core}/configuration/ConfigurationHandler.js +2 -2
  54. package/lib/{instrumentor/base → core}/configuration/ManualStartupConfiguration.js +1 -1
  55. package/lib/core/logging/ConsoleLogger.js +27 -0
  56. package/lib/core/logging/LogLevel.js +12 -0
  57. package/lib/dynatrace-transformer.js +1 -1
  58. package/lib/next/Dynatrace.js +86 -0
  59. package/lib/next/DynatraceSecondGenForwarder.js +17 -0
  60. package/lib/next/IDynatrace.js +2 -0
  61. package/lib/next/IDynatraceForwarder.js +2 -0
  62. package/lib/next/appstart/AppStartObserver.js +32 -0
  63. package/lib/next/appstart/AppStartType.js +38 -0
  64. package/lib/next/events/EventCreator.js +77 -0
  65. package/lib/next/events/EventPipeline.js +57 -0
  66. package/lib/next/events/EventTimestamp.js +24 -0
  67. package/lib/next/events/ViewInfoCreator.js +27 -0
  68. package/lib/next/events/modifier/BaseDataEventModifier.js +31 -0
  69. package/lib/next/events/modifier/EventLimitation.js +69 -0
  70. package/lib/next/events/modifier/EventModifierUtil.js +88 -0
  71. package/lib/next/events/modifier/IEventModifier.js +2 -0
  72. package/lib/next/events/modifier/ModifyEventValidation.js +187 -0
  73. package/lib/next/events/modifier/NonFiniteNumbersModifier.js +50 -0
  74. package/lib/next/events/modifier/SendEventValidation.js +84 -0
  75. package/lib/next/events/spec/EventFieldKeysEnum.js +2 -0
  76. package/lib/next/events/spec/EventSpecContstants.js +46 -0
  77. package/lib/next/events/spec/IAppStartEvent.js +2 -0
  78. package/lib/next/events/spec/ICrashEvent.js +2 -0
  79. package/lib/next/events/spec/IErrorCodeEvent.js +2 -0
  80. package/lib/next/events/spec/IErrorExceptionEvent.js +2 -0
  81. package/lib/next/events/spec/IReactNativeEvent.js +2 -0
  82. package/lib/next/events/spec/IRumEvent.js +2 -0
  83. package/lib/next/provider/ITimestampProvider.js +2 -0
  84. package/lib/next/provider/TimestampProvider.js +10 -0
  85. package/package.json +41 -33
  86. package/react-native-dynatrace.podspec +1 -1
  87. package/src/lib/{instrumentor/base → core}/interface/NativeDynatraceBridge.ts +8 -0
  88. package/typings/react-native-dynatrace.d.ts +0 -1
  89. package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.java +0 -366
  90. package/android/src/main/java/com/dynatrace/android/agent/DynatraceReactPackage.java +0 -67
  91. package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.java +0 -108
  92. package/android/src/main/java/com/dynatrace/android/agent/PrivateDTBridge.java +0 -28
  93. package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.java +0 -192
  94. package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.java +0 -194
  95. package/lib/community/Picker.InstrInfo.js +0 -20
  96. package/lib/community/gesture-handler/Touchables.InstrInfo.js +0 -56
  97. package/lib/instrumentor/DynatraceInstrumentation.js +0 -1
  98. package/lib/instrumentor/base/Application.js +0 -16
  99. package/lib/instrumentor/base/DynatraceInternal.js +0 -34
  100. package/lib/instrumentor/base/Logger.js +0 -16
  101. package/lib/instrumentor/base/model/LogLevel.js +0 -17
  102. package/lib/jsx-runtime.js +0 -69
  103. package/lib/react/Component.js +0 -90
  104. package/lib/react-native/Touchables.InstrInfo.js +0 -60
  105. /package/{lib/instrumentor/base/interface → instrumentation/jsx}/IDynatraceProperties.js +0 -0
  106. /package/{lib → instrumentation/libs}/community/gesture-handler/index.js +0 -0
  107. /package/{lib → instrumentation/libs}/gesture-handler.js +0 -0
  108. /package/{lib → instrumentation/libs}/react-native/index.js +0 -0
  109. /package/{lib → instrumentation/libs}/react-native.js +0 -0
  110. /package/{lib/instrumentor → instrumentation}/model/Reference.js +0 -0
  111. /package/{lib/instrumentor → instrumentation}/parser/Babel.js +0 -0
  112. /package/lib/{instrumentor/base → core}/DynatraceBridge.js +0 -0
  113. /package/lib/{instrumentor/base → core}/NullAction.js +0 -0
  114. /package/lib/{instrumentor/base → core}/NullRootAction.js +0 -0
  115. /package/lib/{instrumentor/base → core}/NullWebRequestTiming.js +0 -0
  116. /package/lib/{instrumentor/base → core}/UserPrivacyOptions.js +0 -0
  117. /package/lib/{instrumentor/base → core}/configuration/ConfigurationBuilder.js +0 -0
  118. /package/lib/{instrumentor/base → core}/configuration/ConfigurationPreset.js +0 -0
  119. /package/lib/{instrumentor/base → core}/configuration/IConfiguration.js +0 -0
  120. /package/lib/{instrumentor/base → core}/interface/IDynatrace.js +0 -0
  121. /package/lib/{instrumentor/base → core}/interface/IDynatraceAction.js +0 -0
  122. /package/lib/{instrumentor/base → core}/interface/IDynatraceInternal.js +0 -0
  123. /package/lib/{instrumentor/base → core}/interface/IDynatraceRootAction.js +0 -0
  124. /package/lib/{instrumentor/base → core}/interface/IWebRequestTiming.js +0 -0
  125. /package/lib/{instrumentor/base → core}/interface/NativeDynatraceBridge.js +0 -0
  126. /package/lib/{instrumentor/base/interface → core/logging}/ILogger.js +0 -0
  127. /package/lib/{instrumentor/base → core}/model/DataCollectionLevel.js +0 -0
  128. /package/lib/{instrumentor/base → core}/model/Json.js +0 -0
  129. /package/lib/{instrumentor/base → core}/model/Platform.js +0 -0
  130. /package/lib/{instrumentor/base → core}/util/StringUtils.js +0 -0
@@ -7,13 +7,18 @@
7
7
 
8
8
  #import <Dynatrace/Dynatrace.h>
9
9
  #import <React/RCTBridgeModule.h>
10
+ #import <React/RCTEventEmitter.h>
10
11
 
11
- @interface DynatraceRNBridge : NSObject <RCTBridgeModule>
12
+ @interface DynatraceRNBridge : RCTEventEmitter <RCTBridgeModule>
12
13
  - (void) newAction:(NSString *)name key:(NSString *)key parentAction:(DTXAction *)parentAction;
13
14
  - (DTXAction *) getAction:(NSString *)key;
14
15
  - (BOOL) shouldWorkOnIosWithPlatform: (NSString *) platform;
15
16
  @end
16
17
 
18
+ @interface HybridBridge : NSObject
19
+ + (void)forwardEvent:(NSDictionary<NSString*,id>* _Nullable)fields NS_SWIFT_NAME(forwardEvent(fields:));
20
+ @end
21
+
17
22
  typedef enum : NSUInteger {
18
23
  DTXActionPlatformJavaScript = 1,
19
24
  DTXActionPlatformXamarin,
@@ -27,6 +32,10 @@ typedef enum : NSUInteger {
27
32
  - (DTX_StatusCode)reportExternalErrorForPlatformType:(DTXActionPlatformType)platformType errorName:(NSString*)errorName errorValue:(NSString*)errorValue reason:(NSString*)reason stacktrace:(NSString*)stacktrace;
28
33
  @end
29
34
 
35
+ @interface DTXAction (CrossPlatform)
36
+ + (DTX_StatusCode)internalReportError:(NSString* _Nonnull)errorName errorValue:(int)errorValue;
37
+ @end
38
+
30
39
  @interface Dynatrace (Events)
31
40
  + (void)sendBizEventWithType:(NSString *)type attributes:(NSDictionary<NSString *, id> *_Nullable)attributes;
32
41
  @end
@@ -11,18 +11,46 @@
11
11
 
12
12
  #import <Foundation/Foundation.h>
13
13
  #import <CoreLocation/CoreLocation.h>
14
+ #import <React/RCTPerformanceLogger.h>
15
+ #import <React/RCTRootView.h>
14
16
 
15
17
  @implementation DynatraceRNBridge
16
18
 
17
19
  NSMutableDictionary *actionDict;
18
20
  NSMutableDictionary *webTimingsDict;
19
21
 
22
+ // Platform types
20
23
  NSString *const PlatformAndroid = @"android";
21
24
  NSString *const PlatformiOS = @"ios";
25
+
26
+ // Data collection levels
22
27
  NSString *const DataCollectionOff = @"OFF";
23
28
  NSString *const DataCollectionPerformance = @"PERFORMANCE";
24
29
  NSString *const DataCollectionUserBehavior = @"USER_BEHAVIOR";
25
30
 
31
+ /**
32
+ * Emitting app start event with this identifier
33
+ */
34
+ NSString *const EmitAppMeasurementsIdentifier = @"dynatraceAppStartMeasurements";
35
+
36
+ // All types which are interesting for us
37
+ NSString *const DownloadStart = @"downloadStart";
38
+ NSString *const DownloadEnd = @"downloadEnd";
39
+ NSString *const RunJSBundleStart = @"runJsBundleStart";
40
+ NSString *const RunJSBundleEnd = @"runJsBundleEnd";
41
+ NSString *const Reload = @"reload";
42
+ NSString *const ContentAppeared = @"contentAppeared";
43
+
44
+ /**
45
+ * Telling us if we can actually emit events
46
+ */
47
+ bool hasListeners = NO;
48
+
49
+ /**
50
+ * When events have been emitted this value will be true, so we don't emit again
51
+ */
52
+ bool didEmit = NO;
53
+
26
54
  RCT_EXPORT_MODULE(DynatraceBridge);
27
55
 
28
56
  - (id) init
@@ -35,6 +63,114 @@ RCT_EXPORT_MODULE(DynatraceBridge);
35
63
  return self;
36
64
  }
37
65
 
66
+ - (NSArray<NSString *> *)supportedEvents {
67
+ return @[EmitAppMeasurementsIdentifier];
68
+ }
69
+
70
+ /**
71
+ * When bridge is starting we will add an observer for content did appear so we can emit our app start measurements
72
+ */
73
+ - (void)setBridge:(RCTBridge *)bridge
74
+ {
75
+ [super setBridge:bridge];
76
+ [[NSNotificationCenter defaultCenter] addObserver:self
77
+ selector:@selector(emitMeasurements)
78
+ name:RCTContentDidAppearNotification
79
+ object:nil];
80
+ }
81
+
82
+ /**
83
+ * Emitting all events which are available and important for our app start measurements
84
+ */
85
+ - (void)emitMeasurements
86
+ {
87
+ if (!didEmit && hasListeners && [self.bridge.performanceLogger valueForTag:RCTPLTTI] != 0) {
88
+ didEmit = YES;
89
+
90
+ NSMutableDictionary<NSString*, NSNumber*> *appStartMeasurements = [[NSMutableDictionary alloc] init];
91
+
92
+ [self addStartMeasurement:RCTPLScriptDownload withName:DownloadStart intoDict:appStartMeasurements];
93
+ [self addEndMeasurement:RCTPLScriptDownload withName:DownloadEnd intoDict:appStartMeasurements];
94
+ [self addStartMeasurement:RCTPLScriptExecution withName:RunJSBundleStart intoDict:appStartMeasurements];
95
+ [self addEndMeasurement:RCTPLScriptExecution withName:RunJSBundleEnd intoDict:appStartMeasurements];
96
+ [self addStartMeasurement:RCTPLBridgeStartup withName:Reload intoDict:appStartMeasurements];
97
+ [self addStartMeasurement:RCTPLTTI withName:ContentAppeared intoDict:appStartMeasurements];
98
+
99
+ if (hasListeners) {
100
+ [self sendEventWithName:EmitAppMeasurementsIdentifier body:appStartMeasurements];
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Adding a start measurement
107
+ *
108
+ * @param type Tag which is used for the internal react native performance logger
109
+ * @param name Name which should be used for inserting a specific timestamp into the dict
110
+ * @param measurements Dictionary which is used to insert the timing
111
+ */
112
+ - (void)addStartMeasurement:(RCTPLTag)type withName:(NSString *)name intoDict:(NSMutableDictionary *) measurements {
113
+ int64_t duration = [self.bridge.performanceLogger durationForTag:type];
114
+ int64_t end = [self.bridge.performanceLogger valueForTag:type];
115
+
116
+ if (duration == 0 || end == 0) {
117
+ return;
118
+ }
119
+
120
+ [measurements setObject:[self correctionOfTimestamp:end-duration] forKey:name];
121
+ }
122
+
123
+ /**
124
+ * Adding a end measurement
125
+ *
126
+ * @param type Tag which is used for the internal react native performance logger
127
+ * @param name Name which should be used for inserting a specific timestamp into the dict
128
+ * @param measurements Dictionary which is used to insert the timing
129
+ */
130
+ - (void)addEndMeasurement:(RCTPLTag)type withName:(NSString *)name intoDict:(NSMutableDictionary *) measurements {
131
+ int64_t end = [self.bridge.performanceLogger valueForTag:type];
132
+
133
+ if (end == 0) {
134
+ return;
135
+ }
136
+
137
+ [measurements setObject:[self correctionOfTimestamp:end] forKey:name];
138
+ }
139
+
140
+ - (NSNumber* )correctionOfTimestamp:(int64_t) timestamp
141
+ {
142
+ return [NSNumber numberWithLongLong:timestamp + [[NSDate date] timeIntervalSince1970] - (CACurrentMediaTime() * 1000)];
143
+ }
144
+
145
+ /**
146
+ * Invalidation should remove the observer for certain events
147
+ */
148
+ - (void)invalidate
149
+ {
150
+ [super invalidate];
151
+ [NSNotificationCenter.defaultCenter removeObserver:self];
152
+ }
153
+
154
+ /**
155
+ * Triggered when starting to emit events
156
+ */
157
+ - (void)startObserving
158
+ {
159
+ hasListeners = YES;
160
+ [self emitMeasurements];
161
+ }
162
+
163
+ /**
164
+ * Triggered when stopping to emit events
165
+ */
166
+ -(void)stopObserving
167
+ {
168
+ hasListeners = NO;
169
+ }
170
+
171
+ /**
172
+ * Constants which are exported to the JS part
173
+ */
38
174
  - (NSDictionary *)constantsToExport
39
175
  {
40
176
  return @{ @"PLATFORM_ANDROID" : PlatformAndroid,
@@ -154,6 +290,16 @@ RCT_EXPORT_METHOD(endVisit: (NSString *) platform)
154
290
  }
155
291
  }
156
292
 
293
+ RCT_EXPORT_METHOD(startView: (NSString *) name)
294
+ {
295
+ [Dynatrace startViewWithName:name];
296
+ }
297
+
298
+ RCT_EXPORT_METHOD(stopView)
299
+ {
300
+ [Dynatrace stopView];
301
+ }
302
+
157
303
  RCT_EXPORT_METHOD(reportErrorWithoutStacktrace:(NSString *)errorName errorCode:(nonnull NSNumber *)errorCode platform: (NSString *) platform)
158
304
  {
159
305
  if ([self shouldWorkOnIosWithPlatform: platform])
@@ -211,6 +357,7 @@ RCT_EXPORT_METHOD(reportErrorInAction:(nonnull NSString *)key errorName:(NSStrin
211
357
  if (action == nil)
212
358
  return;
213
359
  [action reportErrorWithName:errorName errorValue:[errorCode intValue]];
360
+ // [action internalReportError:errorName errorValue:[errorCode intValue]];
214
361
  }
215
362
  }
216
363
 
@@ -309,6 +456,11 @@ RCT_EXPORT_METHOD(sendBizEvent:(NSString *)type withAttributes:(NSDictionary<NSS
309
456
  }
310
457
  }
311
458
 
459
+ RCT_EXPORT_METHOD(forwardEvent:(NSDictionary<NSString*, id>*) attributes)
460
+ {
461
+ [HybridBridge forwardEvent:attributes];
462
+ }
463
+
312
464
  RCT_EXPORT_METHOD(setGPSLocation:(double)latitude andLongitude: (double)longitude platform: (NSString *) platform)
313
465
  {
314
466
  if ([self shouldWorkOnIosWithPlatform: platform])
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsxDevRuntime = require("./lib/jsx-dev-runtime");
3
+ const jsxDevRuntime = require("./instrumentation/jsx/JsxDevRuntime");
4
4
  module.exports = Object.assign({}, jsxDevRuntime);
package/jsx-runtime.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const jsxRuntime = require("./lib/jsx-runtime");
3
+ const jsxRuntime = require("./instrumentation/jsx/JsxRuntime");
4
4
  module.exports = Object.assign({}, jsxRuntime);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplicationHandler = void 0;
4
+ const ConfigurationBuilder_1 = require("./configuration/ConfigurationBuilder");
5
+ const ConfigurationHandler_1 = require("./configuration/ConfigurationHandler");
6
+ const ConsoleLogger_1 = require("./logging/ConsoleLogger");
7
+ const logger = new ConsoleLogger_1.ConsoleLogger('ApplicationHandler');
8
+ exports.ApplicationHandler = {
9
+ startup: (configuration) => {
10
+ if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
11
+ let config = configuration;
12
+ if (config === undefined) {
13
+ config = new ConfigurationBuilder_1.ConfigurationBuilder('', '').buildConfiguration();
14
+ }
15
+ ConfigurationHandler_1.ConfigurationHandler.setConfiguration(config);
16
+ logger.debug('Configuration set: ' + config.toString());
17
+ logger.info('Dynatrace React Native Plugin started!');
18
+ }
19
+ },
20
+ };
@@ -10,12 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Dynatrace = void 0;
13
- const Types_1 = require("../model/Types");
13
+ const Types_1 = require("../../instrumentation/model/Types");
14
+ const DynatraceSecondGenForwarder_1 = require("../next/DynatraceSecondGenForwarder");
14
15
  const StringUtils_1 = require("./util/StringUtils");
15
16
  const DynatraceBridge_1 = require("./DynatraceBridge");
16
17
  const DataCollectionLevel_1 = require("./model/DataCollectionLevel");
17
18
  const UserPrivacyOptions_1 = require("./UserPrivacyOptions");
18
- const Logger_1 = require("./Logger");
19
+ const ConsoleLogger_1 = require("./logging/ConsoleLogger");
19
20
  const ConfigurationHandler_1 = require("./configuration/ConfigurationHandler");
20
21
  const DynatraceRootAction_1 = require("./DynatraceRootAction");
21
22
  const NullRootAction_1 = require("./NullRootAction");
@@ -23,6 +24,8 @@ const DynatraceInternal_1 = require("./DynatraceInternal");
23
24
  const DynatraceAction_1 = require("./DynatraceAction");
24
25
  const NullAction_1 = require("./NullAction");
25
26
  const ErrorHandler_1 = require("./ErrorHandler");
27
+ const Application_1 = require("./Application");
28
+ const logger = new ConsoleLogger_1.ConsoleLogger('Dynatrace');
26
29
  exports.Dynatrace = {
27
30
  start: (configuration) => __awaiter(void 0, void 0, void 0, function* () {
28
31
  if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
@@ -32,15 +35,16 @@ exports.Dynatrace = {
32
35
  (0, ErrorHandler_1.registerErrorHandler)(configuration.reportFatalErrorAsCrash);
33
36
  }
34
37
  else {
35
- Logger_1.Logger.logDebug('Dynatrace error handler will not be enabled as errorHandler was set to false!');
38
+ logger.debug('Dynatrace error handler will not be enabled as errorHandler was set to false!');
36
39
  }
37
- ConfigurationHandler_1.ConfigurationHandler.setConfiguration(configuration);
38
- Logger_1.Logger.logDebug('Configuration set: ' + configuration.toString());
40
+ Application_1.ApplicationHandler.startup(configuration);
39
41
  }
40
42
  else {
41
43
  throw new Error('Configuration is empty! Not allowed for Manual Startup!');
42
44
  }
43
- Logger_1.Logger.logInfo('Dynatrace React Native Plugin started!');
45
+ }
46
+ else {
47
+ logger.debug('Configuration is already available! Duplicated startup blocked.');
44
48
  }
45
49
  }),
46
50
  withMonitoring: (Component, name) => {
@@ -75,17 +79,17 @@ exports.Dynatrace = {
75
79
  key = 'DEFAULT_' + DynatraceInternal_1.DynatraceInternal.getCounter();
76
80
  }
77
81
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(name)) {
78
- Logger_1.Logger.logDebug(`Dynatrace enterManualAction(${name})`);
82
+ logger.debug(`enterManualAction(${name})`);
79
83
  DynatraceBridge_1.DynatraceNative.enterManualAction(name, key, platform === null || platform === void 0 ? void 0 : platform.toString());
80
84
  return new DynatraceRootAction_1.DynatraceRootAction(key, name);
81
85
  }
82
86
  else {
83
- Logger_1.Logger.logDebug('Action Name was empty or null! Action will have no effect.');
87
+ logger.debug('Action Name was empty or null! Action will have no effect.');
84
88
  return new NullRootAction_1.NullRootAction();
85
89
  }
86
90
  }
87
91
  else {
88
- Logger_1.Logger.logInfo(`Dynatrace enterManualAction(${name}): React Native plugin has not been started yet! Action can't be created!`);
92
+ logger.info(`enterManualAction(${name}): React Native plugin has not been started yet! Action can't be created!`);
89
93
  return new NullRootAction_1.NullRootAction();
90
94
  }
91
95
  },
@@ -102,27 +106,28 @@ exports.Dynatrace = {
102
106
  key = 'DEFAULT_' + DynatraceInternal_1.DynatraceInternal.getCounter();
103
107
  }
104
108
  if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(name)) {
105
- Logger_1.Logger.logDebug(`Dynatrace enterAutoAction(${name})`);
109
+ logger.debug(`enterAutoAction(${name})`);
106
110
  DynatraceBridge_1.DynatraceNative.enterAction(name, key, platform === null || platform === void 0 ? void 0 : platform.toString());
107
111
  return new DynatraceAction_1.DynatraceAction(key, name, false);
108
112
  }
109
113
  else {
110
- Logger_1.Logger.logDebug('Action Name was empty or null! Action will have no effect.');
114
+ logger.debug('Action Name was empty or null! Action will have no effect.');
111
115
  return new NullAction_1.NullAction();
112
116
  }
113
117
  }
114
118
  else {
115
- Logger_1.Logger.logInfo(`Dynatrace enterAutoAction(${name}): React Native plugin has not been started yet! Action can't be created!`);
119
+ logger.info(`enterAutoAction(${name}): React Native plugin has not been started yet! Action can't be created!`);
116
120
  return new NullAction_1.NullAction();
117
121
  }
118
122
  },
119
123
  reportError: (errorName, errorCode, platform) => {
120
124
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
121
- Logger_1.Logger.logDebug(`Dynatrace reportError(${errorName}, ${errorCode})`);
125
+ logger.debug(`reportError(${errorName}, ${errorCode})`);
122
126
  DynatraceBridge_1.DynatraceNative.reportErrorWithoutStacktrace(errorName, errorCode, platform === null || platform === void 0 ? void 0 : platform.toString());
127
+ DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportError(errorName, errorCode);
123
128
  }
124
129
  else {
125
- Logger_1.Logger.logInfo(`Dynatrace reportError(${errorName}, ${errorCode}): React Native plugin has not been started yet! Error will not be reported!`);
130
+ logger.info(`reportError(${errorName}, ${errorCode}): React Native plugin has not been started yet! Error will not be reported!`);
126
131
  }
127
132
  },
128
133
  reportErrorWithStacktrace: (errorName, reason, stacktrace, platform) => {
@@ -133,11 +138,12 @@ exports.Dynatrace = {
133
138
  reason = reason.substring(0, reasonNewLineIndex);
134
139
  }
135
140
  }
136
- Logger_1.Logger.logDebug(`Dynatrace reportErrorStacktrace(${errorName}, ${reason}, ${stacktrace})`);
141
+ logger.debug(`reportErrorStacktrace(${errorName}, ${reason}, ${stacktrace})`);
137
142
  DynatraceBridge_1.DynatraceNative.reportError(errorName, '-', reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
143
+ DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportErrorWithStacktrace(errorName, reason, stacktrace);
138
144
  }
139
145
  else {
140
- Logger_1.Logger.logInfo(`Dynatrace reportErrorStacktrace(${errorName}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Error will not be reported!`);
146
+ logger.info(`reportErrorStacktrace(${errorName}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Error will not be reported!`);
141
147
  }
142
148
  },
143
149
  reportErrorStacktrace: (errorName, errorValue, reason, stacktrace, platform) => {
@@ -148,11 +154,12 @@ exports.Dynatrace = {
148
154
  reason = reason.substring(0, reasonNewLineIndex);
149
155
  }
150
156
  }
151
- Logger_1.Logger.logDebug(`Dynatrace reportErrorStacktrace(${errorName}, ${errorValue}, ${reason}, ${stacktrace})`);
157
+ logger.debug(`reportErrorStacktrace(${errorName}, ${errorValue}, ${reason}, ${stacktrace})`);
152
158
  DynatraceBridge_1.DynatraceNative.reportError(errorName, errorValue, reason, stacktrace, platform === null || platform === void 0 ? void 0 : platform.toString());
159
+ DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportErrorStacktrace(errorName, errorValue, reason, stacktrace);
153
160
  }
154
161
  else {
155
- Logger_1.Logger.logInfo(`Dynatrace reportErrorStacktrace(${errorName}, ${errorValue}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Error will not be reported!`);
162
+ logger.info(`reportErrorStacktrace(${errorName}, ${errorValue}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Error will not be reported!`);
156
163
  }
157
164
  },
158
165
  reportCrash: (crashName, reason, stacktrace, platform) => {
@@ -164,12 +171,13 @@ exports.Dynatrace = {
164
171
  reason = reason.substring(0, reasonNewLineIndex);
165
172
  }
166
173
  }
167
- Logger_1.Logger.logDebug(`Dynatrace reportCrash(${crashName}, ${reason}, ${stacktrace})`);
174
+ logger.debug(`reportCrash(${crashName}, ${reason}, ${stacktrace})`);
168
175
  DynatraceBridge_1.DynatraceNative.reportCrash(crashName, reason, stacktrace, false, platform === null || platform === void 0 ? void 0 : platform.toString());
176
+ DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportCrash(crashName, reason, stacktrace);
169
177
  }
170
178
  }
171
179
  else {
172
- Logger_1.Logger.logInfo(`Dynatrace reportCrash(${crashName}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Crash will not be reported!`);
180
+ logger.info(`reportCrash(${crashName}, ${reason}, ${stacktrace}): React Native plugin has not been started yet! Crash will not be reported!`);
173
181
  }
174
182
  },
175
183
  reportCrashWithException: (crashName, crash, platform) => {
@@ -183,108 +191,109 @@ exports.Dynatrace = {
183
191
  crashReason = crashReason.substring(0, reasonNewLineIndex);
184
192
  }
185
193
  }
186
- Logger_1.Logger.logDebug(`Dynatrace reportCrashWithException(${crashName}, ${crash.stack})`);
194
+ logger.debug(`reportCrashWithException(${crashName}, ${crash.stack})`);
187
195
  DynatraceBridge_1.DynatraceNative.reportCrash(crashName, crashReason, crash.stack, true, platform === null || platform === void 0 ? void 0 : platform.toString());
196
+ DynatraceSecondGenForwarder_1.DynatraceSecondGenForwarder.reportCrashWithException(crashName, crash);
188
197
  }
189
198
  }
190
199
  else {
191
- Logger_1.Logger.logInfo(`Dynatrace reportCrashWithException(${crashName}, ${crash}): React Native plugin has not been started yet! Crash will not be reported!`);
200
+ logger.info(`reportCrashWithException(${crashName}, ${crash}): React Native plugin has not been started yet! Crash will not be reported!`);
192
201
  }
193
202
  },
194
203
  sendBizEvent: (type, attributes = {}, platform) => {
195
204
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
196
205
  if (StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(type)) {
197
- Logger_1.Logger.logDebug(`Dynatrace sendBizEvent(${type}, ${attributes})): Type must be a non empty string`);
206
+ logger.debug(`sendBizEvent(${type}, ${attributes})): Type must be a non empty string`);
198
207
  return;
199
208
  }
200
209
  if (typeof attributes !== 'object' ||
201
210
  attributes === null ||
202
211
  Array.isArray(attributes)) {
203
- Logger_1.Logger.logDebug(`Dynatrace sendBizEvent(${type}, ${attributes})): Payload toplevel must be an object`);
212
+ logger.debug(`sendBizEvent(${type}, ${attributes})): Payload toplevel must be an object`);
204
213
  return;
205
214
  }
206
215
  const internalAttributes = Object.assign({}, attributes);
207
- Logger_1.Logger.logDebug(`Dynatrace sendBizEvent(${type}, ${internalAttributes})`);
216
+ logger.debug(`sendBizEvent(${type}, ${internalAttributes})`);
208
217
  DynatraceBridge_1.DynatraceNative.sendBizEvent(type, internalAttributes, platform === null || platform === void 0 ? void 0 : platform.toString());
209
218
  }
210
219
  else {
211
- Logger_1.Logger.logInfo(`Dynatrace sendBizEvent(${type}, ${attributes}): React Native plugin has not been started yet! Biz Event will not be reported!`);
220
+ logger.info(`sendBizEvent(${type}, ${attributes}): React Native plugin has not been started yet! Biz Event will not be reported!`);
212
221
  }
213
222
  },
214
223
  endSession: (platform) => {
215
224
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
216
- Logger_1.Logger.logDebug('Dynatrace endSession()');
225
+ logger.debug('Dynatrace endSession()');
217
226
  DynatraceBridge_1.DynatraceNative.endVisit(platform === null || platform === void 0 ? void 0 : platform.toString());
218
227
  }
219
228
  else {
220
- Logger_1.Logger.logInfo('Dynatrace endSession(): React Native plugin has not been started yet! Session will not be ended!');
229
+ logger.info('endSession(): React Native plugin has not been started yet! Session will not be ended!');
221
230
  }
222
231
  },
223
232
  identifyUser: (user, platform) => {
224
233
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
225
- Logger_1.Logger.logDebug(`Dynatrace identifyUser(${user})`);
234
+ logger.debug(`Dynatrace identifyUser(${user})`);
226
235
  DynatraceBridge_1.DynatraceNative.identifyUser(user, platform === null || platform === void 0 ? void 0 : platform.toString());
227
236
  }
228
237
  else {
229
- Logger_1.Logger.logInfo(`Dynatrace identifyUser(${user}): React Native plugin has not been started yet! Session will not be tagged!`);
238
+ logger.info(`identifyUser(${user}): React Native plugin has not been started yet! Session will not be tagged!`);
230
239
  }
231
240
  },
232
241
  setGPSLocation: (latitude, longitude, platform) => {
233
242
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
234
- Logger_1.Logger.logDebug(`Dynatrace setGPSLocation(${latitude}, ${longitude})`);
243
+ logger.debug(`setGPSLocation(${latitude}, ${longitude})`);
235
244
  DynatraceBridge_1.DynatraceNative.setGPSLocation(latitude, longitude, platform === null || platform === void 0 ? void 0 : platform.toString());
236
245
  }
237
246
  else {
238
- Logger_1.Logger.logInfo(`Dynatrace setGPSLocation(${latitude}, ${longitude}): React Native plugin has not been started yet! GPS Position will not be set!`);
247
+ logger.info(`setGPSLocation(${latitude}, ${longitude}): React Native plugin has not been started yet! GPS Position will not be set!`);
239
248
  }
240
249
  },
241
250
  isCrashReportingOptedIn: (platform) => __awaiter(void 0, void 0, void 0, function* () {
242
251
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
243
- Logger_1.Logger.logDebug('Dynatrace isCrashReportingOptedIn()');
252
+ logger.debug('Dynatrace isCrashReportingOptedIn()');
244
253
  return DynatraceBridge_1.DynatraceNative.isCrashReportingOptedIn(platform === null || platform === void 0 ? void 0 : platform.toString());
245
254
  }
246
255
  else {
247
- Logger_1.Logger.logInfo('Dynatrace isCrashReportingOptedIn(): React Native plugin has not been started yet! Crash reporting value not available!');
256
+ logger.info('isCrashReportingOptedIn(): React Native plugin has not been started yet! Crash reporting value not available!');
248
257
  return false;
249
258
  }
250
259
  }),
251
260
  setCrashReportingOptedIn: (crashReporting, platform) => {
252
261
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
253
- Logger_1.Logger.logDebug(`Dynatrace setCrashReportingOptedIn(${crashReporting})`);
262
+ logger.debug(`setCrashReportingOptedIn(${crashReporting})`);
254
263
  DynatraceBridge_1.DynatraceNative.setCrashReportingOptedIn(crashReporting, platform === null || platform === void 0 ? void 0 : platform.toString());
255
264
  }
256
265
  else {
257
- Logger_1.Logger.logInfo(`Dynatrace setCrashReportingOptedIn(${crashReporting}): React Native plugin has not been started yet! Crash reporting value will not be set!`);
266
+ logger.info(`setCrashReportingOptedIn(${crashReporting}): React Native plugin has not been started yet! Crash reporting value will not be set!`);
258
267
  }
259
268
  },
260
269
  getDataCollectionLevel: (platform) => __awaiter(void 0, void 0, void 0, function* () {
261
270
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
262
- Logger_1.Logger.logDebug('Dynatrace getDataCollectionLevel()');
271
+ logger.debug('getDataCollectionLevel()');
263
272
  return (0, DataCollectionLevel_1.StringToDataCollectionLevel)(yield DynatraceBridge_1.DynatraceNative.getDataCollectionLevel(platform === null || platform === void 0 ? void 0 : platform.toString()));
264
273
  }
265
274
  else {
266
- Logger_1.Logger.logInfo('Dynatrace getDataCollectionLevel(): React Native plugin has not been started yet! Data Collection level not available!');
275
+ logger.info('getDataCollectionLevel(): React Native plugin has not been started yet! Data Collection level not available!');
267
276
  return DataCollectionLevel_1.DataCollectionLevel.Off;
268
277
  }
269
278
  }),
270
279
  setDataCollectionLevel: (dataCollectionLevel, platform) => {
271
280
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
272
- Logger_1.Logger.logDebug(`Dynatrace setDataCollectionLevel(${dataCollectionLevel})`);
281
+ logger.debug(`setDataCollectionLevel(${dataCollectionLevel})`);
273
282
  DynatraceBridge_1.DynatraceNative.setDataCollectionLevel(dataCollectionLevel.toString(), platform === null || platform === void 0 ? void 0 : platform.toString());
274
283
  }
275
284
  else {
276
- Logger_1.Logger.logInfo(`Dynatrace setDataCollectionLevel(${dataCollectionLevel}): React Native plugin has not been started yet! Data Collection level will not be set!`);
285
+ logger.info(`setDataCollectionLevel(${dataCollectionLevel}): React Native plugin has not been started yet! Data Collection level will not be set!`);
277
286
  }
278
287
  },
279
288
  getUserPrivacyOptions: (platform) => __awaiter(void 0, void 0, void 0, function* () {
280
289
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
281
- Logger_1.Logger.logDebug('Dynatrace getUserPrivacyOptions()');
290
+ logger.debug('getUserPrivacyOptions()');
282
291
  const options = yield DynatraceBridge_1.DynatraceNative.getUserPrivacyOptions(platform === null || platform === void 0 ? void 0 : platform.toString());
283
292
  const currentOptions = new UserPrivacyOptions_1.UserPrivacyOptions((0, DataCollectionLevel_1.StringToDataCollectionLevel)(options.dataCollectionLevel), options.crashReportingOptedIn);
284
293
  return currentOptions;
285
294
  }
286
295
  else {
287
- Logger_1.Logger.logInfo('Dynatrace getUserPrivacyOptions(): React Native plugin has not been started yet! User Privacy Options are not available!');
296
+ logger.info('getUserPrivacyOptions(): React Native plugin has not been started yet! User Privacy Options are not available!');
288
297
  return new UserPrivacyOptions_1.UserPrivacyOptions(DataCollectionLevel_1.DataCollectionLevel.Off, false);
289
298
  }
290
299
  }),
@@ -293,26 +302,26 @@ exports.Dynatrace = {
293
302
  if ((userPrivacyOptions.crashReportingOptedIn === true ||
294
303
  userPrivacyOptions.crashReportingOptedIn === false) &&
295
304
  userPrivacyOptions.dataCollectionLevel in DataCollectionLevel_1.DataCollectionLevel) {
296
- Logger_1.Logger.logDebug(`Dynatrace applyUserPrivacyOptions(${JSON.stringify(userPrivacyOptions)})`);
305
+ logger.debug(`applyUserPrivacyOptions(${JSON.stringify(userPrivacyOptions)})`);
297
306
  DynatraceBridge_1.DynatraceNative.applyUserPrivacyOptions(userPrivacyOptions, platform === null || platform === void 0 ? void 0 : platform.toString());
298
307
  }
299
308
  }
300
309
  else {
301
- Logger_1.Logger.logInfo(`Dynatrace applyUserPrivacyOptions(${JSON.stringify(userPrivacyOptions)}): React Native plugin has not been started yet! User Privacy Options can't be applied!`);
310
+ logger.info(`applyUserPrivacyOptions(${JSON.stringify(userPrivacyOptions)}): React Native plugin has not been started yet! User Privacy Options can't be applied!`);
302
311
  }
303
312
  },
304
313
  flushEvents: (platform) => {
305
314
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
306
- Logger_1.Logger.logDebug('Dynatrace flushEvents()');
315
+ logger.debug('flushEvents()');
307
316
  DynatraceBridge_1.DynatraceNative.flushEvents(platform === null || platform === void 0 ? void 0 : platform.toString());
308
317
  }
309
318
  else {
310
- Logger_1.Logger.logInfo('Dynatrace flushEvents(): React Native plugin has not been started yet! Flushing Event not possible!');
319
+ logger.info('flushEvents(): React Native plugin has not been started yet! Flushing Event not possible!');
311
320
  }
312
321
  },
313
322
  setBeaconHeaders: (headers, platform) => {
314
323
  if (ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
315
- Logger_1.Logger.logDebug('Dynatrace setBeaconHeaders(headers)');
324
+ logger.debug('setBeaconHeaders(headers)');
316
325
  if (headers && headers.size > 0) {
317
326
  const obj = {};
318
327
  headers.forEach((value, key) => (obj[key] = value));
@@ -323,7 +332,7 @@ exports.Dynatrace = {
323
332
  }
324
333
  }
325
334
  else {
326
- Logger_1.Logger.logInfo('Dynatrace setBeaconHeaders(headers): React Native plugin has not been started yet! Setting Beacon Headers is not possible!');
335
+ logger.info('setBeaconHeaders(headers): React Native plugin has not been started yet! Setting Beacon Headers is not possible!');
327
336
  }
328
337
  },
329
338
  };