@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
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ReactRuntime = require("react/jsx-runtime");
|
|
4
|
-
const Types_1 = require("../model/Types");
|
|
5
4
|
const FunctionalComponent_1 = require("./components/FunctionalComponent");
|
|
6
5
|
const ClassComponent_1 = require("./components/ClassComponent");
|
|
7
6
|
const ElementHelper_1 = require("./ElementHelper");
|
|
7
|
+
const JsxRuntimeHelpers_1 = require("./JsxRuntimeHelpers");
|
|
8
|
+
const createWrapperProps = (jsxFunction, args) => (Object.assign(Object.assign({}, args[1]), { children: jsxFunction(...args) }));
|
|
9
|
+
const wrapWithComponent = (wrapperComponent, wrapperProps, args) => {
|
|
10
|
+
if ((0, JsxRuntimeHelpers_1.hasKey)(args)) {
|
|
11
|
+
return ReactRuntime.jsx(wrapperComponent, wrapperProps, args[2] + '_dt');
|
|
12
|
+
}
|
|
13
|
+
return ReactRuntime.jsx(wrapperComponent, wrapperProps);
|
|
14
|
+
};
|
|
15
|
+
const wrapFunctionalComponent = (jsxFunction, args) => {
|
|
16
|
+
const wrapperProps = createWrapperProps(jsxFunction, args);
|
|
17
|
+
wrapperProps.dtActionName =
|
|
18
|
+
args[1] !== undefined && args[1].dtActionName !== undefined
|
|
19
|
+
? args[1].dtActionName
|
|
20
|
+
: args[0]._dtInfo.name;
|
|
21
|
+
return wrapWithComponent(FunctionalComponent_1.DynatraceFunctionalComponent, wrapperProps, args);
|
|
22
|
+
};
|
|
23
|
+
const wrapClassComponent = (jsxFunction, args) => {
|
|
24
|
+
const wrapperProps = createWrapperProps(jsxFunction, args);
|
|
25
|
+
return wrapWithComponent(ClassComponent_1.DynatraceClassComponent, wrapperProps, args);
|
|
26
|
+
};
|
|
8
27
|
const instrumentJsxCall = (jsxFunction) => (...args) => {
|
|
9
|
-
if (args[0]
|
|
10
|
-
args
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: args[0]._dtInfo.name;
|
|
18
|
-
if (args[2] !== undefined) {
|
|
19
|
-
return ReactRuntime.jsx(FunctionalComponent_1.DynatraceFunctionalComponent, wrapperProps, args[2] + '_dt');
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return ReactRuntime.jsx(FunctionalComponent_1.DynatraceFunctionalComponent, wrapperProps);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
else if (args[0]._dtInfo.type === Types_1.Types.ClassComponent &&
|
|
26
|
-
args[0].prototype !== undefined &&
|
|
27
|
-
args[0].prototype.isReactComponent !== undefined) {
|
|
28
|
-
const wrapperProps = Object.assign(Object.assign({}, args[1]), { children: jsxFunction(...args) });
|
|
29
|
-
if (args[2] !== undefined) {
|
|
30
|
-
return ReactRuntime.jsx(ClassComponent_1.DynatraceClassComponent, wrapperProps, args[2] + '_dt');
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return ReactRuntime.jsx(ClassComponent_1.DynatraceClassComponent, wrapperProps);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
(0, ElementHelper_1.modifyElement)(args[0], args[1]);
|
|
28
|
+
if (!(0, JsxRuntimeHelpers_1.isInstrumentedType)(args[0]) || (0, ElementHelper_1.isDtActionIgnore)(args[1])) {
|
|
29
|
+
return jsxFunction(...args);
|
|
30
|
+
}
|
|
31
|
+
if ((0, JsxRuntimeHelpers_1.isFunctionalComponentType)(args[0])) {
|
|
32
|
+
return wrapFunctionalComponent(jsxFunction, args);
|
|
33
|
+
}
|
|
34
|
+
if ((0, JsxRuntimeHelpers_1.isClassComponentType)(args[0])) {
|
|
35
|
+
return wrapClassComponent(jsxFunction, args);
|
|
37
36
|
}
|
|
37
|
+
(0, ElementHelper_1.modifyElement)(args[0], args[1]);
|
|
38
38
|
return jsxFunction(...args);
|
|
39
39
|
};
|
|
40
40
|
try {
|
|
@@ -43,6 +43,6 @@ try {
|
|
|
43
43
|
module.exports = Object.assign(Object.assign({}, ReactRuntime), { jsx,
|
|
44
44
|
jsxs });
|
|
45
45
|
}
|
|
46
|
-
catch (
|
|
46
|
+
catch (_a) {
|
|
47
47
|
module.exports = {};
|
|
48
48
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isClassComponentType = exports.isFunctionalComponentType = exports.isInstrumentedType = exports.hasKey = void 0;
|
|
4
|
+
const Types_1 = require("../model/Types");
|
|
5
|
+
const hasKey = (args) => args[2] !== undefined;
|
|
6
|
+
exports.hasKey = hasKey;
|
|
7
|
+
const isInstrumentedType = (type) => type !== undefined && type._dtInfo !== undefined;
|
|
8
|
+
exports.isInstrumentedType = isInstrumentedType;
|
|
9
|
+
const isFunctionalComponentType = (type) => type._dtInfo.type === Types_1.Types.FunctionalComponent;
|
|
10
|
+
exports.isFunctionalComponentType = isFunctionalComponentType;
|
|
11
|
+
const isClassComponentType = (type) => type._dtInfo.type === Types_1.Types.ClassComponent &&
|
|
12
|
+
type.prototype !== undefined &&
|
|
13
|
+
type.prototype.isReactComponent !== undefined;
|
|
14
|
+
exports.isClassComponentType = isClassComponentType;
|
|
@@ -5,6 +5,7 @@ const react_1 = require("react");
|
|
|
5
5
|
const ConfigurationHandler_1 = require("../../../lib/core/configuration/ConfigurationHandler");
|
|
6
6
|
const ConsoleLogger_1 = require("../../../lib/core/logging/ConsoleLogger");
|
|
7
7
|
const Dynatrace_1 = require("../../../lib/core/Dynatrace");
|
|
8
|
+
const LogMessages_1 = require("../../../lib/core/logging/LogMessages");
|
|
8
9
|
const ComponentUtil_1 = require("./ComponentUtil");
|
|
9
10
|
class DynatraceClassComponent extends react_1.Component {
|
|
10
11
|
constructor(props) {
|
|
@@ -15,16 +16,12 @@ class DynatraceClassComponent extends react_1.Component {
|
|
|
15
16
|
}
|
|
16
17
|
render() {
|
|
17
18
|
if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
|
|
18
|
-
this.logger.info(
|
|
19
|
+
this.logger.info(LogMessages_1.LogMessage.COMPONENT_NOT_STARTED);
|
|
19
20
|
}
|
|
20
|
-
else
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
? 'Render '
|
|
25
|
-
: 'Update ';
|
|
26
|
-
this.internalAction = Dynatrace_1.Dynatrace.enterAutoAction(actionPrefix + this.wrappingName);
|
|
27
|
-
}
|
|
21
|
+
else if (ConfigurationHandler_1.ConfigurationHandler.isLifecycleUpdateEnabled() ||
|
|
22
|
+
!this.componentMounted) {
|
|
23
|
+
const actionPrefix = this.componentMounted ? 'Update ' : 'Render ';
|
|
24
|
+
this.internalAction = Dynatrace_1.Dynatrace.enterAutoAction(actionPrefix + this.wrappingName);
|
|
28
25
|
}
|
|
29
26
|
return this.props.children;
|
|
30
27
|
}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDynatraceIgnored = exports.isDynatraceNaming = exports.getNameFromComponent = void 0;
|
|
4
|
-
const
|
|
5
|
-
if (props
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
else if (child.type !== undefined) {
|
|
18
|
-
if (child.type.displayName !== undefined) {
|
|
19
|
-
return child.type.displayName;
|
|
20
|
-
}
|
|
21
|
-
else if (child.type._dtInfo !== undefined) {
|
|
22
|
-
return child.type._dtInfo.name;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
return child.type.name;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
4
|
+
const getChildFromProperties = (props) => {
|
|
5
|
+
if (Array.isArray(props.children) && props.children.length === 1) {
|
|
6
|
+
return props.children[0];
|
|
7
|
+
}
|
|
8
|
+
return props.children;
|
|
9
|
+
};
|
|
10
|
+
const getNameFromChild = (child) => {
|
|
11
|
+
if (child.props !== undefined && child.props.dtActionName !== undefined) {
|
|
12
|
+
return child.props.dtActionName;
|
|
13
|
+
}
|
|
14
|
+
if (child.type === undefined) {
|
|
15
|
+
return 'Undefined Name';
|
|
28
16
|
}
|
|
29
|
-
|
|
17
|
+
if (child.type.displayName !== undefined) {
|
|
18
|
+
return child.type.displayName;
|
|
19
|
+
}
|
|
20
|
+
if (child.type._dtInfo !== undefined) {
|
|
21
|
+
return child.type._dtInfo.name;
|
|
22
|
+
}
|
|
23
|
+
return child.type.name;
|
|
24
|
+
};
|
|
25
|
+
const getNameFromComponent = (props) => {
|
|
26
|
+
if (props === undefined || props.children === undefined) {
|
|
30
27
|
return 'Undefined Name';
|
|
31
28
|
}
|
|
29
|
+
const child = getChildFromProperties(props);
|
|
30
|
+
return getNameFromChild(child);
|
|
32
31
|
};
|
|
33
32
|
exports.getNameFromComponent = getNameFromComponent;
|
|
34
33
|
const isDynatraceNaming = (properties) => typeof properties === 'object' &&
|
|
@@ -5,23 +5,25 @@ const React = require("react");
|
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
6
|
const ConfigurationHandler_1 = require("../../lib/core/configuration/ConfigurationHandler");
|
|
7
7
|
const EventPipeline_1 = require("../../lib/next/events/EventPipeline");
|
|
8
|
+
const EventTimestamp_1 = require("../../lib/next/events/EventTimestamp");
|
|
9
|
+
const TimestampProvider_1 = require("../../lib/next/provider/TimestampProvider");
|
|
8
10
|
const TOUCH_FLUSH_DELAY = 250;
|
|
9
11
|
let pendingTouch = null;
|
|
10
12
|
const getFiberPath = (fiber) => {
|
|
11
|
-
var _a, _b, _c;
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
12
14
|
let anyParentMasked = false;
|
|
13
15
|
let path = [];
|
|
14
16
|
let lastDtName;
|
|
15
17
|
while (fiber != null) {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
path = [
|
|
21
|
-
lastDtName =
|
|
18
|
+
const dtNameFromComponent = (_b = (_a = fiber.type) === null || _a === void 0 ? void 0 : _a.dtActionName) !== null && _b !== void 0 ? _b : (_c = fiber.type) === null || _c === void 0 ? void 0 : _c.dtName;
|
|
19
|
+
const dtNameFromProps = (_e = (_d = fiber.memoizedProps) === null || _d === void 0 ? void 0 : _d.dtActionName) !== null && _e !== void 0 ? _e : (_f = fiber.memoizedProps) === null || _f === void 0 ? void 0 : _f.dtName;
|
|
20
|
+
const dtName = dtNameFromProps !== null && dtNameFromProps !== void 0 ? dtNameFromProps : dtNameFromComponent;
|
|
21
|
+
if (dtName && dtName !== lastDtName) {
|
|
22
|
+
path = [dtName, ...path];
|
|
23
|
+
lastDtName = dtName;
|
|
22
24
|
}
|
|
23
25
|
anyParentMasked =
|
|
24
|
-
anyParentMasked || ((
|
|
26
|
+
anyParentMasked || ((_g = fiber.memoizedProps) === null || _g === void 0 ? void 0 : _g.dtMask) == true;
|
|
25
27
|
fiber = fiber.return;
|
|
26
28
|
}
|
|
27
29
|
return { path, anyParentMasked };
|
|
@@ -58,20 +60,20 @@ const getHostComponentInfo = (event) => {
|
|
|
58
60
|
const id = path.join('/');
|
|
59
61
|
const leaf = path[path.length - 1];
|
|
60
62
|
const components = [leaf];
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
let nameOrigin;
|
|
64
|
+
let detectedName;
|
|
65
|
+
if (fiber.type !== 'RCTText') {
|
|
66
|
+
nameOrigin = 'component';
|
|
67
|
+
detectedName = (_b = fiber.memoizedProps.accessibilityLabel) !== null && _b !== void 0 ? _b : leaf;
|
|
68
|
+
}
|
|
69
|
+
else if (anyParentMasked) {
|
|
70
|
+
nameOrigin = 'masked';
|
|
71
|
+
detectedName = '***';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
nameOrigin = 'text';
|
|
75
|
+
detectedName = flatten(fiber.memoizedProps.children);
|
|
76
|
+
}
|
|
75
77
|
return { id, components, detectedName, nameOrigin };
|
|
76
78
|
};
|
|
77
79
|
const flushTouch = (responderComponentInfo) => {
|
|
@@ -80,12 +82,13 @@ const flushTouch = (responderComponentInfo) => {
|
|
|
80
82
|
const { touchedComponentInfo, positions, timeoutId } = pendingTouch;
|
|
81
83
|
clearTimeout(timeoutId);
|
|
82
84
|
pendingTouch = null;
|
|
83
|
-
const
|
|
85
|
+
const eventTimestamp = new EventTimestamp_1.EventTimestamp(TimestampProvider_1.defaultTimestampProvider);
|
|
86
|
+
const event = Object.assign(Object.assign({ 'characteristics.has_user_interaction': true, 'ui_element.detected_name': touchedComponentInfo.detectedName, 'ui_element.components': touchedComponentInfo.components, 'ui_element.id': touchedComponentInfo.id, 'interaction.name': 'touch', positions, 'ui_element.name_origin': touchedComponentInfo.nameOrigin }, (responderComponentInfo && {
|
|
84
87
|
'ui_element.responder.detected_name': responderComponentInfo.detectedName,
|
|
85
88
|
'ui_element.responder.components': responderComponentInfo.components,
|
|
86
89
|
'ui_element.responder.id': responderComponentInfo.id,
|
|
87
90
|
'ui_element.responder.name_origin': responderComponentInfo.nameOrigin,
|
|
88
|
-
}));
|
|
91
|
+
})), eventTimestamp.getEventTimeInfo());
|
|
89
92
|
EventPipeline_1.EventPipeline.insertEvent(event);
|
|
90
93
|
};
|
|
91
94
|
const onTouch = (e) => {
|
|
@@ -4,12 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.RefreshControl = void 0;
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
6
|
const Types_1 = require("../../model/Types");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
_a._dtInfo = { type: Types_1.Types.RefreshControl },
|
|
14
|
-
_a);
|
|
15
|
-
}
|
|
7
|
+
exports.RefreshControl = typeof react_native_1.RefreshControl === 'object'
|
|
8
|
+
? Object.assign({ _dtInfo: { type: Types_1.Types.RefreshControl } }, react_native_1.RefreshControl) : (_a = class RefreshControl extends react_native_1.RefreshControl {
|
|
9
|
+
},
|
|
10
|
+
_a._dtInfo = { type: Types_1.Types.RefreshControl },
|
|
11
|
+
_a);
|
|
@@ -4,6 +4,7 @@ exports.monitorNavigation = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_native_1 = require("react-native");
|
|
6
6
|
const ConsoleLogger_1 = require("../../../lib/core/logging/ConsoleLogger");
|
|
7
|
+
const LogMessages_1 = require("../../../lib/core/logging/LogMessages");
|
|
7
8
|
const DynatraceBridge_1 = require("../../../lib/core/DynatraceBridge");
|
|
8
9
|
const BaseDataEventModifier_1 = require("../../../lib/next/events/modifier/BaseDataEventModifier");
|
|
9
10
|
const ConfigurationHandler_1 = require("../../../lib/core/configuration/ConfigurationHandler");
|
|
@@ -46,7 +47,7 @@ const monitorNavigation = (getRootState) => {
|
|
|
46
47
|
exports.monitorNavigation = monitorNavigation;
|
|
47
48
|
const startView = (newPath) => {
|
|
48
49
|
if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
|
|
49
|
-
logger.info(
|
|
50
|
+
logger.info(LogMessages_1.LogMessage.NAVIGATION_NOT_STARTED);
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
53
|
const startViewInternalEvent = new BaseDataEventModifier_1.BaseDataEventModifier().modifyEvent(Object.assign({ 'view.detected_name': newPath }, (activePath && {
|
|
@@ -56,16 +57,18 @@ const startView = (newPath) => {
|
|
|
56
57
|
if (typeof fn === 'function') {
|
|
57
58
|
fn(startViewInternalEvent);
|
|
58
59
|
}
|
|
59
|
-
logger.debug(
|
|
60
|
+
logger.debug(LogMessages_1.LogMessage.START_VIEW_INTERNAL, {
|
|
61
|
+
event: JSON.stringify(startViewInternalEvent),
|
|
62
|
+
});
|
|
60
63
|
};
|
|
61
64
|
const stopView = () => {
|
|
62
65
|
if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
|
|
63
|
-
logger.info(
|
|
66
|
+
logger.info(LogMessages_1.LogMessage.NAVIGATION_NOT_STARTED);
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
69
|
const fn = DynatraceBridge_1.DynatraceNative === null || DynatraceBridge_1.DynatraceNative === void 0 ? void 0 : DynatraceBridge_1.DynatraceNative.stopViewInternal;
|
|
67
70
|
if (typeof fn === 'function') {
|
|
68
71
|
fn();
|
|
69
72
|
}
|
|
70
|
-
logger.debug(
|
|
73
|
+
logger.debug(LogMessages_1.LogMessage.STOP_VIEW_INTERNAL);
|
|
71
74
|
};
|
|
@@ -4,6 +4,7 @@ exports.findTouchableName = exports.chooseTouchableName = exports.wrapOnPress =
|
|
|
4
4
|
const ReactNative = require("react-native");
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const ConsoleLogger_1 = require("../../lib/core/logging/ConsoleLogger");
|
|
7
|
+
const LogMessages_1 = require("../../lib/core/logging/LogMessages");
|
|
7
8
|
const ConfigurationHandler_1 = require("../../lib/core/configuration/ConfigurationHandler");
|
|
8
9
|
const Dynatrace_1 = require("../../lib/core/Dynatrace");
|
|
9
10
|
const ComponentUtil_1 = require("../jsx/components/ComponentUtil");
|
|
@@ -31,11 +32,13 @@ function withOnPressMonitoring(Component, fallbackName) {
|
|
|
31
32
|
}
|
|
32
33
|
exports.withOnPressMonitoring = withOnPressMonitoring;
|
|
33
34
|
const dtGetUiBridge = () => {
|
|
35
|
+
var _a;
|
|
34
36
|
const g = globalThis;
|
|
35
|
-
return g
|
|
37
|
+
return (_a = g === null || g === void 0 ? void 0 : g.__DT_UII_BRIDGE) !== null && _a !== void 0 ? _a : null;
|
|
36
38
|
};
|
|
37
39
|
const dtBuildPressPath = (startPath, touchableName) => {
|
|
38
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
const base = (_a = startPath === null || startPath === void 0 ? void 0 : startPath.toString()) !== null && _a !== void 0 ? _a : '';
|
|
39
42
|
if (!base)
|
|
40
43
|
return `Touchable(${touchableName})`;
|
|
41
44
|
const cut1 = base.lastIndexOf('/Text');
|
|
@@ -44,63 +47,72 @@ const dtBuildPressPath = (startPath, touchableName) => {
|
|
|
44
47
|
const parent = cut > 0 ? base.slice(0, cut) : base;
|
|
45
48
|
return parent + `/Touchable(${touchableName})`;
|
|
46
49
|
};
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
const registerPressOnBridge = (args, touchableName, isButtonLike, buttonLabel) => {
|
|
51
|
+
const bridge = dtGetUiBridge();
|
|
52
|
+
if (!bridge || typeof bridge.registerPress !== 'function') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const e = args === null || args === void 0 ? void 0 : args[0];
|
|
57
|
+
const ne = e === null || e === void 0 ? void 0 : e.nativeEvent;
|
|
58
|
+
const x = Number(ne === null || ne === void 0 ? void 0 : ne.pageX);
|
|
59
|
+
const y = Number(ne === null || ne === void 0 ? void 0 : ne.pageY);
|
|
60
|
+
const pos = Number.isFinite(x) && Number.isFinite(y) ? { x, y } : undefined;
|
|
61
|
+
const startPath = typeof bridge.getStartPath === 'function'
|
|
62
|
+
? bridge.getStartPath()
|
|
63
|
+
: null;
|
|
64
|
+
const nameForBridge = isButtonLike
|
|
65
|
+
? buttonLabel || touchableName
|
|
66
|
+
: touchableName;
|
|
67
|
+
bridge.registerPress({
|
|
68
|
+
path: dtBuildPressPath(startPath, nameForBridge),
|
|
69
|
+
elementName: nameForBridge,
|
|
70
|
+
pos,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
const errorMsg = e instanceof Error ? e.stack || e.message : String(e);
|
|
75
|
+
Logger.debug(LogMessages_1.LogMessage.REGISTER_PRESS_HOOK_FAILED, {
|
|
76
|
+
errorMsg,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const notifyPressFromEvent = (args) => {
|
|
81
|
+
if (args[0] && typeof args[0] === 'object' && 'nativeEvent' in args[0]) {
|
|
82
|
+
(0, UserInteraction_1.notifyPress)(args[0]);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const invokeOnPressWithoutConfiguration = (onPress, args) => {
|
|
86
|
+
Logger.info(LogMessages_1.LogMessage.TOUCH_NOT_STARTED);
|
|
87
|
+
onPress(...args);
|
|
88
|
+
};
|
|
89
|
+
const invokeOnPressWithAction = (onPress, args, touchableName) => {
|
|
90
|
+
const action = Dynatrace_1.Dynatrace.enterAutoAction(`Touch on ${touchableName}`);
|
|
91
|
+
let isSync = true;
|
|
92
|
+
try {
|
|
93
|
+
const returnValue = onPress(...args);
|
|
94
|
+
if (returnValue instanceof Promise) {
|
|
95
|
+
isSync = false;
|
|
96
|
+
void Promise.resolve(returnValue).finally(() => {
|
|
97
|
+
action.leaveAction();
|
|
98
|
+
});
|
|
76
99
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
if (isSync) {
|
|
103
|
+
action.leaveAction();
|
|
81
104
|
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const wrapOnPress = (onPress, touchableName, isButtonLike, buttonLabel) => {
|
|
108
|
+
return (...args) => {
|
|
109
|
+
registerPressOnBridge(args, touchableName, isButtonLike, buttonLabel);
|
|
110
|
+
notifyPressFromEvent(args);
|
|
82
111
|
if (!ConfigurationHandler_1.ConfigurationHandler.isConfigurationAvailable()) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
const action = Dynatrace_1.Dynatrace.enterAutoAction(`Touch on ${touchableName}`);
|
|
88
|
-
let isSync = true;
|
|
89
|
-
try {
|
|
90
|
-
const returnValue = onPress(...args);
|
|
91
|
-
if (returnValue instanceof Promise) {
|
|
92
|
-
isSync = false;
|
|
93
|
-
return Promise.resolve(returnValue).finally(() => {
|
|
94
|
-
action.leaveAction();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
finally {
|
|
99
|
-
if (isSync) {
|
|
100
|
-
action.leaveAction();
|
|
101
|
-
}
|
|
102
|
-
}
|
|
112
|
+
invokeOnPressWithoutConfiguration(onPress, args);
|
|
113
|
+
return;
|
|
103
114
|
}
|
|
115
|
+
invokeOnPressWithAction(onPress, args, touchableName);
|
|
104
116
|
};
|
|
105
117
|
};
|
|
106
118
|
exports.wrapOnPress = wrapOnPress;
|
package/lib/core/Application.js
CHANGED
|
@@ -6,6 +6,7 @@ const RuntimeConfigurationObserver_1 = require("../next/configuration/RuntimeCon
|
|
|
6
6
|
const ConfigurationBuilder_1 = require("./configuration/ConfigurationBuilder");
|
|
7
7
|
const ConfigurationHandler_1 = require("./configuration/ConfigurationHandler");
|
|
8
8
|
const ConsoleLogger_1 = require("./logging/ConsoleLogger");
|
|
9
|
+
const LogMessages_1 = require("./logging/LogMessages");
|
|
9
10
|
AppStartObserver_1.AppStartObserver.call();
|
|
10
11
|
RuntimeConfigurationObserver_1.RuntimeConfigurationObserver.call();
|
|
11
12
|
const logger = new ConsoleLogger_1.ConsoleLogger('ApplicationHandler');
|
|
@@ -17,8 +18,10 @@ exports.ApplicationHandler = {
|
|
|
17
18
|
config = new ConfigurationBuilder_1.ConfigurationBuilder('', '').buildConfiguration();
|
|
18
19
|
}
|
|
19
20
|
ConfigurationHandler_1.ConfigurationHandler.setConfiguration(config);
|
|
20
|
-
logger.debug(
|
|
21
|
-
|
|
21
|
+
logger.debug(LogMessages_1.LogMessage.CONFIGURATION_SET, {
|
|
22
|
+
config: config.toString(),
|
|
23
|
+
});
|
|
24
|
+
logger.info(LogMessages_1.LogMessage.PLUGIN_STARTED);
|
|
22
25
|
}
|
|
23
26
|
},
|
|
24
27
|
};
|