@dynatrace/react-native-plugin 2.327.1 → 2.329.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 +426 -169
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceConfigurationModule.kt +48 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRNBridgeImpl.kt +41 -8
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceReactPackage.kt +3 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceRuntimeConfigurationStore.kt +14 -0
- package/android/src/main/java/com/dynatrace/android/agent/DynatraceUtils.kt +103 -47
- package/android/src/new/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +12 -4
- package/android/src/old/java/com/dynatrace/android/agent/DynatraceRNBridge.kt +15 -5
- package/files/default.config.js +7 -0
- package/files/plugin-runtime.gradle +7 -17
- package/files/plugin.gradle +1 -1
- package/instrumentation/DynatraceInstrumentation.js +1 -1
- package/instrumentation/libs/react-native/Touchables.js +9 -0
- package/instrumentation/libs/react-navigation/ReactNavigation.js +53 -18
- package/ios/ConfigurationSubscriber.h +15 -0
- package/ios/DynatraceRNBridge.h +4 -0
- package/ios/DynatraceRNBridge.mm +220 -33
- package/lib/core/Dynatrace.js +8 -11
- package/lib/core/configuration/ConfigurationHandler.js +3 -0
- package/lib/next/Dynatrace.js +14 -32
- package/lib/next/DynatraceEventBus.js +35 -0
- package/lib/next/appstart/AppStartObserver.js +12 -16
- package/lib/next/configuration/INativeRuntimeConfiguration.js +7 -0
- package/lib/next/configuration/RuntimeConfigurationObserver.js +40 -0
- package/lib/next/events/EventBuilderUtil.js +7 -0
- package/lib/next/events/EventData.js +28 -0
- package/lib/next/events/EventPipeline.js +5 -11
- package/lib/next/events/ExceptionEventData.js +26 -0
- package/lib/next/events/{HttpRequestEventBuilder.js → HttpRequestEventData.js} +28 -52
- package/lib/next/events/SessionPropertyEventData.js +22 -0
- package/lib/next/events/interface/IBaseEvent.js +2 -0
- package/lib/next/events/interface/IEventData.js +2 -0
- package/lib/next/events/interface/IExceptionEventData.js +2 -0
- package/lib/next/events/interface/IHttpRequestEventData.js +2 -0
- package/lib/next/events/interface/ISessionPropertyEventData.js +2 -0
- package/lib/next/events/modifier/BaseDataEventModifier.js +1 -3
- package/lib/next/events/modifier/EventModifierUtil.js +34 -41
- package/lib/next/events/modifier/ModifyEventValidation.js +118 -26
- package/lib/next/events/modifier/SendEventValidation.js +53 -22
- package/lib/next/events/modifier/StringLengthEventModifier.js +53 -0
- package/lib/next/events/spec/EventSpecContstants.js +9 -2
- package/package.json +8 -3
- package/public.js +9 -3
- package/react-native-dynatrace.podspec +1 -1
- package/scripts/Config.js +6 -2
- package/scripts/LineOffsetAnalyze.js +1 -4
- package/scripts/core/LineOffsetAnalyzeCall.js +39 -46
- package/src/lib/core/interface/NativeDynatraceBridge.ts +6 -2
- package/types.d.ts +388 -158
- package/lib/next/events/ViewInfoCreator.js +0 -27
- package/lib/next/events/modifier/EventLimitation.js +0 -69
- /package/lib/next/events/{IHttpRequestEventBuilder.js → interface/EventProperty.js} +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppStartObserver = void 0;
|
|
4
|
-
const react_native_1 = require("react-native");
|
|
5
4
|
const EventCreator_1 = require("../events/EventCreator");
|
|
6
5
|
const ConsoleLogger_1 = require("../../core/logging/ConsoleLogger");
|
|
7
|
-
const DynatraceBridge_1 = require("../../core/DynatraceBridge");
|
|
8
6
|
const EventPipeline_1 = require("../events/EventPipeline");
|
|
7
|
+
const DynatraceEventBus_1 = require("../DynatraceEventBus");
|
|
9
8
|
class AppStartObserverImpl {
|
|
10
9
|
constructor() {
|
|
11
10
|
this.EMIT_APP_START = 'dynatraceAppStartMeasurements';
|
|
@@ -15,20 +14,17 @@ class AppStartObserverImpl {
|
|
|
15
14
|
call() {
|
|
16
15
|
}
|
|
17
16
|
setupNativeEventEmitter() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
17
|
+
const emitter = (0, DynatraceEventBus_1.createEmitterNativeOnly)();
|
|
18
|
+
emitter.addListener(this.EMIT_APP_START, (data) => {
|
|
19
|
+
this.logger.debug(`emitter(${JSON.stringify(data)}})`);
|
|
20
|
+
const appStartEvent = (0, EventCreator_1.createAppStartEvent)(data);
|
|
21
|
+
if (appStartEvent != null) {
|
|
22
|
+
EventPipeline_1.EventPipeline.insertEvent(Object.assign({}, appStartEvent));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
this.logger.debug(`emitter(${JSON.stringify(data)}}): App Start event ignored!`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
exports.AppStartObserver = new AppStartObserverImpl();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateDefaultConfiguration = void 0;
|
|
4
|
+
const generateDefaultConfiguration = () => ({
|
|
5
|
+
'3rd_gen_enabled': true,
|
|
6
|
+
});
|
|
7
|
+
exports.generateDefaultConfiguration = generateDefaultConfiguration;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeConfigurationObserver = void 0;
|
|
4
|
+
const DynatraceBridge_1 = require("../../core/DynatraceBridge");
|
|
5
|
+
const DynatraceEventBus_1 = require("../DynatraceEventBus");
|
|
6
|
+
const INativeRuntimeConfiguration_1 = require("./INativeRuntimeConfiguration");
|
|
7
|
+
class RuntimeConfigurationObserverImpl {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.EMIT_CONFIGURATION = 'dynatraceConfiguration';
|
|
10
|
+
this.runtimeConfiguration = (0, INativeRuntimeConfiguration_1.generateDefaultConfiguration)();
|
|
11
|
+
this.observerIsInitiated = false;
|
|
12
|
+
this.subscription = null;
|
|
13
|
+
this.setupNativeEventEmitter();
|
|
14
|
+
}
|
|
15
|
+
getCurrentRuntimeConfiguration() {
|
|
16
|
+
return this.runtimeConfiguration;
|
|
17
|
+
}
|
|
18
|
+
isInitiated() {
|
|
19
|
+
return this.observerIsInitiated;
|
|
20
|
+
}
|
|
21
|
+
setupNativeEventEmitter() {
|
|
22
|
+
const emitter = (0, DynatraceEventBus_1.createEmitterRuntimeConfig)();
|
|
23
|
+
this.subscription = (0, DynatraceEventBus_1.addListenerOnce)(emitter, this.subscription, this.EMIT_CONFIGURATION, (data) => {
|
|
24
|
+
this.runtimeConfiguration = data;
|
|
25
|
+
this.observerIsInitiated = true;
|
|
26
|
+
});
|
|
27
|
+
if (typeof DynatraceBridge_1.DynatraceNative.getCurrentConfiguration === 'function') {
|
|
28
|
+
Promise.resolve(DynatraceBridge_1.DynatraceNative.getCurrentConfiguration())
|
|
29
|
+
.then((data) => {
|
|
30
|
+
if (data) {
|
|
31
|
+
this.runtimeConfiguration = data;
|
|
32
|
+
this.observerIsInitiated = true;
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
.catch(() => {
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.RuntimeConfigurationObserver = new RuntimeConfigurationObserverImpl();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.includeIfTrue = exports.includeIfDefined = void 0;
|
|
4
|
+
const includeIfDefined = (key, value) => (value !== undefined ? { [key]: value } : {});
|
|
5
|
+
exports.includeIfDefined = includeIfDefined;
|
|
6
|
+
const includeIfTrue = (key, value) => value === true ? { [key]: value } : {};
|
|
7
|
+
exports.includeIfTrue = includeIfTrue;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SendEventValidation_1 = require("./modifier/SendEventValidation");
|
|
4
|
+
const EventModifierUtil_1 = require("./modifier/EventModifierUtil");
|
|
5
|
+
const EventBuilderUtil_1 = require("./EventBuilderUtil");
|
|
6
|
+
class EventData {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.rawEventProperties = {};
|
|
9
|
+
}
|
|
10
|
+
addEventProperty(key, value) {
|
|
11
|
+
this.rawEventProperties[key] = value;
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
withDuration(duration) {
|
|
15
|
+
this.duration = duration;
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
toJSON() {
|
|
19
|
+
const sanitizedEventProperties = SendEventValidation_1.SendEventValidation.modifyEvent(Object.assign(Object.assign({}, this.rawEventProperties), (0, EventBuilderUtil_1.includeIfDefined)("duration", this.duration)));
|
|
20
|
+
if (sanitizedEventProperties === null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
(0, EventModifierUtil_1.flagEventProperties)(sanitizedEventProperties);
|
|
24
|
+
(0, EventModifierUtil_1.addIsApiReported)(sanitizedEventProperties);
|
|
25
|
+
return sanitizedEventProperties;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = EventData;
|
|
@@ -6,18 +6,21 @@ const ConsoleLogger_1 = require("../../core/logging/ConsoleLogger");
|
|
|
6
6
|
const BaseDataEventModifier_1 = require("./modifier/BaseDataEventModifier");
|
|
7
7
|
const ValueRestrictionModifier_1 = require("./modifier/ValueRestrictionModifier");
|
|
8
8
|
const ModifyEventValidation_1 = require("./modifier/ModifyEventValidation");
|
|
9
|
-
const ViewInfoCreator_1 = require("./ViewInfoCreator");
|
|
10
9
|
const EventSpecContstants_1 = require("./spec/EventSpecContstants");
|
|
10
|
+
const StringLengthEventModifier_1 = require("./modifier/StringLengthEventModifier");
|
|
11
11
|
class EventPipelineImpl {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.customEventModifierChain = new ModifyEventValidation_1.ModifyEventValidation();
|
|
14
14
|
this.logger = new ConsoleLogger_1.ConsoleLogger('EventPipeline');
|
|
15
15
|
}
|
|
16
16
|
getEventModifierChain() {
|
|
17
|
+
const stringLengthEventModifier = new StringLengthEventModifier_1.StringLengthEventModifier();
|
|
17
18
|
return [
|
|
18
|
-
new BaseDataEventModifier_1.BaseDataEventModifier(
|
|
19
|
+
new BaseDataEventModifier_1.BaseDataEventModifier(),
|
|
20
|
+
stringLengthEventModifier,
|
|
19
21
|
this.customEventModifierChain,
|
|
20
22
|
ValueRestrictionModifier_1.ValueRestrictionModifier,
|
|
23
|
+
stringLengthEventModifier,
|
|
21
24
|
];
|
|
22
25
|
}
|
|
23
26
|
insertEvent(event) {
|
|
@@ -58,14 +61,5 @@ class EventPipelineImpl {
|
|
|
58
61
|
this.logger.debug('removeEventModifier()');
|
|
59
62
|
return this.customEventModifierChain.removeEventModifier(eventModifier);
|
|
60
63
|
}
|
|
61
|
-
generateViewData(name) {
|
|
62
|
-
this.logger.debug(`generateViewData(${name})`);
|
|
63
|
-
if (name != null) {
|
|
64
|
-
this.viewInfo = (0, ViewInfoCreator_1.createViewInfo)(name);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
releaseViewData() {
|
|
68
|
-
this.viewInfo = undefined;
|
|
69
|
-
}
|
|
70
64
|
}
|
|
71
65
|
exports.EventPipeline = new EventPipelineImpl();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SendEventValidation_1 = require("./modifier/SendEventValidation");
|
|
4
|
+
const EventModifierUtil_1 = require("./modifier/EventModifierUtil");
|
|
5
|
+
const EventCreator_1 = require("./EventCreator");
|
|
6
|
+
class ExceptionEventData {
|
|
7
|
+
constructor(error) {
|
|
8
|
+
this.rawEventProperties = {};
|
|
9
|
+
this.error = error;
|
|
10
|
+
}
|
|
11
|
+
addEventProperty(key, value) {
|
|
12
|
+
this.rawEventProperties[key] = value;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
toJSON() {
|
|
16
|
+
const sanitizedEventProperties = SendEventValidation_1.SendEventValidation.modifyEvent(Object.assign({}, this.rawEventProperties));
|
|
17
|
+
if (sanitizedEventProperties === null) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const exceptionEvent = Object.assign(Object.assign({}, (0, EventCreator_1.createErrorEvent)(this.error.name, this.error.message, this.error.stack)), sanitizedEventProperties);
|
|
21
|
+
(0, EventModifierUtil_1.flagEventProperties)(exceptionEvent);
|
|
22
|
+
(0, EventModifierUtil_1.addIsApiReported)(exceptionEvent);
|
|
23
|
+
return exceptionEvent;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = ExceptionEventData;
|
|
@@ -3,16 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ConsoleLogger_1 = require("../../core/logging/ConsoleLogger");
|
|
4
4
|
const TimestampProvider_1 = require("../provider/TimestampProvider");
|
|
5
5
|
const SendEventValidation_1 = require("./modifier/SendEventValidation");
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const EventModifierUtil_1 = require("./modifier/EventModifierUtil");
|
|
7
|
+
const EventBuilderUtil_1 = require("./EventBuilderUtil");
|
|
8
|
+
const logger = new ConsoleLogger_1.ConsoleLogger('HttpRequestEventData');
|
|
9
|
+
class HttpRequestEventData {
|
|
8
10
|
constructor(url, requestMethod) {
|
|
9
11
|
this.url = url;
|
|
10
12
|
this.requestMethod = requestMethod;
|
|
11
13
|
this.duration = 0;
|
|
12
14
|
this.rawEventProperties = {};
|
|
13
15
|
this.traceContextHint = "api_unused";
|
|
14
|
-
this.
|
|
15
|
-
this.hasNfnValues = false;
|
|
16
|
+
this.hasDroppedProperties = false;
|
|
16
17
|
this.triedToOverwriteDuration = false;
|
|
17
18
|
this.requestMethod =
|
|
18
19
|
requestMethod.toUpperCase();
|
|
@@ -51,14 +52,13 @@ class HttpRequestEventBuilder {
|
|
|
51
52
|
this.rawEventProperties[key] = value;
|
|
52
53
|
return this;
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
-
if (!this.
|
|
56
|
-
logger.debug('
|
|
55
|
+
toJSON() {
|
|
56
|
+
if (!this.hasValidMandatoryAttributes()) {
|
|
57
|
+
logger.debug('toJSON(): Dropped invalid event');
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
60
|
this.sanitizeDuration();
|
|
60
61
|
this.sanitizeStatusCode();
|
|
61
|
-
this.sanitizeReasonPhrase();
|
|
62
62
|
this.sanitizeBytesReceived();
|
|
63
63
|
this.sanitizeBytesSent();
|
|
64
64
|
const parsedTraceparentHeader = this.traceparentHeader &&
|
|
@@ -67,25 +67,25 @@ class HttpRequestEventBuilder {
|
|
|
67
67
|
this.traceContextHint = "invalid";
|
|
68
68
|
}
|
|
69
69
|
const hasFailedRequest = this.isStatusCodeError() || !!this.error;
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(
|
|
70
|
+
const sanitizedEventProperties = SendEventValidation_1.SendEventValidation.modifyEvent(this.rawEventProperties);
|
|
71
|
+
(0, EventModifierUtil_1.flagEventProperties)(sanitizedEventProperties);
|
|
72
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, sanitizedEventProperties), { ["url.full"]: this.url, ["network.protocol.name"]: 'http', ["http.request.method"]: this.requestMethod, ["request.trace_context_hint"]: this.traceContextHint, ["duration"]: this.duration, ["start_time"]: TimestampProvider_1.defaultTimestampProvider.getCurrentTimestamp() - this.duration }), (this.triedToOverwriteDuration && {
|
|
73
73
|
["dt.support.api.overridden_fields"]: [
|
|
74
74
|
'duration',
|
|
75
75
|
],
|
|
76
|
-
})),
|
|
76
|
+
})), (0, EventBuilderUtil_1.includeIfDefined)("http.response.status_code", this.statusCode)), (0, EventBuilderUtil_1.includeIfDefined)("http.response.reason_phrase", this.reasonPhrase)), (0, EventBuilderUtil_1.includeIfDefined)("request.bytes_sent", this.bytesSent)), (0, EventBuilderUtil_1.includeIfDefined)("request.bytes_received", this.bytesReceived)), { ["characteristics.has_request"]: true, ["characteristics.is_api_reported"]: true }), (0, EventBuilderUtil_1.includeIfTrue)("characteristics.has_failed_request", hasFailedRequest)), (0, EventBuilderUtil_1.includeIfTrue)("characteristics.has_error", hasFailedRequest)), (this.error !== undefined && Object.assign({ ["characteristics.has_exception"]: true, ["exception.type"]: this.error.name, ["exception.message"]: this.error.message }, (0, EventBuilderUtil_1.includeIfDefined)("exception.stack_trace", this.error.stack)))), (parsedTraceparentHeader && {
|
|
77
77
|
["trace.id"]: parsedTraceparentHeader.traceId,
|
|
78
78
|
["span.id"]: parsedTraceparentHeader.spanId,
|
|
79
|
-
})),
|
|
79
|
+
})), (0, EventBuilderUtil_1.includeIfTrue)("dt.support.api.has_dropped_properties", this.hasDroppedProperties));
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
hasValidMandatoryAttributes() {
|
|
82
82
|
let isValid = true;
|
|
83
83
|
if (this.isInvalidUrl(this.url)) {
|
|
84
|
-
logger.debug(`
|
|
84
|
+
logger.debug(`hasValidMandatoryAttributes(): dropped event since given URL is malformed: ${this.url}`);
|
|
85
85
|
isValid = false;
|
|
86
86
|
}
|
|
87
|
-
if (!
|
|
88
|
-
logger.debug(`
|
|
87
|
+
if (!HttpRequestEventData.allowedRequestMethods.includes(this.requestMethod)) {
|
|
88
|
+
logger.debug(`hasValidMandatoryAttributes(): dropped event since given Request Method is invalid: ${this.requestMethod}`);
|
|
89
89
|
isValid = false;
|
|
90
90
|
}
|
|
91
91
|
return isValid;
|
|
@@ -103,62 +103,39 @@ class HttpRequestEventBuilder {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
sanitizeStatusCode() {
|
|
106
|
-
if (this.statusCode
|
|
106
|
+
if (this.statusCode === undefined && this.error === undefined) {
|
|
107
107
|
this.statusCode = 0;
|
|
108
108
|
}
|
|
109
109
|
if (this.statusCode && this.statusCode < 0) {
|
|
110
|
-
logger.debug('
|
|
110
|
+
logger.debug('HttpRequestEventData: overriding invalid Status Code with 0');
|
|
111
111
|
this.statusCode = 0;
|
|
112
|
-
this.
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
sanitizeReasonPhrase() {
|
|
116
|
-
if (this.reasonPhrase &&
|
|
117
|
-
this.reasonPhrase.length >
|
|
118
|
-
HttpRequestEventBuilder.maxReasonPhraseLength) {
|
|
119
|
-
logger.debug(`HttpRequestEventBuilder: trimming too long Reason Phrase to a length of ${HttpRequestEventBuilder.maxReasonPhraseLength}`);
|
|
120
|
-
this.reasonPhrase = this.reasonPhrase.slice(0, HttpRequestEventBuilder.maxReasonPhraseLength);
|
|
112
|
+
this.hasDroppedProperties = true;
|
|
121
113
|
}
|
|
122
114
|
}
|
|
123
115
|
sanitizeDuration() {
|
|
124
|
-
this.hasNfnValues || (this.hasNfnValues = !Number.isFinite(this.duration));
|
|
125
116
|
if (!Number.isFinite(this.duration) || this.duration < 0) {
|
|
126
|
-
logger.debug('
|
|
117
|
+
logger.debug('HttpRequestEventData: overriding invalid Duration with 0');
|
|
127
118
|
this.duration = 0;
|
|
128
|
-
this.
|
|
119
|
+
this.hasDroppedProperties = true;
|
|
129
120
|
}
|
|
130
121
|
}
|
|
131
122
|
sanitizeBytesSent() {
|
|
132
123
|
if (this.bytesSent && this.bytesSent < 0) {
|
|
133
|
-
logger.debug(`
|
|
124
|
+
logger.debug(`HttpRequestEventData: dropping invalid value for Bytes Sent: ${this.bytesSent}`);
|
|
134
125
|
this.bytesSent = undefined;
|
|
135
|
-
this.
|
|
126
|
+
this.hasDroppedProperties = true;
|
|
136
127
|
}
|
|
137
128
|
}
|
|
138
129
|
sanitizeBytesReceived() {
|
|
139
130
|
if (this.bytesReceived && this.bytesReceived < 0) {
|
|
140
|
-
logger.debug(`
|
|
131
|
+
logger.debug(`HttpRequestEventData: dropping invalid value for Bytes Received: ${this.bytesReceived}`);
|
|
141
132
|
this.bytesReceived = undefined;
|
|
142
|
-
this.
|
|
133
|
+
this.hasDroppedProperties = true;
|
|
143
134
|
}
|
|
144
135
|
}
|
|
145
136
|
isStatusCodeError() {
|
|
146
137
|
return (this.statusCode && 400 <= this.statusCode && this.statusCode <= 599);
|
|
147
138
|
}
|
|
148
|
-
isEventPropertyKey([key, _]) {
|
|
149
|
-
if (key.startsWith("event_properties")) {
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
logger.debug(`HttpRequestEventBuilder: dropped event property '$key' as it did not start with prefix ${"event_properties"}`);
|
|
153
|
-
this.hasDroppedCustomProperties = true;
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
includeIfDefined(key, value) {
|
|
157
|
-
return value !== undefined ? { [key]: value } : {};
|
|
158
|
-
}
|
|
159
|
-
includeIfTrue(key, value) {
|
|
160
|
-
return value === true ? { [key]: value } : {};
|
|
161
|
-
}
|
|
162
139
|
parseTraceparent(header) {
|
|
163
140
|
const traceparentRegex = /^00-([0-9a-f]{32})-([0-9a-f]{16})-0[01]$/;
|
|
164
141
|
const match = header.match(traceparentRegex);
|
|
@@ -181,8 +158,8 @@ class HttpRequestEventBuilder {
|
|
|
181
158
|
return /^0*$/.test(str);
|
|
182
159
|
}
|
|
183
160
|
}
|
|
184
|
-
exports.default =
|
|
185
|
-
|
|
161
|
+
exports.default = HttpRequestEventData;
|
|
162
|
+
HttpRequestEventData.allowedRequestMethods = [
|
|
186
163
|
'GET',
|
|
187
164
|
'HEAD',
|
|
188
165
|
'POST',
|
|
@@ -193,4 +170,3 @@ HttpRequestEventBuilder.allowedRequestMethods = [
|
|
|
193
170
|
'TRACE',
|
|
194
171
|
'PATCH',
|
|
195
172
|
];
|
|
196
|
-
HttpRequestEventBuilder.maxReasonPhraseLength = 5000;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SendEventValidation_1 = require("./modifier/SendEventValidation");
|
|
4
|
+
const EventModifierUtil_1 = require("./modifier/EventModifierUtil");
|
|
5
|
+
class SessionPropertyEventData {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.rawSessionProperties = {};
|
|
8
|
+
}
|
|
9
|
+
addSessionProperty(key, value) {
|
|
10
|
+
this.rawSessionProperties[key] = value;
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
toJSON() {
|
|
14
|
+
const event = SendEventValidation_1.SendSessionPropertyEventValidation.modifyEvent(this.rawSessionProperties);
|
|
15
|
+
if (event != null) {
|
|
16
|
+
event["characteristics.has_session_properties"] = true;
|
|
17
|
+
}
|
|
18
|
+
(0, EventModifierUtil_1.addIsApiReported)(event);
|
|
19
|
+
return event;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.default = SessionPropertyEventData;
|
|
@@ -5,8 +5,7 @@ const ConfigurationHandler_1 = require("../../../core/configuration/Configuratio
|
|
|
5
5
|
const ConsoleLogger_1 = require("../../../core/logging/ConsoleLogger");
|
|
6
6
|
const EventModifierUtil_1 = require("./EventModifierUtil");
|
|
7
7
|
class BaseDataEventModifier {
|
|
8
|
-
constructor(
|
|
9
|
-
this.viewInfo = viewInfo;
|
|
8
|
+
constructor() {
|
|
10
9
|
this.logger = new ConsoleLogger_1.ConsoleLogger('BaseDataEventModifier');
|
|
11
10
|
}
|
|
12
11
|
modifyEvent(event) {
|
|
@@ -14,7 +13,6 @@ class BaseDataEventModifier {
|
|
|
14
13
|
this.logger.debug(`modifyEvent(${JSON.stringify(event)}): Event is null!`);
|
|
15
14
|
return event;
|
|
16
15
|
}
|
|
17
|
-
Object.assign(event, this.viewInfo);
|
|
18
16
|
event["dt.rum.event.source.type"] = 'react_native';
|
|
19
17
|
const bundleName = ConfigurationHandler_1.ConfigurationHandler.getBundleName();
|
|
20
18
|
if (bundleName !== undefined) {
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isKeyCustomProperty = exports.isNotObject = exports.doesNotExceedKeySize = exports.restrictingValueSize = exports.isKeySyntaxAllowed = exports.getReactNativeVersion = exports.containEventPropertiesInArray = exports.addIsApiReported = exports.flagEventProperties = exports.containEventProperties = exports.containSessionProperties = exports.trimString = exports.isObject = void 0;
|
|
4
4
|
const ConsoleLogger_1 = require("../../../core/logging/ConsoleLogger");
|
|
5
|
-
const
|
|
5
|
+
const EventSpecContstants_1 = require("../spec/EventSpecContstants");
|
|
6
6
|
const logger = new ConsoleLogger_1.ConsoleLogger('EventModifierUtil');
|
|
7
|
-
const flattenAdditionalData = (obj, parent, res = {}) => {
|
|
8
|
-
for (const key in obj) {
|
|
9
|
-
const propName = parent != null ? parent + '.' + key : key;
|
|
10
|
-
const valueOfObject = obj[key];
|
|
11
|
-
if ((0, exports.isObject)(valueOfObject)) {
|
|
12
|
-
(0, exports.flattenAdditionalData)(valueOfObject, propName, res);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
res[propName] = obj[key];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return res;
|
|
19
|
-
};
|
|
20
|
-
exports.flattenAdditionalData = flattenAdditionalData;
|
|
21
7
|
const isObject = (obj) => {
|
|
22
8
|
if (obj === null || typeof obj !== 'object') {
|
|
23
9
|
return false;
|
|
@@ -25,25 +11,17 @@ const isObject = (obj) => {
|
|
|
25
11
|
return Object.prototype.toString.call(obj) === '[object Object]';
|
|
26
12
|
};
|
|
27
13
|
exports.isObject = isObject;
|
|
28
|
-
const trimString = (str, maxLength
|
|
14
|
+
const trimString = (key, str, maxLength) => {
|
|
29
15
|
const stringToTrim = str.toString();
|
|
30
16
|
if (stringToTrim.length <= maxLength) {
|
|
31
17
|
return stringToTrim;
|
|
32
18
|
}
|
|
33
19
|
else {
|
|
20
|
+
logger.debug(`trimString(): Limiting value of ${key} as maximum value length (${maxLength}) is reached!`);
|
|
34
21
|
return stringToTrim.substring(0, maxLength);
|
|
35
22
|
}
|
|
36
23
|
};
|
|
37
24
|
exports.trimString = trimString;
|
|
38
|
-
const trimStringValuesInObject = (jsonData) => {
|
|
39
|
-
for (const key in jsonData) {
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(jsonData, key)) {
|
|
41
|
-
jsonData[key] = trimStringValue(jsonData[key]);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return jsonData;
|
|
45
|
-
};
|
|
46
|
-
exports.trimStringValuesInObject = trimStringValuesInObject;
|
|
47
25
|
const containSessionProperties = (jsonData) => {
|
|
48
26
|
for (const key in jsonData) {
|
|
49
27
|
if (key.startsWith(`${"session_properties"}.`)) {
|
|
@@ -70,7 +48,7 @@ const flagEventProperties = (event) => {
|
|
|
70
48
|
};
|
|
71
49
|
exports.flagEventProperties = flagEventProperties;
|
|
72
50
|
const addIsApiReported = (event) => {
|
|
73
|
-
if (event
|
|
51
|
+
if (event != null) {
|
|
74
52
|
event["characteristics.is_api_reported"] = true;
|
|
75
53
|
}
|
|
76
54
|
};
|
|
@@ -101,22 +79,37 @@ const getReactNativeVersion = () => {
|
|
|
101
79
|
return undefined;
|
|
102
80
|
};
|
|
103
81
|
exports.getReactNativeVersion = getReactNativeVersion;
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
82
|
+
const isKeySyntaxAllowed = (entry) => {
|
|
83
|
+
const [key] = entry;
|
|
84
|
+
const rV = EventSpecContstants_1.KEY_NAME_REGEX.test(key);
|
|
85
|
+
if (!rV) {
|
|
86
|
+
logger.debug(`isKeySyntaxAllowed(): Filtering key ${key} as it doesnt fulfill character rules!`);
|
|
87
|
+
}
|
|
88
|
+
return rV;
|
|
110
89
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
exports.isKeySyntaxAllowed = isKeySyntaxAllowed;
|
|
91
|
+
const restrictingValueSize = (entry) => {
|
|
92
|
+
const [key, value] = entry;
|
|
93
|
+
if (typeof value === 'string' &&
|
|
94
|
+
value.length > EventSpecContstants_1.MAX_CUSTOM_EVENT_VALUE_LENGTH) {
|
|
95
|
+
logger.debug(`restrictingValueSize(): Limiting value of ${key} as maximum value length (${EventSpecContstants_1.MAX_CUSTOM_EVENT_VALUE_LENGTH}) is reached!`);
|
|
96
|
+
entry[1] = value.slice(0, EventSpecContstants_1.MAX_CUSTOM_EVENT_VALUE_LENGTH);
|
|
114
97
|
}
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
};
|
|
99
|
+
exports.restrictingValueSize = restrictingValueSize;
|
|
100
|
+
const doesNotExceedKeySize = ([key]) => {
|
|
101
|
+
if (key.length <= EventSpecContstants_1.MAX_CUSTOM_EVENT_KEY_LENGTH) {
|
|
102
|
+
return true;
|
|
117
103
|
}
|
|
118
|
-
else
|
|
119
|
-
|
|
104
|
+
else {
|
|
105
|
+
logger.debug(`doesNotExceedKeySize(): Dropping key ${key} as maximum key length (${EventSpecContstants_1.MAX_CUSTOM_EVENT_KEY_LENGTH}) is reached!`);
|
|
106
|
+
return false;
|
|
120
107
|
}
|
|
121
|
-
return data;
|
|
122
108
|
};
|
|
109
|
+
exports.doesNotExceedKeySize = doesNotExceedKeySize;
|
|
110
|
+
const isNotObject = ([, val]) => typeof val !== 'object' || val === null;
|
|
111
|
+
exports.isNotObject = isNotObject;
|
|
112
|
+
const isKeyCustomProperty = (key) => key.startsWith("event_properties") ||
|
|
113
|
+
key.startsWith("session_properties");
|
|
114
|
+
exports.isKeyCustomProperty = isKeyCustomProperty;
|
|
115
|
+
const toVersionString = (v) => `${v.major}.${v.minor}.${v.patch}${v.prerelease ? `-${v.prerelease}` : ''}`;
|