@datadog/mobile-react-native 3.8.0 → 3.9.0
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/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/ios/Sources/DdRumImplementation.swift +2 -2
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/DdSdkReactNative.js +15 -15
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +2 -2
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js +3 -3
- package/lib/commonjs/sdk/AttributesEncoding/helpers.js.map +1 -1
- package/lib/commonjs/sdk/AttributesEncoding/utils.js +8 -0
- package/lib/commonjs/sdk/AttributesEncoding/utils.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/commonjs/sdk/DdSdkInternal.js +22 -22
- package/lib/commonjs/sdk/DdSdkInternal.js.map +1 -1
- package/lib/commonjs/sdk/EventMappers/EventMapper.js +2 -2
- package/lib/commonjs/sdk/EventMappers/EventMapper.js.map +1 -1
- package/lib/commonjs/utils/time-provider/TimeProvider.js +4 -1
- package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/DdSdkReactNative.js +15 -15
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/rum/DdRum.js +2 -2
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js +3 -3
- package/lib/module/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js +2 -2
- package/lib/module/sdk/AttributesEncoding/defaultEncoders.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/helpers.js +4 -4
- package/lib/module/sdk/AttributesEncoding/helpers.js.map +1 -1
- package/lib/module/sdk/AttributesEncoding/utils.js +7 -0
- package/lib/module/sdk/AttributesEncoding/utils.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +2 -2
- package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
- package/lib/module/sdk/DdSdkInternal.js +21 -22
- package/lib/module/sdk/DdSdkInternal.js.map +1 -1
- package/lib/module/sdk/EventMappers/EventMapper.js +2 -2
- package/lib/module/sdk/EventMappers/EventMapper.js.map +1 -1
- package/lib/module/utils/time-provider/TimeProvider.js +4 -1
- package/lib/module/utils/time-provider/TimeProvider.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/sdk/AttributesEncoding/defaultEncoders.d.ts.map +1 -1
- package/lib/typescript/sdk/AttributesEncoding/utils.d.ts +1 -0
- package/lib/typescript/sdk/AttributesEncoding/utils.d.ts.map +1 -1
- package/lib/typescript/sdk/DdSdkInternal.d.ts +1 -8
- package/lib/typescript/sdk/DdSdkInternal.d.ts.map +1 -1
- package/lib/typescript/utils/time-provider/TimeProvider.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +15 -15
- package/src/__tests__/DdSdkReactNative.test.tsx +139 -19
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +3 -3
- package/src/rum/DdRum.ts +2 -2
- package/src/rum/__tests__/DdRum.test.ts +4 -4
- package/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.tsx +3 -3
- package/src/sdk/AttributesEncoding/__tests__/attributesEncoding.test.ts +25 -0
- package/src/sdk/AttributesEncoding/defaultEncoders.ts +6 -2
- package/src/sdk/AttributesEncoding/helpers.ts +6 -6
- package/src/sdk/AttributesEncoding/utils.ts +8 -0
- package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +2 -2
- package/src/sdk/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +5 -5
- package/src/sdk/DdSdkInternal.ts +23 -30
- package/src/sdk/EventMappers/EventMapper.ts +2 -2
- package/src/sdk/EventMappers/__tests__/EventMapper.test.ts +2 -2
- package/src/utils/__tests__/TimeProvider.test.tsx +49 -0
- package/src/utils/time-provider/TimeProvider.tsx +10 -1
- package/src/version.ts +1 -1
|
@@ -10,7 +10,7 @@ import { AccountInfoSingleton } from '../AccountInfoSingleton/AccountInfoSinglet
|
|
|
10
10
|
import type { AccountInfo } from '../AccountInfoSingleton/types';
|
|
11
11
|
import { AttributesSingleton } from '../AttributesSingleton/AttributesSingleton';
|
|
12
12
|
import type { Attributes } from '../AttributesSingleton/types';
|
|
13
|
-
import {
|
|
13
|
+
import { DdSdk } from '../DdSdk';
|
|
14
14
|
import { UserInfoSingleton } from '../UserInfoSingleton/UserInfoSingleton';
|
|
15
15
|
import type { UserInfo } from '../UserInfoSingleton/types';
|
|
16
16
|
|
|
@@ -92,7 +92,7 @@ export class EventMapper<RawEvent, MapperEvent, NativeEvent> {
|
|
|
92
92
|
)}: ${error}`,
|
|
93
93
|
SdkVerbosity.WARN
|
|
94
94
|
);
|
|
95
|
-
|
|
95
|
+
DdSdk.telemetryDebug('Error while running the event mapper');
|
|
96
96
|
return this.formatMapperEventForNative(backupEvent, backupEvent);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import NativeDdSdkSpec from '../../../specs/NativeDdSdk';
|
|
8
8
|
import { EventMapper } from '../EventMapper';
|
|
9
9
|
|
|
10
10
|
describe('EventMapper', () => {
|
|
@@ -26,7 +26,7 @@ describe('EventMapper', () => {
|
|
|
26
26
|
).toEqual({
|
|
27
27
|
someData: 'some data'
|
|
28
28
|
});
|
|
29
|
-
expect(
|
|
29
|
+
expect(NativeDdSdkSpec.telemetryDebug).toHaveBeenCalledWith(
|
|
30
30
|
'Error while running the event mapper'
|
|
31
31
|
);
|
|
32
32
|
});
|
|
@@ -63,6 +63,55 @@ it('M use unix time W reactNative time unavailable', () => {
|
|
|
63
63
|
expect(now).toBe(1000);
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
+
it('M keep the offset W unix time drifts within the tolerance', () => {
|
|
67
|
+
// GIVEN
|
|
68
|
+
const timeProvider = new MockTimeProvider(1000, 100);
|
|
69
|
+
timeProvider.now();
|
|
70
|
+
|
|
71
|
+
// WHEN
|
|
72
|
+
timeProvider.unixMockedTime = 2000 + 999;
|
|
73
|
+
timeProvider.reactNativeMockedTime = 1100.5;
|
|
74
|
+
const now = timeProvider.now();
|
|
75
|
+
|
|
76
|
+
// THEN
|
|
77
|
+
expect(now).toBe(2000.5);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('M re-sync the offset W unix time moves forward beyond the tolerance', () => {
|
|
81
|
+
// GIVEN
|
|
82
|
+
const timeProvider = new MockTimeProvider(1000, 100);
|
|
83
|
+
timeProvider.now();
|
|
84
|
+
|
|
85
|
+
// WHEN
|
|
86
|
+
const clockChangeMs = 20 * 60 * 1000;
|
|
87
|
+
timeProvider.unixMockedTime = 2000 + clockChangeMs;
|
|
88
|
+
timeProvider.reactNativeMockedTime = 1100;
|
|
89
|
+
const now = timeProvider.now();
|
|
90
|
+
|
|
91
|
+
timeProvider.unixMockedTime = 2010 + clockChangeMs;
|
|
92
|
+
timeProvider.reactNativeMockedTime = 1110.5;
|
|
93
|
+
const nextNow = timeProvider.now();
|
|
94
|
+
|
|
95
|
+
// THEN
|
|
96
|
+
expect(now).toBe(2000 + clockChangeMs);
|
|
97
|
+
expect(nextNow).toBe(2010.5 + clockChangeMs);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('M re-sync the offset W unix time moves backward beyond the tolerance', () => {
|
|
101
|
+
// GIVEN
|
|
102
|
+
const timeProvider = new MockTimeProvider(1_000_000_000, 100);
|
|
103
|
+
timeProvider.now();
|
|
104
|
+
|
|
105
|
+
// WHEN
|
|
106
|
+
const clockChangeMs = -20 * 60 * 1000;
|
|
107
|
+
timeProvider.unixMockedTime = 1_000_001_000 + clockChangeMs;
|
|
108
|
+
timeProvider.reactNativeMockedTime = 1100;
|
|
109
|
+
const now = timeProvider.now();
|
|
110
|
+
|
|
111
|
+
// THEN
|
|
112
|
+
expect(now).toBe(1_000_001_000 + clockChangeMs);
|
|
113
|
+
});
|
|
114
|
+
|
|
66
115
|
it('M ignore performance W global.performance unavailable', () => {
|
|
67
116
|
// GIVEN
|
|
68
117
|
// @ts-expect-error performance is not supposed to be null, but we treat it as such for testing purposes
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
const MAX_DRIFT_MS = 1000;
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* A Timestamp structure holding the
|
|
9
11
|
*/
|
|
@@ -37,7 +39,14 @@ export abstract class TimeProvider {
|
|
|
37
39
|
now(): number {
|
|
38
40
|
const timestamp = this.getTimestamp();
|
|
39
41
|
|
|
40
|
-
if (
|
|
42
|
+
if (
|
|
43
|
+
timestamp.reactNative != null &&
|
|
44
|
+
(this.baseOffset === 0 ||
|
|
45
|
+
Math.abs(
|
|
46
|
+
timestamp.unix - (this.baseOffset + timestamp.reactNative)
|
|
47
|
+
) > MAX_DRIFT_MS)
|
|
48
|
+
) {
|
|
49
|
+
// sync the offset on first use, or when the device clock changed since the last sync
|
|
41
50
|
this.baseOffset = timestamp.unix - timestamp.reactNative;
|
|
42
51
|
}
|
|
43
52
|
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '3.
|
|
2
|
+
export const version = '3.9.0';
|