@datadog/mobile-react-native 1.1.5 → 1.2.0-beta2
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 +2 -2
- package/README.md +18 -14
- package/android/build.gradle +28 -3
- package/android/detekt.yml +572 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +12 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +15 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +143 -8
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +25 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +31 -1
- package/android/src/main/kotlin/com/datadog/reactnative/VitalFrameCallback.kt +41 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +7 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +429 -27
- package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +5 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +40 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +21 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +1 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +1 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +22 -2
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +2 -3
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/TelemetryConfigurationEventForgeryFactory.kt +94 -0
- package/datadog-sourcemaps.gradle +85 -28
- package/ios/Sources/Attributes.swift +0 -4
- package/ios/Sources/DdSdk.m +10 -0
- package/ios/Sources/DdSdk.swift +113 -10
- package/ios/Sources/DdSdkConfiguration.swift +38 -1
- package/ios/Sources/JSRefreshRateListener.swift +86 -0
- package/ios/Sources/QueueHolder.swift +7 -0
- package/ios/Sources/RNDdSdkConfiguration.swift +25 -1
- package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
- package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
- package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
- package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
- package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
- package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
- package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
- package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
- package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
- package/lib/commonjs/DdSdkReactNative.js +140 -59
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +166 -9
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/errorUtils.js +69 -0
- package/lib/commonjs/errorUtils.js.map +1 -0
- package/lib/commonjs/foundation.js +19 -12
- package/lib/commonjs/foundation.js.map +1 -1
- package/lib/commonjs/index.js +20 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/longTasksUtils.js +40 -0
- package/lib/commonjs/longTasksUtils.js.map +1 -0
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -1
- package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +1 -1
- package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
- package/lib/commonjs/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/commonjs/types.js +6 -1
- 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/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
- package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
- package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
- package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
- package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
- package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
- package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
- package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
- package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
- package/lib/module/DdSdkReactNative.js +132 -57
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +154 -8
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/errorUtils.js +54 -0
- package/lib/module/errorUtils.js.map +1 -0
- package/lib/module/foundation.js +18 -12
- package/lib/module/foundation.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/longTasksUtils.js +31 -0
- package/lib/module/longTasksUtils.js.map +1 -0
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +14 -1
- package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/getJsxRuntime.js +1 -1
- package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js +2 -1
- package/lib/module/rum/instrumentation/resourceTracking/domain/distributedTracing.js.map +1 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js +2 -1
- package/lib/module/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.js.map +1 -1
- package/lib/module/types.js +6 -1
- 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/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
- package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
- package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
- package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
- package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
- package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
- package/lib/typescript/DdSdkReactNative.d.ts +18 -3
- package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +114 -0
- package/lib/typescript/errorUtils.d.ts +12 -0
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/longTasksUtils.d.ts +6 -0
- package/lib/typescript/nativeModulesTypes.d.ts +12 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
- package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +1 -0
- package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +1 -1
- package/lib/typescript/types.d.ts +16 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +3 -2
- package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
- package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
- package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
- package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
- package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
- package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
- package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
- package/src/DatadogProvider/DatadogProvider.tsx +122 -0
- package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
- package/src/DatadogProvider/__tests__/initialization.test.tsx +182 -0
- package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
- package/src/DdSdkReactNative.tsx +206 -109
- package/src/DdSdkReactNativeConfiguration.tsx +225 -8
- package/src/__tests__/DdRumWrapper.test.tsx +3 -27
- package/src/__tests__/DdSdkReactNative.test.tsx +57 -13
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +181 -0
- package/src/__tests__/foundation.test.ts +11 -2
- package/src/__tests__/longTasksUtils.ts +23 -0
- package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
- package/src/errorUtils.ts +58 -0
- package/src/foundation.tsx +15 -12
- package/src/index.tsx +9 -1
- package/src/longTasksUtils.ts +30 -0
- package/src/nativeModulesTypes.ts +14 -0
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
- package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +11 -1
- package/src/rum/instrumentation/getJsxRuntime.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
- package/src/rum/instrumentation/resourceTracking/domain/distributedTracing.tsx +3 -1
- package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +1 -1
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/ResourceReporter.ts +2 -1
- package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
- package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +12 -47
- package/src/types.tsx +11 -1
- package/src/version.ts +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 100ms is the lower bound for a noticeable long task event.
|
|
3
|
+
*/
|
|
4
|
+
const MIN_LONG_TASK_THRESHOLD_MS = 100;
|
|
5
|
+
/**
|
|
6
|
+
* 5000ms is considered an Application Not Responding (ANR) event.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const MAX_LONG_TASK_THRESHOLD_MS = 5000;
|
|
10
|
+
/**
|
|
11
|
+
* Makes sure the long task threshold value is above 100 and below 5000.
|
|
12
|
+
* Also makes sure it is a number, passing `0` if it is `false`, as the React Native
|
|
13
|
+
* bridge cannot handle values with dual types.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const adaptLongTaskThreshold = longTaskThreshold => {
|
|
17
|
+
if (!longTaskThreshold) {
|
|
18
|
+
return 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (longTaskThreshold < MIN_LONG_TASK_THRESHOLD_MS) {
|
|
22
|
+
return MIN_LONG_TASK_THRESHOLD_MS;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (longTaskThreshold > MAX_LONG_TASK_THRESHOLD_MS) {
|
|
26
|
+
return MAX_LONG_TASK_THRESHOLD_MS;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return longTaskThreshold;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=longTasksUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["longTasksUtils.ts"],"names":["MIN_LONG_TASK_THRESHOLD_MS","MAX_LONG_TASK_THRESHOLD_MS","adaptLongTaskThreshold","longTaskThreshold"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,0BAA0B,GAAG,GAAnC;AAEA;AACA;AACA;;AACA,MAAMC,0BAA0B,GAAG,IAAnC;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,sBAAsB,GAC/BC,iBADkC,IAEzB;AACT,MAAI,CAACA,iBAAL,EAAwB;AACpB,WAAO,CAAP;AACH;;AACD,MAAIA,iBAAiB,GAAGH,0BAAxB,EAAoD;AAChD,WAAOA,0BAAP;AACH;;AACD,MAAIG,iBAAiB,GAAGF,0BAAxB,EAAoD;AAChD,WAAOA,0BAAP;AACH;;AAED,SAAOE,iBAAP;AACH,CAdM","sourcesContent":["/**\n * 100ms is the lower bound for a noticeable long task event.\n */\nconst MIN_LONG_TASK_THRESHOLD_MS = 100;\n\n/**\n * 5000ms is considered an Application Not Responding (ANR) event.\n */\nconst MAX_LONG_TASK_THRESHOLD_MS = 5000;\n\n/**\n * Makes sure the long task threshold value is above 100 and below 5000.\n * Also makes sure it is a number, passing `0` if it is `false`, as the React Native\n * bridge cannot handle values with dual types.\n */\nexport const adaptLongTaskThreshold = (\n longTaskThreshold: number | false\n): number => {\n if (!longTaskThreshold) {\n return 0;\n }\n if (longTaskThreshold < MIN_LONG_TASK_THRESHOLD_MS) {\n return MIN_LONG_TASK_THRESHOLD_MS;\n }\n if (longTaskThreshold > MAX_LONG_TASK_THRESHOLD_MS) {\n return MAX_LONG_TASK_THRESHOLD_MS;\n }\n\n return longTaskThreshold;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * 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.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
1
|
+
{"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * 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.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
|
|
@@ -7,10 +7,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
*/
|
|
8
8
|
import { InternalLog } from '../../InternalLog';
|
|
9
9
|
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
10
|
+
import { getErrorMessage, getErrorStackTrace, EMPTY_STACK_TRACE } from '../../errorUtils';
|
|
10
11
|
import { DdRum } from '../../foundation';
|
|
11
12
|
import { ErrorSource } from '../../types';
|
|
12
|
-
const EMPTY_MESSAGE = 'Unknown Error';
|
|
13
|
-
const EMPTY_STACK_TRACE = '';
|
|
14
13
|
/**
|
|
15
14
|
* Provides RUM auto-instrumentation feature to track errors as RUM events.
|
|
16
15
|
*/
|
|
@@ -43,8 +42,8 @@ export class DdRumErrorTracking {
|
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
static onGlobalError(error, isFatal) {
|
|
46
|
-
const message =
|
|
47
|
-
const stacktrace =
|
|
45
|
+
const message = getErrorMessage(error);
|
|
46
|
+
const stacktrace = getErrorStackTrace(error);
|
|
48
47
|
DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {
|
|
49
48
|
'_dd.error.is_crash': isFatal,
|
|
50
49
|
'_dd.error.raw': error
|
|
@@ -68,7 +67,7 @@ export class DdRumErrorTracking {
|
|
|
68
67
|
|
|
69
68
|
for (let i = 0; i < params.length; i += 1) {
|
|
70
69
|
const param = params[i];
|
|
71
|
-
const paramStack =
|
|
70
|
+
const paramStack = getErrorStackTrace(param);
|
|
72
71
|
|
|
73
72
|
if (paramStack !== EMPTY_STACK_TRACE) {
|
|
74
73
|
stack = paramStack;
|
|
@@ -80,7 +79,7 @@ export class DdRumErrorTracking {
|
|
|
80
79
|
if (typeof param === 'string') {
|
|
81
80
|
return param;
|
|
82
81
|
} else {
|
|
83
|
-
return
|
|
82
|
+
return getErrorMessage(param);
|
|
84
83
|
}
|
|
85
84
|
}).join(' ');
|
|
86
85
|
DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {
|
|
@@ -88,42 +87,6 @@ export class DdRumErrorTracking {
|
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
static getErrorMessage(error) {
|
|
92
|
-
let message = EMPTY_MESSAGE;
|
|
93
|
-
|
|
94
|
-
if (error === undefined || error === null) {
|
|
95
|
-
message = EMPTY_MESSAGE;
|
|
96
|
-
} else if (typeof error === 'object' && 'message' in error) {
|
|
97
|
-
message = String(error.message);
|
|
98
|
-
} else {
|
|
99
|
-
message = String(error);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return message;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
static getErrorStackTrace(error) {
|
|
106
|
-
let stack = EMPTY_STACK_TRACE;
|
|
107
|
-
|
|
108
|
-
if (error === undefined || error === null) {
|
|
109
|
-
stack = EMPTY_STACK_TRACE;
|
|
110
|
-
} else if (typeof error === 'string') {
|
|
111
|
-
stack = EMPTY_STACK_TRACE;
|
|
112
|
-
} else if (typeof error === 'object') {
|
|
113
|
-
if ('componentStack' in error) {
|
|
114
|
-
stack = String(error.componentStack);
|
|
115
|
-
} else if ('stacktrace' in error) {
|
|
116
|
-
stack = String(error.stacktrace);
|
|
117
|
-
} else if ('stack' in error) {
|
|
118
|
-
stack = String(error.stack);
|
|
119
|
-
} else if ('sourceURL' in error && 'line' in error && 'column' in error) {
|
|
120
|
-
stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return stack;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
90
|
}
|
|
128
91
|
|
|
129
92
|
_defineProperty(DdRumErrorTracking, "isTracking", false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["InternalLog","SdkVerbosity","
|
|
1
|
+
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["InternalLog","SdkVerbosity","getErrorMessage","getErrorStackTrace","EMPTY_STACK_TRACE","DdRum","ErrorSource","DdRumErrorTracking","startTracking","isTracking","log","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","stacktrace","addError","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","_error","_isFatal","_params"],"mappings":"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","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport {\n getErrorMessage,\n getErrorStackTrace,\n EMPTY_STACK_TRACE\n} from '../../errorUtils';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = getErrorMessage(error);\n const stacktrace = getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n}\n"]}
|
|
@@ -8,6 +8,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { InternalLog } from '../../InternalLog';
|
|
10
10
|
import { SdkVerbosity } from '../../SdkVerbosity';
|
|
11
|
+
import { getErrorMessage } from '../../errorUtils';
|
|
12
|
+
import { DdSdk } from '../../foundation';
|
|
11
13
|
import { DdEventsInterceptor } from './DdEventsInterceptor';
|
|
12
14
|
import NoOpEventsInterceptor from './NoOpEventsInterceptor';
|
|
13
15
|
import { areObjectShallowEqual } from './ShallowObjectEqualityChecker';
|
|
@@ -44,7 +46,8 @@ export class DdRumUserInteractionTracking {
|
|
|
44
46
|
jsxRuntime.jsx = (...args) => {
|
|
45
47
|
return this.patchCreateElementFunction(originaljsx, args);
|
|
46
48
|
};
|
|
47
|
-
} catch (e) {
|
|
49
|
+
} catch (e) {
|
|
50
|
+
DdSdk.telemetryDebug(getErrorMessage(e));
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
const originalMemo = React.memo;
|
|
@@ -79,12 +82,22 @@ export class DdRumUserInteractionTracking {
|
|
|
79
82
|
InternalLog.log('Datadog SDK is tracking interactions', SdkVerbosity.INFO);
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
static stopTracking() {
|
|
86
|
+
React.createElement = this.originalCreateElement;
|
|
87
|
+
React.memo = this.originalMemo;
|
|
88
|
+
DdRumUserInteractionTracking.isTracking = false;
|
|
89
|
+
}
|
|
90
|
+
|
|
82
91
|
}
|
|
83
92
|
|
|
84
93
|
_defineProperty(DdRumUserInteractionTracking, "isTracking", false);
|
|
85
94
|
|
|
86
95
|
_defineProperty(DdRumUserInteractionTracking, "eventsInterceptor", new NoOpEventsInterceptor());
|
|
87
96
|
|
|
97
|
+
_defineProperty(DdRumUserInteractionTracking, "originalCreateElement", React.createElement);
|
|
98
|
+
|
|
99
|
+
_defineProperty(DdRumUserInteractionTracking, "originalMemo", React.memo);
|
|
100
|
+
|
|
88
101
|
_defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
|
|
89
102
|
if (props && typeof props.onPress === 'function') {
|
|
90
103
|
const originalOnPress = props. // eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAAN,CAAmC;
|
|
1
|
+
{"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","getErrorMessage","DdSdk","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":"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","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport React from 'react';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { getErrorMessage } from '../../errorUtils';\nimport { DdSdk } from '../../foundation';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n private static originalCreateElement = React.createElement;\n private static originalMemo = React.memo;\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n DdSdk.telemetryDebug(getErrorMessage(e));\n }\n\n const originalMemo = React.memo;\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n\n static stopTracking() {\n React.createElement = this.originalCreateElement;\n React.memo = this.originalMemo;\n DdRumUserInteractionTracking.isTracking = false;\n }\n}\n"]}
|
|
@@ -25,7 +25,7 @@ export const getJsxRuntime = () => {
|
|
|
25
25
|
const jsxRuntime = require('react/jsx-runtime');
|
|
26
26
|
|
|
27
27
|
if (!jsxRuntime.jsx) {
|
|
28
|
-
throw new Error('React
|
|
28
|
+
throw new Error('React jsx runtime does not export new jsx transform');
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return jsxRuntime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntime","jsx","Number"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAMC,UAAU,GAAGL,OAAO,CAAC,mBAAD,CAA1B;;AACA,MAAI,CAACK,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIF,KAAJ,CAAU,
|
|
1
|
+
{"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntime","jsx","Number"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,QAAMC,UAAU,GAAGL,OAAO,CAAC,mBAAD,CAA1B;;AACA,MAAI,CAACK,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIF,KAAJ,CAAU,qDAAV,CAAN;AACH;;AACD,SAAOC,UAAP;AACH,CAvBM;AAyBP;AACA;AACA;;AACA,MAAMF,2BAA2B,GAAG,CAACL,KAAD,EAAgBC,KAAhB,KAA2C;AAC3E,MAAIQ,MAAM,CAACT,KAAD,CAAN,GAAgB,EAApB,EAAwB;AACpB,WAAO,IAAP;AACH;;AACD,MAAIS,MAAM,CAACT,KAAD,CAAN,KAAkB,EAAlB,IAAwBS,MAAM,CAACR,KAAD,CAAN,GAAgB,EAA5C,EAAgD;AAC5C,WAAO,IAAP;AACH;;AACD,SAAO,KAAP;AACH,CARD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const getJsxRuntime = () => {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const [major, minor] = require('react/package.json').version.split('.');\n // We need to check on the version of React before requiring 'react/jsx-runtime') as\n // it might crash other exports if the export does not exist (even if there is a try/catch).\n // See: https://github.com/facebook/metro/issues/836\n if (!isJsxExportedInReactVersion(major, minor)) {\n throw new Error('React version does not support new jsx transform');\n }\n\n // /!\\/!\\/!\\/!\\/!\\/!\\\n // We have to use inline require here because older React versions (below 16.14) don't have jsx-runtime.\n // metro does not support dynamic require, so 'react/jsx-runtime' is replaced by 'react' on postinstall\n // when react is equal or above 16.14 to avoid this require call to fail during the import phase and then\n // disable all further imports.\n // /!\\/!\\/!\\/!\\/!\\/!\\\n //\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const jsxRuntime = require('react/jsx-runtime');\n if (!jsxRuntime.jsx) {\n throw new Error('React jsx runtime does not export new jsx transform');\n }\n return jsxRuntime;\n};\n\n/**\n * JSX Transform is available for React 16.14.0 (last React 16 version) and above\n */\nconst isJsxExportedInReactVersion = (major: string, minor: string): boolean => {\n if (Number(major) > 16) {\n return true;\n }\n if (Number(major) === 16 && Number(minor) > 13) {\n return true;\n }\n return false;\n};\n"]}
|
|
@@ -30,7 +30,8 @@ const generateTracingAttributesWithSampling = tracingSamplingRate => {
|
|
|
30
30
|
traceId: generateTraceId(),
|
|
31
31
|
spanId: generateTraceId(),
|
|
32
32
|
samplingPriorityHeader: '1',
|
|
33
|
-
tracingStrategy: 'KEEP'
|
|
33
|
+
tracingStrategy: 'KEEP',
|
|
34
|
+
rulePsr: tracingSamplingRate / 100
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["distributedTracing.tsx"],"names":["isHostFirstParty","DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegex","tracingSamplingRate","generateTracingAttributesWithSampling","Math","random","traceId","generateTraceId","spanId","radix","MAX_32_BITS_NUMBER","low","floor","high","str","modH","temp","digit","toString"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,gBAAT,QAAiC,mBAAjC;
|
|
1
|
+
{"version":3,"sources":["distributedTracing.tsx"],"names":["isHostFirstParty","DISCARDED_TRACE_ATTRIBUTES","samplingPriorityHeader","tracingStrategy","getTracingAttributes","hostname","firstPartyHostsRegex","tracingSamplingRate","generateTracingAttributesWithSampling","Math","random","traceId","generateTraceId","spanId","rulePsr","radix","MAX_32_BITS_NUMBER","low","floor","high","str","modH","temp","digit","toString"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,gBAAT,QAAiC,mBAAjC;AAiBA,MAAMC,0BAA0D,GAAG;AAC/DC,EAAAA,sBAAsB,EAAE,GADuC;AAE/DC,EAAAA,eAAe,EAAE;AAF8C,CAAnE;AAKA,OAAO,MAAMC,oBAAoB,GAAG,CAAC;AACjCC,EAAAA,QADiC;AAEjCC,EAAAA,oBAFiC;AAGjCC,EAAAA;AAHiC,CAAD,KAQE;AAClC,MAAIF,QAAQ,KAAK,IAAjB,EAAuB;AACnB,WAAOJ,0BAAP;AACH;;AACD,MAAID,gBAAgB,CAACK,QAAD,EAAWC,oBAAX,CAApB,EAAsD;AAClD,WAAOE,qCAAqC,CAACD,mBAAD,CAA5C;AACH;;AACD,SAAON,0BAAP;AACH,CAhBM;;AAkBP,MAAMO,qCAAqC,GACvCD,mBAD0C,IAET;AACjC,MAAIE,IAAI,CAACC,MAAL,KAAgB,GAAhB,IAAuBH,mBAA3B,EAAgD;AAC5C,WAAO;AACHI,MAAAA,OAAO,EAAEC,eAAe,EADrB;AAEHC,MAAAA,MAAM,EAAED,eAAe,EAFpB;AAGHV,MAAAA,sBAAsB,EAAE,GAHrB;AAIHC,MAAAA,eAAe,EAAE,MAJd;AAKHW,MAAAA,OAAO,EAAEP,mBAAmB,GAAG;AAL5B,KAAP;AAOH;;AACD,SAAON,0BAAP;AACH,CAbD;AAeA;AACA;AACA;;;AACA,OAAO,SAASW,eAAT,GAAmC;AACtC,QAAMG,KAAK,GAAG,EAAd;AACA,QAAMC,kBAAkB,GAAG,UAA3B,CAFsC,CAEC;;AACvC,MAAIC,GAAW,GAAGR,IAAI,CAACS,KAAL,CAAWT,IAAI,CAACC,MAAL,KAAgBM,kBAA3B,CAAlB;AACA,MAAIG,IAAY,GAAGV,IAAI,CAACS,KAAL,CAAWT,IAAI,CAACC,MAAL,KAAgBM,kBAA3B,CAAnB;AACA,MAAII,GAAG,GAAG,EAAV;;AAEA,SAAOD,IAAI,GAAG,CAAP,IAAYF,GAAG,GAAG,CAAzB,EAA4B;AACxB;AACA;AACA,UAAMI,IAAI,GAAGF,IAAI,GAAGJ,KAApB;AACA,UAAMO,IAAI,GAAG,CAACD,IAAI,IAAI,EAAT,IAAeJ,GAA5B;AACA,UAAMM,KAAK,GAAGD,IAAI,GAAGP,KAArB,CALwB,CAOxB;;AACAI,IAAAA,IAAI,GAAG,CAACA,IAAI,GAAGE,IAAR,IAAgBN,KAAvB,CARwB,CAQM;AAC9B;;AACAE,IAAAA,GAAG,GAAG,CAACK,IAAI,GAAGC,KAAR,IAAiBR,KAAvB,CAVwB,CAUM;AAE9B;;AACAK,IAAAA,GAAG,GAAGG,KAAK,CAACC,QAAN,KAAmBJ,GAAzB;AACH;;AACD,SAAOA,GAAP;AACH","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { Hostname } from './firstPartyHosts';\nimport { isHostFirstParty } from './firstPartyHosts';\n\nexport type DdRumResourceTracingAttributes =\n | {\n tracingStrategy: 'KEEP';\n traceId: string;\n spanId: string;\n samplingPriorityHeader: '1';\n rulePsr: number;\n }\n | {\n tracingStrategy: 'DISCARD';\n traceId?: void;\n spanId?: void;\n samplingPriorityHeader: '0';\n };\n\nconst DISCARDED_TRACE_ATTRIBUTES: DdRumResourceTracingAttributes = {\n samplingPriorityHeader: '0',\n tracingStrategy: 'DISCARD'\n};\n\nexport const getTracingAttributes = ({\n hostname,\n firstPartyHostsRegex,\n tracingSamplingRate\n}: {\n hostname: Hostname | null;\n firstPartyHostsRegex: RegExp;\n tracingSamplingRate: number;\n}): DdRumResourceTracingAttributes => {\n if (hostname === null) {\n return DISCARDED_TRACE_ATTRIBUTES;\n }\n if (isHostFirstParty(hostname, firstPartyHostsRegex)) {\n return generateTracingAttributesWithSampling(tracingSamplingRate);\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\nconst generateTracingAttributesWithSampling = (\n tracingSamplingRate: number\n): DdRumResourceTracingAttributes => {\n if (Math.random() * 100 <= tracingSamplingRate) {\n return {\n traceId: generateTraceId(),\n spanId: generateTraceId(),\n samplingPriorityHeader: '1',\n tracingStrategy: 'KEEP',\n rulePsr: tracingSamplingRate / 100\n };\n }\n return DISCARDED_TRACE_ATTRIBUTES;\n};\n\n/*\n * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)\n */\nexport function generateTraceId(): string {\n const radix = 10;\n const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1\n let low: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let high: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let str = '';\n\n while (high > 0 && low > 0) {\n // Create an intermediate value with the same modulo as the combined high and low value\n // but requiring 36 bits max (32 for the low value + 4 for the high part)\n const modH = high % radix;\n const temp = (modH << 32) + low;\n const digit = temp % radix;\n\n // update the high value\n high = (high - modH) / radix; // we reuse the modH to avoid the need of a floor op\n // the low value reuses the previous temp value to account for the \"missing mod\" in the high update\n low = (temp - digit) / radix; // we reuse the digit to avoid the need of a floor op\n\n // update the string from right to left\n str = digit.toString() + str;\n }\n return str;\n}\n"]}
|
|
@@ -33,7 +33,8 @@ export class ResourceReporter {
|
|
|
33
33
|
const formatResourceStartContext = tracingAttributes => {
|
|
34
34
|
return tracingAttributes.tracingStrategy === 'DISCARD' ? undefined : {
|
|
35
35
|
'_dd.span_id': tracingAttributes.spanId,
|
|
36
|
-
'_dd.trace_id': tracingAttributes.traceId
|
|
36
|
+
'_dd.trace_id': tracingAttributes.traceId,
|
|
37
|
+
'_dd.rule_psr': tracingAttributes.rulePsr
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","tracingStrategy","undefined","spanId","traceId","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","startResource","key","request","method","url","stopResource","response","statusCode","kind","size"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,2BAAtB;AAGA,SAASC,aAAT,QAA8B,kBAA9B;AAIA,OAAO,MAAMC,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD,EAAoC;AAAA;;AAAA,4CAI7BC,QAAD,IAA2B;AACxC,UAAIC,gBAAoC,GAAGD,QAA3C;;AAEA,WAAK,MAAME,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;AAC/BF,QAAAA,gBAAgB,GAAGC,MAAM,CAACF,QAAD,CAAzB;;AACA,YAAIC,gBAAgB,KAAK,IAAzB,EAA+B;AAC3B;AACH;AACJ;;AAEDG,MAAAA,cAAc,CAACH,gBAAD,CAAd;AACH,KAf8C;;AAC3C,SAAKE,OAAL,GAAeJ,eAAf;AACH;;AALyB;;AAqB9B,MAAMM,0BAA0B,GAC5BC,iBAD+B,IAEO;AACtC,SAAOA,iBAAiB,CAACC,eAAlB,KAAsC,SAAtC,GACDC,SADC,GAED;AACI,mBAAeF,iBAAiB,CAACG,MADrC;AAEI,oBAAgBH,iBAAiB,CAACI;
|
|
1
|
+
{"version":3,"sources":["ResourceReporter.ts"],"names":["DdRum","createTimings","ResourceReporter","constructor","resourceMappers","resource","modifiedResource","mapper","mappers","reportResource","formatResourceStartContext","tracingAttributes","tracingStrategy","undefined","spanId","traceId","rulePsr","formatResourceStopContext","timings","responseStartTime","startTime","stopTime","startResource","key","request","method","url","stopResource","response","statusCode","kind","size"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,QAAsB,2BAAtB;AAGA,SAASC,aAAT,QAA8B,kBAA9B;AAIA,OAAO,MAAMC,gBAAN,CAAuB;AAG1BC,EAAAA,WAAW,CAACC,eAAD,EAAoC;AAAA;;AAAA,4CAI7BC,QAAD,IAA2B;AACxC,UAAIC,gBAAoC,GAAGD,QAA3C;;AAEA,WAAK,MAAME,MAAX,IAAqB,KAAKC,OAA1B,EAAmC;AAC/BF,QAAAA,gBAAgB,GAAGC,MAAM,CAACF,QAAD,CAAzB;;AACA,YAAIC,gBAAgB,KAAK,IAAzB,EAA+B;AAC3B;AACH;AACJ;;AAEDG,MAAAA,cAAc,CAACH,gBAAD,CAAd;AACH,KAf8C;;AAC3C,SAAKE,OAAL,GAAeJ,eAAf;AACH;;AALyB;;AAqB9B,MAAMM,0BAA0B,GAC5BC,iBAD+B,IAEO;AACtC,SAAOA,iBAAiB,CAACC,eAAlB,KAAsC,SAAtC,GACDC,SADC,GAED;AACI,mBAAeF,iBAAiB,CAACG,MADrC;AAEI,oBAAgBH,iBAAiB,CAACI,OAFtC;AAGI,oBAAgBJ,iBAAiB,CAACK;AAHtC,GAFN;AAOH,CAVD;;AAYA,MAAMC,yBAAyB,GAC3BC,OAD8B,IAEJ;AAC1B,SAAO;AACH,4BACIA,OAAO,CAACC,iBAAR,KAA8BN,SAA9B,GACMZ,aAAa,CACTiB,OAAO,CAACE,SADC,EAETF,OAAO,CAACC,iBAFC,EAGTD,OAAO,CAACG,QAHC,CADnB,GAMM;AARP,GAAP;AAUH,CAbD;;AAeA,MAAMZ,cAAc,GAAG,MAAOJ,QAAP,IAAiC;AACpD,QAAML,KAAK,CAACsB,aAAN,CACFjB,QAAQ,CAACkB,GADP,EAEFlB,QAAQ,CAACmB,OAAT,CAAiBC,MAFf,EAGFpB,QAAQ,CAACmB,OAAT,CAAiBE,GAHf,EAIFhB,0BAA0B,CAACL,QAAQ,CAACM,iBAAV,CAJxB,EAKFN,QAAQ,CAACa,OAAT,CAAiBE,SALf,CAAN;AAQApB,EAAAA,KAAK,CAAC2B,YAAN,CACItB,QAAQ,CAACkB,GADb,EAEIlB,QAAQ,CAACuB,QAAT,CAAkBC,UAFtB,EAGIxB,QAAQ,CAACmB,OAAT,CAAiBM,IAHrB,EAIIzB,QAAQ,CAACuB,QAAT,CAAkBG,IAJtB,EAKId,yBAAyB,CAACZ,QAAQ,CAACa,OAAV,CAL7B,EAMIb,QAAQ,CAACa,OAAT,CAAiBG,QANrB;AAQH,CAjBD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum } from '../../../../../foundation';\nimport type { RUMResource } from '../../domain/interfaces/RumResource';\n\nimport { createTimings } from './resourceTiming';\n\ntype ResourceMapper = (resource: RUMResource) => RUMResource | null;\n\nexport class ResourceReporter {\n private mappers: ResourceMapper[];\n\n constructor(resourceMappers: ResourceMapper[]) {\n this.mappers = resourceMappers;\n }\n\n reportResource = (resource: RUMResource) => {\n let modifiedResource: RUMResource | null = resource;\n\n for (const mapper of this.mappers) {\n modifiedResource = mapper(resource);\n if (modifiedResource === null) {\n return;\n }\n }\n\n reportResource(modifiedResource);\n };\n}\n\nconst formatResourceStartContext = (\n tracingAttributes: RUMResource['tracingAttributes']\n): Record<string, unknown> | undefined => {\n return tracingAttributes.tracingStrategy === 'DISCARD'\n ? undefined\n : {\n '_dd.span_id': tracingAttributes.spanId,\n '_dd.trace_id': tracingAttributes.traceId,\n '_dd.rule_psr': tracingAttributes.rulePsr\n };\n};\n\nconst formatResourceStopContext = (\n timings: RUMResource['timings']\n): Record<string, unknown> => {\n return {\n '_dd.resource_timings':\n timings.responseStartTime !== undefined\n ? createTimings(\n timings.startTime,\n timings.responseStartTime,\n timings.stopTime\n )\n : null\n };\n};\n\nconst reportResource = async (resource: RUMResource) => {\n await DdRum.startResource(\n resource.key,\n resource.request.method,\n resource.request.url,\n formatResourceStartContext(resource.tracingAttributes),\n resource.timings.startTime\n );\n\n DdRum.stopResource(\n resource.key,\n resource.response.statusCode,\n resource.request.kind,\n resource.response.size,\n formatResourceStopContext(resource.timings),\n resource.timings.stopTime\n );\n};\n"]}
|
package/lib/module/types.js
CHANGED
|
@@ -8,15 +8,20 @@
|
|
|
8
8
|
* A configuration object to initialize Datadog's features.
|
|
9
9
|
*/
|
|
10
10
|
export class DdSdkConfiguration {
|
|
11
|
-
constructor(clientToken, env, applicationId, nativeCrashReportEnabled, sampleRate, site, trackingConsent, additionalConfig) {
|
|
11
|
+
constructor(clientToken, env, applicationId, nativeCrashReportEnabled, nativeLongTaskThresholdMs, longTaskThresholdMs, sampleRate, site, trackingConsent, additionalConfig, telemetrySampleRate, vitalsUpdateFrequency, configurationForTelemetry) {
|
|
12
12
|
this.clientToken = clientToken;
|
|
13
13
|
this.env = env;
|
|
14
14
|
this.applicationId = applicationId;
|
|
15
15
|
this.nativeCrashReportEnabled = nativeCrashReportEnabled;
|
|
16
|
+
this.nativeLongTaskThresholdMs = nativeLongTaskThresholdMs;
|
|
17
|
+
this.longTaskThresholdMs = longTaskThresholdMs;
|
|
16
18
|
this.sampleRate = sampleRate;
|
|
17
19
|
this.site = site;
|
|
18
20
|
this.trackingConsent = trackingConsent;
|
|
19
21
|
this.additionalConfig = additionalConfig;
|
|
22
|
+
this.telemetrySampleRate = telemetrySampleRate;
|
|
23
|
+
this.vitalsUpdateFrequency = vitalsUpdateFrequency;
|
|
24
|
+
this.configurationForTelemetry = configurationForTelemetry;
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
}
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;AACA;AACA;;AAqOA;AACA;AACA;AACA,WAAYC,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a;;AA0BZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * 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.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","configurationForTelemetry","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,yBALF,EAMEC,mBANF,EAOEC,UAPF,EAQEC,IARF,EASEC,eATF,EAUEC,gBAVF,EAWEC,mBAXF,EAYEC,qBAZF,EAaEC,yBAbF,EAmBT;AAAA,SAlBWZ,WAkBX,GAlBWA,WAkBX;AAAA,SAjBWC,GAiBX,GAjBWA,GAiBX;AAAA,SAhBWC,aAgBX,GAhBWA,aAgBX;AAAA,SAfWC,wBAeX,GAfWA,wBAeX;AAAA,SAdWC,yBAcX,GAdWA,yBAcX;AAAA,SAbWC,mBAaX,GAbWA,mBAaX;AAAA,SAZWC,UAYX,GAZWA,UAYX;AAAA,SAXWC,IAWX,GAXWA,IAWX;AAAA,SAVWC,eAUX,GAVWA,eAUX;AAAA,SATWC,gBASX,GATWA,gBASX;AAAA,SARWC,mBAQX,GARWA,mBAQX;AAAA,SAPWC,qBAOX,GAPWA,qBAOX;AAAA,SANWC,yBAMX,GANWA,yBAMX;AAAE;;AApBwB;AAuBhC;AACA;AACA;;AAqOA;AACA;AACA;AACA,WAAYC,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a;;AA0BZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly nativeLongTaskThresholdMs: number,\n readonly longTaskThresholdMs: number,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object,\n readonly telemetrySampleRate: number,\n readonly vitalsUpdateFrequency: string,\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n }\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * 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.\n * @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.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n"]}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,aAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.2.0-beta2';\n"]}
|
|
@@ -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 {};
|