@datadog/mobile-react-native 3.7.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/DdFlagsImplementation.swift +3 -4
- package/ios/Sources/DdLogsImplementation.swift +8 -8
- package/ios/Sources/DdRumImplementation.swift +25 -25
- package/ios/Sources/DdSdkImplementation.swift +20 -21
- package/ios/Sources/DdTraceImplementation.swift +2 -2
- package/ios/Sources/RCTPromiseTypes.swift +18 -0
- 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/flags/internal.js +9 -1
- package/lib/commonjs/flags/internal.js.map +1 -1
- package/lib/commonjs/flags/rumIntegration.js +104 -0
- package/lib/commonjs/flags/rumIntegration.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.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/flags/internal.js +9 -1
- package/lib/module/flags/internal.js.map +1 -1
- package/lib/module/flags/rumIntegration.js +97 -0
- package/lib/module/flags/rumIntegration.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.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/flags/internal.d.ts.map +1 -1
- package/lib/typescript/flags/rumIntegration.d.ts +14 -0
- package/lib/typescript/flags/rumIntegration.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -1
- package/lib/typescript/index.d.ts.map +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/flags/__tests__/internal.test.ts +39 -0
- package/src/flags/__tests__/rumIntegration.test.ts +493 -0
- package/src/flags/internal.ts +12 -1
- package/src/flags/rumIntegration.ts +140 -0
- package/src/index.tsx +3 -1
- 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
|
@@ -11,8 +11,8 @@ import type { GestureResponderEvent } from 'react-native';
|
|
|
11
11
|
import { InternalLog } from '../../InternalLog';
|
|
12
12
|
import { SdkVerbosity } from '../../config/types';
|
|
13
13
|
import { BufferSingleton } from '../../sdk/DatadogProvider/Buffer/BufferSingleton';
|
|
14
|
-
import { NativeDdSdk } from '../../sdk/DdSdkInternal';
|
|
15
14
|
import { GlobalState } from '../../sdk/GlobalState/GlobalState';
|
|
15
|
+
import NativeDdSdkSpec from '../../specs/NativeDdSdk';
|
|
16
16
|
import { ErrorSource } from '../../types';
|
|
17
17
|
import { DdRum } from '../DdRum';
|
|
18
18
|
import type { ActionEventMapper } from '../eventMappers/actionEventMapper';
|
|
@@ -1444,7 +1444,7 @@ describe('DdRum', () => {
|
|
|
1444
1444
|
test('does not call the native SDK when startAction has not been called before and using old API', async () => {
|
|
1445
1445
|
await DdRum.stopAction({ user: 'me' }, 789);
|
|
1446
1446
|
expect(NativeModules.DdRum.stopAction).not.toHaveBeenCalled();
|
|
1447
|
-
expect(
|
|
1447
|
+
expect(NativeDdSdkSpec.telemetryDebug).not.toHaveBeenCalled();
|
|
1448
1448
|
});
|
|
1449
1449
|
|
|
1450
1450
|
test('calls the native SDK when called with old API', async () => {
|
|
@@ -1456,7 +1456,7 @@ describe('DdRum', () => {
|
|
|
1456
1456
|
{ user: 'me' },
|
|
1457
1457
|
789
|
|
1458
1458
|
);
|
|
1459
|
-
expect(
|
|
1459
|
+
expect(NativeDdSdkSpec.telemetryDebug).toHaveBeenCalledWith(
|
|
1460
1460
|
'DDdRum.stopAction called with the old signature'
|
|
1461
1461
|
);
|
|
1462
1462
|
});
|
|
@@ -1470,7 +1470,7 @@ describe('DdRum', () => {
|
|
|
1470
1470
|
{},
|
|
1471
1471
|
456
|
|
1472
1472
|
);
|
|
1473
|
-
expect(
|
|
1473
|
+
expect(NativeDdSdkSpec.telemetryDebug).toHaveBeenCalledWith(
|
|
1474
1474
|
'DDdRum.stopAction called with the old signature'
|
|
1475
1475
|
);
|
|
1476
1476
|
});
|
|
@@ -9,7 +9,7 @@ import React from 'react';
|
|
|
9
9
|
import { InternalLog } from '../../../InternalLog';
|
|
10
10
|
import { SdkVerbosity } from '../../../config/types/SdkVerbosity';
|
|
11
11
|
import { getErrorMessage } from '../../../sdk/AttributesEncoding/errorUtils';
|
|
12
|
-
import {
|
|
12
|
+
import { DdSdk } from '../../../sdk/DdSdk';
|
|
13
13
|
import { BABEL_PLUGIN_TELEMETRY } from '../../constants';
|
|
14
14
|
|
|
15
15
|
import { DdBabelInteractionTracking } from './DdBabelInteractionTracking';
|
|
@@ -82,7 +82,7 @@ export class DdRumUserInteractionTracking {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
DdSdk?.sendTelemetryLog(
|
|
86
86
|
BABEL_PLUGIN_TELEMETRY,
|
|
87
87
|
DdBabelInteractionTracking.getTelemetryConfig(),
|
|
88
88
|
{ onlyOnce: true }
|
|
@@ -126,7 +126,7 @@ export class DdRumUserInteractionTracking {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
} catch (e) {
|
|
129
|
-
|
|
129
|
+
DdSdk.telemetryDebug(getErrorMessage(e));
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
const originalMemo = React.memo;
|
|
@@ -41,6 +41,31 @@ describe('encodeAttributes', () => {
|
|
|
41
41
|
expect(warn).toHaveBeenCalled();
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
it('drops a null-prototype object without throwing', () => {
|
|
45
|
+
expect(() =>
|
|
46
|
+
encodeAttributes({ bad: Object.create(null) })
|
|
47
|
+
).not.toThrow();
|
|
48
|
+
expect(warn).toHaveBeenCalled();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('drops a value whose toString throws without throwing', () => {
|
|
52
|
+
const bad = {
|
|
53
|
+
toString() {
|
|
54
|
+
throw new Error('boom');
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
Object.setPrototypeOf(bad, null);
|
|
58
|
+
expect(() => encodeAttributes({ bad })).not.toThrow();
|
|
59
|
+
expect(warn).toHaveBeenCalled();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('drops a null-prototype object nested in an array without throwing', () => {
|
|
63
|
+
expect(() =>
|
|
64
|
+
encodeAttributes({ bad: [Object.create(null)] })
|
|
65
|
+
).not.toThrow();
|
|
66
|
+
expect(warn).toHaveBeenCalled();
|
|
67
|
+
});
|
|
68
|
+
|
|
44
69
|
it('drops unsupported root function', () => {
|
|
45
70
|
const result = encodeAttributes(() => {});
|
|
46
71
|
expect(result).toEqual({});
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from './errorUtils';
|
|
17
17
|
import { encodeAttributesInPlace, sanitizeForJson } from './helpers';
|
|
18
18
|
import type { AttributeEncoder, Encodable } from './types';
|
|
19
|
-
import { warn } from './utils';
|
|
19
|
+
import { safeToString, warn } from './utils';
|
|
20
20
|
|
|
21
21
|
/** Primitives: keep them explicit so the full pipeline is used uniformly. */
|
|
22
22
|
export const stringEncoder: AttributeEncoder<string> = {
|
|
@@ -165,7 +165,11 @@ export const mapEncoder: AttributeEncoder<Map<unknown, unknown>> = {
|
|
|
165
165
|
value: sanitizeForJson(v, allEncoders)
|
|
166
166
|
});
|
|
167
167
|
} catch (err) {
|
|
168
|
-
warn(
|
|
168
|
+
warn(
|
|
169
|
+
`Failed to encode Map key: ${safeToString(
|
|
170
|
+
k
|
|
171
|
+
)}. ERROR: ${safeToString(err)}`
|
|
172
|
+
);
|
|
169
173
|
}
|
|
170
174
|
}
|
|
171
175
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import type { AttributeEncoder, Encodable } from './types';
|
|
8
|
-
import { formatPathForLog, isPlainObject, warn } from './utils';
|
|
8
|
+
import { formatPathForLog, isPlainObject, safeToString, warn } from './utils';
|
|
9
9
|
|
|
10
10
|
const MAX_ATTRIBUTES = 256;
|
|
11
11
|
|
|
@@ -69,7 +69,7 @@ export function encodeAttributesInPlace(
|
|
|
69
69
|
warn(
|
|
70
70
|
`Dropped unsupported value in array at '${formatPathForLog(
|
|
71
71
|
path
|
|
72
|
-
)}': ${
|
|
72
|
+
)}': ${safeToString(v)}`
|
|
73
73
|
);
|
|
74
74
|
return undefined;
|
|
75
75
|
};
|
|
@@ -94,9 +94,9 @@ export function encodeAttributesInPlace(
|
|
|
94
94
|
|
|
95
95
|
// Unsupported
|
|
96
96
|
warn(
|
|
97
|
-
`Dropped unsupported value at '${formatPathForLog(
|
|
98
|
-
|
|
99
|
-
)}`
|
|
97
|
+
`Dropped unsupported value at '${formatPathForLog(
|
|
98
|
+
path
|
|
99
|
+
)}': ${safeToString(value)}`
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -138,7 +138,7 @@ export function applyEncoders(
|
|
|
138
138
|
return enc.encode(value as never);
|
|
139
139
|
}
|
|
140
140
|
} catch (err) {
|
|
141
|
-
warn(`Encoder error: ${
|
|
141
|
+
warn(`Encoder error: ${safeToString(err)}`);
|
|
142
142
|
return undefined;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -11,6 +11,14 @@ export function warn(text: string) {
|
|
|
11
11
|
InternalLog.log(`[ATTRIBUTES] ${text}`, SdkVerbosity.WARN);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export function safeToString(value: unknown): string {
|
|
15
|
+
try {
|
|
16
|
+
return String(value);
|
|
17
|
+
} catch {
|
|
18
|
+
return Object.prototype.toString.call(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
export function isPlainObject(v: unknown): v is Record<string, unknown> {
|
|
15
23
|
return !!v && typeof v === 'object' && (v as any).constructor === Object;
|
|
16
24
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { InternalLog } from '../../../InternalLog';
|
|
8
8
|
import { SdkVerbosity } from '../../../config/types/SdkVerbosity';
|
|
9
9
|
import { getErrorStackTrace } from '../../AttributesEncoding/errorUtils';
|
|
10
|
-
import {
|
|
10
|
+
import { DdSdk } from '../../DdSdk';
|
|
11
11
|
|
|
12
12
|
import { DatadogBuffer } from './DatadogBuffer';
|
|
13
13
|
|
|
@@ -206,7 +206,7 @@ export class BoundedBuffer extends DatadogBuffer {
|
|
|
206
206
|
private drainTelemetry = () => {
|
|
207
207
|
Object.values(this.telemetryBuffer).forEach(
|
|
208
208
|
({ message, stack, kind, occurrences }) => {
|
|
209
|
-
|
|
209
|
+
DdSdk.telemetryError(
|
|
210
210
|
`${message} happened ${occurrences} times.`,
|
|
211
211
|
stack,
|
|
212
212
|
kind
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { InternalLog } from '../../../../InternalLog';
|
|
8
|
-
import
|
|
8
|
+
import NativeDdSdkSpec from '../../../../specs/NativeDdSdk';
|
|
9
9
|
import { BoundedBuffer } from '../BoundedBuffer';
|
|
10
10
|
|
|
11
11
|
describe('BoundedBuffer', () => {
|
|
@@ -126,7 +126,7 @@ describe('BoundedBuffer', () => {
|
|
|
126
126
|
await buffer.drain();
|
|
127
127
|
expect(callbackWithId).toHaveBeenCalledTimes(1);
|
|
128
128
|
expect(callbackWithId).toHaveBeenNthCalledWith(1, 'callbackId1');
|
|
129
|
-
expect(
|
|
129
|
+
expect(NativeDdSdkSpec.telemetryError).toHaveBeenCalledWith(
|
|
130
130
|
'Could not generate enough random numbers happened 2 times.',
|
|
131
131
|
'',
|
|
132
132
|
'RandomIdGenerationError'
|
|
@@ -146,7 +146,7 @@ describe('BoundedBuffer', () => {
|
|
|
146
146
|
|
|
147
147
|
await buffer.drain();
|
|
148
148
|
expect(fakeCallback).toHaveBeenCalledTimes(3);
|
|
149
|
-
expect(
|
|
149
|
+
expect(NativeDdSdkSpec.telemetryError).toHaveBeenCalledWith(
|
|
150
150
|
'Buffer overflow happened 1 times.',
|
|
151
151
|
'',
|
|
152
152
|
'BufferOverflow'
|
|
@@ -171,7 +171,7 @@ describe('BoundedBuffer', () => {
|
|
|
171
171
|
expect(fakeCallback).toHaveBeenCalledTimes(1);
|
|
172
172
|
expect(callbackReturningId).not.toHaveBeenCalled();
|
|
173
173
|
expect(callbackWithId).not.toHaveBeenCalled();
|
|
174
|
-
expect(
|
|
174
|
+
expect(NativeDdSdkSpec.telemetryError).toHaveBeenCalledWith(
|
|
175
175
|
'Buffer overflow happened 2 times.',
|
|
176
176
|
'',
|
|
177
177
|
'BufferOverflow'
|
|
@@ -196,7 +196,7 @@ describe('BoundedBuffer', () => {
|
|
|
196
196
|
expect(fakeCallback).toHaveBeenCalledTimes(1);
|
|
197
197
|
expect(callbackReturningId).toHaveBeenCalledTimes(1);
|
|
198
198
|
expect(callbackWithId).toHaveBeenCalledTimes(1);
|
|
199
|
-
expect(
|
|
199
|
+
expect(NativeDdSdkSpec.telemetryError).not.toHaveBeenCalled();
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
202
|
});
|
package/src/sdk/DdSdkInternal.ts
CHANGED
|
@@ -10,16 +10,11 @@ import type { DdNativeSdkType } from '../nativeModulesTypes';
|
|
|
10
10
|
import type { AttributeEncoder } from './AttributesEncoding/types';
|
|
11
11
|
|
|
12
12
|
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
13
|
-
const
|
|
13
|
+
const NativeDdSdkSpec: DdNativeSdkType = require('../specs/NativeDdSdk')
|
|
14
|
+
.default;
|
|
14
15
|
|
|
15
|
-
export type DdSdkType = {
|
|
16
|
+
export type DdSdkType = DdNativeSdkType & {
|
|
16
17
|
readonly attributeEncoders: AttributeEncoder<any>[];
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Initializes Datadog's features.
|
|
20
|
-
* @param configuration: The configuration to use.
|
|
21
|
-
*/
|
|
22
|
-
initialize(configuration: DdSdkNativeConfiguration): Promise<void>;
|
|
23
18
|
};
|
|
24
19
|
|
|
25
20
|
export class DdSdkWrapper implements DdNativeSdkType {
|
|
@@ -30,49 +25,49 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
30
25
|
|
|
31
26
|
initialize(configuration: DdSdkNativeConfiguration): Promise<void> {
|
|
32
27
|
this._attributeEncoders = [...configuration.attributeEncoders];
|
|
33
|
-
return
|
|
28
|
+
return NativeDdSdkSpec.initialize(configuration);
|
|
34
29
|
}
|
|
35
30
|
|
|
36
31
|
getConstants() {
|
|
37
|
-
return
|
|
32
|
+
return NativeDdSdkSpec.getConstants();
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
setUserInfo(user: object): Promise<object> {
|
|
41
|
-
return
|
|
36
|
+
return NativeDdSdkSpec.setUserInfo(user);
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
clearUserInfo(): Promise<void> {
|
|
45
|
-
return
|
|
40
|
+
return NativeDdSdkSpec.clearUserInfo();
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
addUserExtraInfo(extraInfo: object): Promise<object> {
|
|
49
|
-
return
|
|
44
|
+
return NativeDdSdkSpec.addUserExtraInfo(extraInfo);
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
addAttribute(key: string, value: object): Promise<void> {
|
|
53
|
-
return
|
|
48
|
+
return NativeDdSdkSpec.addAttribute(key, value);
|
|
54
49
|
}
|
|
55
50
|
removeAttribute(key: string): Promise<void> {
|
|
56
|
-
return
|
|
51
|
+
return NativeDdSdkSpec.removeAttribute(key);
|
|
57
52
|
}
|
|
58
53
|
addAttributes(attributes: object): Promise<void> {
|
|
59
|
-
return
|
|
54
|
+
return NativeDdSdkSpec.addAttributes(attributes);
|
|
60
55
|
}
|
|
61
56
|
removeAttributes(keys: string[]): Promise<void> {
|
|
62
|
-
return
|
|
57
|
+
return NativeDdSdkSpec.removeAttributes(keys);
|
|
63
58
|
}
|
|
64
59
|
setAccountInfo(account: object): Promise<object> {
|
|
65
|
-
return
|
|
60
|
+
return NativeDdSdkSpec.setAccountInfo(account);
|
|
66
61
|
}
|
|
67
62
|
clearAccountInfo(): Promise<void> {
|
|
68
|
-
return
|
|
63
|
+
return NativeDdSdkSpec.clearAccountInfo();
|
|
69
64
|
}
|
|
70
65
|
addAccountExtraInfo(extraInfo: object): Promise<object> {
|
|
71
|
-
return
|
|
66
|
+
return NativeDdSdkSpec.addAccountExtraInfo(extraInfo);
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
setTrackingConsent(trackingConsent: string): Promise<void> {
|
|
75
|
-
return
|
|
70
|
+
return NativeDdSdkSpec.setTrackingConsent(trackingConsent);
|
|
76
71
|
}
|
|
77
72
|
|
|
78
73
|
sendTelemetryLog(
|
|
@@ -80,11 +75,11 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
80
75
|
attributes: object,
|
|
81
76
|
config: object
|
|
82
77
|
): Promise<void> {
|
|
83
|
-
return
|
|
78
|
+
return NativeDdSdkSpec.sendTelemetryLog(message, attributes, config);
|
|
84
79
|
}
|
|
85
80
|
|
|
86
81
|
telemetryDebug(message: string): Promise<void> {
|
|
87
|
-
return
|
|
82
|
+
return NativeDdSdkSpec.telemetryDebug(message);
|
|
88
83
|
}
|
|
89
84
|
|
|
90
85
|
telemetryError(
|
|
@@ -92,23 +87,23 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
92
87
|
stack: string,
|
|
93
88
|
kind: string
|
|
94
89
|
): Promise<void> {
|
|
95
|
-
return
|
|
90
|
+
return NativeDdSdkSpec.telemetryError(message, stack, kind);
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
consumeWebviewEvent(message: string): Promise<void> {
|
|
99
|
-
return
|
|
94
|
+
return NativeDdSdkSpec.consumeWebviewEvent(message);
|
|
100
95
|
}
|
|
101
96
|
|
|
102
97
|
clearAllData(): Promise<void> {
|
|
103
|
-
return
|
|
98
|
+
return NativeDdSdkSpec.clearAllData();
|
|
104
99
|
}
|
|
105
100
|
|
|
106
101
|
addListener(eventType: string): void {
|
|
107
|
-
return
|
|
102
|
+
return NativeDdSdkSpec.addListener(eventType);
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
removeListeners(count: number): void {
|
|
111
|
-
return
|
|
106
|
+
return NativeDdSdkSpec.removeListeners(count);
|
|
112
107
|
}
|
|
113
108
|
|
|
114
109
|
_setAttributeEncodersForTesting(
|
|
@@ -117,5 +112,3 @@ export class DdSdkWrapper implements DdNativeSdkType {
|
|
|
117
112
|
this._attributeEncoders = [...attributeEncoders];
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
|
-
|
|
121
|
-
export { NativeDdSdk };
|
|
@@ -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';
|