@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
@@ -1,366 +0,0 @@
1
- package com.dynatrace.android.agent;
2
-
3
- import static com.dynatrace.android.agent.DynatraceUtils.toHashMap;
4
-
5
- import com.dynatrace.android.agent.conf.DynatraceConfigurationBuilder;
6
- import com.dynatrace.android.agent.crash.PlatformType;
7
- import com.facebook.react.bridge.Promise;
8
- import com.facebook.react.bridge.WritableMap;
9
- import com.facebook.react.bridge.ReadableMap;
10
- import com.facebook.react.bridge.Arguments;
11
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
12
- import com.facebook.react.bridge.ReactApplicationContext;
13
- import com.facebook.react.bridge.ReactMethod;
14
- import com.facebook.react.bridge.ReadableMapKeySetIterator;
15
-
16
- import java.net.URI;
17
- import java.net.URISyntaxException;
18
- import java.util.Hashtable;
19
- import java.util.HashMap;
20
- import java.util.Map;
21
-
22
- import android.location.Location;
23
-
24
- import org.json.JSONObject;
25
-
26
- import com.dynatrace.android.agent.conf.DataCollectionLevel;
27
- import com.dynatrace.android.agent.conf.UserPrivacyOptions;
28
-
29
- public class DynatraceRNBridgeImpl {
30
-
31
- private HashMap<String, WebRequestTiming> webTimings;
32
- private HashMap<String, DTXAction> actions;
33
- private static final String PLATFORM_ANDROID = "android";
34
- private static final String PLATFORM_IOS = "ios";
35
- private static final String DATA_COLLECTION_OFF = "OFF";
36
- private static final String DATA_COLLECTION_PERFORMANCE = "PERFORMANCE";
37
- private static final String DATA_COLLECTION_USERBEHAVIOR = "USER_BEHAVIOR";
38
-
39
- public static final String NAME = "DynatraceBridge";
40
-
41
- private static PrivateDTBridge _internal;
42
- private final ReactApplicationContext reactApplicationContext;
43
-
44
- public DynatraceRNBridgeImpl(ReactApplicationContext reactContext, PrivateDTBridge internal) {
45
- webTimings = new HashMap<>();
46
- actions = new HashMap<>();
47
- _internal = internal;
48
- reactApplicationContext = reactContext;
49
- }
50
-
51
- public Map<String, Object> getConstants() {
52
- final Map<String, Object> constants = new HashMap<>();
53
- constants.put("PLATFORM_ANDROID", PLATFORM_ANDROID);
54
- constants.put("PLATFORM_IOS", PLATFORM_IOS);
55
- constants.put("DATA_COLLECTION_OFF", DATA_COLLECTION_OFF);
56
- constants.put("DATA_COLLECTION_PERFORMANCE", DATA_COLLECTION_PERFORMANCE);
57
- constants.put("DATA_COLLECTION_USERBEHAVIOR", DATA_COLLECTION_USERBEHAVIOR);
58
- return constants;
59
- }
60
-
61
- public void start(ReadableMap configuration, Promise promise) {
62
- if (configuration == null) {
63
- promise.resolve(false);
64
- return;
65
- } else {
66
- if(configuration.getString("applicationId") == null || configuration.getString("beaconUrl") == null){
67
- promise.resolve(false);
68
- return;
69
- }
70
-
71
- DynatraceConfigurationBuilder builder = new DynatraceConfigurationBuilder(configuration.getString("applicationId"),
72
- configuration.getString("beaconUrl"));
73
-
74
- builder.withUserOptIn(configuration.getBoolean("userOptIn"));
75
- builder.withCrashReporting(configuration.getBoolean("reportCrash"));
76
- // 0 == Debug / 1 == Info
77
- builder.withDebugLogging(configuration.getInt("logLevel") == 0);
78
-
79
- Dynatrace.startup(reactApplicationContext, builder.buildConfiguration());
80
-
81
- promise.resolve(true);
82
- }
83
- }
84
-
85
- //
86
- // Expects a key which is generated in JS. This is to circumvent the async callback system.
87
- //
88
- public void enterAction(String name, String key, String platform) {
89
- if (this.shouldWorkOnAndroid(platform)) {
90
- try {
91
- newAction(name, key);
92
- }
93
- catch (Exception e) {}
94
- }
95
- }
96
-
97
- public void enterManualAction(String name, String key, String platform) {
98
- if (this.shouldWorkOnAndroid(platform)) {
99
- actions.put(key, Dynatrace.enterAction(name));
100
- }
101
- }
102
-
103
- public void enterManualActionWithParent(String name, String key, String parentKey, String platform) {
104
- if (this.shouldWorkOnAndroid(platform)) {
105
- DTXAction parent = actions.get(parentKey);
106
-
107
- if (parent != null) {
108
- actions.put(key, Dynatrace.enterAction(name, parent));
109
- } else {
110
- enterManualAction(name, key, platform);
111
- }
112
- }
113
- }
114
-
115
- public void leaveAction(String key, boolean leave, String platform) {
116
- if (this.shouldWorkOnAndroid(platform)) {
117
- DTXAction action = getAction(key);
118
- if (action == null) return;
119
- if (action instanceof DTXAutoAction){
120
- ((DTXAutoAction) action).startTimer();
121
- }else{
122
- action.leaveAction();
123
- }
124
-
125
- actions.remove(key);
126
- }
127
- }
128
-
129
- public void cancelAction(String key, String platform) {
130
- if (this.shouldWorkOnAndroid(platform)) {
131
- DTXAction action = getAction(key);
132
- if (action == null) return;
133
- action.cancel();
134
- actions.remove(key);
135
- }
136
- }
137
-
138
- public void endVisit(String platform) {
139
- if (this.shouldWorkOnAndroid(platform)) {
140
- Dynatrace.endVisit();
141
- }
142
- }
143
-
144
- public void reportErrorWithoutStacktrace(String errorName, int errorCode, String platform) {
145
- if (this.shouldWorkOnAndroid(platform)) {
146
- Dynatrace.reportError(errorName, errorCode);
147
- }
148
- }
149
-
150
- /**
151
- * Reports a stacktrace
152
- * @param errorName Name of the Error - SyntaxError
153
- * @param errorValue Value of the Error
154
- * @param reason Reason for the Error
155
- * @param stacktrace Whole Stacktrace
156
- * @param platform Platform wise or both
157
- */
158
- public void reportError(String errorName, String errorValue, String reason, String stacktrace, String platform){
159
- if (this.shouldWorkOnAndroid(platform)) {
160
- Dynatrace.reportError(PlatformType.CUSTOM, errorName, errorValue, reason, stacktrace);
161
- }
162
- }
163
-
164
- public void reportCrash(String errorName, String reason, String stacktrace, boolean isRealError, String platform){
165
- if (this.shouldWorkOnAndroid(platform)) {
166
- Dynatrace.reportCrash(isRealError ? PlatformType.JAVA_SCRIPT : PlatformType.CUSTOM, errorName, reason, stacktrace);
167
- // Generate new session like iOS to make sure the behavior is the same
168
- Dynatrace.createNewSession();
169
- }
170
- }
171
-
172
- public void reportErrorInAction(String key, String errorName, int errorCode, String platform) {
173
- if (this.shouldWorkOnAndroid(platform)) {
174
- DTXAction action = getAction(key);
175
- if (action == null) return;
176
- action.reportError(errorName, errorCode);
177
- }
178
- }
179
-
180
- public void reportValue(String key, String valueName, String value, String platform) {
181
- if (this.shouldWorkOnAndroid(platform)) {
182
- DTXAction action = getAction(key);
183
- if (action == null) return;
184
- action.reportValue(valueName, value);
185
- }
186
- }
187
-
188
- public void getRequestTag(String key, String url, Promise promise){
189
- DTXAction action = getAction(key);
190
-
191
- if (action == null){
192
- promise.resolve(Dynatrace.getRequestTag());
193
- return;
194
- };
195
-
196
- promise.resolve(action.getRequestTag());
197
- }
198
-
199
- public void startWebRequestTiming(String requestTag, String url) {
200
- if (requestTag != null) {
201
- WebRequestTiming timing = Dynatrace.getWebRequestTiming(requestTag);
202
- if(timing != null){
203
- webTimings.put(requestTag, timing);
204
- timing.startWebRequestTiming();
205
- }
206
- }
207
- }
208
-
209
- public void stopWebRequestTiming(String requestTag, String url, int responseCode, String responseMessage) {
210
- stopWebRequestTimingWithSize(requestTag, url, responseCode, responseMessage, -1, -1);
211
- }
212
-
213
- public void stopWebRequestTimingWithSize(String requestTag, String url, int responseCode, String responseMessage, long requestSize, long responseSize) {
214
- if (requestTag != null) {
215
- WebRequestTiming timing = webTimings.get(requestTag);
216
- if (timing != null) {
217
- try {
218
- timing.stopWebRequestTiming(new URI(url), responseCode, responseMessage, requestSize, responseSize);
219
- webTimings.remove(requestTag);
220
- } catch (URISyntaxException ex) {
221
- // do nothing
222
- }
223
- }
224
- }
225
- }
226
-
227
- public void identifyUser(String user, String plaform) {
228
- if (this.shouldWorkOnAndroid(plaform)) {
229
- Dynatrace.identifyUser(user);
230
- }
231
- }
232
-
233
- public void reportEventInAction(String actionKey, String name, String platform) {
234
- if (this.shouldWorkOnAndroid(platform)) {
235
- DTXAction action = getAction(actionKey);
236
- if (action == null) return;
237
- action.reportEvent(name);
238
- }
239
- }
240
-
241
- public void reportStringValueInAction(String actionKey, String name, String value, String platform) {
242
- if (this.shouldWorkOnAndroid(platform)) {
243
- DTXAction action = getAction(actionKey);
244
- if (action == null) return;
245
- action.reportValue(name, value);
246
- }
247
- }
248
-
249
- public void reportIntValueInAction(String actionKey, String name, int value, String platform) {
250
- if (this.shouldWorkOnAndroid(platform)) {
251
- DTXAction action = getAction(actionKey);
252
- if (action == null) return;
253
- action.reportValue(name, value);
254
- }
255
- }
256
-
257
- public void reportDoubleValueInAction(String actionKey, String name, double value, String platform) {
258
- if (this.shouldWorkOnAndroid(platform)) {
259
- DTXAction action = getAction(actionKey);
260
- if (action == null) return;
261
- action.reportValue(name, value);
262
- }
263
- }
264
-
265
- public void sendBizEvent(String type, ReadableMap attributes, String platform) {
266
- if(this.shouldWorkOnAndroid(platform)) {
267
- Dynatrace.sendBizEvent(type, new JSONObject(toHashMap(attributes)));
268
- }
269
- }
270
-
271
- public void forwardEvent(ReadableMap attributes) {
272
- HybridBridge.forwardEvent(new JSONObject(toHashMap(attributes)));
273
- }
274
-
275
- public void setGPSLocation(double latitude, double longitude, String platform){
276
- if(this.shouldWorkOnAndroid(platform)){
277
- Location location = new Location("");
278
- location.setLatitude(latitude);
279
- location.setLongitude(longitude);
280
- Dynatrace.setGpsLocation(location);
281
- }
282
- }
283
-
284
- public void flushEvents(String platform){
285
- if(this.shouldWorkOnAndroid(platform)){
286
- Dynatrace.flushEvents();
287
- }
288
- }
289
-
290
- public void isCrashReportingOptedIn(String platform, Promise promise){
291
- if(this.shouldWorkOnAndroid(platform)){
292
- promise.resolve(Dynatrace.isCrashReportingOptedIn());
293
- }
294
- }
295
-
296
- public void setCrashReportingOptedIn(boolean crashReporting, String platform){
297
- if(this.shouldWorkOnAndroid(platform)){
298
- Dynatrace.setCrashReportingOptedIn(crashReporting);
299
- }
300
- }
301
-
302
- public void setDataCollectionLevel(String collectionLevel, String platform){
303
- if(this.shouldWorkOnAndroid(platform)){
304
- Dynatrace.setDataCollectionLevel(DataCollectionLevel.valueOf(collectionLevel));
305
- }
306
- }
307
-
308
- public void getDataCollectionLevel(String platform, Promise promise){
309
- if(this.shouldWorkOnAndroid(platform)){
310
- DataCollectionLevel level = Dynatrace.getDataCollectionLevel();
311
- promise.resolve(level.name());
312
- }
313
- }
314
-
315
- public void setBeaconHeaders(ReadableMap headers, String platform){
316
- if(this.shouldWorkOnAndroid(platform)){
317
- if (headers == null) {
318
- Dynatrace.setBeaconHeaders(null);
319
- } else {
320
- Map<String, String> beaconHeaders = new HashMap<>();
321
- ReadableMapKeySetIterator iterator = headers.keySetIterator();
322
- while (iterator.hasNextKey()) {
323
- String currentKey = iterator.nextKey();
324
- beaconHeaders.put(currentKey, headers.getString(currentKey));
325
- }
326
- Dynatrace.setBeaconHeaders(beaconHeaders);
327
- }
328
- }
329
- }
330
-
331
- public void applyUserPrivacyOptions(ReadableMap userPrivacyOptions, String platform){
332
- if(this.shouldWorkOnAndroid(platform)){
333
- UserPrivacyOptions.Builder optionsBuilder = UserPrivacyOptions.builder();
334
- optionsBuilder.withCrashReportingOptedIn(userPrivacyOptions.getBoolean("_crashReportingOptedIn"));
335
- optionsBuilder.withDataCollectionLevel(DataCollectionLevel.valueOf(userPrivacyOptions.getString("_dataCollectionLevel")));
336
-
337
- Dynatrace.applyUserPrivacyOptions(optionsBuilder
338
- .build()
339
- );
340
- }
341
- }
342
-
343
- public void getUserPrivacyOptions(String platform, Promise promise){
344
- if(this.shouldWorkOnAndroid(platform)){
345
- UserPrivacyOptions options = Dynatrace.getUserPrivacyOptions();
346
- WritableMap privacyMap = Arguments.createMap();
347
- privacyMap.putString("dataCollectionLevel", options.getDataCollectionLevel().name());
348
- privacyMap.putBoolean("crashReportingOptedIn", options.isCrashReportingOptedIn());
349
- promise.resolve(privacyMap);
350
- }
351
- }
352
-
353
- private void newAction(String name, String key) throws Exception {
354
- if (name == null) throw new Exception("action name is null");
355
- actions.put(key, _internal.enterAction(name));
356
- }
357
-
358
- private DTXAction getAction(String key){
359
- return actions.get(key);
360
- }
361
-
362
- private Boolean shouldWorkOnAndroid(String platform) {
363
- return platform == null || platform.equals(PLATFORM_ANDROID) || platform.equals("");
364
- }
365
-
366
- }
@@ -1,67 +0,0 @@
1
- package com.dynatrace.android.agent;
2
-
3
- import androidx.annotation.Nullable;
4
- import android.util.Log;
5
-
6
- import com.facebook.react.ReactPackage;
7
- import com.facebook.react.TurboReactPackage;
8
- import com.facebook.react.bridge.NativeModule;
9
- import com.facebook.react.bridge.ReactApplicationContext;
10
- import com.facebook.react.module.model.ReactModuleInfo;
11
- import com.facebook.react.module.model.ReactModuleInfoProvider;
12
- import com.facebook.react.uimanager.ViewManager;
13
-
14
- import java.util.HashMap;
15
- import java.util.Map;
16
-
17
- import java.util.Arrays;
18
- import java.util.Collections;
19
- import java.util.List;
20
-
21
- public class DynatraceReactPackage extends TurboReactPackage implements ReactPackage {
22
-
23
- @Override
24
- public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
25
- return Collections.emptyList();
26
- }
27
-
28
- @Override
29
- public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
30
- PrivateDTBridge bridge = new PrivateDTBridge(reactContext);
31
- return Arrays.<NativeModule>asList(new DynatraceRNBridge(reactContext, bridge), bridge);
32
- }
33
-
34
- @Override
35
- public ReactModuleInfoProvider getReactModuleInfoProvider() {
36
- final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
37
- boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
38
- moduleInfos.put(
39
- DynatraceRNBridgeImpl.NAME,
40
- new ReactModuleInfo(
41
- DynatraceRNBridgeImpl.NAME,
42
- DynatraceRNBridgeImpl.NAME,
43
- false, // canOverrideExistingModule
44
- false, // needsEagerInit
45
- true, // hasConstants
46
- false, // isCxxModule
47
- isTurboModule // isTurboModule
48
- ));
49
-
50
- return new ReactModuleInfoProvider() {
51
- @Override
52
- public Map<String, ReactModuleInfo> getReactModuleInfos() {
53
- return moduleInfos;
54
- }
55
- };
56
- }
57
-
58
- @Nullable
59
- @Override
60
- public NativeModule getModule(String name, ReactApplicationContext reactContext) {
61
- if (name.equals(DynatraceRNBridgeImpl.NAME)) {
62
- return new DynatraceRNBridge(reactContext, new PrivateDTBridge(reactContext));
63
- } else {
64
- return null;
65
- }
66
- }
67
- }
@@ -1,108 +0,0 @@
1
- package com.dynatrace.android.agent;
2
-
3
- import java.util.ArrayList;
4
- import java.util.HashMap;
5
-
6
- import com.facebook.react.bridge.ReadableArray;
7
- import com.facebook.react.bridge.ReadableMap;
8
- import com.facebook.react.bridge.ReadableMapKeySetIterator;
9
-
10
- /**
11
- * @author matthias.hochrieser
12
- */
13
- class DynatraceUtils {
14
-
15
- // https://github.com/facebook/react-native/blob/1e8f3b11027fe0a7514b4fc97d0798d3c64bc895/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java#L56
16
- private static ArrayList<Object> toArrayList(ReadableArray array) {
17
- ArrayList<Object> arrayList = new ArrayList<>(array.size());
18
- for (int i = 0, size = array.size(); i < size; i++) {
19
- switch (array.getType(i)) {
20
- case Null:
21
- arrayList.add(null);
22
- break;
23
- case Boolean:
24
- arrayList.add(array.getBoolean(i));
25
- break;
26
- case Number:
27
- double value = array.getDouble(i);
28
-
29
- if(Double.isFinite(value)){
30
- if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE && value == (int) value) {
31
- // This is a int
32
- arrayList.add((int) array.getDouble(i));
33
- }
34
-
35
- if (value >= Long.MIN_VALUE && value <= Long.MAX_VALUE && value == (long) value){
36
- // This is a long
37
- arrayList.add((long) array.getDouble(i));
38
- }
39
-
40
- break;
41
- }
42
-
43
- arrayList.add(array.getDouble(i));
44
- break;
45
- case String:
46
- arrayList.add(array.getString(i));
47
- break;
48
- case Map:
49
- arrayList.add(toHashMap(array.getMap(i)));
50
- break;
51
- case Array:
52
- arrayList.add(toArrayList(array.getArray(i)));
53
- break;
54
- default:
55
- throw new IllegalArgumentException("Could not convert object at index: " + i + ".");
56
- }
57
- }
58
- return arrayList;
59
- }
60
-
61
- static HashMap<String, Object> toHashMap(ReadableMap map) {
62
- HashMap<String, Object> hashMap = new HashMap<>();
63
- ReadableMapKeySetIterator iterator = map.keySetIterator();
64
- while (iterator.hasNextKey()) {
65
- String key = iterator.nextKey();
66
- switch (map.getType(key)) {
67
- case Null:
68
- hashMap.put(key, null);
69
- break;
70
- case Boolean:
71
- hashMap.put(key, map.getBoolean(key));
72
- break;
73
- case Number:
74
- double value = map.getDouble(key);
75
-
76
- if(Double.isFinite(value)){
77
- if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE && value == (int) value) {
78
- // This is a int
79
- hashMap.put(key, (int) map.getDouble(key));
80
- }
81
-
82
- if (value >= Long.MIN_VALUE && value <= Long.MAX_VALUE && value == (long) value){
83
- // This is a long
84
- hashMap.put(key, (long) map.getDouble(key));
85
- }
86
-
87
- break;
88
- }
89
-
90
- hashMap.put(key, map.getDouble(key));
91
- break;
92
- case String:
93
- hashMap.put(key, map.getString(key));
94
- break;
95
- case Map:
96
- hashMap.put(key,toHashMap(map.getMap(key)));
97
- break;
98
- case Array:
99
- hashMap.put(key, toArrayList(map.getArray(key)));
100
- break;
101
- default:
102
- throw new IllegalArgumentException("Could not convert object with key: " + key + ".");
103
- }
104
- }
105
- return hashMap;
106
- }
107
-
108
- }
@@ -1,28 +0,0 @@
1
- package com.dynatrace.android.agent;
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext;
4
- import com.facebook.react.bridge.ReactContextBaseJavaModule;
5
- import com.facebook.react.bridge.ReactMethod;
6
-
7
- public class PrivateDTBridge extends ReactContextBaseJavaModule {
8
-
9
- public PrivateDTBridge(ReactApplicationContext reactContext) {
10
- super(reactContext);
11
- }
12
-
13
- @Override
14
- public String getName() {
15
- return "PrivateDTBridge";
16
- }
17
-
18
- /**
19
- * Helper method which should not be called.
20
- * @param name Action name
21
- * @return Action
22
- */
23
- @ReactMethod
24
- public DTXAction enterAction(String name) {
25
- return Dynatrace.integrateNewAction(name);
26
- }
27
-
28
- }