@datadog/mobile-react-native 1.5.2 → 1.7.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/DatadogSDKReactNative.podspec +2 -2
- package/android/build.gradle +2 -1
- package/android/gradle.properties +1 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdLogs.kt +162 -6
- package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +25 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +32 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +11 -1
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +10 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +242 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +27 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +126 -30
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +19 -1
- package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +2 -2
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +18 -1
- package/ios/Sources/Attributes.swift +7 -0
- package/ios/Sources/DdLogs.m +31 -0
- package/ios/Sources/DdLogs.swift +84 -4
- package/ios/Sources/DdRum.m +8 -0
- package/ios/Sources/DdRum.swift +17 -0
- package/ios/Sources/DdSdk.swift +40 -0
- package/ios/Sources/DdSdkConfiguration.swift +19 -1
- package/ios/Sources/RNDdSdkConfiguration.swift +11 -1
- package/lib/commonjs/DdSdkReactNative.js +6 -2
- package/lib/commonjs/DdSdkReactNative.js.map +1 -1
- package/lib/commonjs/DdSdkReactNativeConfiguration.js +45 -2
- package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/commonjs/InternalLog.js +6 -2
- package/lib/commonjs/InternalLog.js.map +1 -1
- package/lib/commonjs/errorUtils.js +20 -1
- package/lib/commonjs/errorUtils.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/logs/DdLogs.js +102 -11
- package/lib/commonjs/logs/DdLogs.js.map +1 -1
- package/lib/commonjs/logs/eventMapper.js.map +1 -1
- package/lib/commonjs/nativeModulesTypes.js.map +1 -1
- package/lib/commonjs/rum/DdRum.js +14 -0
- package/lib/commonjs/rum/DdRum.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +62 -46
- package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
- package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
- package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
- package/lib/commonjs/rum/types.js.map +1 -1
- package/lib/commonjs/types.js +4 -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/DdSdkReactNative.js +6 -2
- package/lib/module/DdSdkReactNative.js.map +1 -1
- package/lib/module/DdSdkReactNativeConfiguration.js +42 -1
- package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
- package/lib/module/InternalLog.js +2 -1
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/errorUtils.js +15 -0
- package/lib/module/errorUtils.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/logs/DdLogs.js +103 -12
- package/lib/module/logs/DdLogs.js.map +1 -1
- package/lib/module/logs/eventMapper.js.map +1 -1
- package/lib/module/nativeModulesTypes.js.map +1 -1
- package/lib/module/rum/DdRum.js +12 -0
- package/lib/module/rum/DdRum.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js +63 -46
- package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
- package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
- package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
- package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
- package/lib/module/rum/types.js.map +1 -1
- package/lib/module/types.js +4 -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/DdSdkReactNativeConfiguration.d.ts +47 -0
- package/lib/typescript/InternalLog.d.ts +1 -0
- package/lib/typescript/errorUtils.d.ts +2 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/logs/DdLogs.d.ts +13 -5
- package/lib/typescript/logs/eventMapper.d.ts +5 -5
- package/lib/typescript/logs/types.d.ts +34 -8
- package/lib/typescript/nativeModulesTypes.d.ts +51 -4
- package/lib/typescript/rum/DdRum.d.ts +2 -0
- package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
- package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -1
- package/lib/typescript/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +5 -2
- package/lib/typescript/rum/types.d.ts +4 -0
- package/lib/typescript/types.d.ts +8 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/DdSdkReactNative.tsx +9 -1
- package/src/DdSdkReactNativeConfiguration.tsx +56 -1
- package/src/InternalLog.tsx +3 -1
- package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +20 -3
- package/src/__tests__/errorUtils.test.ts +49 -0
- package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +14 -14
- package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +474 -109
- package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +18 -0
- package/src/errorUtils.ts +15 -0
- package/src/index.tsx +6 -2
- package/src/logs/DdLogs.ts +166 -16
- package/src/logs/__tests__/DdLogs.test.ts +169 -0
- package/src/logs/__tests__/eventMapper.test.ts +34 -0
- package/src/logs/eventMapper.ts +15 -4
- package/src/logs/types.ts +36 -8
- package/src/nativeModulesTypes.ts +81 -4
- package/src/rum/DdRum.ts +17 -0
- package/src/rum/__tests__/DdRum.test.ts +12 -27
- package/src/rum/instrumentation/DdRumErrorTracking.tsx +44 -10
- package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +7 -4
- package/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.ts +11 -3
- package/src/rum/types.ts +5 -0
- package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +5 -0
- package/src/types.tsx +5 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["eventMapper.ts"],"names":["EventMapper","formatLogEventToNativeLog","logEvent","formatRawLogToNativeEvent","rawLog","formatRawLogToLogEvent","additionalInformation","userInfo","attributes","generateEventMapper","logEventMapper"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,iCAA5B;
|
|
1
|
+
{"version":3,"sources":["eventMapper.ts"],"names":["EventMapper","formatLogEventToNativeLog","logEvent","formatRawLogToNativeEvent","rawLog","formatRawLogToLogEvent","additionalInformation","userInfo","attributes","generateEventMapper","logEventMapper"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,iCAA5B;AAYA,OAAO,MAAMC,yBAAyB,GAClCC,QADqC,IAEJ;AACjC,SAAOA,QAAP;AACH,CAJM;AAMP,OAAO,MAAMC,yBAAyB,GAClCC,MADqC,IAEJ;AACjC,SAAOA,MAAP;AACH,CAJM;AAMP,OAAO,MAAMC,sBAAsB,GAAG,CAClCD,MADkC,EAElCE,qBAFkC,KAMvB;AACX,SAAO,EACH,GAAGF,MADA;AAEHG,IAAAA,QAAQ,EAAED,qBAAqB,CAACC,QAF7B;AAGHC,IAAAA,UAAU,EAAEF,qBAAqB,CAACE;AAH/B,GAAP;AAKH,CAZM;AAcP,OAAO,MAAMC,mBAAmB,GAC5BC,cAD+B,IAG/B,IAAIV,WAAJ,CACIU,cADJ,EAEIL,sBAFJ,EAGIJ,yBAHJ,EAIIE,yBAJJ,CAHG","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 { Attributes } from '../sdk/AttributesSingleton/types';\nimport { EventMapper } from '../sdk/EventMappers/EventMapper';\nimport type { UserInfo } from '../sdk/UserInfoSingleton/types';\n\nimport type {\n LogEvent,\n LogEventMapper,\n NativeLog,\n NativeLogWithError,\n RawLog,\n RawLogWithError\n} from './types';\n\nexport const formatLogEventToNativeLog = (\n logEvent: LogEvent\n): NativeLog | NativeLogWithError => {\n return logEvent;\n};\n\nexport const formatRawLogToNativeEvent = (\n rawLog: RawLog | RawLogWithError\n): NativeLog | NativeLogWithError => {\n return rawLog;\n};\n\nexport const formatRawLogToLogEvent = (\n rawLog: RawLog | RawLogWithError,\n additionalInformation: {\n userInfo: UserInfo;\n attributes: Attributes;\n }\n): LogEvent => {\n return {\n ...rawLog,\n userInfo: additionalInformation.userInfo,\n attributes: additionalInformation.attributes\n };\n};\n\nexport const generateEventMapper = (\n logEventMapper: LogEventMapper | undefined\n) =>\n new EventMapper(\n logEventMapper,\n formatRawLogToLogEvent,\n formatLogEventToNativeLog,\n formatRawLogToNativeEvent\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<object>;\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 * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: 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<object>;\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 * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: 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 DEBUG level.\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 INFO level.\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 WARN level.\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 ERROR level.\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 * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n debugWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with INDO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n infoWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n warnWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n errorWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): 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 /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: object): 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"]}
|
package/lib/module/rum/DdRum.js
CHANGED
|
@@ -174,6 +174,18 @@ class DdRumWrapper {
|
|
|
174
174
|
return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
stopSession() {
|
|
178
|
+
InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);
|
|
179
|
+
return bufferVoidNativeCall(() => this.nativeRum.stopSession());
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
addFeatureFlagEvaluation(name, value) {
|
|
183
|
+
InternalLog.log(`Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(value)}`, SdkVerbosity.DEBUG);
|
|
184
|
+
return bufferVoidNativeCall(() => this.nativeRum.addFeatureFlagEvaluation(name, {
|
|
185
|
+
value
|
|
186
|
+
}));
|
|
187
|
+
}
|
|
188
|
+
|
|
177
189
|
registerErrorEventMapper(errorEventMapper) {
|
|
178
190
|
this.errorEventMapper = generateErrorEventMapper(errorEventMapper);
|
|
179
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdRum.ts"],"names":["NativeModules","InternalLog","SdkVerbosity","TimeProvider","bufferVoidNativeCall","DdSdk","generateActionEventMapper","generateErrorEventMapper","generateResourceEventMapper","timeProvider","generateEmptyPromise","Promise","resolve","DdRumWrapper","DdRum","undefined","type","name","context","timestampMs","mappedEvent","actionEventMapper","applyEventMapper","nativeRum","stopAction","args","isNewStopActionAPI","now","isOldStopActionAPI","lastActionData","telemetryDebug","log","WARN","startView","key","DEBUG","stopView","startAction","nativeCallArgs","getStopActionNativeCallArgs","callNativeStopAction","addAction","actionContext","startResource","method","url","stopResource","statusCode","kind","size","resourceContext","resourceEventMapper","addError","message","source","stacktrace","errorEventMapper","updatedContext","addTiming","registerErrorEventMapper","unregisterErrorEventMapper","registerResourceEventMapper","unregisterResourceEventMapper","registerActionEventMapper","unregisterActionEventMapper"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SAASC,oBAAT,QAAqC,gDAArC;AACA,SAASC,KAAT,QAAsB,cAAtB;AAGA,SAASC,yBAAT,QAA0C,kCAA1C;AAEA,SAASC,wBAAT,QAAyC,iCAAzC;AAEA,SAASC,2BAAT,QAA4C,oCAA5C;AAQA,MAAMC,YAAY,GAAG,IAAIN,YAAJ,EAArB;;AAEA,MAAMO,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;;AAEA,MAAMC,YAAN,CAAwC;AAAA;AAAA,uCACCb,aAAa,CAACc,KADf;;AAAA;;AAAA,8CAGTP,wBAAwB,CAACQ,SAAD,CAHf;;AAAA,iDAINP,2BAA2B,CAACO,SAAD,CAJrB;;AAAA,+CAKRT,yBAAyB,CAACS,SAAD,CALjB;;AAAA,kDAoEL,CAC3BC,IAD2B,EAE3BC,IAF2B,EAG3BC,OAH2B,EAI3BC,WAJ2B,KAKX;AAChB,YAAMC,WAAW,GAAG,KAAKC,iBAAL,CAAuBC,gBAAvB,CAAwC;AACxDN,QAAAA,IADwD;AAExDC,QAAAA,IAFwD;AAGxDC,QAAAA,OAHwD;AAIxDC,QAAAA;AAJwD,OAAxC,CAApB;;AAMA,UAAI,CAACC,WAAL,EAAkB;AACd,eAAOhB,oBAAoB,CAAC,MACxB,KAAKmB,SAAL,CAAeC,UAAf,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G;AAC5B,SAAKX,mBAAL,GAA2B3C,2BAA2B,CAACO,SAAD,CAAtD;AACH;;AAEDgD,EAAAA,yBAAyB,CAAC1C,iBAAD,EAAuC;AAC5D,SAAKA,iBAAL,GAAyBf,yBAAyB,CAACe,iBAAD,CAAlD;AACH;;AAED2C,EAAAA,2BAA2B,GAAG;AAC1B,SAAK3C,iBAAL,GAAyBf,yBAAyB,CAACS,SAAD,CAAlD;AACH;;AA/TmC;;AAkUxC,MAAMW,kBAAkB,GACpBD,IADuB,IActB;AACD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAA1B;AACH,CAhBD;;AAkBA,MAAMG,kBAAkB,GACpBH,IADuB,IAS4B;AACnD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+B,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,WAAzD;AACH,CAXD;;AAaA,OAAO,MAAMX,KAAK,GAAG,IAAID,YAAJ,EAAd","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 { GestureResponderEvent } from 'react-native';\nimport { NativeModules } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport { TimeProvider } from '../TimeProvider';\nimport type { DdNativeRumType } from '../nativeModulesTypes';\nimport { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport { DdSdk } from '../sdk/DdSdk';\n\nimport type { ActionEventMapper } from './eventMappers/actionEventMapper';\nimport { generateActionEventMapper } from './eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './eventMappers/errorEventMapper';\nimport { generateErrorEventMapper } from './eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport { generateResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport type {\n DdRumType,\n RumActionType,\n ResourceKind,\n ErrorSource\n} from './types';\n\nconst timeProvider = new TimeProvider();\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdRumWrapper implements DdRumType {\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: { type: RumActionType; name: string };\n private errorEventMapper = generateErrorEventMapper(undefined);\n private resourceEventMapper = generateResourceEventMapper(undefined);\n private actionEventMapper = generateActionEventMapper(undefined);\n\n startView(\n key: string,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM View “${name}” #${key}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startView(key, name, context, timestampMs)\n );\n }\n\n stopView(\n key: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopView(key, context, timestampMs)\n );\n }\n\n startAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n this.lastActionData = { type, name };\n return bufferVoidNativeCall(() =>\n this.nativeRum.startAction(type, name, context, timestampMs)\n );\n }\n\n stopAction(\n ...args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ): Promise<void> {\n InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);\n const nativeCallArgs = this.getStopActionNativeCallArgs(args);\n this.lastActionData = undefined;\n if (!nativeCallArgs) {\n return generateEmptyPromise();\n }\n return this.callNativeStopAction(...nativeCallArgs);\n }\n\n private callNativeStopAction = (\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n type,\n name,\n {\n '_dd.action.drop_action': true\n },\n timestampMs\n )\n );\n }\n\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n private getStopActionNativeCallArgs = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ):\n | [\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ]\n | null => {\n if (isNewStopActionAPI(args)) {\n return [\n args[0],\n args[1],\n args[2] || {},\n args[3] || timeProvider.now()\n ];\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug(\n 'DDdRum.stopAction called with the old signature'\n );\n const { type, name } = this.lastActionData;\n return [\n type,\n name,\n args[0] || {},\n args[1] || timeProvider.now()\n ];\n }\n InternalLog.log(\n 'DdRum.startAction needs to be called before DdRum.stopAction',\n SdkVerbosity.WARN\n );\n } else {\n InternalLog.log(\n 'DdRum.stopAction was called with wrong arguments',\n SdkVerbosity.WARN\n );\n }\n\n return null;\n };\n\n addAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n actionContext?: GestureResponderEvent\n ): Promise<void> {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs,\n actionContext\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(\n `Adding RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n startResource(\n key: string,\n method: string,\n url: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Resource #${key} ${method}: ${url}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startResource(key, method, url, context, timestampMs)\n );\n }\n\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number = -1,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n resourceContext?: XMLHttpRequest\n ): Promise<void> {\n const mappedEvent = this.resourceEventMapper.applyEventMapper({\n key,\n statusCode,\n kind,\n size,\n context,\n timestampMs,\n resourceContext\n });\n if (!mappedEvent) {\n /**\n * To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.\n * It will be picked up by the resource mappers we implement on the native side that will drop the resource.\n * This ensures we don't have any \"started\" resource left in memory on the native side.\n */\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n key,\n statusCode,\n kind,\n size,\n {\n '_dd.resource.drop_resource': true\n },\n timestampMs\n )\n );\n }\n\n InternalLog.log(\n `Stopping RUM Resource #${key} status:${statusCode}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n mappedEvent.key,\n mappedEvent.statusCode,\n mappedEvent.kind,\n mappedEvent.size,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n const mappedEvent = this.errorEventMapper.applyEventMapper({\n message,\n source,\n stacktrace,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);\n const updatedContext: any = mappedEvent.context;\n updatedContext['_dd.error.source_type'] = 'react-native';\n return bufferVoidNativeCall(() =>\n this.nativeRum.addError(\n mappedEvent.message,\n mappedEvent.source,\n mappedEvent.stacktrace,\n updatedContext,\n mappedEvent.timestampMs\n )\n );\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\n `Adding timing “${name}” to RUM View`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n\n registerErrorEventMapper(errorEventMapper: ErrorEventMapper) {\n this.errorEventMapper = generateErrorEventMapper(errorEventMapper);\n }\n\n unregisterErrorEventMapper() {\n this.errorEventMapper = generateErrorEventMapper(undefined);\n }\n\n registerResourceEventMapper(resourceEventMapper: ResourceEventMapper) {\n this.resourceEventMapper = generateResourceEventMapper(\n resourceEventMapper\n );\n }\n\n unregisterResourceEventMapper() {\n this.resourceEventMapper = generateResourceEventMapper(undefined);\n }\n\n registerActionEventMapper(actionEventMapper: ActionEventMapper) {\n this.actionEventMapper = generateActionEventMapper(actionEventMapper);\n }\n\n unregisterActionEventMapper() {\n this.actionEventMapper = generateActionEventMapper(undefined);\n }\n}\n\nconst isNewStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n] => {\n return typeof args[0] === 'string';\n};\n\nconst isOldStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined';\n};\n\nexport const DdRum = new DdRumWrapper();\n"]}
|
|
1
|
+
{"version":3,"sources":["DdRum.ts"],"names":["NativeModules","InternalLog","SdkVerbosity","TimeProvider","bufferVoidNativeCall","DdSdk","generateActionEventMapper","generateErrorEventMapper","generateResourceEventMapper","timeProvider","generateEmptyPromise","Promise","resolve","DdRumWrapper","DdRum","undefined","type","name","context","timestampMs","mappedEvent","actionEventMapper","applyEventMapper","nativeRum","stopAction","args","isNewStopActionAPI","now","isOldStopActionAPI","lastActionData","telemetryDebug","log","WARN","startView","key","DEBUG","stopView","startAction","nativeCallArgs","getStopActionNativeCallArgs","callNativeStopAction","addAction","actionContext","startResource","method","url","stopResource","statusCode","kind","size","resourceContext","resourceEventMapper","addError","message","source","stacktrace","errorEventMapper","updatedContext","addTiming","stopSession","addFeatureFlagEvaluation","value","JSON","stringify","registerErrorEventMapper","unregisterErrorEventMapper","registerResourceEventMapper","unregisterResourceEventMapper","registerActionEventMapper","unregisterActionEventMapper"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SAASC,oBAAT,QAAqC,gDAArC;AACA,SAASC,KAAT,QAAsB,cAAtB;AAGA,SAASC,yBAAT,QAA0C,kCAA1C;AAEA,SAASC,wBAAT,QAAyC,iCAAzC;AAEA,SAASC,2BAAT,QAA4C,oCAA5C;AAQA,MAAMC,YAAY,GAAG,IAAIN,YAAJ,EAArB;;AAEA,MAAMO,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;;AAEA,MAAMC,YAAN,CAAwC;AAAA;AAAA,uCACCb,aAAa,CAACc,KADf;;AAAA;;AAAA,8CAGTP,wBAAwB,CAACQ,SAAD,CAHf;;AAAA,iDAINP,2BAA2B,CAACO,SAAD,CAJrB;;AAAA,+CAKRT,yBAAyB,CAACS,SAAD,CALjB;;AAAA,kDAoEL,CAC3BC,IAD2B,EAE3BC,IAF2B,EAG3BC,OAH2B,EAI3BC,WAJ2B,KAKX;AAChB,YAAMC,WAAW,GAAG,KAAKC,iBAAL,CAAuBC,gBAAvB,CAAwC;AACxDN,QAAAA,IADwD;AAExDC,QAAAA,IAFwD;AAGxDC,QAAAA,OAHwD;AAIxDC,QAAAA;AAJwD,OAAxC,CAApB;;AAMA,UAAI,CAACC,WAAL,EAAkB;AACd,eAAOhB,oBAAoB,CAAC,MACxB,KAAKm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AI,CAACC,SAAL,CAC5DF,KAD4D,CAE9D,EAHN,EAII3D,YAAY,CAACiC,KAJjB;AAMA,WAAO/B,oBAAoB,CAAC,MACxB,KAAKmB,SAAL,CAAeqC,wBAAf,CAAwC3C,IAAxC,EAA8C;AAAE4C,MAAAA;AAAF,KAA9C,CADuB,CAA3B;AAGH;;AAEDG,EAAAA,wBAAwB,CAACR,gBAAD,EAAqC;AACzD,SAAKA,gBAAL,GAAwBjD,wBAAwB,CAACiD,gBAAD,CAAhD;AACH;;AAEDS,EAAAA,0BAA0B,GAAG;AACzB,SAAKT,gBAAL,GAAwBjD,wBAAwB,CAACQ,SAAD,CAAhD;AACH;;AAEDmD,EAAAA,2BAA2B,CAACf,mBAAD,EAA2C;AAClE,SAAKA,mBAAL,GAA2B3C,2BAA2B,CAClD2C,mBADkD,CAAtD;AAGH;;AAEDgB,EAAAA,6BAA6B,GAAG;AAC5B,SAAKhB,mBAAL,GAA2B3C,2BAA2B,CAACO,SAAD,CAAtD;AACH;;AAEDqD,EAAAA,yBAAyB,CAAC/C,iBAAD,EAAuC;AAC5D,SAAKA,iBAAL,GAAyBf,yBAAyB,CAACe,iBAAD,CAAlD;AACH;;AAEDgD,EAAAA,2BAA2B,GAAG;AAC1B,SAAKhD,iBAAL,GAAyBf,yBAAyB,CAACS,SAAD,CAAlD;AACH;;AAhVmC;;AAmVxC,MAAMW,kBAAkB,GACpBD,IADuB,IActB;AACD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAA1B;AACH,CAhBD;;AAkBA,MAAMG,kBAAkB,GACpBH,IADuB,IAS4B;AACnD,SAAO,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,QAAnB,IAA+B,OAAOA,IAAI,CAAC,CAAD,CAAX,KAAmB,WAAzD;AACH,CAXD;;AAaA,OAAO,MAAMX,KAAK,GAAG,IAAID,YAAJ,EAAd","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 { GestureResponderEvent } from 'react-native';\nimport { NativeModules } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport { TimeProvider } from '../TimeProvider';\nimport type { DdNativeRumType } from '../nativeModulesTypes';\nimport { bufferVoidNativeCall } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport { DdSdk } from '../sdk/DdSdk';\n\nimport type { ActionEventMapper } from './eventMappers/actionEventMapper';\nimport { generateActionEventMapper } from './eventMappers/actionEventMapper';\nimport type { ErrorEventMapper } from './eventMappers/errorEventMapper';\nimport { generateErrorEventMapper } from './eventMappers/errorEventMapper';\nimport type { ResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport { generateResourceEventMapper } from './eventMappers/resourceEventMapper';\nimport type {\n DdRumType,\n RumActionType,\n ResourceKind,\n ErrorSource\n} from './types';\n\nconst timeProvider = new TimeProvider();\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdRumWrapper implements DdRumType {\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: { type: RumActionType; name: string };\n private errorEventMapper = generateErrorEventMapper(undefined);\n private resourceEventMapper = generateResourceEventMapper(undefined);\n private actionEventMapper = generateActionEventMapper(undefined);\n\n startView(\n key: string,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM View “${name}” #${key}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startView(key, name, context, timestampMs)\n );\n }\n\n stopView(\n key: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(`Stopping RUM View #${key}`, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopView(key, context, timestampMs)\n );\n }\n\n startAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n this.lastActionData = { type, name };\n return bufferVoidNativeCall(() =>\n this.nativeRum.startAction(type, name, context, timestampMs)\n );\n }\n\n stopAction(\n ...args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ): Promise<void> {\n InternalLog.log('Stopping current RUM Action', SdkVerbosity.DEBUG);\n const nativeCallArgs = this.getStopActionNativeCallArgs(args);\n this.lastActionData = undefined;\n if (!nativeCallArgs) {\n return generateEmptyPromise();\n }\n return this.callNativeStopAction(...nativeCallArgs);\n }\n\n private callNativeStopAction = (\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ): Promise<void> => {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n type,\n name,\n {\n '_dd.action.drop_action': true\n },\n timestampMs\n )\n );\n }\n\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n };\n\n private getStopActionNativeCallArgs = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n ):\n | [\n type: RumActionType,\n name: string,\n context: object,\n timestampMs: number\n ]\n | null => {\n if (isNewStopActionAPI(args)) {\n return [\n args[0],\n args[1],\n args[2] || {},\n args[3] || timeProvider.now()\n ];\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug(\n 'DDdRum.stopAction called with the old signature'\n );\n const { type, name } = this.lastActionData;\n return [\n type,\n name,\n args[0] || {},\n args[1] || timeProvider.now()\n ];\n }\n InternalLog.log(\n 'DdRum.startAction needs to be called before DdRum.stopAction',\n SdkVerbosity.WARN\n );\n } else {\n InternalLog.log(\n 'DdRum.stopAction was called with wrong arguments',\n SdkVerbosity.WARN\n );\n }\n\n return null;\n };\n\n addAction(\n type: RumActionType,\n name: string,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n actionContext?: GestureResponderEvent\n ): Promise<void> {\n const mappedEvent = this.actionEventMapper.applyEventMapper({\n type,\n name,\n context,\n timestampMs,\n actionContext\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(\n `Adding RUM Action “${name}” (${type})`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addAction(\n mappedEvent.type,\n mappedEvent.name,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n startResource(\n key: string,\n method: string,\n url: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n InternalLog.log(\n `Starting RUM Resource #${key} ${method}: ${url}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.startResource(key, method, url, context, timestampMs)\n );\n }\n\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size: number = -1,\n context: object = {},\n timestampMs: number = timeProvider.now(),\n resourceContext?: XMLHttpRequest\n ): Promise<void> {\n const mappedEvent = this.resourceEventMapper.applyEventMapper({\n key,\n statusCode,\n kind,\n size,\n context,\n timestampMs,\n resourceContext\n });\n if (!mappedEvent) {\n /**\n * To drop the resource we call `stopResource` and pass the `_dd.drop_resource` attribute in the context.\n * It will be picked up by the resource mappers we implement on the native side that will drop the resource.\n * This ensures we don't have any \"started\" resource left in memory on the native side.\n */\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n key,\n statusCode,\n kind,\n size,\n {\n '_dd.resource.drop_resource': true\n },\n timestampMs\n )\n );\n }\n\n InternalLog.log(\n `Stopping RUM Resource #${key} status:${statusCode}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.stopResource(\n mappedEvent.key,\n mappedEvent.statusCode,\n mappedEvent.kind,\n mappedEvent.size,\n mappedEvent.context,\n mappedEvent.timestampMs\n )\n );\n }\n\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> {\n const mappedEvent = this.errorEventMapper.applyEventMapper({\n message,\n source,\n stacktrace,\n context,\n timestampMs\n });\n if (!mappedEvent) {\n return generateEmptyPromise();\n }\n InternalLog.log(`Adding RUM Error “${message}”`, SdkVerbosity.DEBUG);\n const updatedContext: any = mappedEvent.context;\n updatedContext['_dd.error.source_type'] = 'react-native';\n return bufferVoidNativeCall(() =>\n this.nativeRum.addError(\n mappedEvent.message,\n mappedEvent.source,\n mappedEvent.stacktrace,\n updatedContext,\n mappedEvent.timestampMs\n )\n );\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\n `Adding timing “${name}” to RUM View`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n\n stopSession(): Promise<void> {\n InternalLog.log('Stopping RUM Session', SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopSession());\n }\n\n addFeatureFlagEvaluation(name: string, value: unknown): Promise<void> {\n InternalLog.log(\n `Adding feature flag evaluation for name: ${name} with value: ${JSON.stringify(\n value\n )}`,\n SdkVerbosity.DEBUG\n );\n return bufferVoidNativeCall(() =>\n this.nativeRum.addFeatureFlagEvaluation(name, { value })\n );\n }\n\n registerErrorEventMapper(errorEventMapper: ErrorEventMapper) {\n this.errorEventMapper = generateErrorEventMapper(errorEventMapper);\n }\n\n unregisterErrorEventMapper() {\n this.errorEventMapper = generateErrorEventMapper(undefined);\n }\n\n registerResourceEventMapper(resourceEventMapper: ResourceEventMapper) {\n this.resourceEventMapper = generateResourceEventMapper(\n resourceEventMapper\n );\n }\n\n unregisterResourceEventMapper() {\n this.resourceEventMapper = generateResourceEventMapper(undefined);\n }\n\n registerActionEventMapper(actionEventMapper: ActionEventMapper) {\n this.actionEventMapper = generateActionEventMapper(actionEventMapper);\n }\n\n unregisterActionEventMapper() {\n this.actionEventMapper = generateActionEventMapper(undefined);\n }\n}\n\nconst isNewStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n] => {\n return typeof args[0] === 'string';\n};\n\nconst isOldStopActionAPI = (\n args:\n | [\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ]\n | [context?: object, timestampMs?: number]\n): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined';\n};\n\nexport const DdRum = new DdRumWrapper();\n"]}
|
|
@@ -7,7 +7,8 @@ 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
|
+
import { getErrorMessage, getErrorStackTrace, EMPTY_STACK_TRACE, getErrorName, DEFAULT_ERROR_NAME } from '../../errorUtils';
|
|
11
|
+
import { DdLogs } from '../../logs/DdLogs';
|
|
11
12
|
import { DdRum } from '../DdRum';
|
|
12
13
|
import { ErrorSource } from '../types';
|
|
13
14
|
/**
|
|
@@ -38,62 +39,78 @@ export class DdRumErrorTracking {
|
|
|
38
39
|
} else {
|
|
39
40
|
InternalLog.log('Datadog SDK cannot track errors, ErrorUtils is not defined', SdkVerbosity.ERROR);
|
|
40
41
|
}
|
|
41
|
-
} // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
static onGlobalError(error, isFatal) {
|
|
45
|
-
const message = getErrorMessage(error);
|
|
46
|
-
const stacktrace = getErrorStackTrace(error);
|
|
47
|
-
DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {
|
|
48
|
-
'_dd.error.is_crash': isFatal,
|
|
49
|
-
'_dd.error.raw': error
|
|
50
|
-
}).then(() => {
|
|
51
|
-
DdRumErrorTracking.isInDefaultErrorHandler = true;
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
DdRumErrorTracking.defaultErrorHandler(error, isFatal);
|
|
55
|
-
} finally {
|
|
56
|
-
DdRumErrorTracking.isInDefaultErrorHandler = false;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
42
|
}
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
if (DdRumErrorTracking.isInDefaultErrorHandler) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
44
|
+
}
|
|
65
45
|
|
|
66
|
-
|
|
46
|
+
_defineProperty(DdRumErrorTracking, "isTracking", false);
|
|
67
47
|
|
|
68
|
-
|
|
69
|
-
const param = params[i];
|
|
70
|
-
const paramStack = getErrorStackTrace(param);
|
|
48
|
+
_defineProperty(DdRumErrorTracking, "isInDefaultErrorHandler", false);
|
|
71
49
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
_defineProperty(DdRumErrorTracking, "defaultErrorHandler", (_error, _isFatal) => {});
|
|
51
|
+
|
|
52
|
+
_defineProperty(DdRumErrorTracking, "defaultConsoleError", (..._params) => {});
|
|
53
|
+
|
|
54
|
+
_defineProperty(DdRumErrorTracking, "onGlobalError", (error, isFatal) => {
|
|
55
|
+
const message = getErrorMessage(error);
|
|
56
|
+
const stacktrace = getErrorStackTrace(error);
|
|
57
|
+
const errorName = getErrorName(error);
|
|
58
|
+
DdRumErrorTracking.reportError(message, ErrorSource.SOURCE, stacktrace, errorName, {
|
|
59
|
+
'_dd.error.is_crash': isFatal,
|
|
60
|
+
'_dd.error.raw': error
|
|
61
|
+
}).then(() => {
|
|
62
|
+
DdRumErrorTracking.isInDefaultErrorHandler = true;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
DdRumErrorTracking.defaultErrorHandler(error, isFatal);
|
|
66
|
+
} finally {
|
|
67
|
+
DdRumErrorTracking.isInDefaultErrorHandler = false;
|
|
76
68
|
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
77
71
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} else {
|
|
82
|
-
return getErrorMessage(param);
|
|
83
|
-
}
|
|
84
|
-
}).join(' ');
|
|
85
|
-
DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {
|
|
86
|
-
DdRumErrorTracking.defaultConsoleError.apply(console, params);
|
|
87
|
-
});
|
|
72
|
+
_defineProperty(DdRumErrorTracking, "onConsoleError", (...params) => {
|
|
73
|
+
if (DdRumErrorTracking.isInDefaultErrorHandler) {
|
|
74
|
+
return;
|
|
88
75
|
}
|
|
89
76
|
|
|
90
|
-
|
|
77
|
+
let stack = EMPTY_STACK_TRACE;
|
|
78
|
+
let errorName = DEFAULT_ERROR_NAME;
|
|
91
79
|
|
|
92
|
-
|
|
80
|
+
for (let i = 0; i < params.length; i += 1) {
|
|
81
|
+
const param = params[i];
|
|
82
|
+
const paramStack = getErrorStackTrace(param);
|
|
93
83
|
|
|
94
|
-
|
|
84
|
+
if (paramStack !== EMPTY_STACK_TRACE) {
|
|
85
|
+
stack = paramStack;
|
|
86
|
+
}
|
|
95
87
|
|
|
96
|
-
|
|
88
|
+
const paramErrorName = getErrorName(param);
|
|
97
89
|
|
|
98
|
-
|
|
90
|
+
if (paramErrorName !== DEFAULT_ERROR_NAME) {
|
|
91
|
+
errorName = paramErrorName;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (errorName !== DEFAULT_ERROR_NAME && stack !== EMPTY_STACK_TRACE) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const message = params.map(param => {
|
|
100
|
+
if (typeof param === 'string') {
|
|
101
|
+
return param;
|
|
102
|
+
} else {
|
|
103
|
+
return getErrorMessage(param);
|
|
104
|
+
}
|
|
105
|
+
}).join(' ');
|
|
106
|
+
DdRumErrorTracking.reportError(message, ErrorSource.CONSOLE, stack, errorName).then(() => {
|
|
107
|
+
DdRumErrorTracking.defaultConsoleError.apply(console, params);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
_defineProperty(DdRumErrorTracking, "reportError", (message, source, stacktrace, errorName, context = {}) => {
|
|
112
|
+
return Promise.all([DdRum.addError(message, source, stacktrace, context), DdLogs.error(message, errorName, message, stacktrace, { ...context,
|
|
113
|
+
'_dd.error_log.is_crash': true
|
|
114
|
+
})]);
|
|
115
|
+
});
|
|
99
116
|
//# sourceMappingURL=DdRumErrorTracking.js.map
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
1
|
+
{"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["InternalLog","SdkVerbosity","getErrorMessage","getErrorStackTrace","EMPTY_STACK_TRACE","getErrorName","DEFAULT_ERROR_NAME","DdLogs","DdRum","ErrorSource","DdRumErrorTracking","startTracking","isTracking","log","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","_error","_isFatal","_params","isFatal","message","stacktrace","errorName","reportError","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","paramErrorName","map","join","CONSOLE","apply","source","context","Promise","all","addError"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAI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H;;AAED,QACIX,SAAS,KAAK1B,kBAAd,IACAgC,KAAK,KAAKlC,iBAFd,EAGE;AACE;AACH;AACJ;;AAED,QAAM0B,OAAO,GAAGO,MAAM,CACjBO,GADW,CACPH,KAAK,IAAI;AACV,QAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC3B,aAAOA,KAAP;AACH,KAFD,MAEO;AACH,aAAOvC,eAAe,CAACuC,KAAD,CAAtB;AACH;AACJ,GAPW,EAQXI,IARW,CAQN,GARM,CAAhB;AAzFKnC,EAAAA,kBAmGL,CAAKuB,WAAL,CAAiBH,OAAjB,EAA0BrB,WAAW,CAACqC,OAAtC,EAA+CR,KAA/C,EAAsDN,SAAtD,EAAiEG,IAAjE,CACI,MAAM;AACFzB,IAAAA,kBAAkB,CAACQ,mBAAnB,CAAuC6B,KAAvC,CAA6C5B,OAA7C,EAAsDkB,MAAtD;AACH,GAHL;AAKH,C;;gBAxGQ3B,kB,iBA0GoB,CACzBoB,OADyB,EAEzBkB,MAFyB,EAGzBjB,UAHyB,EAIzBC,SAJyB,EAKzBiB,OAAe,GAAG,EALO,KAMD;AACxB,SAAOC,OAAO,CAACC,GAAR,CAAY,CACf3C,KAAK,CAAC4C,QAAN,CAAetB,OAAf,EAAwBkB,MAAxB,EAAgCjB,UAAhC,EAA4CkB,OAA5C,CADe,EAEf1C,MAAM,CAACa,KAAP,CAAaU,OAAb,EAAsBE,SAAtB,EAAiCF,OAAjC,EAA0CC,UAA1C,EAAsD,EAClD,GAAGkB,OAD+C;AAElD,8BAA0B;AAFwB,GAAtD,CAFe,CAAZ,CAAP;AAOH,C","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 getErrorName,\n DEFAULT_ERROR_NAME\n} from '../../errorUtils';\nimport { DdLogs } from '../../logs/DdLogs';\nimport { DdRum } from '../DdRum';\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 static onGlobalError = (error: any, isFatal?: boolean): void => {\n const message = getErrorMessage(error);\n const stacktrace = getErrorStackTrace(error);\n const errorName = getErrorName(error);\n this.reportError(message, ErrorSource.SOURCE, stacktrace, errorName, {\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 let errorName: string = DEFAULT_ERROR_NAME;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n\n const paramStack = getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n }\n\n const paramErrorName = getErrorName(param);\n if (paramErrorName !== DEFAULT_ERROR_NAME) {\n errorName = paramErrorName;\n }\n\n if (\n errorName !== DEFAULT_ERROR_NAME &&\n stack !== EMPTY_STACK_TRACE\n ) {\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 this.reportError(message, ErrorSource.CONSOLE, stack, errorName).then(\n () => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n }\n );\n };\n\n private static reportError = (\n message: string,\n source: ErrorSource,\n stacktrace: string,\n errorName: string,\n context: object = {}\n ): Promise<[void, void]> => {\n return Promise.all([\n DdRum.addError(message, source, stacktrace, context),\n DdLogs.error(message, errorName, message, stacktrace, {\n ...context,\n '_dd.error_log.is_crash': true\n })\n ]);\n };\n}\n"]}
|
|
@@ -30,7 +30,7 @@ export class DdEventsInterceptor {
|
|
|
30
30
|
this.debouncingStartedTimestamp = currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;
|
|
31
31
|
}
|
|
32
32
|
} else {
|
|
33
|
-
InternalLog.log(DdEventsInterceptor.
|
|
33
|
+
InternalLog.log(DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE, SdkVerbosity.DEBUG);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -90,5 +90,5 @@ export class DdEventsInterceptor {
|
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
_defineProperty(DdEventsInterceptor, "
|
|
93
|
+
_defineProperty(DdEventsInterceptor, "ACTION_EVENT_DROPPED_DEBUG_MESSAGE", 'An action event was dropped because either the `onPress` method arguments' + ' were undefined or they were missing the target information.' + ' This log can happen if you use an abstraction component with an `onPress` prop' + ' that does not receive the native event is first argument.' + ' In this case, you can ignore this log.');
|
|
94
94
|
//# sourceMappingURL=DdEventsInterceptor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","RumActionType","UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","log","
|
|
1
|
+
{"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","RumActionType","UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","log","ACTION_EVENT_DROPPED_DEBUG_MESSAGE","DEBUG","event","resolvedTargetName","resolveTargetName","addAction","TAP","undefined","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,WAAT,QAA4B,sBAA5B;AACA,SAASC,YAAT,QAA6B,uBAA7B;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,aAAT,QAA8B,aAA9B;AAIA,OAAO,MAAMC,mBAAmB,GAAG,gBAA5B;AACP,MAAMC,8BAA8B,GAAG,EAAvC;AACA,MAAMC,qCAAq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;;AACA,QAAIW,kBAAkB,IAAI,IAA1B,EAAgC;AAC5B,aAAOA,kBAAP;AACH;;AACD,UAAME,kBAAkB,4BAAGb,UAAU,CAACc,aAAd,0DAAG,sBAA0BD,kBAArD;;AACA,QAAIA,kBAAkB,IAAI,IAA1B,EAAgC;AAC5B,aAAOA,kBAAP;AACH;;AACD,UAAME,eAAe,GAAG,KAAKC,sBAAL,CACpBhB,UAAU,CAACiB,WADS,CAAxB;AAGA,WAAOF,eAAe,IAAIjC,mBAA1B;AACH;;AAEOkC,EAAAA,sBAAsB,CAACC,WAAD,EAAkC;AAC5D,QAAIF,eAAe,GAAG,IAAtB;;AACA,QAAI,OAAOE,WAAP,KAAuB,QAA3B,EAAqC;AACjCF,MAAAA,eAAe,GAAGE,WAAlB;AACH,KAFD,MAEO,IAAIA,WAAW,IAAI,OAAOA,WAAW,CAACC,IAAnB,KAA4B,QAA/C,EAAyD;AAC5DH,MAAAA,eAAe,GAAGE,WAAW,CAACC,IAA9B;AACH;;AACD,WAAOH,eAAP;AACH;;AAEOH,EAAAA,sBAAsB,CAACZ,UAAD,EAAiC;AAC3D,QAAImB,WAAW,GAAGnB,UAAlB;;AACA,WAAOmB,WAAP,EAAoB;AAChB,YAAMC,KAAK,GAAGD,WAAW,CAACL,aAA1B;;AACA,UAAIM,KAAK,IAAIA,KAAK,CAACnC,mBAAD,CAAlB,EAAyC;AACrC,eAAOmC,KAAK,CAACnC,mBAAD,CAAZ;AACH;;AACDkC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AA/EyD;;gBAAjDnC,mB,wCAEL,8EACA,8DADA,GAEA,iFAFA,GAGA,4DAHA,GAIA,yC","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 { GestureResponderEvent } from 'react-native';\n\nimport { InternalLog } from '../../../InternalLog';\nimport { SdkVerbosity } from '../../../SdkVerbosity';\nimport { DdRum } from '../../DdRum';\nimport { RumActionType } from '../../types';\n\nimport type EventsInterceptor from './EventsInterceptor';\n\nexport const UNKNOWN_TARGET_NAME = 'unknown_target';\nconst DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;\nconst HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;\nconst DD_ACTION_NAME_PROP = 'dd-action-name';\n\nexport class DdEventsInterceptor implements EventsInterceptor {\n static ACTION_EVENT_DROPPED_DEBUG_MESSAGE =\n 'An action event was dropped because either the `onPress` method arguments' +\n ' were undefined or they were missing the target information.' +\n ' This log can happen if you use an abstraction component with an `onPress` prop' +\n ' that does not receive the native event is first argument.' +\n ' In this case, you can ignore this log.';\n\n private debouncingStartedTimestamp = Number.MIN_VALUE;\n\n interceptOnPress(...args: any[]): void {\n if (args.length > 0 && args[0] && args[0]._targetInst) {\n const currentTime = Date.now();\n const timestampDifference = Math.abs(\n Date.now() - this.debouncingStartedTimestamp\n );\n if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {\n const targetNode = args[0]._targetInst;\n this.handleTargetEvent(targetNode, args[0]);\n // we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function\n this.debouncingStartedTimestamp =\n currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;\n }\n } else {\n InternalLog.log(\n DdEventsInterceptor.ACTION_EVENT_DROPPED_DEBUG_MESSAGE,\n SdkVerbosity.DEBUG\n );\n }\n }\n\n private handleTargetEvent(targetNode: any, event: unknown) {\n if (targetNode) {\n const resolvedTargetName = this.resolveTargetName(targetNode);\n DdRum.addAction(\n RumActionType.TAP,\n resolvedTargetName,\n {},\n undefined,\n event as GestureResponderEvent\n );\n }\n }\n\n private resolveTargetName(targetNode: any): string {\n const closestActionLabel = this.findClosestActionLabel(targetNode);\n if (closestActionLabel != null) {\n return closestActionLabel;\n }\n const accessibilityLabel = targetNode.memoizedProps?.accessibilityLabel;\n if (accessibilityLabel != null) {\n return accessibilityLabel;\n }\n const elementTypeName = this.resolveElementTypeName(\n targetNode.elementType\n );\n return elementTypeName || UNKNOWN_TARGET_NAME;\n }\n\n private resolveElementTypeName(elementType: any): string | null {\n let elementTypeName = null;\n if (typeof elementType === 'string') {\n elementTypeName = elementType;\n } else if (elementType && typeof elementType.name === 'string') {\n elementTypeName = elementType.name;\n }\n return elementTypeName;\n }\n\n private findClosestActionLabel(targetNode: any): string | null {\n let currentNode = targetNode;\n while (currentNode) {\n const props = currentNode.memoizedProps;\n if (props && props[DD_ACTION_NAME_PROP]) {\n return props[DD_ACTION_NAME_PROP];\n }\n currentNode = currentNode.return;\n }\n return null;\n }\n}\n"]}
|
|
@@ -5,9 +5,17 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Does a shallow comparison between 2 objects
|
|
8
|
+
* Does a shallow comparison between 2 objects.
|
|
9
|
+
*
|
|
10
|
+
* In some rare cases, one of the objects can be `undefined` or `null`.
|
|
11
|
+
* This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.
|
|
9
12
|
*/
|
|
10
13
|
export const areObjectShallowEqual = (objectA, objectB) => {
|
|
14
|
+
// Handle edge case when one object is `undefined` or `null`
|
|
15
|
+
if (!objectA || !objectB) {
|
|
16
|
+
return objectA === objectB;
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
const keys = Object.keys(objectA);
|
|
12
20
|
|
|
13
21
|
if (keys.length !== Object.keys(objectB).length) {
|
package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ShallowObjectEqualityChecker.ts"],"names":["areObjectShallowEqual","objectA","objectB","keys","Object","length","key"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,qBAAqB,GAAG,CACjCC,OADiC,EAEjCC,OAFiC,KAGvB;AACV,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYF,OAAZ,CAAb;;AACA,MAAIE,IAAI,CAACE,MAAL,KAAgBD,MAAM,CAACD,IAAP,CAAYD,OAAZ,EAAqBG,MAAzC,EAAiD;AAC7C,WAAO,KAAP;AACH;;AACD,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACpB,QAAIF,OAAO,CAACK,GAAD,CAAP,KAAiBJ,OAAO,CAACI,GAAD,CAA5B,EAAmC;AAC/B,aAAO,KAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,
|
|
1
|
+
{"version":3,"sources":["ShallowObjectEqualityChecker.ts"],"names":["areObjectShallowEqual","objectA","objectB","keys","Object","length","key"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,qBAAqB,GAAG,CACjCC,OADiC,EAEjCC,OAFiC,KAGvB;AACV;AACA,MAAI,CAACD,OAAD,IAAY,CAACC,OAAjB,EAA0B;AACtB,WAAOD,OAAO,KAAKC,OAAnB;AACH;;AAED,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYF,OAAZ,CAAb;;AACA,MAAIE,IAAI,CAACE,MAAL,KAAgBD,MAAM,CAACD,IAAP,CAAYD,OAAZ,EAAqBG,MAAzC,EAAiD;AAC7C,WAAO,KAAP;AACH;;AACD,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACpB,QAAIF,OAAO,CAACK,GAAD,CAAP,KAAiBJ,OAAO,CAACI,GAAD,CAA5B,EAAmC;AAC/B,aAAO,KAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,CAnBM","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 * Does a shallow comparison between 2 objects.\n *\n * In some rare cases, one of the objects can be `undefined` or `null`.\n * This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.\n */\nexport const areObjectShallowEqual = (\n objectA: Record<string, unknown> | undefined | null,\n objectB: Record<string, unknown> | undefined | null\n): boolean => {\n // Handle edge case when one object is `undefined` or `null`\n if (!objectA || !objectB) {\n return objectA === objectB;\n }\n\n const keys = Object.keys(objectA);\n if (keys.length !== Object.keys(objectB).length) {\n return false;\n }\n for (const key of keys) {\n if (objectA[key] !== objectB[key]) {\n return false;\n }\n }\n return true;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["types.ts"],"names":["RumActionType","ErrorSource","PropagatorType"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;
|
|
1
|
+
{"version":3,"sources":["types.ts"],"names":["RumActionType","ErrorSource","PropagatorType"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AA+IA;AACA;AACA;AACA,WAAYA,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;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;WAdYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W;;AAeZ,WAAYC,cAAZ;;WAAYA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;GAAAA,c,KAAAA,c","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 * 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 * Stops the current RUM Session.\n */\n stopSession(): 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\n/**\n * Type of instrumentation on the host.\n * - DATADOG: Datadog’s propagator (`x-datadog-*`)\n * - TRACECONTEXT: W3C Trace Context (`traceparent`)\n * - B3: B3 single header (`b3`)\n * - B3MULTI: B3 multiple headers (`X-B3-*`)\n */\nexport enum PropagatorType {\n DATADOG = 'datadog',\n TRACECONTEXT = 'tracecontext',\n B3 = 'b3',\n B3MULTI = 'b3multi'\n}\n\nexport type FirstPartyHost = {\n match: string;\n propagatorTypes: PropagatorType[];\n};\n"]}
|
package/lib/module/types.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* A configuration object to initialize Datadog's features.
|
|
9
9
|
*/
|
|
10
10
|
export class DdSdkConfiguration {
|
|
11
|
-
constructor(clientToken, env, applicationId, nativeCrashReportEnabled, nativeLongTaskThresholdMs, longTaskThresholdMs, sampleRate, site, trackingConsent, additionalConfig, telemetrySampleRate, vitalsUpdateFrequency, trackFrustrations, configurationForTelemetry) {
|
|
11
|
+
constructor(clientToken, env, applicationId, nativeCrashReportEnabled, nativeLongTaskThresholdMs, longTaskThresholdMs, sampleRate, site, trackingConsent, additionalConfig, telemetrySampleRate, vitalsUpdateFrequency, uploadFrequency, batchSize, trackFrustrations, trackBackgroundEvents, configurationForTelemetry) {
|
|
12
12
|
this.clientToken = clientToken;
|
|
13
13
|
this.env = env;
|
|
14
14
|
this.applicationId = applicationId;
|
|
@@ -21,7 +21,10 @@ export class DdSdkConfiguration {
|
|
|
21
21
|
this.additionalConfig = additionalConfig;
|
|
22
22
|
this.telemetrySampleRate = telemetrySampleRate;
|
|
23
23
|
this.vitalsUpdateFrequency = vitalsUpdateFrequency;
|
|
24
|
+
this.uploadFrequency = uploadFrequency;
|
|
25
|
+
this.batchSize = batchSize;
|
|
24
26
|
this.trackFrustrations = trackFrustrations;
|
|
27
|
+
this.trackBackgroundEvents = trackBackgroundEvents;
|
|
25
28
|
this.configurationForTelemetry = configurationForTelemetry;
|
|
26
29
|
}
|
|
27
30
|
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","configurationForTelemetry"],"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,
|
|
1
|
+
{"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","uploadFrequency","batchSize","trackFrustrations","trackBackgroundEvents","configurationForTelemetry"],"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,eAbF,EAcEC,SAdF,EAeEC,iBAfF,EAgBEC,qBAhBF,EAiBEC,yBAjBF,EAyBT;AAAA,SAxBWhB,WAwBX,GAxBWA,WAwBX;AAAA,SAvBWC,GAuBX,GAvBWA,GAuBX;AAAA,SAtBWC,aAsBX,GAtBWA,aAsBX;AAAA,SArBWC,wBAqBX,GArBWA,wBAqBX;AAAA,SApBWC,yBAoBX,GApBWA,yBAoBX;AAAA,SAnBWC,mBAmBX,GAnBWA,mBAmBX;AAAA,SAlBWC,UAkBX,GAlBWA,UAkBX;AAAA,SAjBWC,IAiBX,GAjBWA,IAiBX;AAAA,SAhBWC,eAgBX,GAhBWA,eAgBX;AAAA,SAfWC,gBAeX,GAfWA,gBAeX;AAAA,SAdWC,mBAcX,GAdWA,mBAcX;AAAA,SAbWC,qBAaX,GAbWA,qBAaX;AAAA,SAZWC,eAYX,GAZWA,eAYX;AAAA,SAXWC,SAWX,GAXWA,SAWX;AAAA,SAVWC,iBAUX,GAVWA,iBAUX;AAAA,SATWC,qBASX,GATWA,qBASX;AAAA,SARWC,yBAQX,GARWA,yBAQX;AAAE;;AA1BwB;AA6BhC;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 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 uploadFrequency: string,\n readonly batchSize: string,\n readonly trackFrustrations: boolean,\n readonly trackBackgroundEvents: boolean,\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n reactVersion: string;\n reactNativeVersion: string;\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 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"]}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.
|
|
1
|
+
{"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.7.0';\n"]}
|