@datadog/mobile-react-native 1.0.0-rc5 → 1.0.0-rc8
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/DatadogSDKReactNative.podspec +1 -1
- package/README.md +48 -17
- package/android/build.gradle +1 -1
- package/android/gradle.properties +4 -4
- package/ios/Sources/DdSdk.swift +6 -3
- package/lib/commonjs/DdSdkReactNative.js +35 -31
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +20 -7
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +10 -5
- package/lib/commonjs/InternalLog.js.map +1 -1
- package/lib/commonjs/ProxyConfiguration.js.map +1 -1
- package/lib/commonjs/SdkVerbosity.js.map +1 -1
- package/lib/commonjs/TimeProvider.js +72 -0
- package/lib/commonjs/TimeProvider.js.map +1 -0
- package/lib/commonjs/Timer.js +10 -23
- package/lib/commonjs/Timer.js.map +1 -1
- package/lib/commonjs/TrackingConsent.js.map +1 -1
- package/lib/commonjs/foundation.js +19 -54
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +27 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +16 -11
- package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +19 -23
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +118 -42
- package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -19
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -4
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js +1 -1
- package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js +34 -0
- package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
- package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/URLHostParser.js +33 -0
- package/lib/commonjs/rum/instrumentation/URLHostParser.js.map +1 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/DdSdkReactNative.js +33 -29
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +21 -8
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/InternalLog.js +11 -5
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/ProxyConfiguration.js.map +1 -1
- package/lib/module/SdkVerbosity.js.map +1 -1
- package/lib/module/TimeProvider.js +63 -0
- package/lib/module/TimeProvider.js.map +1 -0
- package/lib/module/Timer.js +14 -23
- package/lib/module/Timer.js.map +1 -1
- package/lib/module/TrackingConsent.js.map +1 -1
- package/lib/module/foundation.js +16 -39
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +4 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js +12 -10
- package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +19 -23
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js +113 -39
- package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +44 -17
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumXhr.js +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js +1 -1
- package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js +25 -0
- package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
- package/lib/module/rum/instrumentation/TraceIdentifier.js.map +1 -1
- package/lib/module/rum/instrumentation/URLHostParser.js +24 -0
- package/lib/module/rum/instrumentation/URLHostParser.js.map +1 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/DdSdkReactNative.d.ts +6 -6
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -3
- package/lib/typescript/InternalLog.d.ts +5 -0
- package/lib/typescript/TimeProvider.d.ts +20 -0
- package/lib/typescript/Timer.d.ts +3 -2
- package/lib/typescript/index.d.ts +4 -3
- package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +2 -2
- package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +19 -9
- package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
- package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +13 -3
- package/lib/typescript/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
- package/lib/typescript/rum/instrumentation/URLHostParser.d.ts +6 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +6 -3
- package/src/DdSdkReactNative.tsx +116 -70
- package/src/DdSdkReactNativeConfiguration.tsx +22 -13
- package/src/InternalLog.tsx +18 -16
- package/src/ProxyConfiguration.tsx +5 -5
- package/src/SdkVerbosity.tsx +4 -4
- package/src/TimeProvider.tsx +64 -0
- package/src/Timer.ts +20 -35
- package/src/TrackingConsent.tsx +3 -3
- package/src/__mocks__/InternalLog.tsx +9 -0
- package/src/__tests__/DdRumWrapper.test.tsx +40 -33
- package/src/__tests__/DdSdkReactNative.test.tsx +712 -513
- package/src/__tests__/InternalLog.test.tsx +114 -117
- package/src/__tests__/TimeProvider.test.tsx +75 -0
- package/src/__tests__/Timer.test.ts +148 -57
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +151 -92
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +168 -116
- package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +789 -644
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +239 -85
- package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +31 -0
- package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +13 -15
- package/src/__tests__/rum/instrumentation/URLHostParser.test.ts +40 -0
- package/src/__tests__/rum/instrumentation/__utils__/XMLHttpRequestMock.ts +97 -0
- package/src/foundation.tsx +13 -10
- package/src/index.tsx +15 -4
- package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +49 -44
- package/src/rum/instrumentation/DdRumResourceTracking.tsx +369 -234
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -29
- package/src/rum/instrumentation/DdRumXhr.tsx +21 -11
- package/src/rum/instrumentation/EventsInterceptor.tsx +3 -3
- package/src/rum/instrumentation/NoOpEventsInterceptor.tsx +2 -2
- package/src/rum/instrumentation/ShallowObjectEqualityChecker.ts +24 -0
- package/src/rum/instrumentation/TraceIdentifier.tsx +19 -19
- package/src/rum/instrumentation/URLHostParser.ts +23 -0
- package/src/types.tsx +199 -158
- package/src/version.ts +1 -1
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc8';\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DdSdkReactNativeConfiguration } from
|
|
2
|
-
import type { TrackingConsent } from
|
|
1
|
+
import type { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
|
|
2
|
+
import type { TrackingConsent } from './TrackingConsent';
|
|
3
3
|
/**
|
|
4
4
|
* This class initializes the Datadog SDK, and sets up communication with the server.
|
|
5
5
|
*/
|
|
@@ -18,10 +18,10 @@ export declare class DdSdkReactNative {
|
|
|
18
18
|
private static readonly NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
19
19
|
private static wasInitialized;
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
* Initializes the Datadog SDK.
|
|
22
|
+
* @param configuration the configuration for the SDK library
|
|
23
|
+
* @returns a Promise.
|
|
24
|
+
*/
|
|
25
25
|
static initialize(configuration: DdSdkReactNativeConfiguration): Promise<void>;
|
|
26
26
|
/**
|
|
27
27
|
* Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TrackingConsent } from './TrackingConsent';
|
|
2
|
-
import type { SdkVerbosity } from './SdkVerbosity';
|
|
3
1
|
import type { ProxyConfiguration } from './ProxyConfiguration';
|
|
2
|
+
import type { SdkVerbosity } from './SdkVerbosity';
|
|
3
|
+
import { TrackingConsent } from './TrackingConsent';
|
|
4
4
|
/**
|
|
5
5
|
* The SDK configuration class.
|
|
6
6
|
* It will be used to configure the SDK functionality at initialization.
|
|
@@ -14,12 +14,24 @@ export declare class DdSdkReactNativeConfiguration {
|
|
|
14
14
|
readonly trackErrors: boolean;
|
|
15
15
|
readonly trackingConsent: TrackingConsent;
|
|
16
16
|
nativeCrashReportEnabled: boolean;
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.
|
|
19
|
+
*/
|
|
20
|
+
sampleRate?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Percentage of sampled RUM sessions. Range `0`-`100`.
|
|
23
|
+
*/
|
|
24
|
+
sessionSamplingRate: number;
|
|
25
|
+
/**
|
|
26
|
+
* Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.
|
|
27
|
+
*/
|
|
28
|
+
resourceTracingSamplingRate: number;
|
|
18
29
|
site: string;
|
|
19
30
|
verbosity: SdkVerbosity | undefined;
|
|
20
31
|
nativeViewTracking: boolean;
|
|
21
32
|
proxyConfig?: ProxyConfiguration;
|
|
22
33
|
serviceName?: string;
|
|
34
|
+
firstPartyHosts: string[];
|
|
23
35
|
additionalConfig: {
|
|
24
36
|
[k: string]: any;
|
|
25
37
|
};
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { SdkVerbosity } from './SdkVerbosity';
|
|
2
|
+
/**
|
|
3
|
+
* /!\ DO NOT USE THIS IN YOUR APP /!\\
|
|
4
|
+
*
|
|
5
|
+
* This logger is only for debugging the Datadog SDK.
|
|
6
|
+
*/
|
|
2
7
|
export declare class InternalLog {
|
|
3
8
|
private static levelMap;
|
|
4
9
|
static verbosity: SdkVerbosity | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Timestamp structure holding the
|
|
3
|
+
*/
|
|
4
|
+
export declare type Timestamp = {
|
|
5
|
+
unix: number;
|
|
6
|
+
react_native: number | null;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Simple class providing timestamps in milliseconds.
|
|
10
|
+
* If available, it will use the `performance.now()` method, and will fallback on `Date.now()` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
export declare class TimeProvider {
|
|
13
|
+
private canUsePerformanceNow;
|
|
14
|
+
/** Keeps an average offset between the unix time and the provided timestamp. */
|
|
15
|
+
private baseOffset;
|
|
16
|
+
constructor();
|
|
17
|
+
getTimestamp(): Timestamp;
|
|
18
|
+
now(): number;
|
|
19
|
+
private performanceNow;
|
|
20
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { TimeProvider } from './TimeProvider';
|
|
1
2
|
/**
|
|
2
3
|
* Simple timer which records time ticks. Shouldn't be re-used once stopped.
|
|
3
4
|
* All timestamps/durations returned are in milliseconds.
|
|
4
5
|
*/
|
|
5
6
|
export default class Timer {
|
|
7
|
+
private timeProvider;
|
|
6
8
|
private times;
|
|
9
|
+
constructor(timeProvider?: TimeProvider);
|
|
7
10
|
get startTime(): number;
|
|
8
11
|
get stopTime(): number;
|
|
9
12
|
start(): void;
|
|
@@ -14,7 +17,5 @@ export default class Timer {
|
|
|
14
17
|
timeAt(label: string): number;
|
|
15
18
|
reset(): void;
|
|
16
19
|
private durationBetweenTicks;
|
|
17
|
-
private performanceNow;
|
|
18
|
-
private canUsePerformanceNow;
|
|
19
20
|
private checkLabelExists;
|
|
20
21
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
2
1
|
import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
|
|
3
2
|
import { DdSdkReactNative } from './DdSdkReactNative';
|
|
3
|
+
import { InternalLog } from './InternalLog';
|
|
4
4
|
import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
|
|
5
|
-
import { TrackingConsent } from './TrackingConsent';
|
|
6
5
|
import { SdkVerbosity } from './SdkVerbosity';
|
|
7
|
-
|
|
6
|
+
import { TrackingConsent } from './TrackingConsent';
|
|
7
|
+
import { DdLogs, DdTrace, DdRum } from './foundation';
|
|
8
|
+
export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type EventsInterceptor from './EventsInterceptor';
|
|
2
2
|
export declare const UNKNOWN_TARGET_NAME = "unknown_target";
|
|
3
3
|
export declare class DdEventsInterceptor implements EventsInterceptor {
|
|
4
|
+
static ACTION_EVENT_DROPPED_WARN_MESSAGE: string;
|
|
4
5
|
private debouncingStartedTimestamp;
|
|
5
6
|
interceptOnPress(...args: any[]): void;
|
|
6
7
|
private handleTargetEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
3
|
-
*/
|
|
2
|
+
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
3
|
+
*/
|
|
4
4
|
export declare class DdRumErrorTracking {
|
|
5
5
|
private static isTracking;
|
|
6
6
|
private static isInDefaultErrorHandler;
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
/// <reference types="react-native" />
|
|
2
|
+
import type { DdRumResourceTracingAttributes } from './DdRumXhr';
|
|
2
3
|
export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
|
|
3
4
|
export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
|
|
4
5
|
export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
|
|
5
6
|
export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
|
|
6
|
-
export declare const SAMPLED_HEADER_KEY = "x-datadog-sampled";
|
|
7
7
|
export declare const ORIGIN_RUM = "rum";
|
|
8
|
+
export declare const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
|
|
8
9
|
export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
|
|
9
10
|
/**
|
|
10
|
-
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
11
|
-
*/
|
|
11
|
+
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
12
|
+
*/
|
|
12
13
|
export declare class DdRumResourceTracking {
|
|
13
14
|
private static isTracking;
|
|
15
|
+
private static tracingSamplingRate;
|
|
16
|
+
private static firstPartyHostsRegex;
|
|
14
17
|
private static originalXhrOpen;
|
|
15
18
|
private static originalXhrSend;
|
|
16
19
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
static startTracking(
|
|
20
|
+
* Starts tracking resources and sends a RUM Resource event every time a network request is detected.
|
|
21
|
+
*/
|
|
22
|
+
static startTracking({ tracingSamplingRate, firstPartyHosts }: {
|
|
23
|
+
tracingSamplingRate: number;
|
|
24
|
+
firstPartyHosts: string[];
|
|
25
|
+
}): void;
|
|
20
26
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
static startTrackingInternal(xhrType:
|
|
27
|
+
* Starts tracking resources and sends a RUM Resource event every time a fetch or XHR call is detected.
|
|
28
|
+
*/
|
|
29
|
+
static startTrackingInternal(xhrType: typeof XMLHttpRequest, { tracingSamplingRate, firstPartyHosts }: {
|
|
30
|
+
tracingSamplingRate: number;
|
|
31
|
+
firstPartyHosts: string[];
|
|
32
|
+
}): void;
|
|
24
33
|
static stopTracking(): void;
|
|
34
|
+
static getTracingAttributes(url: string): DdRumResourceTracingAttributes;
|
|
25
35
|
static proxyXhr(xhrType: any): void;
|
|
26
36
|
private static proxyOpen;
|
|
27
37
|
private static proxySend;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Provides RUM auto-instrumentation feature to track user interaction as RUM events.
|
|
3
|
-
* For now we are only covering the "onPress" events.
|
|
4
|
-
*/
|
|
2
|
+
* Provides RUM auto-instrumentation feature to track user interaction as RUM events.
|
|
3
|
+
* For now we are only covering the "onPress" events.
|
|
4
|
+
*/
|
|
5
5
|
export declare class DdRumUserInteractionTracking {
|
|
6
6
|
private static isTracking;
|
|
7
7
|
private static eventsInterceptor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react-native" />
|
|
2
|
-
import type Timer from
|
|
2
|
+
import type Timer from '../../Timer';
|
|
3
3
|
export interface DdRumXhr extends XMLHttpRequest {
|
|
4
4
|
_datadog_xhr: DdRumXhrContext;
|
|
5
5
|
}
|
|
@@ -8,6 +8,16 @@ export interface DdRumXhrContext {
|
|
|
8
8
|
url: string;
|
|
9
9
|
reported: boolean;
|
|
10
10
|
timer: Timer;
|
|
11
|
-
|
|
12
|
-
traceId: string;
|
|
11
|
+
tracingAttributes: DdRumResourceTracingAttributes;
|
|
13
12
|
}
|
|
13
|
+
export declare type DdRumResourceTracingAttributes = {
|
|
14
|
+
tracingStrategy: 'KEEP';
|
|
15
|
+
traceId: string;
|
|
16
|
+
spanId: string;
|
|
17
|
+
samplingPriorityHeader: '1';
|
|
18
|
+
} | {
|
|
19
|
+
tracingStrategy: 'DISCARD';
|
|
20
|
+
traceId?: void;
|
|
21
|
+
spanId?: void;
|
|
22
|
+
samplingPriorityHeader: '0';
|
|
23
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.0.0-
|
|
1
|
+
export declare const version = "1.0.0-rc8";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc8",
|
|
4
4
|
"description": "A client-side React Native module to interact with Datadog",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"datadog",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"types": "lib/typescript/index.d.ts",
|
|
32
32
|
"react-native": "src/index",
|
|
33
|
-
"source": "src
|
|
33
|
+
"source": "src",
|
|
34
34
|
"module": "lib/module/index",
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
@@ -44,6 +44,9 @@
|
|
|
44
44
|
"react": ">=16.13.1",
|
|
45
45
|
"react-native": ">=0.63.4 <1.0"
|
|
46
46
|
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@testing-library/react-native": "7.0.2"
|
|
49
|
+
},
|
|
47
50
|
"jest": {
|
|
48
51
|
"preset": "react-native",
|
|
49
52
|
"modulePathIgnorePatterns": [
|
|
@@ -68,5 +71,5 @@
|
|
|
68
71
|
]
|
|
69
72
|
]
|
|
70
73
|
},
|
|
71
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "67456f90ac95007f8f99beb065ccbf6ec9a6f478"
|
|
72
75
|
}
|
package/src/DdSdkReactNative.tsx
CHANGED
|
@@ -4,87 +4,114 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type {DdSdkReactNativeConfiguration} from
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
7
|
+
import type { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
|
|
8
|
+
import { InternalLog } from './InternalLog';
|
|
9
|
+
import { ProxyType } from './ProxyConfiguration';
|
|
10
|
+
import { SdkVerbosity } from './SdkVerbosity';
|
|
11
|
+
import type { TrackingConsent } from './TrackingConsent';
|
|
12
|
+
import { DdSdk } from './foundation';
|
|
13
|
+
import { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';
|
|
14
|
+
import { DdRumResourceTracking } from './rum/instrumentation/DdRumResourceTracking';
|
|
15
|
+
import { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';
|
|
16
|
+
import { DdSdkConfiguration } from './types';
|
|
17
|
+
import { version as sdkVersion } from './version';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* This class initializes the Datadog SDK, and sets up communication with the server.
|
|
21
21
|
*/
|
|
22
22
|
export class DdSdkReactNative {
|
|
23
|
-
|
|
24
|
-
private static readonly
|
|
25
|
-
private static readonly
|
|
26
|
-
private static readonly
|
|
27
|
-
private static readonly
|
|
28
|
-
|
|
23
|
+
private static readonly DD_SOURCE_KEY = '_dd.source';
|
|
24
|
+
private static readonly DD_SDK_VERSION = '_dd.sdk_version';
|
|
25
|
+
private static readonly DD_SERVICE_NAME = '_dd.service_name';
|
|
26
|
+
private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';
|
|
27
|
+
private static readonly DD_NATIVE_VIEW_TRACKING_KEY =
|
|
28
|
+
'_dd.native_view_tracking';
|
|
29
29
|
|
|
30
30
|
// Proxy
|
|
31
|
-
private static readonly DD_PROXY_TYPE_KEY =
|
|
32
|
-
private static readonly DD_PROXY_ADDRESS_KEY =
|
|
33
|
-
private static readonly DD_PROXY_PORT_KEY =
|
|
34
|
-
private static readonly DD_PROXY_USERNAME_KEY =
|
|
35
|
-
private static readonly DD_PROXY_PASSWORD_KEY =
|
|
36
|
-
|
|
37
|
-
private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY = "_dd.long_task.threshold"
|
|
38
|
-
private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200
|
|
31
|
+
private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';
|
|
32
|
+
private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';
|
|
33
|
+
private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';
|
|
34
|
+
private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';
|
|
35
|
+
private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';
|
|
39
36
|
|
|
37
|
+
private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =
|
|
38
|
+
'_dd.long_task.threshold';
|
|
39
|
+
private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;
|
|
40
40
|
|
|
41
|
-
private static wasInitialized = false
|
|
41
|
+
private static wasInitialized = false;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
static initialize(
|
|
44
|
+
* Initializes the Datadog SDK.
|
|
45
|
+
* @param configuration the configuration for the SDK library
|
|
46
|
+
* @returns a Promise.
|
|
47
|
+
*/
|
|
48
|
+
static initialize(
|
|
49
|
+
configuration: DdSdkReactNativeConfiguration
|
|
50
|
+
): Promise<void> {
|
|
49
51
|
return new Promise<void>((resolve, reject) => {
|
|
50
52
|
if (DdSdkReactNative.wasInitialized) {
|
|
51
|
-
InternalLog.log(
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
InternalLog.log(
|
|
54
|
+
"Can't initialize Datadog, SDK was already initialized",
|
|
55
|
+
SdkVerbosity.WARN
|
|
56
|
+
);
|
|
57
|
+
resolve();
|
|
58
|
+
return;
|
|
54
59
|
}
|
|
55
60
|
|
|
56
|
-
InternalLog.verbosity = configuration.verbosity
|
|
57
|
-
|
|
58
|
-
configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =
|
|
59
|
-
|
|
60
|
-
configuration.additionalConfig[
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
InternalLog.verbosity = configuration.verbosity;
|
|
62
|
+
|
|
63
|
+
configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =
|
|
64
|
+
'react-native';
|
|
65
|
+
configuration.additionalConfig[
|
|
66
|
+
DdSdkReactNative.DD_SDK_VERSION
|
|
67
|
+
] = sdkVersion;
|
|
68
|
+
configuration.additionalConfig[
|
|
69
|
+
DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY
|
|
70
|
+
] = configuration.nativeViewTracking;
|
|
71
|
+
if (configuration.verbosity) {
|
|
72
|
+
configuration.additionalConfig[
|
|
73
|
+
DdSdkReactNative.DD_SDK_VERBOSITY_KEY
|
|
74
|
+
] = configuration.verbosity;
|
|
63
75
|
}
|
|
64
76
|
|
|
65
77
|
if (configuration.proxyConfig) {
|
|
66
78
|
const additionalConfig = configuration.additionalConfig;
|
|
67
79
|
const proxyConfig = configuration.proxyConfig;
|
|
68
80
|
|
|
69
|
-
additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =
|
|
70
|
-
|
|
71
|
-
additionalConfig[DdSdkReactNative.
|
|
81
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =
|
|
82
|
+
proxyConfig.type;
|
|
83
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =
|
|
84
|
+
proxyConfig.address;
|
|
85
|
+
additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =
|
|
86
|
+
proxyConfig.port;
|
|
72
87
|
if (proxyConfig.username && proxyConfig.password) {
|
|
73
|
-
if (proxyConfig.type
|
|
74
|
-
console.warn(
|
|
88
|
+
if (proxyConfig.type === ProxyType.SOCKS) {
|
|
89
|
+
console.warn(
|
|
90
|
+
"SOCKS proxy configuration doesn't support Basic authentication."
|
|
91
|
+
);
|
|
75
92
|
} else {
|
|
76
|
-
additionalConfig[
|
|
77
|
-
|
|
93
|
+
additionalConfig[
|
|
94
|
+
DdSdkReactNative.DD_PROXY_USERNAME_KEY
|
|
95
|
+
] = proxyConfig.username;
|
|
96
|
+
additionalConfig[
|
|
97
|
+
DdSdkReactNative.DD_PROXY_PASSWORD_KEY
|
|
98
|
+
] = proxyConfig.password;
|
|
78
99
|
}
|
|
79
100
|
}
|
|
80
101
|
}
|
|
81
102
|
|
|
82
103
|
if (configuration.serviceName) {
|
|
83
|
-
configuration.additionalConfig[
|
|
104
|
+
configuration.additionalConfig[
|
|
105
|
+
DdSdkReactNative.DD_SERVICE_NAME
|
|
106
|
+
] = configuration.serviceName;
|
|
84
107
|
}
|
|
85
108
|
|
|
86
|
-
configuration.additionalConfig[
|
|
87
|
-
|
|
109
|
+
configuration.additionalConfig[
|
|
110
|
+
DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY
|
|
111
|
+
] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
|
|
112
|
+
|
|
113
|
+
configuration.additionalConfig['_dd.first_party_hosts'] =
|
|
114
|
+
configuration.firstPartyHosts;
|
|
88
115
|
|
|
89
116
|
DdSdk.initialize(
|
|
90
117
|
new DdSdkConfiguration(
|
|
@@ -92,20 +119,28 @@ export class DdSdkReactNative {
|
|
|
92
119
|
configuration.env,
|
|
93
120
|
configuration.applicationId,
|
|
94
121
|
configuration.nativeCrashReportEnabled,
|
|
95
|
-
configuration.sampleRate
|
|
122
|
+
configuration.sampleRate === undefined
|
|
123
|
+
? configuration.sessionSamplingRate
|
|
124
|
+
: configuration.sampleRate,
|
|
96
125
|
configuration.site,
|
|
97
126
|
configuration.trackingConsent,
|
|
98
127
|
configuration.additionalConfig
|
|
99
128
|
)
|
|
100
|
-
).then(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
129
|
+
).then(
|
|
130
|
+
() => {
|
|
131
|
+
InternalLog.log(
|
|
132
|
+
'Datadog SDK was initialized',
|
|
133
|
+
SdkVerbosity.INFO
|
|
134
|
+
);
|
|
135
|
+
DdSdkReactNative.enableFeatures(configuration);
|
|
136
|
+
DdSdkReactNative.wasInitialized = true;
|
|
137
|
+
resolve();
|
|
138
|
+
},
|
|
139
|
+
rejection => {
|
|
140
|
+
reject(rejection);
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
});
|
|
109
144
|
}
|
|
110
145
|
|
|
111
146
|
/**
|
|
@@ -115,8 +150,11 @@ export class DdSdkReactNative {
|
|
|
115
150
|
*/
|
|
116
151
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
117
152
|
static setAttributes(attributes: object): Promise<void> {
|
|
118
|
-
InternalLog.log(
|
|
119
|
-
|
|
153
|
+
InternalLog.log(
|
|
154
|
+
`Setting attributes ${JSON.stringify(attributes)}`,
|
|
155
|
+
SdkVerbosity.DEBUG
|
|
156
|
+
);
|
|
157
|
+
return DdSdk.setAttributes(attributes);
|
|
120
158
|
}
|
|
121
159
|
|
|
122
160
|
/**
|
|
@@ -126,8 +164,11 @@ export class DdSdkReactNative {
|
|
|
126
164
|
*/
|
|
127
165
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
128
166
|
static setUser(user: object): Promise<void> {
|
|
129
|
-
InternalLog.log(
|
|
130
|
-
|
|
167
|
+
InternalLog.log(
|
|
168
|
+
`Setting user ${JSON.stringify(user)}`,
|
|
169
|
+
SdkVerbosity.DEBUG
|
|
170
|
+
);
|
|
171
|
+
return DdSdk.setUser(user);
|
|
131
172
|
}
|
|
132
173
|
|
|
133
174
|
/**
|
|
@@ -136,21 +177,26 @@ export class DdSdkReactNative {
|
|
|
136
177
|
* @returns a Promise.
|
|
137
178
|
*/
|
|
138
179
|
static setTrackingConsent(consent: TrackingConsent): Promise<void> {
|
|
139
|
-
InternalLog.log(
|
|
140
|
-
return DdSdk.setTrackingConsent(consent)
|
|
180
|
+
InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);
|
|
181
|
+
return DdSdk.setTrackingConsent(consent);
|
|
141
182
|
}
|
|
142
183
|
|
|
143
|
-
private static enableFeatures(
|
|
184
|
+
private static enableFeatures(
|
|
185
|
+
configuration: DdSdkReactNativeConfiguration
|
|
186
|
+
) {
|
|
144
187
|
if (configuration.trackInteractions) {
|
|
145
188
|
DdRumUserInteractionTracking.startTracking();
|
|
146
189
|
}
|
|
147
190
|
|
|
148
191
|
if (configuration.trackResources) {
|
|
149
|
-
DdRumResourceTracking.startTracking(
|
|
192
|
+
DdRumResourceTracking.startTracking({
|
|
193
|
+
tracingSamplingRate: configuration.resourceTracingSamplingRate,
|
|
194
|
+
firstPartyHosts: configuration.firstPartyHosts
|
|
195
|
+
});
|
|
150
196
|
}
|
|
151
197
|
|
|
152
198
|
if (configuration.trackErrors) {
|
|
153
199
|
DdRumErrorTracking.startTracking();
|
|
154
200
|
}
|
|
155
201
|
}
|
|
156
|
-
}
|
|
202
|
+
}
|
|
@@ -4,25 +4,36 @@
|
|
|
4
4
|
* Copyright 2016-Present Datadog, Inc.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { TrackingConsent } from './TrackingConsent'
|
|
8
|
-
import type { SdkVerbosity } from './SdkVerbosity'
|
|
9
7
|
import type { ProxyConfiguration } from './ProxyConfiguration';
|
|
8
|
+
import type { SdkVerbosity } from './SdkVerbosity';
|
|
9
|
+
import { TrackingConsent } from './TrackingConsent';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The SDK configuration class.
|
|
13
13
|
* It will be used to configure the SDK functionality at initialization.
|
|
14
14
|
*/
|
|
15
15
|
export class DdSdkReactNativeConfiguration {
|
|
16
|
-
|
|
17
16
|
public nativeCrashReportEnabled: boolean = false;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
public
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.
|
|
19
|
+
*/
|
|
20
|
+
public sampleRate?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Percentage of sampled RUM sessions. Range `0`-`100`.
|
|
23
|
+
*/
|
|
24
|
+
public sessionSamplingRate: number = 100.0;
|
|
25
|
+
/**
|
|
26
|
+
* Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.
|
|
27
|
+
*/
|
|
28
|
+
public resourceTracingSamplingRate: number = 20.0;
|
|
29
|
+
public site: string = 'US';
|
|
30
|
+
public verbosity: SdkVerbosity | undefined = undefined;
|
|
31
|
+
public nativeViewTracking: boolean = false;
|
|
32
|
+
public proxyConfig?: ProxyConfiguration = undefined;
|
|
33
|
+
public serviceName?: string = undefined;
|
|
34
|
+
public firstPartyHosts: string[] = [];
|
|
24
35
|
|
|
25
|
-
public additionalConfig: {[k: string]: any} = {};
|
|
36
|
+
public additionalConfig: { [k: string]: any } = {};
|
|
26
37
|
|
|
27
38
|
constructor(
|
|
28
39
|
readonly clientToken: string,
|
|
@@ -32,7 +43,5 @@ export class DdSdkReactNativeConfiguration {
|
|
|
32
43
|
readonly trackResources: boolean = false,
|
|
33
44
|
readonly trackErrors: boolean = false,
|
|
34
45
|
readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED
|
|
35
|
-
) {
|
|
36
|
-
|
|
37
|
-
}
|
|
46
|
+
) {}
|
|
38
47
|
}
|