@dynatrace/react-native-plugin 2.337.3 → 2.341.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -21
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +0 -1
- package/files/default.config.js +2 -0
- package/files/plugin.gradle +1 -1
- package/instrumentation/BabelPluginDynatrace.js +1 -1
- package/instrumentation/DynatraceInstrumentation.js +1 -1
- package/instrumentation/jsx/CreateElement.js +5 -9
- package/instrumentation/jsx/ElementHelper.js +5 -6
- package/instrumentation/jsx/JsxDevRuntime.js +33 -31
- package/instrumentation/jsx/JsxRuntime.js +30 -30
- package/instrumentation/jsx/JsxRuntimeHelpers.js +14 -0
- package/instrumentation/jsx/components/ClassComponent.js +6 -9
- package/instrumentation/jsx/components/ComponentUtil.js +24 -25
- package/instrumentation/libs/UserInteraction.js +27 -24
- package/instrumentation/libs/react-native/RefreshControl.js +5 -9
- package/instrumentation/libs/react-navigation/ReactNavigation.js +7 -4
- package/instrumentation/libs/withOnPressMonitoring.js +67 -55
- package/lib/core/Application.js +5 -2
- package/lib/core/Dynatrace.js +113 -44
- package/lib/core/DynatraceAction.js +78 -23
- package/lib/core/DynatraceInternal.js +39 -26
- package/lib/core/DynatraceRootAction.js +6 -3
- package/lib/core/DynatraceWebRequestTiming.js +25 -4
- package/lib/core/ErrorHandler.js +46 -19
- package/lib/core/NullAction.js +1 -3
- package/lib/core/logging/ConsoleLogger.js +17 -6
- package/lib/core/logging/LogMessages.js +764 -0
- package/lib/core/logging/LogType.js +9 -0
- package/lib/core/util/JsonUtils.js +6 -0
- package/lib/features/ui-interaction/IUserInteractionEvent.js +1 -1
- package/lib/features/ui-interaction/Runtime.js +7 -3
- package/lib/features/ui-interaction/TouchMetaResolver.js +4 -3
- package/lib/next/Dynatrace.js +42 -22
- package/lib/next/appstart/AppStartObserver.js +7 -2
- package/lib/next/events/EventPipeline.js +12 -5
- package/lib/next/events/EventTimestamp.js +5 -1
- package/lib/next/events/ExceptionEventData.js +1 -1
- package/lib/next/events/HttpRequestEventData.js +18 -9
- package/lib/next/events/interface/HttpRequestEventDataTypes.js +2 -0
- package/lib/next/events/modifier/BaseDataEventModifier.js +4 -1
- package/lib/next/events/modifier/EventModifierUtil.js +12 -5
- package/lib/next/events/modifier/ModifyEventValidation.js +99 -58
- package/lib/next/events/modifier/SendEventValidation.js +10 -4
- package/lib/next/events/modifier/StringLengthEventModifier.js +4 -1
- package/lib/next/events/modifier/ValueRestrictionModifier.js +5 -1
- package/lib/next/events/spec/EventSpecContstants.js +6 -2
- package/lib/next/util/TraceContextUtils.js +4 -3
- package/package.json +7 -5
- package/react-native-dynatrace.podspec +1 -1
- package/scripts/Config.js +7 -3
- package/scripts/DebugFlag.js +20 -0
- package/scripts/FileOperationHelper.js +15 -39
- package/scripts/Logger.js +2 -3
- package/scripts/core/InstrumentCall.js +101 -80
- package/scripts/util/CustomArgumentUtil.js +8 -6
- package/types.d.ts +159 -8
|
@@ -8,6 +8,7 @@ const NullAction_1 = require("./NullAction");
|
|
|
8
8
|
const DynatraceInternal_1 = require("./DynatraceInternal");
|
|
9
9
|
const ConfigurationHandler_1 = require("./configuration/ConfigurationHandler");
|
|
10
10
|
const ConsoleLogger_1 = require("./logging/ConsoleLogger");
|
|
11
|
+
const LogMessages_1 = require("./logging/LogMessages");
|
|
11
12
|
class DynatraceRootAction extends DynatraceAction_1.DynatraceAction {
|
|
12
13
|
constructor(key, name) {
|
|
13
14
|
super(key, name, true);
|
|
@@ -15,7 +16,7 @@ class DynatraceRootAction extends DynatraceAction_1.DynatraceAction {
|
|
|
15
16
|
}
|
|
16
17
|
enterAction(name, platform) {
|
|
17
18
|
if (this.closed) {
|
|
18
|
-
this.logger.debug(
|
|
19
|
+
this.logger.debug(LogMessages_1.LogMessage.ROOT_ACTION_ENTER_CLOSED, { name });
|
|
19
20
|
return new NullAction_1.NullAction();
|
|
20
21
|
}
|
|
21
22
|
let childKey;
|
|
@@ -29,12 +30,14 @@ class DynatraceRootAction extends DynatraceAction_1.DynatraceAction {
|
|
|
29
30
|
childKey = 'DEFAULT_' + DynatraceInternal_1.DynatraceInternal.getCounter();
|
|
30
31
|
}
|
|
31
32
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(name)) {
|
|
32
|
-
this.logger.debug(
|
|
33
|
+
this.logger.debug(LogMessages_1.LogMessage.ROOT_ACTION_ENTER, { name });
|
|
33
34
|
DynatraceBridge_1.DynatraceNative.enterManualActionWithParent(name, childKey, this.key, platform === null || platform === void 0 ? void 0 : platform.toString());
|
|
34
35
|
return new DynatraceAction_1.DynatraceAction(childKey, name, true);
|
|
35
36
|
}
|
|
36
37
|
else {
|
|
37
|
-
this.logger.debug(
|
|
38
|
+
this.logger.debug(LogMessages_1.LogMessage.ROOT_ACTION_ENTER_NAME_EMPTY, {
|
|
39
|
+
name,
|
|
40
|
+
});
|
|
38
41
|
return new NullAction_1.NullAction();
|
|
39
42
|
}
|
|
40
43
|
}
|
|
@@ -4,6 +4,7 @@ exports.DynatraceWebRequestTiming = void 0;
|
|
|
4
4
|
const DynatraceBridge_1 = require("./DynatraceBridge");
|
|
5
5
|
const ConsoleLogger_1 = require("./logging/ConsoleLogger");
|
|
6
6
|
const StringUtils_1 = require("./util/StringUtils");
|
|
7
|
+
const LogMessages_1 = require("./logging/LogMessages");
|
|
7
8
|
const logger = new ConsoleLogger_1.ConsoleLogger('DynatraceWebRequestTiming');
|
|
8
9
|
class DynatraceWebRequestTiming {
|
|
9
10
|
constructor(requestTag, url) {
|
|
@@ -13,11 +14,17 @@ class DynatraceWebRequestTiming {
|
|
|
13
14
|
startWebRequestTiming() {
|
|
14
15
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.requestTag) &&
|
|
15
16
|
!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url)) {
|
|
16
|
-
logger.debug(
|
|
17
|
+
logger.debug(LogMessages_1.LogMessage.WEB_REQUEST_TIMING_START, {
|
|
18
|
+
url: this.url,
|
|
19
|
+
requestTag: this.requestTag,
|
|
20
|
+
});
|
|
17
21
|
DynatraceBridge_1.DynatraceNative.startWebRequestTiming(this.requestTag, this.url);
|
|
18
22
|
}
|
|
19
23
|
else {
|
|
20
|
-
logger.debug(
|
|
24
|
+
logger.debug(LogMessages_1.LogMessage.WEB_REQUEST_TIMING_START_FAILED, {
|
|
25
|
+
url: this.url,
|
|
26
|
+
requestTag: this.requestTag,
|
|
27
|
+
});
|
|
21
28
|
}
|
|
22
29
|
}
|
|
23
30
|
stopWebRequestTiming(responseCode, responseMessage) {
|
|
@@ -28,11 +35,25 @@ class DynatraceWebRequestTiming {
|
|
|
28
35
|
!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(this.url) &&
|
|
29
36
|
responseCode != null &&
|
|
30
37
|
!StringUtils_1.StringUtils.isStringNullOrUndefined(responseMessage)) {
|
|
31
|
-
logger.debug(
|
|
38
|
+
logger.debug(LogMessages_1.LogMessage.WEB_REQUEST_TIMING_STOP, {
|
|
39
|
+
responseCode,
|
|
40
|
+
responseMessage,
|
|
41
|
+
requestSize,
|
|
42
|
+
responseSize,
|
|
43
|
+
url: this.url,
|
|
44
|
+
requestTag: this.requestTag,
|
|
45
|
+
});
|
|
32
46
|
DynatraceBridge_1.DynatraceNative.stopWebRequestTimingWithSize(this.requestTag, this.url, responseCode, responseMessage, requestSize, responseSize);
|
|
33
47
|
}
|
|
34
48
|
else {
|
|
35
|
-
logger.debug(
|
|
49
|
+
logger.debug(LogMessages_1.LogMessage.WEB_REQUEST_TIMING_STOP_FAILED, {
|
|
50
|
+
responseCode,
|
|
51
|
+
responseMessage,
|
|
52
|
+
requestSize,
|
|
53
|
+
responseSize,
|
|
54
|
+
url: this.url,
|
|
55
|
+
requestTag: this.requestTag,
|
|
56
|
+
});
|
|
36
57
|
}
|
|
37
58
|
}
|
|
38
59
|
getRequestTag() {
|
package/lib/core/ErrorHandler.js
CHANGED
|
@@ -1,42 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reportErrorToDynatrace = exports.startErrorHandler = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
4
5
|
const DynatraceInternal_1 = require("./DynatraceInternal");
|
|
5
|
-
const Dynatrace_1 = require("./Dynatrace");
|
|
6
6
|
const StringUtils_1 = require("./util/StringUtils");
|
|
7
7
|
const ConsoleLogger_1 = require("./logging/ConsoleLogger");
|
|
8
|
-
const
|
|
8
|
+
const LogMessages_1 = require("./logging/LogMessages");
|
|
9
9
|
const logger = new ConsoleLogger_1.ConsoleLogger('ErrorHandler');
|
|
10
10
|
let manualStart = { enabled: false };
|
|
11
11
|
const startErrorHandler = (reportFatalErrorAsCrash) => {
|
|
12
12
|
manualStart = {
|
|
13
13
|
enabled: true,
|
|
14
|
-
reportFatalErrorAsCrash
|
|
14
|
+
reportFatalErrorAsCrash,
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
exports.startErrorHandler = startErrorHandler;
|
|
18
18
|
const reportErrorToDynatrace = (exception, isFatal, reportFatalErrorAsCrashFromConfig, autoStart) => {
|
|
19
|
-
if (!autoStart
|
|
19
|
+
if (!isErrorHandlingEnabled(autoStart)) {
|
|
20
20
|
return 0;
|
|
21
|
-
const reportFatalErrorAsCrash = manualStart.enabled
|
|
22
|
-
? manualStart.reportFatalErrorAsCrash
|
|
23
|
-
: reportFatalErrorAsCrashFromConfig;
|
|
24
|
-
if (exception != null && isExceptionAnError(exception)) {
|
|
25
|
-
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(exception.name)) {
|
|
26
|
-
if (isFatal === undefined) {
|
|
27
|
-
isFatal = false;
|
|
28
|
-
}
|
|
29
|
-
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(isFatal, String(exception.name), adjustedReason(exception.message), exception.stack != null ? exception.stack : '', reportFatalErrorAsCrash);
|
|
30
|
-
logger.debug(`reportErrorToDynatrace(${exception}, ${isFatal})`);
|
|
31
|
-
}
|
|
32
21
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
logger.debug(
|
|
22
|
+
if (!isExceptionAnErrorWithName(exception)) {
|
|
23
|
+
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(false, String(exception), '', '', true);
|
|
24
|
+
logger.debug(LogMessages_1.LogMessage.REPORT_ERROR_TO_DYNATRACE, {
|
|
25
|
+
exception: String(exception),
|
|
26
|
+
isFatal: '-1',
|
|
27
|
+
});
|
|
28
|
+
return getCrashDelay();
|
|
36
29
|
}
|
|
37
|
-
|
|
30
|
+
const resolvedIsFatal = isFatal !== null && isFatal !== void 0 ? isFatal : false;
|
|
31
|
+
const reportFatalErrorAsCrash = resolveReportFatalErrorAsCrash(reportFatalErrorAsCrashFromConfig);
|
|
32
|
+
const { errorName, errorReason, errorStack } = buildErrorDetails(exception);
|
|
33
|
+
reportErrorFromException(resolvedIsFatal, reportFatalErrorAsCrash, errorName, errorReason, errorStack);
|
|
34
|
+
logger.debug(LogMessages_1.LogMessage.REPORT_ERROR_TO_DYNATRACE, {
|
|
35
|
+
exception: String(exception),
|
|
36
|
+
isFatal: String(resolvedIsFatal),
|
|
37
|
+
});
|
|
38
|
+
return getCrashDelay();
|
|
38
39
|
};
|
|
39
40
|
exports.reportErrorToDynatrace = reportErrorToDynatrace;
|
|
41
|
+
const isErrorHandlingEnabled = (autoStart) => autoStart || manualStart.enabled;
|
|
42
|
+
const resolveReportFatalErrorAsCrash = (reportFatalErrorAsCrashFromConfig) => manualStart.enabled
|
|
43
|
+
? manualStart.reportFatalErrorAsCrash
|
|
44
|
+
: reportFatalErrorAsCrashFromConfig;
|
|
45
|
+
const isExceptionAnErrorWithName = (exception) => {
|
|
46
|
+
if (exception == null || !isExceptionAnError(exception)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return !StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(exception.name);
|
|
50
|
+
};
|
|
51
|
+
const buildErrorDetails = (exception) => {
|
|
52
|
+
var _a;
|
|
53
|
+
return ({
|
|
54
|
+
errorName: String(exception.name),
|
|
55
|
+
errorReason: adjustedReason(exception.message),
|
|
56
|
+
errorStack: (_a = exception.stack) !== null && _a !== void 0 ? _a : '',
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const reportErrorFromException = (isFatal, reportFatalErrorAsCrash, errorName, errorReason, errorStack) => {
|
|
60
|
+
if (isFatal && reportFatalErrorAsCrash) {
|
|
61
|
+
DynatraceInternal_1.DynatraceInternal.reportFatalErrorAsCrashFromHandler(isFatal, errorName, errorReason, errorStack);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
DynatraceInternal_1.DynatraceInternal.reportErrorFromHandler(isFatal, errorName, errorReason, errorStack);
|
|
65
|
+
};
|
|
66
|
+
const getCrashDelay = () => (react_native_1.Platform.OS === 'ios' ? 200 : 0);
|
|
40
67
|
const adjustedReason = (reason) => {
|
|
41
68
|
if (!StringUtils_1.StringUtils.isStringNullEmptyOrUndefined(reason)) {
|
|
42
69
|
const reasonNewLineIndex = reason.indexOf('\n');
|
package/lib/core/NullAction.js
CHANGED
|
@@ -3,21 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ConsoleLogger = void 0;
|
|
4
4
|
const ConfigurationHandler_1 = require("../configuration/ConfigurationHandler");
|
|
5
5
|
const LogLevel_1 = require("./LogLevel");
|
|
6
|
+
const LogMessages_1 = require("./LogMessages");
|
|
7
|
+
const LogType_1 = require("./LogType");
|
|
6
8
|
class ConsoleLogger {
|
|
7
9
|
constructor(name, logLevel) {
|
|
8
10
|
this.name = name;
|
|
9
11
|
this.level = logLevel;
|
|
10
12
|
}
|
|
11
|
-
debug(
|
|
13
|
+
debug(key, ...args) {
|
|
12
14
|
if (this.isDebugEnabled()) {
|
|
13
|
-
this.logMessage(
|
|
15
|
+
this.logMessage(key, args[0]);
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
|
-
info(
|
|
17
|
-
this.logMessage(
|
|
18
|
+
info(key, ...args) {
|
|
19
|
+
this.logMessage(key, args[0]);
|
|
18
20
|
}
|
|
19
|
-
logMessage(
|
|
20
|
-
|
|
21
|
+
logMessage(key, params) {
|
|
22
|
+
var _a;
|
|
23
|
+
const entry = LogMessages_1.LOG_MESSAGES[key];
|
|
24
|
+
let message = typeof entry.template === 'function'
|
|
25
|
+
? entry.template(params)
|
|
26
|
+
: entry.template;
|
|
27
|
+
if ('documentationUri' in entry && entry.documentationUri) {
|
|
28
|
+
message += `\nFor more information, see: ${entry.documentationUri}`;
|
|
29
|
+
}
|
|
30
|
+
const logType = 'logType' in entry ? (_a = entry.logType) !== null && _a !== void 0 ? _a : LogType_1.LogType.Info : LogType_1.LogType.Info;
|
|
31
|
+
console.log(`[${logType}][${this.name}]: ${message}`);
|
|
21
32
|
}
|
|
22
33
|
isDebugEnabled() {
|
|
23
34
|
return (this.level === LogLevel_1.LogLevel.Debug ||
|