@datadog/mobile-react-native-apollo-client 2.0.0-rc.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/LICENSE +201 -0
- package/README.md +93 -0
- package/lib/commonjs/DatadogLink.js +44 -0
- package/lib/commonjs/DatadogLink.js.map +1 -0
- package/lib/commonjs/helpers.js +58 -0
- package/lib/commonjs/helpers.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/DatadogLink.js +32 -0
- package/lib/module/DatadogLink.js.map +1 -0
- package/lib/module/helpers.js +44 -0
- package/lib/module/helpers.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +66 -0
- package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +269 -0
- package/lib/typescript/core/src/InternalLog.d.ts +12 -0
- package/lib/typescript/core/src/ProxyConfiguration.d.ts +56 -0
- package/lib/typescript/core/src/SdkVerbosity.d.ts +9 -0
- package/lib/typescript/core/src/TrackingConsent.d.ts +8 -0
- package/lib/typescript/core/src/index.d.ts +13 -0
- package/lib/typescript/core/src/logs/DdLogs.d.ts +22 -0
- package/lib/typescript/core/src/logs/eventMapper.d.ts +11 -0
- package/lib/typescript/core/src/logs/types.d.ts +80 -0
- package/lib/typescript/core/src/nativeModulesTypes.d.ts +92 -0
- package/lib/typescript/core/src/rum/DdRum.d.ts +38 -0
- package/lib/typescript/core/src/rum/eventMappers/actionEventMapper.d.ts +21 -0
- package/lib/typescript/core/src/rum/eventMappers/errorEventMapper.d.ts +21 -0
- package/lib/typescript/core/src/rum/eventMappers/resourceEventMapper.d.ts +24 -0
- package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +16 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +15 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +21 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/EventsInterceptor.d.ts +3 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/NoOpEventsInterceptor.d.ts +4 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +7 -0
- package/lib/typescript/core/src/rum/instrumentation/interactionTracking/getJsxRuntime.d.ts +1 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +16 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +45 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/distributedTracingHeaders.d.ts +21 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +8 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts +4 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts +8 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/internalDevResourceBlocklist.d.ts +6 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/resourceTiming.d.ts +17 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/URLHostParser.d.ts +6 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/XHRProxy.d.ts +20 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/responseSize.d.ts +2 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +13 -0
- package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +27 -0
- package/lib/typescript/core/src/rum/types.d.ts +131 -0
- package/lib/typescript/core/src/sdk/AttributesSingleton/AttributesSingleton.d.ts +12 -0
- package/lib/typescript/core/src/sdk/AttributesSingleton/types.d.ts +3 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
- package/lib/typescript/core/src/sdk/DatadogProvider/DatadogProvider.d.ts +26 -0
- package/lib/typescript/core/src/sdk/DdSdk.d.ts +3 -0
- package/lib/typescript/core/src/sdk/EventMappers/EventMapper.d.ts +24 -0
- package/lib/typescript/core/src/sdk/EventMappers/utils/deepClone.d.ts +10 -0
- package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts +12 -0
- package/lib/typescript/core/src/sdk/UserInfoSingleton/types.d.ts +6 -0
- package/lib/typescript/core/src/specs/NativeDdLogs.d.ts +69 -0
- package/lib/typescript/core/src/specs/NativeDdRum.d.ts +92 -0
- package/lib/typescript/core/src/specs/NativeDdSdk.d.ts +46 -0
- package/lib/typescript/core/src/specs/NativeDdTrace.d.ts +23 -0
- package/lib/typescript/core/src/trace/DdTrace.d.ts +3 -0
- package/lib/typescript/core/src/types.d.ts +81 -0
- package/lib/typescript/core/src/utils/TimeProvider.d.ts +20 -0
- package/lib/typescript/core/src/utils/Timer.d.ts +21 -0
- package/lib/typescript/core/src/utils/errorUtils.d.ts +14 -0
- package/lib/typescript/core/src/utils/jsUtils.d.ts +1 -0
- package/lib/typescript/core/src/utils/longTasksUtils.d.ts +6 -0
- package/lib/typescript/core/src/version.d.ts +1 -0
- package/lib/typescript/react-native-apollo-client/src/DatadogLink.d.ts +4 -0
- package/lib/typescript/react-native-apollo-client/src/helpers.d.ts +7 -0
- package/lib/typescript/react-native-apollo-client/src/index.d.ts +1 -0
- package/package.json +82 -0
- package/src/DatadogLink.ts +46 -0
- package/src/__tests__/__utils__/createCat.json +125 -0
- package/src/__tests__/__utils__/getCountries.json +103 -0
- package/src/__tests__/__utils__/getCountry.json +96 -0
- package/src/__tests__/__utils__/operationMock.ts +32 -0
- package/src/__tests__/helpers.test.ts +65 -0
- package/src/helpers.ts +54 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
|
|
2
|
+
import { EventMapper } from '../../sdk/EventMappers/EventMapper';
|
|
3
|
+
import type { ResourceKind } from '../types';
|
|
4
|
+
declare type RawResource = {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly statusCode: number;
|
|
7
|
+
readonly kind: ResourceKind;
|
|
8
|
+
readonly size: number;
|
|
9
|
+
context: object;
|
|
10
|
+
readonly timestampMs: number;
|
|
11
|
+
resourceContext: XMLHttpRequest | undefined;
|
|
12
|
+
};
|
|
13
|
+
declare type ResourceEvent = RawResource & AdditionalEventDataForMapper;
|
|
14
|
+
declare type NativeResource = {
|
|
15
|
+
key: string;
|
|
16
|
+
statusCode: number;
|
|
17
|
+
kind: ResourceKind;
|
|
18
|
+
size: number;
|
|
19
|
+
context: object;
|
|
20
|
+
timestampMs: number;
|
|
21
|
+
};
|
|
22
|
+
export declare type ResourceEventMapper = (event: ResourceEvent) => ResourceEvent | null;
|
|
23
|
+
export declare const generateResourceEventMapper: (eventMapper: ResourceEventMapper | undefined) => EventMapper<RawResource, ResourceEvent, NativeResource>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DdRumErrorTracking {
|
|
5
|
+
private static isTracking;
|
|
6
|
+
private static isInDefaultErrorHandler;
|
|
7
|
+
private static defaultErrorHandler;
|
|
8
|
+
private static defaultConsoleError;
|
|
9
|
+
/**
|
|
10
|
+
* Starts tracking errors and sends a RUM Error event every time an error is detected.
|
|
11
|
+
*/
|
|
12
|
+
static startTracking(): void;
|
|
13
|
+
static onGlobalError: (error: any, isFatal?: boolean) => void;
|
|
14
|
+
static onConsoleError: (...params: unknown[]) => void;
|
|
15
|
+
private static reportError;
|
|
16
|
+
}
|
package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type EventsInterceptor from './EventsInterceptor';
|
|
2
|
+
export declare const UNKNOWN_TARGET_NAME = "unknown_target";
|
|
3
|
+
export declare class DdEventsInterceptor implements EventsInterceptor {
|
|
4
|
+
static ACTION_EVENT_DROPPED_DEBUG_MESSAGE: string;
|
|
5
|
+
private debouncingStartedTimestamp;
|
|
6
|
+
private actionNameAttribute?;
|
|
7
|
+
constructor({ actionNameAttribute }?: {
|
|
8
|
+
actionNameAttribute?: string;
|
|
9
|
+
});
|
|
10
|
+
interceptOnPress(...args: any[]): void;
|
|
11
|
+
private handleTargetEvent;
|
|
12
|
+
private resolveTargetName;
|
|
13
|
+
private resolveElementTypeName;
|
|
14
|
+
private findClosestActionLabel;
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
*/
|
|
5
|
+
export declare class DdRumUserInteractionTracking {
|
|
6
|
+
private static isTracking;
|
|
7
|
+
private static eventsInterceptor;
|
|
8
|
+
private static originalCreateElement;
|
|
9
|
+
private static originalMemo;
|
|
10
|
+
private static originalJsx;
|
|
11
|
+
private static patchCreateElementFunction;
|
|
12
|
+
/**
|
|
13
|
+
* Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.
|
|
14
|
+
* Please note that we are only considering as valid - for - tracking only the user interactions that have
|
|
15
|
+
* a visible output (either an UI state change or a Resource request)
|
|
16
|
+
*/
|
|
17
|
+
static startTracking({ actionNameAttribute }?: {
|
|
18
|
+
actionNameAttribute?: string;
|
|
19
|
+
}): void;
|
|
20
|
+
static stopTracking(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Does a shallow comparison between 2 objects.
|
|
3
|
+
*
|
|
4
|
+
* In some rare cases, one of the objects can be `undefined` or `null`.
|
|
5
|
+
* This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.
|
|
6
|
+
*/
|
|
7
|
+
export declare const areObjectShallowEqual: (objectA: Record<string, unknown> | undefined | null, objectB: Record<string, unknown> | undefined | null) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getJsxRuntime: () => any;
|
package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FirstPartyHost } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DdRumResourceTracking {
|
|
6
|
+
private static isTracking;
|
|
7
|
+
private static requestProxy;
|
|
8
|
+
/**
|
|
9
|
+
* Starts tracking resources and sends a RUM Resource event every time a network request is detected.
|
|
10
|
+
*/
|
|
11
|
+
static startTracking({ tracingSamplingRate, firstPartyHosts }: {
|
|
12
|
+
tracingSamplingRate: number;
|
|
13
|
+
firstPartyHosts: FirstPartyHost[];
|
|
14
|
+
}): void;
|
|
15
|
+
static stopTracking(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PropagatorType } from '../../../types';
|
|
2
|
+
import type { RegexMap } from '../requestProxy/interfaces/RequestProxy';
|
|
3
|
+
import type { Hostname } from './firstPartyHosts';
|
|
4
|
+
export declare type DdRumResourceTracingAttributes = {
|
|
5
|
+
tracingStrategy: 'KEEP';
|
|
6
|
+
traceId: TraceId;
|
|
7
|
+
spanId: SpanId;
|
|
8
|
+
samplingPriorityHeader: '1' | '0';
|
|
9
|
+
rulePsr: number;
|
|
10
|
+
propagatorTypes: PropagatorType[];
|
|
11
|
+
} | {
|
|
12
|
+
tracingStrategy: 'DISCARD';
|
|
13
|
+
traceId?: void;
|
|
14
|
+
spanId?: void;
|
|
15
|
+
samplingPriorityHeader: '0';
|
|
16
|
+
};
|
|
17
|
+
export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegexMap, tracingSamplingRate }: {
|
|
18
|
+
hostname: Hostname | null;
|
|
19
|
+
firstPartyHostsRegexMap: RegexMap;
|
|
20
|
+
tracingSamplingRate: number;
|
|
21
|
+
}) => DdRumResourceTracingAttributes;
|
|
22
|
+
/**
|
|
23
|
+
* Using branded types will ensure we don't accidentally use
|
|
24
|
+
* traceId for spanId when generating headers.
|
|
25
|
+
*/
|
|
26
|
+
export declare type TraceId = TraceIdentifier & {
|
|
27
|
+
_brand: 'traceId';
|
|
28
|
+
};
|
|
29
|
+
export declare type SpanId = TraceIdentifier & {
|
|
30
|
+
_brand: 'spanId';
|
|
31
|
+
};
|
|
32
|
+
export declare class TraceIdentifier {
|
|
33
|
+
private low;
|
|
34
|
+
private high;
|
|
35
|
+
constructor();
|
|
36
|
+
toString: (radix: number) => string;
|
|
37
|
+
/**
|
|
38
|
+
* This function pads the trace with `0`.
|
|
39
|
+
* It should not be used with a `length` lower than the trace, as we return the full trace in this case.
|
|
40
|
+
* @param radix radix for the trace
|
|
41
|
+
* @param length minimum length
|
|
42
|
+
* @returns padded string
|
|
43
|
+
*/
|
|
44
|
+
toPaddedString: (radix: number, length: number) => string;
|
|
45
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DdRumResourceTracingAttributes } from './distributedTracing';
|
|
2
|
+
export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
|
|
3
|
+
/**
|
|
4
|
+
* Datadog headers
|
|
5
|
+
*/
|
|
6
|
+
export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
|
|
7
|
+
export declare const ORIGIN_RUM = "rum";
|
|
8
|
+
export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
|
|
9
|
+
export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
|
|
10
|
+
/**
|
|
11
|
+
* OTel headers
|
|
12
|
+
*/
|
|
13
|
+
export declare const TRACECONTEXT_HEADER_KEY = "traceparent";
|
|
14
|
+
export declare const B3_HEADER_KEY = "b3";
|
|
15
|
+
export declare const B3_MULTI_TRACE_ID_HEADER_KEY = "X-B3-TraceId";
|
|
16
|
+
export declare const B3_MULTI_SPAN_ID_HEADER_KEY = "X-B3-SpanId";
|
|
17
|
+
export declare const B3_MULTI_SAMPLED_HEADER_KEY = "X-B3-Sampled";
|
|
18
|
+
export declare const getTracingHeaders: (tracingAttributes: DdRumResourceTracingAttributes) => {
|
|
19
|
+
header: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FirstPartyHost, PropagatorType } from '../../../types';
|
|
2
|
+
import type { RegexMap } from '../requestProxy/interfaces/RequestProxy';
|
|
3
|
+
export declare type Hostname = {
|
|
4
|
+
_type: 'Hostname';
|
|
5
|
+
} & string;
|
|
6
|
+
export declare const NO_MATCH_REGEX: RegExp;
|
|
7
|
+
export declare const firstPartyHostsRegexMapBuilder: (firstPartyHosts: FirstPartyHost[]) => RegexMap;
|
|
8
|
+
export declare const getPropagatorsForHost: (hostname: Hostname, firstPartyHostsRegexMap: RegexMap) => PropagatorType[] | null;
|
package/lib/typescript/core/src/rum/instrumentation/resourceTracking/graphql/graphqlHeaders.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const DATADOG_GRAPH_QL_OPERATION_NAME_HEADER: string;
|
|
2
|
+
export declare const DATADOG_GRAPH_QL_VARIABLES_HEADER: string;
|
|
3
|
+
export declare const DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER: string;
|
|
4
|
+
export declare const isDatadogCustomHeader: (header: string) => RegExpMatchArray | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RUMResource } from '../../interfaces/RumResource';
|
|
2
|
+
declare type ResourceMapper = (resource: RUMResource) => RUMResource | null;
|
|
3
|
+
export declare class ResourceReporter {
|
|
4
|
+
private mappers;
|
|
5
|
+
constructor(resourceMappers: ResourceMapper[]);
|
|
6
|
+
reportResource: (resource: RUMResource) => void;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RUMResource } from '../../interfaces/RumResource';
|
|
2
|
+
/**
|
|
3
|
+
* Filters RN symbolicate calls and Expo logs calls that happen only in dev.
|
|
4
|
+
* @param resource RUMResource
|
|
5
|
+
*/
|
|
6
|
+
export declare const filterDevResource: (resource: RUMResource) => RUMResource | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Timing {
|
|
2
|
+
/**
|
|
3
|
+
* Time relative (absolute in case of iOS) to some point, in ns.
|
|
4
|
+
*/
|
|
5
|
+
startTime: number;
|
|
6
|
+
/**
|
|
7
|
+
* Duration in ns.
|
|
8
|
+
*/
|
|
9
|
+
duration: number;
|
|
10
|
+
}
|
|
11
|
+
interface ResourceTimings {
|
|
12
|
+
firstByte: Timing;
|
|
13
|
+
download: Timing;
|
|
14
|
+
fetch: Timing;
|
|
15
|
+
}
|
|
16
|
+
export declare function createTimings(startTime: number, responseStartTime: number, responseEndTime: number): ResourceTimings;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Hostname } from '../../distributedTracing/firstPartyHosts';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the host from an URL.
|
|
4
|
+
* @returns the host (without the port) or null if could not cast the URL as host
|
|
5
|
+
*/
|
|
6
|
+
export declare const URLHostParser: (url: string) => Hostname | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RequestProxyOptions } from '../interfaces/RequestProxy';
|
|
2
|
+
import { RequestProxy } from '../interfaces/RequestProxy';
|
|
3
|
+
import type { ResourceReporter } from './DatadogRumResource/ResourceReporter';
|
|
4
|
+
interface XHRProxyProviders {
|
|
5
|
+
xhrType: typeof XMLHttpRequest;
|
|
6
|
+
resourceReporter: ResourceReporter;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Proxies XMLHTTPRequest to track resources.
|
|
10
|
+
*/
|
|
11
|
+
export declare class XHRProxy extends RequestProxy {
|
|
12
|
+
private providers;
|
|
13
|
+
private static originalXhrOpen;
|
|
14
|
+
private static originalXhrSend;
|
|
15
|
+
private static originalXhrSetRequestHeader;
|
|
16
|
+
constructor(providers: XHRProxyProviders);
|
|
17
|
+
onTrackingStart: (context: RequestProxyOptions) => void;
|
|
18
|
+
onTrackingStop: () => void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PropagatorType } from '../../../../types';
|
|
2
|
+
export interface RequestProxyOptions {
|
|
3
|
+
tracingSamplingRate: number;
|
|
4
|
+
firstPartyHostsRegexMap: RegexMap;
|
|
5
|
+
}
|
|
6
|
+
export declare type RegexMap = {
|
|
7
|
+
regex: RegExp;
|
|
8
|
+
propagatorType: PropagatorType;
|
|
9
|
+
}[];
|
|
10
|
+
export declare abstract class RequestProxy {
|
|
11
|
+
abstract onTrackingStart: (context: RequestProxyOptions) => void;
|
|
12
|
+
abstract onTrackingStop: () => void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ResourceKind } from '../../../../types';
|
|
2
|
+
import type { DdRumResourceTracingAttributes } from '../../distributedTracing/distributedTracing';
|
|
3
|
+
export interface RUMResource {
|
|
4
|
+
key: string;
|
|
5
|
+
request: {
|
|
6
|
+
method: string;
|
|
7
|
+
url: string;
|
|
8
|
+
kind: ResourceKind;
|
|
9
|
+
};
|
|
10
|
+
tracingAttributes: DdRumResourceTracingAttributes;
|
|
11
|
+
graphqlAttributes?: DdRumResourceGraphqlAttributes;
|
|
12
|
+
response: {
|
|
13
|
+
statusCode: number;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
timings: {
|
|
17
|
+
startTime: number;
|
|
18
|
+
stopTime: number;
|
|
19
|
+
responseStartTime?: number;
|
|
20
|
+
};
|
|
21
|
+
resourceContext?: XMLHttpRequest;
|
|
22
|
+
}
|
|
23
|
+
export declare type DdRumResourceGraphqlAttributes = {
|
|
24
|
+
operationType?: string;
|
|
25
|
+
operationName?: string;
|
|
26
|
+
variables?: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The entry point to use Datadog's RUM feature.
|
|
3
|
+
*/
|
|
4
|
+
export declare type DdRumType = {
|
|
5
|
+
/**
|
|
6
|
+
* Start tracking a RUM View.
|
|
7
|
+
* @param key: The view unique key identifier.
|
|
8
|
+
* @param name: The view name.
|
|
9
|
+
* @param context: The additional context to send.
|
|
10
|
+
* @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
|
|
11
|
+
*/
|
|
12
|
+
startView(key: string, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Stop tracking a RUM View.
|
|
15
|
+
* @param key: The view unique key identifier.
|
|
16
|
+
* @param context: The additional context to send.
|
|
17
|
+
* @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
18
|
+
*/
|
|
19
|
+
stopView(key: string, context?: object, timestampMs?: number): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Start tracking a RUM Action.
|
|
22
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
23
|
+
* @param name: The action name.
|
|
24
|
+
* @param context: The additional context to send.
|
|
25
|
+
* @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
|
|
26
|
+
*/
|
|
27
|
+
startAction(type: RumActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Stop tracking the ongoing RUM Action.
|
|
30
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
31
|
+
* @param name: The action name.
|
|
32
|
+
* @param context: The additional context to send.
|
|
33
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
34
|
+
*/
|
|
35
|
+
stopAction(type: RumActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Stop tracking the ongoing RUM Action.
|
|
38
|
+
*
|
|
39
|
+
* Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.
|
|
40
|
+
*
|
|
41
|
+
* @deprecated add the `type` and `name` of the action as first two arguments.
|
|
42
|
+
* @param context: The additional context to send.
|
|
43
|
+
* @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
44
|
+
*/
|
|
45
|
+
stopAction(context?: object, timestampMs?: number): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Add a RUM Action.
|
|
48
|
+
* @param type: The action type (tap, scroll, swipe, back, custom).
|
|
49
|
+
* @param name: The action name.
|
|
50
|
+
* @param context: The additional context to send.
|
|
51
|
+
* @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
52
|
+
*/
|
|
53
|
+
addAction(type: RumActionType, name: string, context?: object, timestampMs?: number): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Start tracking a RUM Resource.
|
|
56
|
+
* @param key: The resource unique key identifier.
|
|
57
|
+
* @param method: The resource method (GET, POST, …).
|
|
58
|
+
* @param url: The resource url.
|
|
59
|
+
* @param context: The additional context to send.
|
|
60
|
+
* @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
|
|
61
|
+
*/
|
|
62
|
+
startResource(key: string, method: string, url: string, context?: object, timestampMs?: number): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Stop tracking a RUM Resource.
|
|
65
|
+
* @param key: The resource unique key identifier.
|
|
66
|
+
* @param statusCode: The resource status code.
|
|
67
|
+
* @param kind: The resource's kind (xhr, document, image, css, font, …).
|
|
68
|
+
* @param size: The resource size in bytes. If size is unknown, use -1.
|
|
69
|
+
* @param context: The additional context to send.
|
|
70
|
+
* @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
|
|
71
|
+
*/
|
|
72
|
+
stopResource(key: string, statusCode: number, kind: ResourceKind, size?: number, context?: object, timestampMs?: number): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Add a RUM Error.
|
|
75
|
+
* @param message: The error message.
|
|
76
|
+
* @param source: The error source (network, source, console, webview, custom).
|
|
77
|
+
* @param stacktrace: The error stacktrace.
|
|
78
|
+
* @param context: The additional context to send.
|
|
79
|
+
* @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
|
|
80
|
+
*/
|
|
81
|
+
addError(message: string, source: ErrorSource, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.
|
|
84
|
+
* @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.
|
|
85
|
+
*/
|
|
86
|
+
addTiming(name: string): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Stops the current RUM Session.
|
|
89
|
+
*/
|
|
90
|
+
stopSession(): Promise<void>;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Describe the type of a RUM Action.
|
|
94
|
+
*/
|
|
95
|
+
export declare enum RumActionType {
|
|
96
|
+
/** User tapped on a widget. */
|
|
97
|
+
TAP = "TAP",
|
|
98
|
+
/** User scrolled a view. */
|
|
99
|
+
SCROLL = "SCROLL",
|
|
100
|
+
/** User swiped on a view. */
|
|
101
|
+
SWIPE = "SWIPE",
|
|
102
|
+
/** User pressed hardware back button (Android only). */
|
|
103
|
+
BACK = "BACK",
|
|
104
|
+
/** A custom action. */
|
|
105
|
+
CUSTOM = "CUSTOM"
|
|
106
|
+
}
|
|
107
|
+
export declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
|
|
108
|
+
export declare enum ErrorSource {
|
|
109
|
+
NETWORK = "NETWORK",
|
|
110
|
+
SOURCE = "SOURCE",
|
|
111
|
+
CONSOLE = "CONSOLE",
|
|
112
|
+
WEBVIEW = "WEBVIEW",
|
|
113
|
+
CUSTOM = "CUSTOM"
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Type of instrumentation on the host.
|
|
117
|
+
* - DATADOG: Datadog’s propagator (`x-datadog-*`)
|
|
118
|
+
* - TRACECONTEXT: W3C Trace Context (`traceparent`)
|
|
119
|
+
* - B3: B3 single header (`b3`)
|
|
120
|
+
* - B3MULTI: B3 multiple headers (`X-B3-*`)
|
|
121
|
+
*/
|
|
122
|
+
export declare enum PropagatorType {
|
|
123
|
+
DATADOG = "datadog",
|
|
124
|
+
TRACECONTEXT = "tracecontext",
|
|
125
|
+
B3 = "b3",
|
|
126
|
+
B3MULTI = "b3multi"
|
|
127
|
+
}
|
|
128
|
+
export declare type FirstPartyHost = {
|
|
129
|
+
match: string;
|
|
130
|
+
propagatorTypes: PropagatorType[];
|
|
131
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Attributes } from './types';
|
|
2
|
+
declare class AttributesProvider {
|
|
3
|
+
private attributes;
|
|
4
|
+
setAttributes: (attributes: Attributes) => void;
|
|
5
|
+
getAttributes: () => Attributes;
|
|
6
|
+
}
|
|
7
|
+
export declare class AttributesSingleton {
|
|
8
|
+
private static attributesProvider;
|
|
9
|
+
static getInstance: () => AttributesProvider;
|
|
10
|
+
static reset: () => void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DatadogBuffer } from './DatadogBuffer';
|
|
2
|
+
export declare class BoundedBuffer extends DatadogBuffer {
|
|
3
|
+
private bufferSize;
|
|
4
|
+
private buffer;
|
|
5
|
+
private idTable;
|
|
6
|
+
private telemetryBuffer;
|
|
7
|
+
constructor(bufferSize?: number);
|
|
8
|
+
addCallback: (callback: () => Promise<void>) => Promise<void>;
|
|
9
|
+
addCallbackReturningId: (callback: () => Promise<string>) => Promise<string>;
|
|
10
|
+
addCallbackWithId: (callback: (id: string) => Promise<void>, bufferId: string) => Promise<void>;
|
|
11
|
+
drain: () => Promise<void>;
|
|
12
|
+
private generateRandomBufferId;
|
|
13
|
+
private addTelemetryEvent;
|
|
14
|
+
private drainTelemetry;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare abstract class DatadogBuffer {
|
|
2
|
+
/**
|
|
3
|
+
* Add a callback that takes no input and yields no output to the buffer.
|
|
4
|
+
*/
|
|
5
|
+
abstract addCallback: (callback: () => Promise<void>) => Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Add a callback that returns an id to the buffer.
|
|
8
|
+
* This method also returns an id (possibly different), to be passed to addCallbackWithId.
|
|
9
|
+
*/
|
|
10
|
+
abstract addCallbackReturningId: (callback: () => Promise<string>) => Promise<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Add a callback that takes an id as input to the buffer.
|
|
13
|
+
* This id must be obtained by calling addCallbackReturningId.
|
|
14
|
+
*/
|
|
15
|
+
abstract addCallbackWithId: (callback: (id: string) => Promise<void>, id: string) => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Execute all callbacks in the buffer.
|
|
18
|
+
*/
|
|
19
|
+
abstract drain: () => void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DatadogBuffer } from './DatadogBuffer';
|
|
2
|
+
export declare class PassThroughBuffer extends DatadogBuffer {
|
|
3
|
+
addCallback: (callback: () => any) => any;
|
|
4
|
+
addCallbackReturningId: (callback: () => any) => any;
|
|
5
|
+
addCallbackWithId: (callback: (id: string) => any, id: string) => any;
|
|
6
|
+
drain: () => undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const bufferVoidNativeCall: (callback: () => Promise<void>) => Promise<void>;
|
|
2
|
+
export declare const bufferNativeCallReturningId: (callback: () => Promise<string>) => Promise<string>;
|
|
3
|
+
export declare const bufferNativeCallWithId: (callback: (id: string) => Promise<void>, id: string) => Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
import { DatadogProviderConfiguration } from '../../DdSdkReactNativeConfiguration';
|
|
4
|
+
import type { PartialInitializationConfiguration, AutoInstrumentationConfiguration } from '../../DdSdkReactNativeConfiguration';
|
|
5
|
+
declare type Props = PropsWithChildren<{
|
|
6
|
+
/**
|
|
7
|
+
* If a `DatadogProviderConfiguration` instance is passed, the SDK will start tracking errors, resources and actions and sending events.
|
|
8
|
+
*
|
|
9
|
+
* If a `AutoInstrumentationConfiguration` object is passed, the SDK will start tracking errors, resources and actions. To start sending events, call `DatadogProvider.initialize`.
|
|
10
|
+
*/
|
|
11
|
+
configuration: DatadogProviderConfiguration | AutoInstrumentationConfiguration;
|
|
12
|
+
/**
|
|
13
|
+
* Callback to be run once the SDK starts sending events.
|
|
14
|
+
*/
|
|
15
|
+
onInitialization?: () => void;
|
|
16
|
+
}>;
|
|
17
|
+
declare type StaticProperties = {
|
|
18
|
+
initialize: (configuration: PartialInitializationConfiguration) => Promise<void>;
|
|
19
|
+
onInitialization?: () => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Set up the Datadog React Native SDK.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DatadogProvider: React.FC<Props> & StaticProperties;
|
|
25
|
+
export declare const __internalResetIsInitializedForTesting: () => void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Attributes } from '../AttributesSingleton/types';
|
|
2
|
+
import type { UserInfo } from '../UserInfoSingleton/types';
|
|
3
|
+
export declare type AdditionalEventDataForMapper = {
|
|
4
|
+
userInfo: UserInfo;
|
|
5
|
+
attributes: Attributes;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Generic class for applying event mappers.
|
|
9
|
+
*
|
|
10
|
+
* Calls params in this order: formatRawEventForMapper, eventMapper, formatMapperEventForNative.
|
|
11
|
+
*
|
|
12
|
+
* @param eventMapper the user-registered event mapper
|
|
13
|
+
* @param formatRawEventForMapper formatter that gets the raw event (from javascript call) and returns the input given to the mapper
|
|
14
|
+
* @param formatMapperEventForNative formatter that gets the ouput of the mapper, and returns the input given to the native SDKs
|
|
15
|
+
* @param formatRawEventForNative called when no event mapper is registered
|
|
16
|
+
*/
|
|
17
|
+
export declare class EventMapper<RawEvent, MapperEvent, NativeEvent> {
|
|
18
|
+
private eventMapper?;
|
|
19
|
+
private formatRawEventForMapper;
|
|
20
|
+
private formatMapperEventForNative;
|
|
21
|
+
private formatRawEventForNative;
|
|
22
|
+
constructor(eventMapper: ((event: MapperEvent) => MapperEvent | null) | undefined, formatRawEventForMapper: (event: RawEvent, additionalData: AdditionalEventDataForMapper) => MapperEvent, formatMapperEventForNative: (event: MapperEvent, originalEvent: MapperEvent) => NativeEvent, formatRawEventForNative: (event: RawEvent) => NativeEvent);
|
|
23
|
+
applyEventMapper: (rawEvent: RawEvent) => NativeEvent | null;
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple deep clone inspired from https://github.com/angus-c/just/blob/master/packages/collection-clone/index.cjs
|
|
3
|
+
* Functions and RegExp will be returned as they are.
|
|
4
|
+
* Maps and Sets are cloned even though they won't be accepted by React Native, just in case they are mutated by the user to avoid side effects.
|
|
5
|
+
*
|
|
6
|
+
* We added support for circular references by limiting the number of depth levels to 8.
|
|
7
|
+
* @param originalObject
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare const deepClone: <T>(originalObject: T, depth?: number) => T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UserInfo } from './types';
|
|
2
|
+
declare class UserInfoProvider {
|
|
3
|
+
private userInfo;
|
|
4
|
+
setUserInfo: (userInfo: UserInfo) => void;
|
|
5
|
+
getUserInfo: () => UserInfo;
|
|
6
|
+
}
|
|
7
|
+
export declare class UserInfoSingleton {
|
|
8
|
+
private static userInfoProvider;
|
|
9
|
+
static getInstance: () => UserInfoProvider;
|
|
10
|
+
static reset: () => void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|