@dynatrace/react-native-plugin 2.285.2 → 2.287.2

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.
package/README.md CHANGED
@@ -30,7 +30,7 @@ If you want to start using this plugin and are not a Dynatrace customer yet, hea
30
30
  This agent versions are configured in this plugin:
31
31
 
32
32
  * Android Agent: 8.287.1.1006
33
- * iOS Agent: 8.285.1.1004
33
+ * iOS Agent: 8.287.2.1009
34
34
 
35
35
  ## Quick Setup
36
36
 
@@ -356,7 +356,11 @@ let timing = new DynatraceWebRequestTiming(url, tag);
356
356
 
357
357
  try {
358
358
  timing.startWebRequestTiming();
359
- let axiosResponse = await axios.get(url);
359
+ let axiosResponse = await axios.get(url, {
360
+ headers: {
361
+ timing.getRequestTagHeader(): tag
362
+ }
363
+ });
360
364
  timing.stopWebRequestTiming(axiosResponse.status, axiosResponse.data);
361
365
  } catch (error) {
362
366
  timing.stopWebRequestTiming(-1, error);
@@ -365,6 +369,26 @@ try {
365
369
  }
366
370
  ```
367
371
 
372
+ There is also the option to report values for request and response size:
373
+
374
+ ```js
375
+ let url = 'https://www.dynatrace.com';
376
+ // You can also use enterAutoAction if desired
377
+ let action = Dynatrace.enterManualAction("Manual Web Request");
378
+ let tag = await action.getRequestTag(url);
379
+ let timing = new DynatraceWebRequestTiming(url, tag);
380
+
381
+ try {
382
+ timing.startWebRequestTiming();
383
+ let axiosResponse = await axios.get(url);
384
+ timing.stopWebRequestTimingWithSize(axiosResponse.status, axiosResponse.data, 122, 63);
385
+ } catch (error) {
386
+ timing.stopWebRequestTiming(-1, error);
387
+ } finally {
388
+ action.leaveAction();
389
+ }
390
+ ```
391
+
368
392
  ### Report values
369
393
 
370
394
  For any open action you can report certain values. The following API is available for action:
@@ -1296,6 +1320,10 @@ If you are struggling with a problem, submit a support ticket to Dynatrace (supp
1296
1320
  <br/><br/>
1297
1321
  ## Changelog
1298
1322
 
1323
+ 2.287.2
1324
+ * Update Android (8.287.1.1006) & iOS Agent (8.287.2.1009)
1325
+ * Added request and response size to [manual web request tagging](#manual-web-request-tagging)
1326
+
1299
1327
  2.285.2
1300
1328
  * Fixed bridge module issue for older React Native versions (< 0.65.0)
1301
1329
  * Introduced support for @react-native/metro-babel-transformer
@@ -13,7 +13,8 @@ import com.facebook.react.bridge.ReactApplicationContext;
13
13
  import com.facebook.react.bridge.ReactMethod;
14
14
  import com.facebook.react.bridge.ReadableMapKeySetIterator;
15
15
 
16
- import java.net.MalformedURLException;
16
+ import java.net.URI;
17
+ import java.net.URISyntaxException;
17
18
  import java.util.Hashtable;
18
19
  import java.util.HashMap;
19
20
  import java.util.Map;
@@ -207,13 +208,17 @@ public class DynatraceRNBridgeImpl {
207
208
  }
208
209
 
209
210
  public void stopWebRequestTiming(String requestTag, String url, int responseCode, String responseMessage) {
211
+ stopWebRequestTimingWithSize(requestTag, url, responseCode, responseMessage, -1, -1);
212
+ }
213
+
214
+ public void stopWebRequestTimingWithSize(String requestTag, String url, int responseCode, String responseMessage, long requestSize, long responseSize) {
210
215
  if (requestTag != null) {
211
216
  WebRequestTiming timing = webTimings.get(requestTag);
212
217
  if (timing != null) {
213
218
  try {
214
- timing.stopWebRequestTiming(url, responseCode, responseMessage);
219
+ timing.stopWebRequestTiming(new URI(url), responseCode, responseMessage, requestSize, responseSize);
215
220
  webTimings.remove(requestTag);
216
- } catch (MalformedURLException ex) {
221
+ } catch (URISyntaxException ex) {
217
222
  // do nothing
218
223
  }
219
224
  }
@@ -105,6 +105,11 @@ public class DynatraceRNBridge extends NativeDynatraceBridgeSpec {
105
105
  this.impl.stopWebRequestTiming(requestTag, url, (int) responseCode, responseMessage);
106
106
  }
107
107
 
108
+ @Override
109
+ public void stopWebRequestTimingWithSize(String requestTag, String url, double responseCode, String responseMessage, double requestSize, double responseSize) {
110
+ this.impl.stopWebRequestTimingWithSize(requestTag, url, (int) responseCode, responseMessage, (long) requestSize, (long) responseSize);
111
+ }
112
+
108
113
  @Override
109
114
  public void identifyUser(String user, String platform) {
110
115
  this.impl.identifyUser(user, platform);
@@ -107,6 +107,11 @@ public class DynatraceRNBridge extends ReactContextBaseJavaModule {
107
107
  this.impl.stopWebRequestTiming(requestTag, url, responseCode, responseMessage);
108
108
  }
109
109
 
110
+ @ReactMethod
111
+ public void stopWebRequestTimingWithSize(String requestTag, String url, int responseCode, String responseMessage, double requestSize, double responseSize) {
112
+ this.impl.stopWebRequestTimingWithSize(requestTag, url, responseCode, responseMessage, (long) requestSize, (long) responseSize);
113
+ }
114
+
110
115
  @ReactMethod
111
116
  public void identifyUser(String user, String platform) {
112
117
  this.impl.identifyUser(user, platform);
@@ -5,19 +5,10 @@
5
5
  #ifndef DynatraceRNBridge_h
6
6
  #define DynatraceRNBridge_h
7
7
 
8
- @import Dynatrace;
9
-
10
- // For Turbo Module
11
- #ifdef RCT_NEW_ARCH_ENABLED
12
- #import "DynatraceBridgeSpec.h"
13
-
14
- @interface DynatraceRNBridge : NSObject <DynatraceBridgeSpec>
15
- // For Legacy Native Module
16
- #else
8
+ #import <Dynatrace/Dynatrace.h>
17
9
  #import <React/RCTBridgeModule.h>
18
10
 
19
11
  @interface DynatraceRNBridge : NSObject <RCTBridgeModule>
20
- #endif
21
12
  - (void) newAction:(NSString *)name key:(NSString *)key parentAction:(DTXAction *)parentAction;
22
13
  - (DTXAction *) getAction:(NSString *)key;
23
14
  - (BOOL) shouldWorkOnIosWithPlatform: (NSString *) platform;
@@ -26,6 +17,7 @@
26
17
  typedef enum : NSUInteger {
27
18
  DTXActionPlatformJavaScript = 1,
28
19
  DTXActionPlatformXamarin,
20
+ DTXActionPlatformCustom = 10
29
21
  } DTXActionPlatformType;
30
22
 
31
23
  @interface DTXAction (ExternalAgents)
@@ -1,5 +1,5 @@
1
1
  //
2
- // DynatraceRNBridge.m
2
+ // DynatraceRNBridge.mm
3
3
  //
4
4
 
5
5
  #import "DynatraceRNBridge.h"
@@ -168,7 +168,7 @@ RCT_EXPORT_METHOD(reportError:(NSString *)errorName errorValue:(NSString *)error
168
168
  {
169
169
  if ([self shouldWorkOnIosWithPlatform: platform])
170
170
  {
171
- [DTXAction reportExternalErrorForPlatformType:-1 errorName:errorName errorValue:errorValue reason:errorReason stacktrace:stacktrace];
171
+ [DTXAction reportExternalErrorForPlatformType:DTXActionPlatformCustom errorName:errorName errorValue:errorValue reason:errorReason stacktrace:stacktrace];
172
172
  }
173
173
  }
174
174
 
@@ -179,7 +179,7 @@ RCT_EXPORT_METHOD(reportCrash:(NSString *)errorName errorReason:(NSString *)erro
179
179
  if(isRealError){
180
180
  [DTXAction reportExternalCrashForPlatformType:DTXActionPlatformJavaScript crashName:errorName reason:errorReason stacktrace:stacktrace];
181
181
  }else{
182
- [DTXAction reportExternalCrashForPlatformType:-1 crashName:errorName reason:errorReason stacktrace:stacktrace];
182
+ [DTXAction reportExternalCrashForPlatformType:DTXActionPlatformCustom crashName:errorName reason:errorReason stacktrace:stacktrace];
183
183
  }
184
184
 
185
185
  // We ignore the newSession parameter and always end the session as the iOS agent has no troubles with this behavior
@@ -187,22 +187,24 @@ RCT_EXPORT_METHOD(reportCrash:(NSString *)errorName errorReason:(NSString *)erro
187
187
  }
188
188
  }
189
189
 
190
- RCT_EXPORT_METHOD(storeCrash:(NSString *)crashName reason:(NSString *)reason stacktrace:(NSString *)stacktrace platform:(NSString *) platform) {
191
- if ([self shouldWorkOnIosWithPlatform: platform])
192
- {
193
- NSString* dirPath = [[[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] firstObject] path];
194
- dirPath = [dirPath stringByAppendingPathComponent:@"DTXExternalCrashes"];
195
- // Create the Application Support/DTXExternalCrashes directory if it does not exist
196
- if (![[NSFileManager defaultManager] fileExistsAtPath:dirPath]) {
197
- NSError *e;
198
- [[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:&e];
199
- NSAssert(e == nil, @"Couldn't create Application Support directory, %@", e.localizedDescription);
200
- }
201
- NSDictionary* crashDict = @{ @"crashName": crashName, @"reason": reason, @"stacktrace": stacktrace, @"technologyType": @"j" };
202
- NSData* jsonData = [NSJSONSerialization dataWithJSONObject:crashDict options:NSJSONWritingPrettyPrinted error:nil];
203
- NSString* crashJson= [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
204
- // Store react native crash
205
- [[NSFileManager defaultManager] createFileAtPath:[dirPath stringByAppendingPathComponent:@"RNCrash.txt"] contents:[crashJson dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
190
+ RCT_EXPORT_METHOD(storeCrash:(NSString *)crashName reason:(NSString *)reason stacktrace:(NSString *)stacktrace newSession:(BOOL)newSession) {
191
+ NSString* dirPath = [[[[NSFileManager defaultManager] URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] firstObject] path];
192
+ dirPath = [dirPath stringByAppendingPathComponent:@"DTXExternalCrashes"];
193
+ // Create the Application Support/DTXExternalCrashes directory if it does not exist
194
+ if (![[NSFileManager defaultManager] fileExistsAtPath:dirPath]) {
195
+ NSError *e;
196
+ [[NSFileManager defaultManager] createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:&e];
197
+ NSAssert(e == nil, @"Couldn't create Application Support directory, %@", e.localizedDescription);
198
+ }
199
+ NSDictionary* crashDict = @{ @"crashName": crashName, @"reason": reason, @"stacktrace": stacktrace, @"technologyType": @"j" };
200
+ NSData* jsonData = [NSJSONSerialization dataWithJSONObject:crashDict options:NSJSONWritingPrettyPrinted error:nil];
201
+ NSString* crashJson= [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
202
+ // Store react native crash
203
+ [[NSFileManager defaultManager] createFileAtPath:[dirPath stringByAppendingPathComponent:@"RNCrash.txt"] contents:[crashJson dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
204
+
205
+ // Create a new session if the app is in debug mode or reloadOnFatalError value is set to true where the crash is caught and the app is not forced to shutdown
206
+ if (newSession) {
207
+ [Dynatrace endVisit];
206
208
  }
207
209
  }
208
210
 
@@ -367,19 +369,13 @@ RCT_EXPORT_METHOD(setDataCollectionLevel:(nonnull NSString *) dataCollectionLeve
367
369
  {
368
370
  if ([self shouldWorkOnIosWithPlatform: platform])
369
371
  {
370
- int dataCollectionLevelEnum;
371
-
372
372
  if([dataCollectionLevel isEqualToString: DataCollectionPerformance]){
373
- dataCollectionLevelEnum = DTX_DataCollectionPerformance;
373
+ [Dynatrace setDataCollectionLevel:DTX_DataCollectionPerformance completion:^(BOOL successful) {}];
374
374
  }else if([dataCollectionLevel isEqualToString: DataCollectionUserBehavior]){
375
- dataCollectionLevelEnum = DTX_DataCollectionUserBehavior;
375
+ [Dynatrace setDataCollectionLevel:DTX_DataCollectionUserBehavior completion:^(BOOL successful) {}];
376
376
  }else{
377
- dataCollectionLevelEnum = DTX_DataCollectionOff;
377
+ [Dynatrace setDataCollectionLevel:DTX_DataCollectionOff completion:^(BOOL successful) {}];
378
378
  }
379
-
380
- [Dynatrace setDataCollectionLevel:dataCollectionLevelEnum completion:^(BOOL successful) {
381
- // Do nothing - Not sure
382
- }];
383
379
  }
384
380
  }
385
381
 
@@ -477,7 +473,7 @@ RCT_EXPORT_METHOD(applyUserPrivacyOptions:(NSDictionary *) userPrivacyOptions pl
477
473
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
478
474
  (const facebook::react::ObjCTurboModule::InitParams &)params
479
475
  {
480
- return std::make_shared<facebook::react::<NativeDynatraceBridgeSpecJSI>>(params);
476
+ return std::make_shared<facebook::react::NativeDynatraceBridgeSpecJSI>(params);
481
477
  }
482
478
  #endif
483
479
 
@@ -7,9 +7,9 @@
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
- 680D85DC2243B77D007953B5 /* DynatraceRNBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 680D85DB2243B77D007953B5 /* DynatraceRNBridge.m */; };
10
+ 680D85DC2243B77D007953B5 /* DynatraceRNBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 680D85DB2243B77D007953B5 /* DynatraceRNBridge.mm */; };
11
11
  68368004225F1139001BFE0F /* libDynatrace.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 68FC4BE92243D05900C87820 /* libDynatrace.a */; };
12
- FE85101429BB606C0073625D /* DynatraceRNBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 680D85DB2243B77D007953B5 /* DynatraceRNBridge.m */; };
12
+ FE85101429BB606C0073625D /* DynatraceRNBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 680D85DB2243B77D007953B5 /* DynatraceRNBridge.mm */; };
13
13
  FE85101629BB606C0073625D /* libDynatrace.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 68FC4BE92243D05900C87820 /* libDynatrace.a */; };
14
14
  /* End PBXBuildFile section */
15
15
 
@@ -37,7 +37,7 @@
37
37
  /* Begin PBXFileReference section */
38
38
  134814201AA4EA6300B7C361 /* libRNDynatrace.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNDynatrace.a; sourceTree = BUILT_PRODUCTS_DIR; };
39
39
  680D85DA2243B77D007953B5 /* DynatraceRNBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynatraceRNBridge.h; sourceTree = "<group>"; };
40
- 680D85DB2243B77D007953B5 /* DynatraceRNBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DynatraceRNBridge.m; sourceTree = "<group>"; };
40
+ 680D85DB2243B77D007953B5 /* DynatraceRNBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DynatraceRNBridge.mm; sourceTree = "<group>"; };
41
41
  68FC4BE92243D05900C87820 /* libDynatrace.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libDynatrace.a; path = lib/libDynatrace.a; sourceTree = "<group>"; };
42
42
  68FC4BEA2243D05900C87820 /* Dynatrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Dynatrace.h; path = lib/Dynatrace.h; sourceTree = "<group>"; };
43
43
  FE85101B29BB606C0073625D /* libRNDynatrace-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libRNDynatrace-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -77,7 +77,7 @@
77
77
  134814211AA4EA7D00B7C361 /* Products */,
78
78
  FE85101B29BB606C0073625D /* libRNDynatrace-tvOS.a */,
79
79
  680D85DA2243B77D007953B5 /* DynatraceRNBridge.h */,
80
- 680D85DB2243B77D007953B5 /* DynatraceRNBridge.m */,
80
+ 680D85DB2243B77D007953B5 /* DynatraceRNBridge.mm */,
81
81
  680D868C2243CCA0007953B5 /* Frameworks */,
82
82
  );
83
83
  sourceTree = "<group>";
@@ -166,7 +166,7 @@
166
166
  isa = PBXSourcesBuildPhase;
167
167
  buildActionMask = 2147483647;
168
168
  files = (
169
- 680D85DC2243B77D007953B5 /* DynatraceRNBridge.m in Sources */,
169
+ 680D85DC2243B77D007953B5 /* DynatraceRNBridge.mm in Sources */,
170
170
  );
171
171
  runOnlyForDeploymentPostprocessing = 0;
172
172
  };
@@ -174,7 +174,7 @@
174
174
  isa = PBXSourcesBuildPhase;
175
175
  buildActionMask = 2147483647;
176
176
  files = (
177
- FE85101429BB606C0073625D /* DynatraceRNBridge.m in Sources */,
177
+ FE85101429BB606C0073625D /* DynatraceRNBridge.mm in Sources */,
178
178
  );
179
179
  runOnlyForDeploymentPostprocessing = 0;
180
180
  };
@@ -10,7 +10,7 @@ class DynatraceWebRequestTiming {
10
10
  this.url = url;
11
11
  }
12
12
  startWebRequestTiming() {
13
- if (this.requestTag != null && !StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url)) {
13
+ if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.requestTag) && !StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url)) {
14
14
  DynatraceBridge_1.DynatraceNative.startWebRequestTiming(this.requestTag, this.url);
15
15
  }
16
16
  else {
@@ -18,13 +18,17 @@ class DynatraceWebRequestTiming {
18
18
  }
19
19
  }
20
20
  stopWebRequestTiming(responseCode, responseMessage) {
21
- if (this.requestTag != null && !StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url) &&
22
- responseCode != null && !(Boolean(StringUtils_1.StringUtils.isStringNullOrUndefined(responseMessage)))) {
23
- DynatraceBridge_1.DynatraceNative.stopWebRequestTiming(this.requestTag, this.url, responseCode, responseMessage);
21
+ this.stopWebRequestTimingWithSize(responseCode, responseMessage, -1, -1);
22
+ }
23
+ stopWebRequestTimingWithSize(responseCode, responseMessage, requestSize, responseSize) {
24
+ if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.requestTag) && !StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url) &&
25
+ responseCode != null && !StringUtils_1.StringUtils.isStringNullOrUndefined(responseMessage)) {
26
+ DynatraceBridge_1.DynatraceNative.stopWebRequestTimingWithSize(this.requestTag, this.url, responseCode, responseMessage, requestSize, responseSize);
24
27
  }
25
28
  else {
26
- Logger_1.Logger.logDebug(`Web Request Timing could not be stopped! - Request Tag:
27
- ${this.requestTag} Url: ${this.url} responseCode: ${responseCode} responseMessage: ${responseMessage}`);
29
+ Logger_1.Logger.logDebug(`Web Request Timing could not be stopped! - requestTag: ${this.requestTag} ` +
30
+ `url: ${this.url} responseCode: ${responseCode} responseMessage: ${responseMessage} ` +
31
+ `requestSize: ${requestSize} responseSize: ${responseSize}`);
28
32
  }
29
33
  }
30
34
  getRequestTag() {
@@ -6,6 +6,9 @@ class NullWebRequestTiming {
6
6
  stopWebRequestTiming(responseCode, responseMessage) {
7
7
  return;
8
8
  }
9
+ stopWebRequestTimingWithSize(responseCode, responseMessage, requestSize, responseSize) {
10
+ return;
11
+ }
9
12
  getRequestTag() {
10
13
  return '';
11
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynatrace/react-native-plugin",
3
- "version": "2.285.2",
3
+ "version": "2.287.2",
4
4
  "description": "This plugin gives you the ability to use the Dynatrace Mobile agent in your react native application.",
5
5
  "main": "index.js",
6
6
  "types": "typings/react-native-dynatrace.d.ts",
@@ -71,7 +71,7 @@
71
71
  "author": "Dynatrace",
72
72
  "license": "SEE LICENSE IN LICENSE.md",
73
73
  "dependencies": {
74
- "@babel/runtime": "^7.24.0",
74
+ "@babel/runtime": "^7.24.1",
75
75
  "jscodeshift": "^0.15.2",
76
76
  "plist": "^3.1.0",
77
77
  "proxy-polyfill": "^0.3.2",
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
14
14
  s.homepage = package['homepage']
15
15
  s.ios.deployment_target = "12.0"
16
16
  s.tvos.deployment_target = "12.0"
17
- s.source_files = ["ios/*.{h,m}","ios/lib/*.h"]
17
+ s.source_files = ["ios/*.{h,mm}"]
18
18
 
19
19
  s.license = { :type => 'Commercial', :text => 'https://github.com/Dynatrace/dem-license/blob/main/LICENSE.md'}
20
20
 
@@ -111,7 +111,7 @@ Pod::Spec.new do |s|
111
111
  #
112
112
 
113
113
  s.dependency "React"
114
- s.dependency 'Dynatrace', '~> 8.285.1.1004'
114
+ s.dependency 'Dynatrace', '~> 8.287.2.1009'
115
115
 
116
116
  # Allows for better compatibility for older and newer versions
117
117
  if defined?(install_modules_dependencies)
@@ -79,6 +79,9 @@ export interface Spec extends TurboModule {
79
79
  startWebRequestTiming(requestTag: string, url: string): void;
80
80
 
81
81
  stopWebRequestTiming(requestTag: string, url: string, responseCode: number, responseMessage: string): void;
82
+
83
+ stopWebRequestTimingWithSize(requestTag: string, url: string, responseCode: number, responseMessage: string,
84
+ requestSize: number, responseSize: number): void;
82
85
  }
83
86
 
84
87
  // eslint-disable-next-line @typescript-eslint/consistent-type-definitions