@dynatrace/react-native-plugin 2.339.1 → 2.343.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 (62) hide show
  1. package/README.md +149 -23
  2. package/android/build.gradle +11 -2
  3. package/android/src/main/java/com/dynatrace/android/agent/DynatraceAppStartModule.kt +9 -31
  4. package/android/src/main/java/com/dynatrace/android/agent/DynatraceConfigurationModule.kt +1 -0
  5. package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +41 -1
  6. package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.kt +1 -0
  7. package/android/src/main/java/com/dynatrace/android/agent/ScreenshotSelfMonitor.kt +175 -0
  8. package/android/src/main/java/com/dynatrace/android/agent/UIChangeScreenshotListener.kt +124 -0
  9. package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +33 -0
  10. package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +40 -0
  11. package/files/plugin.gradle +1 -1
  12. package/instrumentation/BabelPluginDynatrace.js +1 -1
  13. package/instrumentation/DynatraceInstrumentation.js +1 -1
  14. package/instrumentation/jsx/CreateElement.js +5 -9
  15. package/instrumentation/jsx/ElementHelper.js +5 -6
  16. package/instrumentation/jsx/JsxDevRuntime.js +33 -31
  17. package/instrumentation/jsx/JsxRuntime.js +30 -30
  18. package/instrumentation/jsx/JsxRuntimeHelpers.js +14 -0
  19. package/instrumentation/jsx/components/ClassComponent.js +4 -8
  20. package/instrumentation/jsx/components/ComponentUtil.js +24 -25
  21. package/instrumentation/libs/UserInteraction.js +27 -24
  22. package/instrumentation/libs/react-native/RefreshControl.js +5 -9
  23. package/instrumentation/libs/withOnPressMonitoring.js +66 -57
  24. package/ios/DTXScreenshotSelfMonitor.h +29 -0
  25. package/ios/DTXScreenshotSelfMonitor.mm +213 -0
  26. package/ios/DTXScreenshotSelfMonitorSwizzler.h +15 -0
  27. package/ios/DTXScreenshotSelfMonitorSwizzler.mm +68 -0
  28. package/ios/DynatraceRNBridge.h +6 -0
  29. package/ios/DynatraceRNBridge.mm +53 -0
  30. package/lib/core/Dynatrace.js +2 -0
  31. package/lib/core/DynatraceAction.js +1 -3
  32. package/lib/core/DynatraceInternal.js +38 -40
  33. package/lib/core/ErrorHandler.js +41 -21
  34. package/lib/core/NullAction.js +1 -3
  35. package/lib/core/logging/LogMessages.js +42 -0
  36. package/lib/core/util/JsonUtils.js +6 -0
  37. package/lib/features/ui-interaction/IUserInteractionEvent.js +1 -1
  38. package/lib/features/ui-interaction/Runtime.js +1 -1
  39. package/lib/features/ui-interaction/TouchMetaResolver.js +4 -3
  40. package/lib/next/Dynatrace.js +26 -1
  41. package/lib/next/events/EventPipeline.js +48 -31
  42. package/lib/next/events/HttpRequestEventData.js +3 -3
  43. package/lib/next/events/interface/HttpRequestEventDataTypes.js +2 -0
  44. package/lib/next/events/modifier/ModifyEventValidation.js +79 -51
  45. package/lib/next/events/spec/EventSpecContstants.js +1 -1
  46. package/lib/next/userAction/NullUserAction.js +15 -0
  47. package/lib/next/userAction/UserAction.js +2 -0
  48. package/lib/next/userAction/UserActionConfiguration.js +10 -0
  49. package/lib/next/userAction/UserActionImpl.js +70 -0
  50. package/lib/next/util/TraceContextUtils.js +8 -14
  51. package/lib/next/util/Utils.js +13 -0
  52. package/package.json +11 -6
  53. package/public.js +3 -1
  54. package/react-native-dynatrace.podspec +10 -3
  55. package/scripts/Config.js +22 -4
  56. package/scripts/DebugFlag.js +20 -0
  57. package/scripts/FileOperationHelper.js +15 -39
  58. package/scripts/Logger.js +2 -3
  59. package/scripts/core/InstrumentCall.js +110 -81
  60. package/scripts/util/CustomArgumentUtil.js +8 -6
  61. package/src/lib/core/interface/NativeDynatraceBridge.ts +34 -1
  62. package/types.d.ts +187 -9
@@ -5,6 +5,7 @@ const ConsoleLogger_1 = require("../../../core/logging/ConsoleLogger");
5
5
  const LogMessages_1 = require("../../../core/logging/LogMessages");
6
6
  const EventSpecContstants_1 = require("../spec/EventSpecContstants");
7
7
  const EventModifierUtil_1 = require("./EventModifierUtil");
8
+ const JsonUtils_1 = require("../../../core/util/JsonUtils");
8
9
  class ModifyEventValidation {
9
10
  constructor() {
10
11
  this.customEventModifierChain = [];
@@ -23,35 +24,15 @@ class ModifyEventValidation {
23
24
  return false;
24
25
  }
25
26
  modifyEvent(event) {
26
- if (this.customEventModifierChain.length > 0) {
27
- const eventCopy = Object.assign({}, event);
28
- let exceptionOccured = false;
29
- let isDiscarded = false;
30
- for (const modifier of this.customEventModifierChain) {
31
- try {
32
- const eventRv = modifier.modifyEvent(event);
33
- if (!eventRv) {
34
- isDiscarded = true;
35
- break;
36
- }
37
- else {
38
- event = eventRv;
39
- }
40
- }
41
- catch (_a) {
42
- if (event != null) {
43
- exceptionOccured = true;
44
- }
45
- }
46
- }
47
- if (!isDiscarded) {
48
- event = this.sanitizeUserEnrichedEvent(eventCopy, event, exceptionOccured);
49
- }
50
- else {
51
- return null;
52
- }
27
+ if (this.customEventModifierChain.length === 0) {
28
+ return event;
53
29
  }
54
- return event;
30
+ const eventCopy = Object.assign({}, event);
31
+ const modifiedEventResult = this.applyCustomModifiers(event);
32
+ if (modifiedEventResult.isDiscarded) {
33
+ return null;
34
+ }
35
+ return this.sanitizeUserEnrichedEvent(eventCopy, modifiedEventResult.event, modifiedEventResult.exceptionOccured);
55
36
  }
56
37
  isCustomPropertiesAllowed(key, hasSessionPropertyCharacteristics) {
57
38
  if (hasSessionPropertyCharacteristics) {
@@ -155,32 +136,15 @@ class ModifyEventValidation {
155
136
  validEntries.push([prop, value]);
156
137
  continue;
157
138
  }
158
- if (!this.isCustomPropertiesAllowed(prop, originalJSONEvent["characteristics.has_session_properties"] === true)) {
139
+ const validationResult = this.validateModifiedEntry(prop, value, originalValue, originalJSONEvent, overriddenKeys);
140
+ if (validationResult.entry !== undefined) {
141
+ validEntries.push(validationResult.entry);
142
+ }
143
+ if (validationResult.droppedCustomProperties) {
159
144
  droppedCustomProperties = true;
160
- continue;
161
145
  }
162
- const isNewlyAdded = typeof originalValue === 'undefined';
163
- const isForbiddenKey = this.isKeyNameForbidden(prop, isNewlyAdded);
164
- if (isForbiddenKey) {
165
- if (!isNewlyAdded) {
166
- validEntries.push([prop, originalValue]);
167
- }
146
+ if (validationResult.droppedProperties) {
168
147
  droppedProperties = true;
169
- continue;
170
- }
171
- if (!isNewlyAdded && !overriddenKeys.includes(prop)) {
172
- overriddenKeys.push(prop);
173
- }
174
- if (!isNewlyAdded &&
175
- EventSpecContstants_1.MODIFY_EVENT_WHITELIST_STRING_FIELDS.includes(prop)) {
176
- const maximumLength = Math.max(originalJSONEvent[prop].toString().length, EventSpecContstants_1.MAX_CUSTOM_EVENT_VALUE_LENGTH);
177
- validEntries.push([
178
- prop,
179
- (0, EventModifierUtil_1.trimString)(prop, value.toString(), maximumLength),
180
- ]);
181
- }
182
- else {
183
- validEntries.push([prop, value]);
184
148
  }
185
149
  }
186
150
  if (droppedCustomProperties) {
@@ -241,6 +205,43 @@ class ModifyEventValidation {
241
205
  return entries;
242
206
  }, resultEntries);
243
207
  }
208
+ validateModifiedEntry(prop, value, originalValue, originalJSONEvent, overriddenKeys) {
209
+ if (!this.isCustomPropertiesAllowed(prop, originalJSONEvent["characteristics.has_session_properties"] === true)) {
210
+ return {
211
+ droppedCustomProperties: true,
212
+ droppedProperties: false,
213
+ };
214
+ }
215
+ const isNewlyAdded = originalValue === undefined;
216
+ const isForbiddenKey = this.isKeyNameForbidden(prop, isNewlyAdded);
217
+ if (isForbiddenKey) {
218
+ return {
219
+ entry: isNewlyAdded ? undefined : [prop, originalValue],
220
+ droppedCustomProperties: false,
221
+ droppedProperties: true,
222
+ };
223
+ }
224
+ if (!isNewlyAdded && !overriddenKeys.includes(prop)) {
225
+ overriddenKeys.push(prop);
226
+ }
227
+ if (!isNewlyAdded &&
228
+ EventSpecContstants_1.MODIFY_EVENT_WHITELIST_STRING_FIELDS.includes(prop)) {
229
+ const maximumLength = Math.max(JsonUtils_1.JsonUtils.stringify(originalJSONEvent[prop]).length, EventSpecContstants_1.MAX_CUSTOM_EVENT_VALUE_LENGTH);
230
+ return {
231
+ entry: [
232
+ prop,
233
+ (0, EventModifierUtil_1.trimString)(prop, JsonUtils_1.JsonUtils.stringify(value), maximumLength),
234
+ ],
235
+ droppedCustomProperties: false,
236
+ droppedProperties: false,
237
+ };
238
+ }
239
+ return {
240
+ entry: [prop, value],
241
+ droppedCustomProperties: false,
242
+ droppedProperties: false,
243
+ };
244
+ }
244
245
  validateAddedEntries(addedEntries) {
245
246
  const validEntries = [];
246
247
  let droppedProperties = false;
@@ -274,6 +275,33 @@ class ModifyEventValidation {
274
275
  }
275
276
  return validEntries;
276
277
  }
278
+ applyCustomModifiers(event) {
279
+ let currentEvent = event;
280
+ let exceptionOccured = false;
281
+ for (const modifier of this.customEventModifierChain) {
282
+ try {
283
+ const eventRv = modifier.modifyEvent(currentEvent);
284
+ if (!eventRv) {
285
+ return {
286
+ event: currentEvent,
287
+ exceptionOccured,
288
+ isDiscarded: true,
289
+ };
290
+ }
291
+ currentEvent = eventRv;
292
+ }
293
+ catch (_a) {
294
+ if (currentEvent != null) {
295
+ exceptionOccured = true;
296
+ }
297
+ }
298
+ }
299
+ return {
300
+ event: currentEvent,
301
+ exceptionOccured,
302
+ isDiscarded: false,
303
+ };
304
+ }
277
305
  enforcePropertyLimit(entries) {
278
306
  const result = [];
279
307
  let propertyCount = 0;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ALL_APP_START_KEYS = exports.EVENT_WHITELIST_SIZE = exports.MODIFY_EVENT_WHITELIST_NAMESPACE = exports.MODIFY_EVENT_WHITELIST_STRING_FIELDS = exports.MODIFY_EVENT_WHITELIST_FIELDS = exports.SEND_SESSION_PROPERTY_EVENT_WHITELIST_FIELDS = exports.SEND_EXCEPTION_EVENT_WHITELIST_FIELDS = exports.SEND_EVENT_WHITELIST_FIELDS = exports.SEND_SESSION_PROPERTY_EVENT_WHITELIST_NAMESPACES = exports.SEND_EXCEPTION_EVENT_WHITELIST_NAMESPACES = exports.SEND_EVENT_WHITELIST_NAMESPACES = exports.AllCharacteristicsKeys = exports.KEY_NAME_REGEX = exports.MAX_CUSTOM_EVENT_VALUE_LENGTH = exports.MAX_CUSTOM_EVENT_KEY_LENGTH = exports.MAX_CUSTOM_EVENT_FIELDS = exports.SPECIFICATION_VERSION = void 0;
4
- exports.SPECIFICATION_VERSION = '0.23.0';
4
+ exports.SPECIFICATION_VERSION = '0.24.0';
5
5
  exports.MAX_CUSTOM_EVENT_FIELDS = 50;
6
6
  exports.MAX_CUSTOM_EVENT_KEY_LENGTH = 100;
7
7
  exports.MAX_CUSTOM_EVENT_VALUE_LENGTH = 5000;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NullUserAction = void 0;
4
+ class NullUserAction {
5
+ getCustomName() {
6
+ return '';
7
+ }
8
+ isCompleteAutomatically() {
9
+ return false;
10
+ }
11
+ setCompleteAutomatically(enabled) { }
12
+ complete() { }
13
+ addEventProperty(key, value) { }
14
+ }
15
+ exports.NullUserAction = NullUserAction;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserActionConfiguration = void 0;
4
+ class UserActionConfiguration {
5
+ constructor(customName, completeAutomatically = false) {
6
+ this.customName = customName;
7
+ this.completeAutomatically = completeAutomatically;
8
+ }
9
+ }
10
+ exports.UserActionConfiguration = UserActionConfiguration;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserActionImpl = void 0;
4
+ const DynatraceBridge_1 = require("../../core/DynatraceBridge");
5
+ const ConsoleLogger_1 = require("../../core/logging/ConsoleLogger");
6
+ const LogMessages_1 = require("../../core/logging/LogMessages");
7
+ const Utils_1 = require("../util/Utils");
8
+ const randomActionId = () => (0, Utils_1.randomHex)(16);
9
+ class UserActionImpl {
10
+ constructor(configuration) {
11
+ this.completed = false;
12
+ this.logger = new ConsoleLogger_1.ConsoleLogger('UserAction');
13
+ this.customName = configuration.customName;
14
+ this.completeAutomatically = configuration.completeAutomatically;
15
+ this.actionId = randomActionId();
16
+ DynatraceBridge_1.DynatraceNative.createUserAction(this.actionId, this.customName, this.completeAutomatically, null);
17
+ this.logger.debug(LogMessages_1.LogMessage.USER_ACTION_CREATED, {
18
+ customName: this.customName,
19
+ completeAutomatically: this.completeAutomatically,
20
+ actionId: this.actionId,
21
+ });
22
+ }
23
+ getCustomName() {
24
+ return this.customName;
25
+ }
26
+ isCompleteAutomatically() {
27
+ return this.completeAutomatically;
28
+ }
29
+ setCompleteAutomatically(enabled) {
30
+ if (this.completed) {
31
+ return;
32
+ }
33
+ this.logger.debug(LogMessages_1.LogMessage.USER_ACTION_SET_COMPLETE_AUTOMATICALLY, {
34
+ enabled,
35
+ customName: this.customName,
36
+ });
37
+ this.completeAutomatically = enabled;
38
+ DynatraceBridge_1.DynatraceNative.setCompleteUserActionAutomatically(this.actionId, enabled);
39
+ }
40
+ complete() {
41
+ if (this.completed) {
42
+ return;
43
+ }
44
+ this.completed = true;
45
+ this.logger.debug(LogMessages_1.LogMessage.USER_ACTION_COMPLETE, {
46
+ customName: this.customName,
47
+ });
48
+ DynatraceBridge_1.DynatraceNative.completeUserAction(this.actionId);
49
+ }
50
+ addEventProperty(key, value) {
51
+ if (this.completed) {
52
+ return;
53
+ }
54
+ this.logger.debug(LogMessages_1.LogMessage.USER_ACTION_ADD_EVENT_PROPERTY, {
55
+ key,
56
+ value: String(value),
57
+ customName: this.customName,
58
+ });
59
+ if (typeof value === 'string') {
60
+ DynatraceBridge_1.DynatraceNative.addEventStringPropertyToUserAction(this.actionId, key, value);
61
+ }
62
+ else if (typeof value === 'number') {
63
+ DynatraceBridge_1.DynatraceNative.addEventDoublePropertyToUserAction(this.actionId, key, value);
64
+ }
65
+ else {
66
+ DynatraceBridge_1.DynatraceNative.addEventBooleanPropertyToUserAction(this.actionId, key, value);
67
+ }
68
+ }
69
+ }
70
+ exports.UserActionImpl = UserActionImpl;
@@ -4,6 +4,7 @@ exports.trimTraceState = exports.generateTracestate = exports.generateTraceparen
4
4
  const ConsoleLogger_1 = require("../../core/logging/ConsoleLogger");
5
5
  const LogMessages_1 = require("../../core/logging/LogMessages");
6
6
  const ConfigurationHandler_1 = require("../../core/configuration/ConfigurationHandler");
7
+ const Utils_1 = require("./Utils");
7
8
  const logger = new ConsoleLogger_1.ConsoleLogger('TraceContextUtils');
8
9
  const parseTraceparent = (traceparent) => {
9
10
  const traceparentRegex = /^[0-9a-f]{2}-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;
@@ -26,27 +27,18 @@ const parseTraceparent = (traceparent) => {
26
27
  exports.parseTraceparent = parseTraceparent;
27
28
  const allZeros = (str) => /^0*$/.test(str);
28
29
  const generateTraceparentHeader = () => {
29
- let traceId = randomHex(32);
30
+ let traceId = (0, Utils_1.randomHex)(32);
30
31
  if (/^0+$/.test(traceId)) {
31
32
  traceId = '1' + traceId.slice(1);
32
33
  }
33
- let spanId = randomHex(16);
34
+ let spanId = (0, Utils_1.randomHex)(16);
34
35
  if (/^0+$/.test(spanId)) {
35
36
  spanId = '1' + spanId.slice(1);
36
37
  }
37
38
  return `00-${traceId}-${spanId}-01`;
38
39
  };
39
40
  exports.generateTraceparentHeader = generateTraceparentHeader;
40
- const randomHex = (length) => {
41
- let hex = '';
42
- while (hex.length < length) {
43
- hex += Math.floor(Math.random() * 0xffffffff)
44
- .toString(16)
45
- .padStart(8, '0');
46
- }
47
- return hex.slice(0, length);
48
- };
49
- const generateTracestate = (parentId, existingTracestate) => {
41
+ const generateTracestate = (parentId, traceparentFromDynatrace, existingTracestate) => {
50
42
  const instanceId = ConfigurationHandler_1.ConfigurationHandler.getInstanceId();
51
43
  const sessionId = ConfigurationHandler_1.ConfigurationHandler.getSessionId();
52
44
  const applicationId = ConfigurationHandler_1.ConfigurationHandler.getApplicationId();
@@ -55,10 +47,12 @@ const generateTracestate = (parentId, existingTracestate) => {
55
47
  !(instanceId && sessionId && applicationId && tracestateKeyPrefix)) {
56
48
  return undefined;
57
49
  }
58
- const version = 1;
59
50
  const originMarker = 'dtr';
51
+ const version = 2;
60
52
  const capture = 0;
61
- let tracestate = `${tracestateKeyPrefix}@${originMarker}=${version};${parentId};${capture};${formatApplicationId(applicationId)};${instanceId};${sessionId}`;
53
+ const formattedApplicationId = formatApplicationId(applicationId);
54
+ const tpSource = traceparentFromDynatrace ? 1 : 2;
55
+ let tracestate = `${tracestateKeyPrefix}@${originMarker}=${version};${parentId};${capture};${formattedApplicationId};${instanceId};${sessionId};${tpSource}`;
62
56
  if (typeof existingTracestate === 'string' && existingTracestate.trim()) {
63
57
  tracestate += `,${existingTracestate}`;
64
58
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomHex = void 0;
4
+ const randomHex = (length) => {
5
+ let hex = '';
6
+ while (hex.length < length) {
7
+ hex += Math.floor(Math.random() * 0xffffffff)
8
+ .toString(16)
9
+ .padStart(8, '0');
10
+ }
11
+ return hex.slice(0, length);
12
+ };
13
+ exports.randomHex = randomHex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynatrace/react-native-plugin",
3
- "version": "2.339.1",
3
+ "version": "2.343.1",
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": "types.d.ts",
@@ -26,7 +26,7 @@
26
26
  "test": "jest --runInBand",
27
27
  "test:coverage": "jest --runInBand --coverage",
28
28
  "test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand",
29
- "test:local": "npm run lint && node runner.js test",
29
+ "test:local": "node cleanMacFiles.js && npm run lint && node runner.js test",
30
30
  "test:examples": "node tests/jsdoc_examples/RunJestTest.js",
31
31
  "tsc:local": "tsc -p tsconfig.local.json",
32
32
  "tsc:types": "tsc -p tsconfig.types.json && rollup -c rollup.config.types.mjs",
@@ -49,11 +49,11 @@
49
49
  "author": "Dynatrace",
50
50
  "license": "SEE LICENSE IN LICENSE.md",
51
51
  "dependencies": {
52
- "@babel/runtime": "^7.29.7",
53
- "jscodeshift": "^17.3.0",
52
+ "@babel/runtime": "^8.0.0",
53
+ "jscodeshift": "^17.4.0",
54
54
  "plist": "^3.1.0",
55
55
  "proxy-polyfill": "^0.3.2",
56
- "semver": "^7.8.3"
56
+ "semver": "^7.8.5"
57
57
  },
58
58
  "homepage": "https://www.dynatrace.com/",
59
59
  "peerDependencies": {
@@ -68,7 +68,11 @@
68
68
  },
69
69
  "ast-types": "npm:ast-types-x",
70
70
  "flow-parser": "0.160",
71
- "tmp": ">=0.2.6"
71
+ "tmp": ">=0.2.6",
72
+ "ws": "^7.5.11",
73
+ "@istanbuljs/load-nyc-config": {
74
+ "js-yaml": "^3.15.0"
75
+ }
72
76
  },
73
77
  "devDependencies": {
74
78
  "@babel/plugin-transform-class-properties": "^7.27.1",
@@ -174,6 +178,7 @@
174
178
  "lib/next/events/spec/*.js",
175
179
  "lib/next/util/*.js",
176
180
  "lib/next/provider/*.js",
181
+ "lib/next/userAction/*.js",
177
182
  "lib/features/ui-interaction/*.js",
178
183
  "src/lib/core/interface/NativeDynatraceBridge.ts",
179
184
  "types.d.ts"
package/public.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExceptionEventData = exports.SessionPropertyEventData = exports.EventData = exports.HttpRequestEventData = exports.DynatraceWebRequestTiming = exports.UserPrivacyOptions = exports.LogLevel = exports.Platform = exports.ConfigurationBuilder = exports.ManualStartupConfiguration = exports.DataCollectionLevel = exports.Dynatrace = void 0;
3
+ exports.UserActionConfiguration = exports.ExceptionEventData = exports.SessionPropertyEventData = exports.EventData = exports.HttpRequestEventData = exports.DynatraceWebRequestTiming = exports.UserPrivacyOptions = exports.LogLevel = exports.Platform = exports.ConfigurationBuilder = exports.ManualStartupConfiguration = exports.DataCollectionLevel = exports.Dynatrace = void 0;
4
4
  var Dynatrace_1 = require("./lib/core/Dynatrace");
5
5
  Object.defineProperty(exports, "Dynatrace", { enumerable: true, get: function () { return Dynatrace_1.Dynatrace; } });
6
6
  var DataCollectionLevel_1 = require("./lib/core/model/DataCollectionLevel");
@@ -25,4 +25,6 @@ var SessionPropertyEventData_1 = require("./lib/next/events/SessionPropertyEvent
25
25
  Object.defineProperty(exports, "SessionPropertyEventData", { enumerable: true, get: function () { return SessionPropertyEventData_1.default; } });
26
26
  var ExceptionEventData_1 = require("./lib/next/events/ExceptionEventData");
27
27
  Object.defineProperty(exports, "ExceptionEventData", { enumerable: true, get: function () { return ExceptionEventData_1.default; } });
28
+ var UserActionConfiguration_1 = require("./lib/next/userAction/UserActionConfiguration");
29
+ Object.defineProperty(exports, "UserActionConfiguration", { enumerable: true, get: function () { return UserActionConfiguration_1.UserActionConfiguration; } });
28
30
  require("./react-augmentation");
@@ -12,10 +12,17 @@ Pod::Spec.new do |s|
12
12
  s.version = package['version']
13
13
  s.summary = package['description']
14
14
  s.homepage = package['homepage']
15
- s.ios.deployment_target = "12.0"
16
- s.tvos.deployment_target = "12.0"
15
+ s.ios.deployment_target = "15.0"
16
+ s.tvos.deployment_target = "15.0"
17
17
  s.source_files = ["ios/*.{h,mm}"]
18
18
 
19
+ # Build-time off-switch for screenshot self-monitoring (replay metrics), passed at `pod install`:
20
+ # DYNATRACE_REPLAY_METRICS_ENABLED=0 pod install
21
+ # Defaults to enabled; when set to 0 the monitor is compiled out (DynatraceRNBridge.mm #if guard).
22
+ if ENV['DYNATRACE_REPLAY_METRICS_ENABLED'] == '0'
23
+ s.prefix_header_contents = '#define DTX_REPLAY_METRICS_ENABLED 0'
24
+ end
25
+
19
26
  s.license = { :type => 'Commercial', :text => 'https://github.com/Dynatrace/dem-license/blob/main/LICENSE.md'}
20
27
 
21
28
  # --- License ----------------------------------------------------------- #
@@ -111,7 +118,7 @@ Pod::Spec.new do |s|
111
118
  #
112
119
 
113
120
  s.dependency "React"
114
- s.dependency 'Dynatrace', '~> 8.339.1.1011'
121
+ s.dependency 'Dynatrace', '~> 8.343.1.1007'
115
122
 
116
123
  # Allows for better compatibility for older and newer versions
117
124
  if defined?(install_modules_dependencies)
package/scripts/Config.js CHANGED
@@ -12,6 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.checkConfiguration = exports.addDefaultConfigs = exports.readConfig = exports.readConfigDefault = exports.defaultConfig = exports.ERROR_CONFIG_NOT_AVAILABLE = void 0;
14
14
  const path = require("node:path");
15
+ const node_fs_1 = require("node:fs");
15
16
  const FileOperationHelper_1 = require("./FileOperationHelper");
16
17
  const Logger_1 = require("./Logger");
17
18
  const PathsConstants_1 = require("./PathsConstants");
@@ -45,9 +46,19 @@ exports.defaultConfig = {
45
46
  };
46
47
  const readConfigDefault = () => {
47
48
  const customArguments = (0, CustomArgumentUtil_1.readCustomArguments)();
48
- const configPath = customArguments.isCustomConfigurationPathSet()
49
- ? path.join(PathsConstants_1.default.getApplicationPath(), customArguments.getCustomConfigurationPath())
50
- : PathsConstants_1.default.getConfigFilePath();
49
+ let configPath;
50
+ if (customArguments.isCustomConfigurationPathSet()) {
51
+ configPath = path.resolve(PathsConstants_1.default.getApplicationPath(), customArguments.getCustomConfigurationPath());
52
+ }
53
+ else {
54
+ const envConfig = process.env.DYNATRACE_CONFIG;
55
+ if (envConfig === undefined || envConfig.trim() === '') {
56
+ configPath = PathsConstants_1.default.getConfigFilePath();
57
+ }
58
+ else {
59
+ configPath = path.resolve(PathsConstants_1.default.getApplicationPath(), envConfig.trim());
60
+ }
61
+ }
51
62
  return (0, exports.readConfig)(configPath);
52
63
  };
53
64
  exports.readConfigDefault = readConfigDefault;
@@ -80,9 +91,16 @@ exports.checkConfiguration = checkConfiguration;
80
91
  const createNewConfiguration = (pathToDynatraceConfig) => __awaiter(void 0, void 0, void 0, function* () {
81
92
  const defaultConfigContent = yield FileOperationHelper_1.default.readTextFromFile(PathsConstants_1.default.getDefaultConfig());
82
93
  yield FileOperationHelper_1.default.writeTextToFile(pathToDynatraceConfig, defaultConfigContent);
83
- Logger_1.default.logMessageSync('Created dynatrace.config.js - Please insert your configuration and update the file!', Logger_1.default.INFO);
94
+ logConfigCreatedMessage();
84
95
  });
96
+ const logConfigCreatedMessage = () => {
97
+ const message = 'Created dynatrace.config.js - Please insert your configuration and update the file!';
98
+ Logger_1.default.logMessageSync(message, Logger_1.default.INFO);
99
+ };
85
100
  const patchMalformedConfiguration = (pathToDynatraceConfig) => {
101
+ if (!(0, node_fs_1.existsSync)(pathToDynatraceConfig)) {
102
+ return;
103
+ }
86
104
  const configContent = FileOperationHelper_1.default.readTextFromFileSync(pathToDynatraceConfig);
87
105
  if (configContent.indexOf('\u200B') !== -1) {
88
106
  FileOperationHelper_1.default.writeTextToFileSync(pathToDynatraceConfig, configContent.split('\u200B').join(''));
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isDebugEnabled = void 0;
5
+ const PathsConstants_1 = require("./PathsConstants");
6
+ let cached;
7
+ const isDebugEnabled = () => {
8
+ var _a;
9
+ if (cached === undefined) {
10
+ try {
11
+ const { readConfig } = require('./Config');
12
+ cached = ((_a = readConfig(PathsConstants_1.default.getConfigFilePath()).react) === null || _a === void 0 ? void 0 : _a.debug) === true;
13
+ }
14
+ catch (_b) {
15
+ cached = false;
16
+ }
17
+ }
18
+ return cached;
19
+ };
20
+ exports.isDebugEnabled = isDebugEnabled;
@@ -71,49 +71,25 @@ const mkdirSyncRecursive = (directory) => {
71
71
  }
72
72
  }
73
73
  };
74
- const deleteDirectory = (dir) => new Promise((resolve, reject) => {
75
- fs.access(dir, (err) => {
76
- if (err) {
77
- return reject(err);
78
- }
79
- fs.readdir(dir, (err, files) => {
80
- if (err) {
81
- return reject(err);
82
- }
83
- Promise.all(files.map((file) => deleteFile(path.join(dir, file)))).then(() => {
84
- fs.rmdir(dir, (err) => {
85
- if (err) {
86
- return reject(err);
87
- }
88
- resolve();
89
- });
90
- }).catch(reject);
91
- });
92
- });
74
+ const deleteDirectory = (dir) => __awaiter(void 0, void 0, void 0, function* () {
75
+ yield fsPromise.access(dir);
76
+ const files = yield fsPromise.readdir(dir);
77
+ yield Promise.all(files.map((file) => deleteFile(path.join(dir, file))));
78
+ yield fsPromise.rmdir(dir);
93
79
  });
94
80
  const deleteDirectorySync = (dir) => {
95
81
  fs.accessSync(dir);
96
82
  const files = fs.readdirSync(dir);
97
- files.map((file) => deleteFileSync(path.join(dir, file)));
83
+ files.forEach((file) => deleteFileSync(path.join(dir, file)));
98
84
  fs.rmdirSync(dir);
99
85
  };
100
- const deleteFile = (filePath) => new Promise((resolve, reject) => {
101
- fs.lstat(filePath, (err, stats) => {
102
- if (err) {
103
- return reject(err);
104
- }
105
- if (stats.isDirectory()) {
106
- resolve(deleteDirectory(filePath));
107
- }
108
- else {
109
- fs.unlink(filePath, (err) => {
110
- if (err) {
111
- return reject(err);
112
- }
113
- resolve();
114
- });
115
- }
116
- });
86
+ const deleteFile = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
87
+ const stats = yield fsPromise.lstat(filePath);
88
+ if (stats.isDirectory()) {
89
+ yield deleteDirectory(filePath);
90
+ return;
91
+ }
92
+ yield fsPromise.unlink(filePath);
117
93
  });
118
94
  const deleteFileSync = (filePath) => {
119
95
  const stats = fs.lstatSync(filePath);
@@ -157,7 +133,7 @@ const copyDirectory = (from, to) => {
157
133
  }
158
134
  });
159
135
  };
160
- const allowedRootFolders = ['src', 'node_modules'];
136
+ const allowedRootFolders = new Set(['src', 'node_modules']);
161
137
  const getAllFiles = (log, dir, base = '', isRoot = false) => __awaiter(void 0, void 0, void 0, function* () {
162
138
  const entries = yield fsPromise.readdir(dir);
163
139
  let files = [];
@@ -166,7 +142,7 @@ const getAllFiles = (log, dir, base = '', isRoot = false) => __awaiter(void 0, v
166
142
  const relPath = path.join(base, entry);
167
143
  const stat = yield fsPromise.stat(fullPath);
168
144
  if (stat.isDirectory()) {
169
- if (isRoot && !allowedRootFolders.includes(entry)) {
145
+ if (isRoot && !allowedRootFolders.has(entry)) {
170
146
  yield log(`🔸 Skipping folder: ${entry}`);
171
147
  continue;
172
148
  }
package/scripts/Logger.js CHANGED
@@ -5,7 +5,7 @@ const fs = require("fs");
5
5
  const nodePath = require("path");
6
6
  const FileOperationHelper_1 = require("./FileOperationHelper");
7
7
  const PathsConstants_1 = require("./PathsConstants");
8
- const Config_1 = require("./Config");
8
+ const DebugFlag_1 = require("./DebugFlag");
9
9
  const ERROR = 0;
10
10
  const INFO = 1;
11
11
  const WARNING = 2;
@@ -26,8 +26,7 @@ const closeLogFile = () => {
26
26
  .catch(errorHandling);
27
27
  };
28
28
  const logErrorSync = (_message) => {
29
- const config = (0, Config_1.readConfig)(PathsConstants_1.default.getConfigFilePath());
30
- if (config.react !== undefined && config.react.debug) {
29
+ if ((0, DebugFlag_1.isDebugEnabled)()) {
31
30
  logMessageSync(_message, ERROR, true);
32
31
  }
33
32
  };