@datadog/mobile-react-native 1.6.0 → 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.
Files changed (63) hide show
  1. package/DatadogSDKReactNative.podspec +2 -2
  2. package/android/build.gradle +2 -1
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +16 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +28 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +6 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +6 -0
  7. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +17 -0
  8. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +120 -28
  9. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +17 -1
  10. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +15 -0
  11. package/ios/Sources/DdRum.m +5 -0
  12. package/ios/Sources/DdRum.swift +10 -0
  13. package/ios/Sources/DdSdk.swift +38 -0
  14. package/ios/Sources/DdSdkConfiguration.swift +12 -0
  15. package/ios/Sources/RNDdSdkConfiguration.swift +6 -0
  16. package/lib/commonjs/DdSdkReactNative.js +1 -1
  17. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  18. package/lib/commonjs/DdSdkReactNativeConfiguration.js +45 -2
  19. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  20. package/lib/commonjs/index.js +12 -0
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  23. package/lib/commonjs/rum/DdRum.js +8 -0
  24. package/lib/commonjs/rum/DdRum.js.map +1 -1
  25. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -2
  26. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  27. package/lib/commonjs/types.js +4 -1
  28. package/lib/commonjs/types.js.map +1 -1
  29. package/lib/commonjs/version.js +1 -1
  30. package/lib/commonjs/version.js.map +1 -1
  31. package/lib/module/DdSdkReactNative.js +1 -1
  32. package/lib/module/DdSdkReactNative.js.map +1 -1
  33. package/lib/module/DdSdkReactNativeConfiguration.js +42 -1
  34. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  35. package/lib/module/index.js +2 -2
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/module/nativeModulesTypes.js.map +1 -1
  38. package/lib/module/rum/DdRum.js +7 -0
  39. package/lib/module/rum/DdRum.js.map +1 -1
  40. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +4 -2
  41. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  42. package/lib/module/types.js +4 -1
  43. package/lib/module/types.js.map +1 -1
  44. package/lib/module/version.js +1 -1
  45. package/lib/module/version.js.map +1 -1
  46. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +47 -0
  47. package/lib/typescript/index.d.ts +2 -2
  48. package/lib/typescript/nativeModulesTypes.d.ts +7 -0
  49. package/lib/typescript/rum/DdRum.d.ts +1 -0
  50. package/lib/typescript/types.d.ts +4 -1
  51. package/lib/typescript/version.d.ts +1 -1
  52. package/package.json +2 -2
  53. package/src/DdSdkReactNative.tsx +3 -0
  54. package/src/DdSdkReactNativeConfiguration.tsx +56 -1
  55. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +20 -3
  56. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +47 -25
  57. package/src/index.tsx +6 -2
  58. package/src/nativeModulesTypes.ts +8 -0
  59. package/src/rum/DdRum.ts +12 -0
  60. package/src/rum/instrumentation/DdRumErrorTracking.tsx +5 -2
  61. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +3 -0
  62. package/src/types.tsx +3 -0
  63. package/src/version.ts +1 -1
@@ -108,7 +108,9 @@ _defineProperty(DdRumErrorTracking, "onConsoleError", (...params) => {
108
108
  });
109
109
  });
110
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)]);
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
+ })]);
113
115
  });
114
116
  //# sourceMappingURL=DdRumErrorTracking.js.map
@@ -1 +1 @@
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;AAIA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SACIC,eADJ,EAEIC,kBAFJ,EAGIC,iBAHJ,EAIIC,YAJJ,EAKIC,kBALJ,QAMO,kBANP;AAOA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,WAAT,QAA4B,UAA5B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BZ,MAAAA,WAAW,C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sDN,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,OALyB,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,EAAsDkB,OAAtD,CAFe,CAAZ,CAAP;AAIH,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, context)\n ]);\n };\n}\n"]}
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;AAIA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SACIC,eADJ,EAEIC,kBAFJ,EAGIC,iBAHJ,EAIIC,YAJJ,EAKIC,kBALJ,QAMO,kBANP;AAOA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,WAAT,QAA4B,UAA5B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BZ,MAAAA,WAAW,CAACa,GAAZ,CACI,wCADJ,EAEIZ,YAAY,CAACa,IAFjB;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZL,MAAAA,kBAAkB,CAACM,mBAAnB,GAAyCD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AHL;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"]}
@@ -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
 
@@ -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,iBAbF,EAcEC,yBAdF,EAsBT;AAAA,SArBWb,WAqBX,GArBWA,WAqBX;AAAA,SApBWC,GAoBX,GApBWA,GAoBX;AAAA,SAnBWC,aAmBX,GAnBWA,aAmBX;AAAA,SAlBWC,wBAkBX,GAlBWA,wBAkBX;AAAA,SAjBWC,yBAiBX,GAjBWA,yBAiBX;AAAA,SAhBWC,mBAgBX,GAhBWA,mBAgBX;AAAA,SAfWC,UAeX,GAfWA,UAeX;AAAA,SAdWC,IAcX,GAdWA,IAcX;AAAA,SAbWC,eAaX,GAbWA,eAaX;AAAA,SAZWC,gBAYX,GAZWA,gBAYX;AAAA,SAXWC,mBAWX,GAXWA,mBAWX;AAAA,SAVWC,qBAUX,GAVWA,qBAUX;AAAA,SATWC,iBASX,GATWA,iBASX;AAAA,SARWC,yBAQX,GARWA,yBAQX;AAAE;;AAvBwB;AA0BhC;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 trackFrustrations: 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"]}
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"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '1.6.0';
2
+ export const version = '1.7.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -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.6.0';\n"]}
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"]}
@@ -12,6 +12,34 @@ export declare enum VitalsUpdateFrequency {
12
12
  RARE = "RARE",
13
13
  NEVER = "NEVER"
14
14
  }
15
+ export declare enum UploadFrequency {
16
+ /**
17
+ * Upload data every 1000ms.
18
+ */
19
+ FREQUENT = "FREQUENT",
20
+ /**
21
+ * Upload data every 5000ms.
22
+ */
23
+ AVERAGE = "AVERAGE",
24
+ /**
25
+ * Upload data every 10000ms.
26
+ */
27
+ RARE = "RARE"
28
+ }
29
+ export declare enum BatchSize {
30
+ /**
31
+ * Upload less frequent, larger batches of data
32
+ */
33
+ LARGE = "LARGE",
34
+ /**
35
+ * Use default size for batches of data
36
+ */
37
+ MEDIUM = "MEDIUM",
38
+ /**
39
+ * Upload more frequent, smaller batches of data
40
+ */
41
+ SMALL = "SMALL"
42
+ }
15
43
  export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
16
44
  export declare type LegacyFirstPartyHost = string;
17
45
  /**
@@ -130,6 +158,22 @@ export declare class DdSdkReactNativeConfiguration {
130
158
  * Enables tracking of frustration signals (error taps). Defaults to `true`.
131
159
  */
132
160
  trackFrustrations: boolean;
161
+ /**
162
+ * Sets the preferred frequency for uploading batches of data.
163
+ */
164
+ uploadFrequency: UploadFrequency;
165
+ /**
166
+ * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.
167
+ * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.
168
+ */
169
+ batchSize: BatchSize;
170
+ /**
171
+ * Enables tracking of RUM event when no RUM View is active.
172
+ *
173
+ * By default, background events are not tracked. Enabling this feature might increase the
174
+ * number of sessions tracked and impact your billing.
175
+ */
176
+ trackBackgroundEvents: boolean;
133
177
  logEventMapper: LogEventMapper | null;
134
178
  errorEventMapper: ErrorEventMapper | null;
135
179
  resourceEventMapper: ResourceEventMapper | null;
@@ -196,6 +240,9 @@ export declare type PartialInitializationConfiguration = {
196
240
  readonly telemetrySampleRate?: number;
197
241
  readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;
198
242
  readonly trackFrustrations?: boolean;
243
+ readonly uploadFrequency?: UploadFrequency;
244
+ readonly batchSize?: BatchSize;
245
+ readonly trackBackgroundEvents?: boolean;
199
246
  };
200
247
  export declare const buildConfigurationFromPartialConfiguration: (features: AutoInstrumentationConfiguration, configuration: PartialInitializationConfiguration) => DdSdkReactNativeConfiguration;
201
248
  export declare class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {
@@ -1,4 +1,4 @@
1
- import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency } from './DdSdkReactNativeConfiguration';
1
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency, UploadFrequency, BatchSize } from './DdSdkReactNativeConfiguration';
2
2
  import { DdSdkReactNative } from './DdSdkReactNative';
3
3
  import { InternalLog } from './InternalLog';
4
4
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -9,4 +9,4 @@ import { DdRum } from './rum/DdRum';
9
9
  import { RumActionType, ErrorSource, PropagatorType } from './rum/types';
10
10
  import { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';
11
11
  import { DdTrace } from './trace/DdTrace';
12
- export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType };
12
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType, UploadFrequency, BatchSize };
@@ -218,6 +218,13 @@ export declare type DdNativeRumType = {
218
218
  * Stops the current RUM Session.
219
219
  */
220
220
  stopSession(): Promise<void>;
221
+ /**
222
+ * Adds the result of evaluating a feature flag with a given name and value to the view.
223
+ * Feature flag evaluations are local to the active view and are cleared when the view is stopped.
224
+ * @param name: The name of the feature flag
225
+ * @param value: The value of the feature flag, encapsulated in an object to accept all types
226
+ */
227
+ addFeatureFlagEvaluation(name: string, value: object): Promise<void>;
221
228
  };
222
229
  declare type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
223
230
  declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
@@ -26,6 +26,7 @@ declare class DdRumWrapper implements DdRumType {
26
26
  addError(message: string, source: ErrorSource, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
27
27
  addTiming(name: string): Promise<void>;
28
28
  stopSession(): Promise<void>;
29
+ addFeatureFlagEvaluation(name: string, value: unknown): Promise<void>;
29
30
  registerErrorEventMapper(errorEventMapper: ErrorEventMapper): void;
30
31
  unregisterErrorEventMapper(): void;
31
32
  registerResourceEventMapper(resourceEventMapper: ResourceEventMapper): void;
@@ -14,7 +14,10 @@ export declare class DdSdkConfiguration {
14
14
  readonly additionalConfig: object;
15
15
  readonly telemetrySampleRate: number;
16
16
  readonly vitalsUpdateFrequency: string;
17
+ readonly uploadFrequency: string;
18
+ readonly batchSize: string;
17
19
  readonly trackFrustrations: boolean;
20
+ readonly trackBackgroundEvents: boolean;
18
21
  readonly configurationForTelemetry: {
19
22
  initializationType: string;
20
23
  trackErrors: boolean;
@@ -23,7 +26,7 @@ export declare class DdSdkConfiguration {
23
26
  reactVersion: string;
24
27
  reactNativeVersion: string;
25
28
  };
26
- constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, trackFrustrations: boolean, configurationForTelemetry: {
29
+ constructor(clientToken: string, env: string, applicationId: string, nativeCrashReportEnabled: boolean, nativeLongTaskThresholdMs: number, longTaskThresholdMs: number, sampleRate: number, site: string, trackingConsent: string, additionalConfig: object, telemetrySampleRate: number, vitalsUpdateFrequency: string, uploadFrequency: string, batchSize: string, trackFrustrations: boolean, trackBackgroundEvents: boolean, configurationForTelemetry: {
27
30
  initializationType: string;
28
31
  trackErrors: boolean;
29
32
  trackInteractions: boolean;
@@ -1 +1 @@
1
- export declare const version = "1.6.0";
1
+ export declare const version = "1.7.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  ]
79
79
  },
80
- "gitHead": "b95779b45f4917992f898f426a6640472b77cc3d"
80
+ "gitHead": "e7eb5ba2ac1eefbacf5c60695c7d761560c4f2cb"
81
81
  }
@@ -118,7 +118,10 @@ export class DdSdkReactNative {
118
118
  configuration.additionalConfig,
119
119
  configuration.telemetrySampleRate,
120
120
  configuration.vitalsUpdateFrequency,
121
+ configuration.uploadFrequency,
122
+ configuration.batchSize,
121
123
  configuration.trackFrustrations,
124
+ configuration.trackBackgroundEvents,
122
125
  {
123
126
  initializationType: params.initializationModeForTelemetry,
124
127
  trackErrors: configuration.trackErrors,
@@ -21,6 +21,36 @@ export enum VitalsUpdateFrequency {
21
21
  NEVER = 'NEVER'
22
22
  }
23
23
 
24
+ export enum UploadFrequency {
25
+ /**
26
+ * Upload data every 1000ms.
27
+ */
28
+ FREQUENT = 'FREQUENT',
29
+ /**
30
+ * Upload data every 5000ms.
31
+ */
32
+ AVERAGE = 'AVERAGE',
33
+ /**
34
+ * Upload data every 10000ms.
35
+ */
36
+ RARE = 'RARE'
37
+ }
38
+
39
+ export enum BatchSize {
40
+ /**
41
+ * Upload less frequent, larger batches of data
42
+ */
43
+ LARGE = 'LARGE',
44
+ /**
45
+ * Use default size for batches of data
46
+ */
47
+ MEDIUM = 'MEDIUM',
48
+ /**
49
+ * Upload more frequent, smaller batches of data
50
+ */
51
+ SMALL = 'SMALL'
52
+ }
53
+
24
54
  export type FirstPartyHostsConfiguration = (
25
55
  | FirstPartyHost
26
56
  | LegacyFirstPartyHost
@@ -70,7 +100,10 @@ const DEFAULTS = {
70
100
  errorEventMapper: null,
71
101
  resourceEventMapper: null,
72
102
  actionEventMapper: null,
73
- trackFrustrations: true
103
+ trackFrustrations: true,
104
+ uploadFrequency: UploadFrequency.AVERAGE,
105
+ batchSize: BatchSize.MEDIUM,
106
+ trackBackgroundEvents: false
74
107
  };
75
108
 
76
109
  /**
@@ -188,6 +221,25 @@ export class DdSdkReactNativeConfiguration {
188
221
  */
189
222
  public trackFrustrations: boolean = DEFAULTS.trackFrustrations;
190
223
 
224
+ /**
225
+ * Sets the preferred frequency for uploading batches of data.
226
+ */
227
+ public uploadFrequency: UploadFrequency = DEFAULTS.uploadFrequency;
228
+
229
+ /**
230
+ * Defines the Datadog SDK policy when batching data together before uploading it to Datadog servers.
231
+ * Smaller batches mean smaller but more network requests, whereas larger batches mean fewer but larger network requests.
232
+ */
233
+ public batchSize: BatchSize = DEFAULTS.batchSize;
234
+
235
+ /**
236
+ * Enables tracking of RUM event when no RUM View is active.
237
+ *
238
+ * By default, background events are not tracked. Enabling this feature might increase the
239
+ * number of sessions tracked and impact your billing.
240
+ */
241
+ public trackBackgroundEvents: boolean = DEFAULTS.trackBackgroundEvents;
242
+
191
243
  public logEventMapper: LogEventMapper | null = DEFAULTS.logEventMapper;
192
244
 
193
245
  public errorEventMapper: ErrorEventMapper | null =
@@ -300,6 +352,9 @@ export type PartialInitializationConfiguration = {
300
352
  readonly telemetrySampleRate?: number;
301
353
  readonly vitalsUpdateFrequency?: VitalsUpdateFrequency;
302
354
  readonly trackFrustrations?: boolean;
355
+ readonly uploadFrequency?: UploadFrequency;
356
+ readonly batchSize?: BatchSize;
357
+ readonly trackBackgroundEvents?: boolean;
303
358
  };
304
359
 
305
360
  const setConfigurationAttribute = <
@@ -4,7 +4,11 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- import { buildConfigurationFromPartialConfiguration } from '../DdSdkReactNativeConfiguration';
7
+ import {
8
+ BatchSize,
9
+ UploadFrequency,
10
+ buildConfigurationFromPartialConfiguration
11
+ } from '../DdSdkReactNativeConfiguration';
8
12
  import { ProxyConfiguration, ProxyType } from '../ProxyConfiguration';
9
13
  import { SdkVerbosity } from '../SdkVerbosity';
10
14
  import { TrackingConsent } from '../TrackingConsent';
@@ -30,6 +34,7 @@ describe('DdSdkReactNativeConfiguration', () => {
30
34
  "actionEventMapper": null,
31
35
  "additionalConfig": {},
32
36
  "applicationId": "fake-app-id",
37
+ "batchSize": "MEDIUM",
33
38
  "clientToken": "fake-client-token",
34
39
  "env": "fake-env",
35
40
  "errorEventMapper": null,
@@ -47,11 +52,13 @@ describe('DdSdkReactNativeConfiguration', () => {
47
52
  "sessionSamplingRate": 100,
48
53
  "site": "US1",
49
54
  "telemetrySampleRate": 20,
55
+ "trackBackgroundEvents": false,
50
56
  "trackErrors": false,
51
57
  "trackFrustrations": true,
52
58
  "trackInteractions": false,
53
59
  "trackResources": false,
54
60
  "trackingConsent": "granted",
61
+ "uploadFrequency": "AVERAGE",
55
62
  "verbosity": undefined,
56
63
  "vitalsUpdateFrequency": "AVERAGE",
57
64
  }
@@ -95,7 +102,10 @@ describe('DdSdkReactNativeConfiguration', () => {
95
102
  nativeCrashReportEnabled: true,
96
103
  nativeLongTaskThresholdMs: 345,
97
104
  longTaskThresholdMs: 567,
98
- trackFrustrations: true
105
+ trackFrustrations: true,
106
+ uploadFrequency: UploadFrequency.FREQUENT,
107
+ batchSize: BatchSize.LARGE,
108
+ trackBackgroundEvents: true
99
109
  }
100
110
  )
101
111
  ).toMatchInlineSnapshot(`
@@ -105,6 +115,7 @@ describe('DdSdkReactNativeConfiguration', () => {
105
115
  "additionalField": "fake-value",
106
116
  },
107
117
  "applicationId": "fake-app-id",
118
+ "batchSize": "LARGE",
108
119
  "clientToken": "fake-client-token",
109
120
  "env": "fake-env",
110
121
  "errorEventMapper": [Function],
@@ -130,11 +141,13 @@ describe('DdSdkReactNativeConfiguration', () => {
130
141
  "sessionSamplingRate": 80,
131
142
  "site": "EU",
132
143
  "telemetrySampleRate": 20,
144
+ "trackBackgroundEvents": true,
133
145
  "trackErrors": true,
134
146
  "trackFrustrations": true,
135
147
  "trackInteractions": true,
136
148
  "trackResources": true,
137
149
  "trackingConsent": "pending",
150
+ "uploadFrequency": "FREQUENT",
138
151
  "verbosity": "debug",
139
152
  "version": "1.4.5",
140
153
  "versionSuffix": "codepush-3",
@@ -167,7 +180,8 @@ describe('DdSdkReactNativeConfiguration', () => {
167
180
  nativeCrashReportEnabled: false,
168
181
  nativeLongTaskThresholdMs: false,
169
182
  longTaskThresholdMs: false,
170
- trackFrustrations: false
183
+ trackFrustrations: false,
184
+ trackBackgroundEvents: false
171
185
  }
172
186
  )
173
187
  ).toMatchInlineSnapshot(`
@@ -175,6 +189,7 @@ describe('DdSdkReactNativeConfiguration', () => {
175
189
  "actionEventMapper": null,
176
190
  "additionalConfig": {},
177
191
  "applicationId": "",
192
+ "batchSize": "MEDIUM",
178
193
  "clientToken": "",
179
194
  "env": "",
180
195
  "errorEventMapper": null,
@@ -192,11 +207,13 @@ describe('DdSdkReactNativeConfiguration', () => {
192
207
  "sessionSamplingRate": 0,
193
208
  "site": "",
194
209
  "telemetrySampleRate": 20,
210
+ "trackBackgroundEvents": false,
195
211
  "trackErrors": false,
196
212
  "trackFrustrations": false,
197
213
  "trackInteractions": false,
198
214
  "trackResources": false,
199
215
  "trackingConsent": "granted",
216
+ "uploadFrequency": "AVERAGE",
200
217
  "verbosity": undefined,
201
218
  "version": "",
202
219
  "versionSuffix": "",
@@ -83,7 +83,8 @@ it('M intercept and send a RUM event W onGlobalError() {no message}', async () =
83
83
  {
84
84
  '_dd.error.raw': error,
85
85
  '_dd.error.is_crash': is_fatal,
86
- '_dd.error.source_type': 'react-native'
86
+ '_dd.error.source_type': 'react-native',
87
+ '_dd.error_log.is_crash': true
87
88
  }
88
89
  );
89
90
  });
@@ -123,7 +124,8 @@ it('M intercept and send a RUM event W onGlobalError() {empty stack trace}', asy
123
124
  {
124
125
  '_dd.error.raw': error,
125
126
  '_dd.error.is_crash': is_fatal,
126
- '_dd.error.source_type': 'react-native'
127
+ '_dd.error.source_type': 'react-native',
128
+ '_dd.error_log.is_crash': true
127
129
  }
128
130
  );
129
131
  });
@@ -164,7 +166,8 @@ it('M intercept and send a RUM event W onGlobalError() {Error object}', async ()
164
166
  {
165
167
  '_dd.error.raw': error,
166
168
  '_dd.error.is_crash': is_fatal,
167
- '_dd.error.source_type': 'react-native'
169
+ '_dd.error.source_type': 'react-native',
170
+ '_dd.error_log.is_crash': true
168
171
  }
169
172
  );
170
173
  });
@@ -209,7 +212,8 @@ it('M intercept and send a RUM event W onGlobalError() {CustomError object}', as
209
212
  {
210
213
  '_dd.error.raw': error,
211
214
  '_dd.error.is_crash': is_fatal,
212
- '_dd.error.source_type': 'react-native'
215
+ '_dd.error.source_type': 'react-native',
216
+ '_dd.error_log.is_crash': true
213
217
  }
214
218
  );
215
219
  });
@@ -252,7 +256,8 @@ it('M intercept and send a RUM event W onGlobalError() {with source file info}',
252
256
  {
253
257
  '_dd.error.raw': error,
254
258
  '_dd.error.is_crash': is_fatal,
255
- '_dd.error.source_type': 'react-native'
259
+ '_dd.error.source_type': 'react-native',
260
+ '_dd.error_log.is_crash': true
256
261
  }
257
262
  );
258
263
  });
@@ -297,7 +302,8 @@ it('M intercept and send a RUM event W onGlobalError() {with component stack}',
297
302
  {
298
303
  '_dd.error.raw': error,
299
304
  '_dd.error.is_crash': is_fatal,
300
- '_dd.error.source_type': 'react-native'
305
+ '_dd.error.source_type': 'react-native',
306
+ '_dd.error_log.is_crash': true
301
307
  }
302
308
  );
303
309
  });
@@ -342,7 +348,8 @@ it('M intercept and send a RUM event W onGlobalError() {with stack}', async () =
342
348
  {
343
349
  '_dd.error.raw': error,
344
350
  '_dd.error.is_crash': is_fatal,
345
- '_dd.error.source_type': 'react-native'
351
+ '_dd.error.source_type': 'react-native',
352
+ '_dd.error_log.is_crash': true
346
353
  }
347
354
  );
348
355
  });
@@ -388,7 +395,8 @@ it('M intercept and send a RUM event W onGlobalError() {with stacktrace}', async
388
395
  {
389
396
  '_dd.error.raw': error,
390
397
  '_dd.error.is_crash': is_fatal,
391
- '_dd.error.source_type': 'react-native'
398
+ '_dd.error.source_type': 'react-native',
399
+ '_dd.error_log.is_crash': true
392
400
  }
393
401
  );
394
402
  });
@@ -440,7 +448,8 @@ it('M not report error in console handler W onGlobalError() {with console report
440
448
  {
441
449
  '_dd.error.raw': error,
442
450
  '_dd.error.is_crash': is_fatal,
443
- '_dd.error.source_type': 'react-native'
451
+ '_dd.error.source_type': 'react-native',
452
+ '_dd.error_log.is_crash': true
444
453
  }
445
454
  );
446
455
  });
@@ -473,14 +482,15 @@ it('M intercept and send a RUM event W onConsole() {Error with source file info}
473
482
  );
474
483
  expect(baseConsoleErrorCalled).toStrictEqual(true);
475
484
  expect(DdLogs.errorWithError).toHaveBeenCalledTimes(1);
476
- expect(
477
- DdLogs.errorWithError
478
- ).toHaveBeenCalledWith(
485
+ expect(DdLogs.errorWithError).toHaveBeenCalledWith(
479
486
  'Oops I did it again! Something bad happened',
480
487
  'Error',
481
488
  'Oops I did it again! Something bad happened',
482
489
  'at ./path/to/file.js:1038:57',
483
- { '_dd.error.source_type': 'react-native' }
490
+ {
491
+ '_dd.error.source_type': 'react-native',
492
+ '_dd.error_log.is_crash': true
493
+ }
484
494
  );
485
495
  });
486
496
 
@@ -514,14 +524,15 @@ it('M intercept and send a RUM event W onConsole() {Error with component stack}'
514
524
  );
515
525
  expect(baseConsoleErrorCalled).toStrictEqual(true);
516
526
  expect(DdLogs.errorWithError).toHaveBeenCalledTimes(1);
517
- expect(
518
- DdLogs.errorWithError
519
- ).toHaveBeenCalledWith(
527
+ expect(DdLogs.errorWithError).toHaveBeenCalledWith(
520
528
  'Oops I did it again! Something bad happened',
521
529
  'Error',
522
530
  'Oops I did it again! Something bad happened',
523
531
  'doSomething() at ./path/to/file.js:67:3,nestedCall() at ./path/to/file.js:1064:9,root() at ./path/to/index.js:10:1',
524
- { '_dd.error.source_type': 'react-native' }
532
+ {
533
+ '_dd.error.source_type': 'react-native',
534
+ '_dd.error_log.is_crash': true
535
+ }
525
536
  );
526
537
  });
527
538
 
@@ -552,7 +563,10 @@ it('M intercept and send a RUM event W onConsole() {message only}', async () =>
552
563
  'Error',
553
564
  'Something bad happened',
554
565
  '',
555
- { '_dd.error.source_type': 'react-native' }
566
+ {
567
+ '_dd.error.source_type': 'react-native',
568
+ '_dd.error_log.is_crash': true
569
+ }
556
570
  );
557
571
  });
558
572
 
@@ -585,14 +599,15 @@ it('M intercept and send a RUM event W onConsole() {Error with source file and n
585
599
  );
586
600
  expect(baseConsoleErrorCalled).toStrictEqual(true);
587
601
  expect(DdLogs.errorWithError).toHaveBeenCalledTimes(1);
588
- expect(
589
- DdLogs.errorWithError
590
- ).toHaveBeenCalledWith(
602
+ expect(DdLogs.errorWithError).toHaveBeenCalledWith(
591
603
  'Oops I did it again! Something bad happened',
592
604
  'CustomConsoleError',
593
605
  'Oops I did it again! Something bad happened',
594
606
  'at ./path/to/file.js:1038:57',
595
- { '_dd.error.source_type': 'react-native' }
607
+ {
608
+ '_dd.error.source_type': 'react-native',
609
+ '_dd.error_log.is_crash': true
610
+ }
596
611
  );
597
612
  });
598
613
 
@@ -636,7 +651,10 @@ describe.each([
636
651
  'Error',
637
652
  errorMessage,
638
653
  '',
639
- { '_dd.error.source_type': 'react-native' }
654
+ {
655
+ '_dd.error.source_type': 'react-native',
656
+ '_dd.error_log.is_crash': true
657
+ }
640
658
  );
641
659
  });
642
660
  });
@@ -678,7 +696,8 @@ it('M intercept and send a RUM event W on error() {called from RNErrorHandler}',
678
696
  {
679
697
  '_dd.error.raw': error,
680
698
  '_dd.error.is_crash': is_fatal,
681
- '_dd.error.source_type': 'react-native'
699
+ '_dd.error.source_type': 'react-native',
700
+ '_dd.error_log.is_crash': true
682
701
  }
683
702
  );
684
703
  });
@@ -711,7 +730,10 @@ it('M intercept and send a RUM event W onConsole() {called from RNErrorHandler}'
711
730
  'Error',
712
731
  'Oops I did it again!',
713
732
  '',
714
- { '_dd.error.source_type': 'react-native' }
733
+ {
734
+ '_dd.error.source_type': 'react-native',
735
+ '_dd.error_log.is_crash': true
736
+ }
715
737
  );
716
738
  });
717
739