@datadog/mobile-react-native 1.1.4 → 1.2.0-beta1

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 (125) hide show
  1. package/README.md +18 -14
  2. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +8 -0
  3. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +10 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +25 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +2 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -0
  7. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +52 -0
  8. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +7 -0
  9. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +1 -0
  10. package/ios/Sources/DdSdk.m +10 -0
  11. package/ios/Sources/DdSdk.swift +17 -0
  12. package/ios/Sources/DdSdkConfiguration.swift +4 -0
  13. package/ios/Sources/RNDdSdkConfiguration.swift +2 -0
  14. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
  15. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  16. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
  17. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  18. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
  19. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  20. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
  21. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  22. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
  23. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  24. package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
  25. package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
  26. package/lib/commonjs/DdSdkReactNative.js +138 -56
  27. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  28. package/lib/commonjs/DdSdkReactNativeConfiguration.js +102 -9
  29. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  30. package/lib/commonjs/errorUtils.js +60 -0
  31. package/lib/commonjs/errorUtils.js.map +1 -0
  32. package/lib/commonjs/foundation.js +19 -12
  33. package/lib/commonjs/foundation.js.map +1 -1
  34. package/lib/commonjs/index.js +20 -0
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  37. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
  38. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  39. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -1
  40. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  41. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +1 -1
  42. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -1
  43. package/lib/commonjs/types.js +2 -1
  44. package/lib/commonjs/types.js.map +1 -1
  45. package/lib/commonjs/version.js +1 -1
  46. package/lib/commonjs/version.js.map +1 -1
  47. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
  48. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  49. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
  50. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  51. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
  52. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  53. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
  54. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  55. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
  56. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  57. package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
  58. package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
  59. package/lib/module/DdSdkReactNative.js +130 -54
  60. package/lib/module/DdSdkReactNative.js.map +1 -1
  61. package/lib/module/DdSdkReactNativeConfiguration.js +91 -8
  62. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  63. package/lib/module/errorUtils.js +45 -0
  64. package/lib/module/errorUtils.js.map +1 -0
  65. package/lib/module/foundation.js +18 -12
  66. package/lib/module/foundation.js.map +1 -1
  67. package/lib/module/index.js +3 -2
  68. package/lib/module/index.js.map +1 -1
  69. package/lib/module/nativeModulesTypes.js.map +1 -1
  70. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
  71. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  72. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +14 -1
  73. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  74. package/lib/module/rum/instrumentation/getJsxRuntime.js +1 -1
  75. package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -1
  76. package/lib/module/types.js +2 -1
  77. package/lib/module/types.js.map +1 -1
  78. package/lib/module/version.js +1 -1
  79. package/lib/module/version.js.map +1 -1
  80. package/lib/typescript/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
  81. package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
  82. package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
  83. package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
  84. package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
  85. package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
  86. package/lib/typescript/DdSdkReactNative.d.ts +23 -1
  87. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +63 -0
  88. package/lib/typescript/errorUtils.d.ts +4 -0
  89. package/lib/typescript/index.d.ts +3 -2
  90. package/lib/typescript/nativeModulesTypes.d.ts +12 -0
  91. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
  92. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
  93. package/lib/typescript/types.d.ts +2 -1
  94. package/lib/typescript/version.d.ts +1 -1
  95. package/package.json +2 -2
  96. package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
  97. package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
  98. package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
  99. package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
  100. package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
  101. package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
  102. package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
  103. package/src/DatadogProvider/DatadogProvider.tsx +122 -0
  104. package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
  105. package/src/DatadogProvider/__tests__/initialization.test.tsx +174 -0
  106. package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
  107. package/src/DdSdkReactNative.tsx +205 -105
  108. package/src/DdSdkReactNativeConfiguration.tsx +160 -8
  109. package/src/__tests__/DdRumWrapper.test.tsx +3 -27
  110. package/src/__tests__/DdSdkReactNative.test.tsx +1 -0
  111. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +168 -0
  112. package/src/__tests__/foundation.test.ts +11 -2
  113. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
  114. package/src/errorUtils.ts +50 -0
  115. package/src/foundation.tsx +15 -12
  116. package/src/index.tsx +9 -1
  117. package/src/nativeModulesTypes.ts +14 -0
  118. package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
  119. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +11 -1
  120. package/src/rum/instrumentation/getJsxRuntime.ts +1 -1
  121. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
  122. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
  123. package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +3 -0
  124. package/src/types.tsx +2 -1
  125. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","TrackingConsent","GRANTED","undefined"],"mappings":";;;;;;;AAQA;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AAQI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGC,iCAAgBC,OAPrD,EAQT;AAAA,SAPWR,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDAlDyC,KAkDzC;;AAAA;;AAAA,iDA1CmC,KA0CnC;;AAAA,yDAtC2C,IAsC3C;;AAAA,kCArCoB,IAqCpB;;AAAA,uCApC2CG,SAoC3C;;AAAA,gDAnCmC,KAmCnC;;AAAA,yCAlCwCA,SAkCxC;;AAAA,yCAjC4BA,SAiC5B;;AAAA,6CAhCiC,EAgCjC;;AAAA;;AAAA;;AAAA,8CAV8C,EAU9C;AAAE;;AAnDmC","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 { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean = false;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = 100.0;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number = 20.0;\n public site: string = 'US';\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = false;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = [];\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n public additionalConfig: { [k: string]: any } = {};\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED\n ) {}\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["DEFAULTS","nativeCrashReportEnabled","sessionSamplingRate","resourceTracingSamplingRate","site","nativeViewTracking","getFirstPartyHosts","getAdditionalConfig","trackingConsent","TrackingConsent","GRANTED","telemetrySampleRate","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","undefined","addDefaultValuesToAutoInstrumentationConfiguration","features","firstPartyHosts","setConfigurationAttribute","attribute","configuration","value","name","buildConfigurationFromPartialConfiguration","remainingConfiguration","SdkConfiguration","Object","keys","forEach","DatadogProviderConfiguration","InitializationMode","SYNC"],"mappings":";;;;;;;AAQA;;;;AAEA,MAAMA,QAAQ,GAAG;AACbC,EAAAA,wBAAwB,EAAE,KADb;AAEbC,EAAAA,mBAAmB,EAAE,KAFR;AAGbC,EAAAA,2BAA2B,EAAE,IAHhB;AAIbC,EAAAA,IAAI,EAAE,KAJO;AAKbC,EAAAA,kBAAkB,EAAE,KALP;AAMbC,EAAAA,kBAAkB,EAAE,MAAM,EANb;AAObC,EAAAA,mBAAmB,EAAE,OAAO,EAAP,CAPR;AAQbC,EAAAA,eAAe,EAAEC,iCAAgBC,OARpB;AASbC,EAAAA,mBAAmB,EAAE;AATR,CAAjB;AAYA;AACA;AACA;AACA;;AACO,MAAMC,6BAAN,CAAoC;AAGvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AASI;AACJ;AACA;AACA;AACA;AACA;AACA;A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;;AAAA,gDAC5BwB,kBAAkB,CAACC,IADS;AAAA;;AAAA;;;IAIpED,kB;;;WAAAA,kB;AAAAA,EAAAA,kB;AAAAA,EAAAA,kB;GAAAA,kB,kCAAAA,kB","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 { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\nconst DEFAULTS = {\n nativeCrashReportEnabled: false,\n sessionSamplingRate: 100.0,\n resourceTracingSamplingRate: 20.0,\n site: 'US1',\n nativeViewTracking: false,\n getFirstPartyHosts: () => [],\n getAdditionalConfig: () => ({}),\n trackingConsent: TrackingConsent.GRANTED,\n telemetrySampleRate: 20.0\n};\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean =\n DEFAULTS.nativeCrashReportEnabled;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = DEFAULTS.sessionSamplingRate;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number =\n DEFAULTS.resourceTracingSamplingRate;\n public site: string = DEFAULTS.site;\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = DEFAULTS.nativeViewTracking;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = DEFAULTS.getFirstPartyHosts();\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n /**\n * The sampling rate for Internal Telemetry (info related to the work of the\n * SDK internals).\n *\n * The sampling rate must be a value between 0 and 100. A value of 0 means no\n * telemetry will be sent, 100 means all telemetry will be sent. When\n * `telemetrySampleRate` is not set, the default value from the iOS and\n * Android SDK is used, which is 20.\n */\n public telemetrySampleRate: number = DEFAULTS.telemetrySampleRate;\n\n public additionalConfig: {\n [k: string]: any;\n } = DEFAULTS.getAdditionalConfig();\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = DEFAULTS.trackingConsent\n ) {}\n}\n\n/**\n * Auto Instrumentation configuration passed to DatadogProvider.\n * Does not include default values.\n */\nexport type AutoInstrumentationConfiguration = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts?: string[];\n readonly resourceTracingSamplingRate?: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * Parameters needed to start auto instrumentation. Includes default values.\n */\nexport type AutoInstrumentationParameters = {\n readonly trackInteractions: boolean;\n readonly trackResources: boolean;\n readonly firstPartyHosts: string[];\n readonly resourceTracingSamplingRate: number;\n readonly trackErrors: boolean;\n};\n\n/**\n * We could use `Proxy` instead of this function, but `Proxy` is not available on\n * the older android jsc that can still be used.\n */\nexport const addDefaultValuesToAutoInstrumentationConfiguration = (\n features: AutoInstrumentationConfiguration\n): AutoInstrumentationParameters => {\n return {\n ...features,\n firstPartyHosts:\n features.firstPartyHosts || DEFAULTS.getFirstPartyHosts(),\n resourceTracingSamplingRate:\n features.resourceTracingSamplingRate ||\n DEFAULTS.resourceTracingSamplingRate\n };\n};\n\nexport type PartialInitializationConfiguration = {\n readonly clientToken: string;\n readonly env: string;\n readonly applicationId: string;\n readonly sessionSamplingRate?: number;\n readonly site?: string;\n readonly verbosity?: SdkVerbosity | undefined;\n readonly nativeViewTracking?: boolean;\n readonly proxyConfig?: ProxyConfiguration;\n readonly serviceName?: string;\n readonly version?: string;\n versionSuffix?: string;\n readonly additionalConfig?: { [k: string]: any };\n readonly trackingConsent?: TrackingConsent;\n readonly nativeCrashReportEnabled?: boolean;\n readonly telemetrySampleRate?: number;\n};\n\nconst setConfigurationAttribute = <\n AttributeName extends keyof DdSdkReactNativeConfiguration\n>(\n attribute: {\n value?: DdSdkReactNativeConfiguration[AttributeName];\n name: AttributeName;\n },\n configuration: DdSdkReactNativeConfiguration\n) => {\n if (attribute.value !== undefined) {\n configuration[attribute.name] = attribute.value;\n }\n};\n\nexport const buildConfigurationFromPartialConfiguration = (\n features: AutoInstrumentationConfiguration,\n configuration: PartialInitializationConfiguration\n): DdSdkReactNativeConfiguration => {\n const {\n clientToken,\n env,\n applicationId,\n ...remainingConfiguration\n } = configuration;\n const SdkConfiguration = new DdSdkReactNativeConfiguration(\n clientToken,\n env,\n applicationId,\n features.trackInteractions,\n features.trackResources,\n features.trackErrors,\n configuration.trackingConsent\n );\n\n (Object.keys(\n remainingConfiguration\n ) as (keyof typeof remainingConfiguration)[]).forEach(name => {\n setConfigurationAttribute(\n { value: remainingConfiguration[name], name },\n SdkConfiguration\n );\n });\n\n setConfigurationAttribute(\n {\n name: 'resourceTracingSamplingRate',\n value: features.resourceTracingSamplingRate\n },\n SdkConfiguration\n );\n setConfigurationAttribute(\n { name: 'firstPartyHosts', value: features.firstPartyHosts },\n SdkConfiguration\n );\n\n return SdkConfiguration;\n};\n\nexport class DatadogProviderConfiguration extends DdSdkReactNativeConfiguration {\n public initializationMode: InitializationMode = InitializationMode.SYNC;\n}\n\nexport enum InitializationMode {\n SYNC = 'SYNC',\n ASYNC = 'ASYNC'\n}\n"]}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getErrorStackTrace = exports.getErrorMessage = exports.EMPTY_STACK_TRACE = exports.EMPTY_MESSAGE = void 0;
7
+
8
+ /*
9
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
10
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
11
+ * Copyright 2016-Present Datadog, Inc.
12
+ */
13
+ const EMPTY_MESSAGE = 'Unknown Error';
14
+ exports.EMPTY_MESSAGE = EMPTY_MESSAGE;
15
+ const EMPTY_STACK_TRACE = '';
16
+ exports.EMPTY_STACK_TRACE = EMPTY_STACK_TRACE;
17
+
18
+ const getErrorMessage = error => {
19
+ let message = EMPTY_MESSAGE;
20
+
21
+ if (error === undefined || error === null) {
22
+ message = EMPTY_MESSAGE;
23
+ } else if (typeof error === 'object' && 'message' in error) {
24
+ message = String(error.message);
25
+ } else {
26
+ message = String(error);
27
+ }
28
+
29
+ return message;
30
+ };
31
+
32
+ exports.getErrorMessage = getErrorMessage;
33
+
34
+ const getErrorStackTrace = error => {
35
+ let stack = EMPTY_STACK_TRACE;
36
+
37
+ try {
38
+ if (error === undefined || error === null) {
39
+ stack = EMPTY_STACK_TRACE;
40
+ } else if (typeof error === 'string') {
41
+ stack = EMPTY_STACK_TRACE;
42
+ } else if (typeof error === 'object') {
43
+ if ('componentStack' in error) {
44
+ stack = String(error.componentStack);
45
+ } else if ('stacktrace' in error) {
46
+ stack = String(error.stacktrace);
47
+ } else if ('stack' in error) {
48
+ stack = String(error.stack);
49
+ } else if ('sourceURL' in error && 'line' in error && 'column' in error) {
50
+ stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
51
+ }
52
+ }
53
+ } catch (e) {// Do nothing
54
+ }
55
+
56
+ return stack;
57
+ };
58
+
59
+ exports.getErrorStackTrace = getErrorStackTrace;
60
+ //# sourceMappingURL=errorUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["errorUtils.ts"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","getErrorMessage","error","message","undefined","String","getErrorStackTrace","stack","componentStack","stacktrace","sourceURL","line","column","e"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEO,MAAMA,aAAa,GAAG,eAAtB;;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;;AAEA,MAAMC,eAAe,GAAIC,KAAD,IAAoC;AAC/D,MAAIC,OAAO,GAAGJ,aAAd;;AACA,MAAIG,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGJ,aAAV;AACH,GAFD,MAEO,IAAI,OAAOG,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXM;;;;AAaA,MAAMG,kBAAkB,GAAIJ,KAAD,IAAoC;AAClE,MAAIK,KAAK,GAAGP,iBAAZ;;AAEA,MAAI;AACA,QAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,oBAAoBA,KAAxB,EAA+B;AAC3BK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFD,MAEO,IAAI,gBAAgBN,KAApB,EAA2B;AAC9BK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACO,UAAP,CAAd;AACH,OAFM,MAEA,IAAI,WAAWP,KAAf,EAAsB;AACzBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACK,KAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeL,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEK,QAAAA,KAAK,GAAI,MAAKL,KAAK,CAACQ,SAAU,IAAGR,KAAK,CAACS,IAAK,IAAGT,KAAK,CAACU,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOC,CAAP,EAAU,CACR;AACH;;AACD,SAAON,KAAP;AACH,CA3BM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const EMPTY_MESSAGE = 'Unknown Error';\nexport const EMPTY_STACK_TRACE = '';\n\nexport const getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\nexport const getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
@@ -21,6 +21,8 @@ var _SdkVerbosity = require("./SdkVerbosity");
21
21
 
22
22
  var _TimeProvider = require("./TimeProvider");
23
23
 
24
+ var _bufferNativeCall = require("./DatadogProvider/Buffer/bufferNativeCall");
25
+
24
26
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
27
 
26
28
  const timeProvider = new _TimeProvider.TimeProvider();
@@ -62,7 +64,7 @@ class DdTraceWrapper {
62
64
  }
63
65
 
64
66
  startSpan(operation, context = {}, timestampMs = timeProvider.now()) {
65
- let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
67
+ let spanId = (0, _bufferNativeCall.bufferNativeCallReturningId)(() => this.nativeTrace.startSpan(operation, context, timestampMs));
66
68
 
67
69
  _InternalLog.InternalLog.log("Starting span “" + operation + "” #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
68
70
 
@@ -72,7 +74,7 @@ class DdTraceWrapper {
72
74
  finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
73
75
  _InternalLog.InternalLog.log("Finishing span #" + spanId, _SdkVerbosity.SdkVerbosity.DEBUG);
74
76
 
75
- return this.nativeTrace.finishSpan(spanId, context, timestampMs);
77
+ return (0, _bufferNativeCall.bufferNativeCallWithId)(id => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);
76
78
  }
77
79
 
78
80
  }
@@ -93,12 +95,17 @@ class DdRumWrapper {
93
95
 
94
96
  _defineProperty(this, "getStopActionNativeCall", args => {
95
97
  if (isNewStopActionAPI(args)) {
96
- return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now());
98
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()));
97
99
  }
98
100
 
99
101
  if (isOldStopActionAPI(args)) {
100
102
  if (this.lastActionData) {
101
- return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());
103
+ DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature');
104
+ const {
105
+ type,
106
+ name
107
+ } = this.lastActionData;
108
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));
102
109
  }
103
110
 
104
111
  _InternalLog.InternalLog.log("DdRum.startAction needs to be called before DdRum.stopAction", _SdkVerbosity.SdkVerbosity.WARN);
@@ -113,13 +120,13 @@ class DdRumWrapper {
113
120
  startView(key, name, context = {}, timestampMs = timeProvider.now()) {
114
121
  _InternalLog.InternalLog.log("Starting RUM View “" + name + "” #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
115
122
 
116
- return this.nativeRum.startView(key, name, context, timestampMs);
123
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startView(key, name, context, timestampMs));
117
124
  }
118
125
 
119
126
  stopView(key, context = {}, timestampMs = timeProvider.now()) {
120
127
  _InternalLog.InternalLog.log("Stopping RUM View #" + key, _SdkVerbosity.SdkVerbosity.DEBUG);
121
128
 
122
- return this.nativeRum.stopView(key, context, timestampMs);
129
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopView(key, context, timestampMs));
123
130
  }
124
131
 
125
132
  startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
@@ -129,7 +136,7 @@ class DdRumWrapper {
129
136
  type,
130
137
  name
131
138
  };
132
- return this.nativeRum.startAction(type, name, context, timestampMs);
139
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startAction(type, name, context, timestampMs));
133
140
  }
134
141
 
135
142
  stopAction(...args) {
@@ -143,19 +150,19 @@ class DdRumWrapper {
143
150
  addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
144
151
  _InternalLog.InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", _SdkVerbosity.SdkVerbosity.DEBUG);
145
152
 
146
- return this.nativeRum.addAction(type, name, context, timestampMs);
153
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addAction(type, name, context, timestampMs));
147
154
  }
148
155
 
149
156
  startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
150
157
  _InternalLog.InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, _SdkVerbosity.SdkVerbosity.DEBUG);
151
158
 
152
- return this.nativeRum.startResource(key, method, url, context, timestampMs);
159
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
153
160
  }
154
161
 
155
162
  stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now()) {
156
163
  _InternalLog.InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, _SdkVerbosity.SdkVerbosity.DEBUG);
157
164
 
158
- return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
165
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));
159
166
  }
160
167
 
161
168
  addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
@@ -163,13 +170,13 @@ class DdRumWrapper {
163
170
 
164
171
  let updatedContext = context;
165
172
  updatedContext["_dd.error.source_type"] = "react-native";
166
- return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
173
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));
167
174
  }
168
175
 
169
176
  addTiming(name) {
170
177
  _InternalLog.InternalLog.log("Adding timing “" + name + "” to RUM View", _SdkVerbosity.SdkVerbosity.DEBUG);
171
178
 
172
- return this.nativeRum.addTiming(name);
179
+ return (0, _bufferNativeCall.bufferVoidNativeCall)(() => this.nativeRum.addTiming(name));
173
180
  }
174
181
 
175
182
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;;;AAGA,MAAMA,YAAY,GAAG,IAAIC,0BAAJ,EAArB;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCAECC,2BAAcC,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDC,6BAAYC,GAAZ,CAAgB,yBAA0BH,OAA1B,GAAoC,GAApD,EAAyDI,2BAAaC,KAAtE;;AACA,WAAO,KAAKC,UAAL,CAAgBP,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDM,EAAAA,IAAI,CAACP,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDC,6BAAYC,GAAZ,CAAgB,wBAAyBH,OAAzB,GAAmC,GAAnD,EAAwDI,2BAAaC,KAArE;;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBP,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDO,EAAAA,IAAI,CAACR,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDC,6BAAYC,GAAZ,CAAgB,wBAAyBH,OAAzB,GAAmC,GAAnD,EAAwDI,2BAAaC,KAArE;;AACA,WAAO,KAAKC,UAAL,CAAgBE,IAAhB,CAAqBR,OAArB,EAA8BC,OAA9B,CAAP;AACH;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,OAAvB,GAAiC,GAAjD,EAAsDI,2BAAaC,KAAnE;;AACA,QAAI6C,cAAmB,GAAGjD,OAA1B;AACAiD,IAAAA,cAAc,CAAC,uBAAD,CAAd,GAA0C,cAA1C;AACA,WAAO,KAAK1B,SAAL,CAAeuB,QAAf,CAAwB/C,OAAxB,EAAiCgD,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqEpC,WAArE,CAAP;AACH;;AAEDqC,EAAAA,SAAS,CAACvB,IAAD,EAA8B;AACnC1B,6BAAYC,GAAZ,CAAgB,oBAAoByB,IAApB,GAA2B,eAA3C,EAA4DxB,2BAAaC,KAAzE;;AACA,WAAO,KAAKmB,SAAL,CAAe2B,SAAf,CAAyBvB,IAAzB,CAAP;AACH;;AArEmC;;AAwExC,MAAMwB,KAAsB,GAAGvD,2BAAcuD,KAA7C;;AACA,MAAMtD,MAAkB,GAAG,IAAIF,aAAJ,EAA3B;;AACA,MAAMe,OAAoB,GAAG,IAAID,cAAJ,EAA7B;;AACA,MAAMa,KAAgB,GAAG,IAAID,YAAJ,EAAzB","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 { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now())\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
1
+ {"version":3,"sources":["foundation.tsx"],"names":["timeProvider","TimeProvider","DdLogsWrapper","NativeModules","DdLogs","debug","message","context","InternalLog","log","SdkVerbosity","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","id","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","DdSdk","telemetryDebug","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming"],"mappings":";;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;AAEA,MAAMA,YA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AAC,uBAAD,CAAd,GAA0C,cAA1C;AACA,WAAO,4CAAqB,MAAM,KAAK5B,SAAL,CAAeyB,QAAf,CAAwBlD,OAAxB,EAAiCmD,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqEvC,WAArE,CAA3B,CAAP;AACH;;AAEDwC,EAAAA,SAAS,CAACvB,IAAD,EAA8B;AACnC7B,6BAAYC,GAAZ,CAAgB,oBAAoB4B,IAApB,GAA2B,eAA3C,EAA4D3B,2BAAaC,KAAzE;;AACA,WAAO,4CAAqB,MAAM,KAAKoB,SAAL,CAAe6B,SAAf,CAAyBvB,IAAzB,CAA3B,CAAP;AACH;;AAvEmC;;AA0ExC,MAAMH,KAAsB,GAAG/B,2BAAc+B,KAA7C;;AACA,MAAM9B,MAAkB,GAAG,IAAIF,aAAJ,EAA3B;;AACA,MAAMe,OAAoB,GAAG,IAAID,cAAJ,EAA7B;;AACA,MAAMc,KAAgB,GAAG,IAAID,YAAJ,EAAzB","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 { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\nimport { bufferNativeCallReturningId, bufferNativeCallWithId, bufferVoidNativeCall } from './DatadogProvider/Buffer/bufferNativeCall';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = bufferNativeCallReturningId(() =>this.nativeTrace.startSpan(operation, context, timestampMs));\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId((id) => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()))\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature')\n const {type, name} = this.lastActionData;\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addAction(type, name, context, timestampMs));\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return bufferVoidNativeCall(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
@@ -3,12 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "DatadogProvider", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _DatadogProvider.DatadogProvider;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "DatadogProviderConfiguration", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _DdSdkReactNativeConfiguration.DatadogProviderConfiguration;
16
+ }
17
+ });
6
18
  Object.defineProperty(exports, "DdSdkReactNativeConfiguration", {
7
19
  enumerable: true,
8
20
  get: function () {
9
21
  return _DdSdkReactNativeConfiguration.DdSdkReactNativeConfiguration;
10
22
  }
11
23
  });
24
+ Object.defineProperty(exports, "InitializationMode", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _DdSdkReactNativeConfiguration.InitializationMode;
28
+ }
29
+ });
12
30
  Object.defineProperty(exports, "DdSdkReactNative", {
13
31
  enumerable: true,
14
32
  get: function () {
@@ -76,6 +94,8 @@ Object.defineProperty(exports, "ErrorSource", {
76
94
  }
77
95
  });
78
96
 
97
+ var _DatadogProvider = require("./DatadogProvider/DatadogProvider");
98
+
79
99
  var _DdSdkReactNativeConfiguration = require("./DdSdkReactNativeConfiguration");
80
100
 
81
101
  var _DdSdkReactNative = require("./DdSdkReactNative");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;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\nimport { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;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\nimport { DatadogProvider } from './DatadogProvider/DatadogProvider';\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\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;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
1
+ {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
@@ -9,18 +9,17 @@ var _InternalLog = require("../../InternalLog");
9
9
 
10
10
  var _SdkVerbosity = require("../../SdkVerbosity");
11
11
 
12
+ var _errorUtils = require("../../errorUtils");
13
+
12
14
  var _foundation = require("../../foundation");
13
15
 
14
16
  var _types = require("../../types");
15
17
 
16
18
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
19
 
18
- const EMPTY_MESSAGE = 'Unknown Error';
19
- const EMPTY_STACK_TRACE = '';
20
20
  /**
21
21
  * Provides RUM auto-instrumentation feature to track errors as RUM events.
22
22
  */
23
-
24
23
  class DdRumErrorTracking {
25
24
  // eslint-disable-next-line
26
25
  // eslint-disable-next-line
@@ -51,8 +50,8 @@ class DdRumErrorTracking {
51
50
 
52
51
 
53
52
  static onGlobalError(error, isFatal) {
54
- const message = DdRumErrorTracking.getErrorMessage(error);
55
- const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
53
+ const message = (0, _errorUtils.getErrorMessage)(error);
54
+ const stacktrace = (0, _errorUtils.getErrorStackTrace)(error);
56
55
 
57
56
  _foundation.DdRum.addError(message, _types.ErrorSource.SOURCE, stacktrace, {
58
57
  '_dd.error.is_crash': isFatal,
@@ -73,13 +72,13 @@ class DdRumErrorTracking {
73
72
  return;
74
73
  }
75
74
 
76
- let stack = EMPTY_STACK_TRACE;
75
+ let stack = _errorUtils.EMPTY_STACK_TRACE;
77
76
 
78
77
  for (let i = 0; i < params.length; i += 1) {
79
78
  const param = params[i];
80
- const paramStack = DdRumErrorTracking.getErrorStackTrace(param);
79
+ const paramStack = (0, _errorUtils.getErrorStackTrace)(param);
81
80
 
82
- if (paramStack !== EMPTY_STACK_TRACE) {
81
+ if (paramStack !== _errorUtils.EMPTY_STACK_TRACE) {
83
82
  stack = paramStack;
84
83
  break;
85
84
  }
@@ -89,7 +88,7 @@ class DdRumErrorTracking {
89
88
  if (typeof param === 'string') {
90
89
  return param;
91
90
  } else {
92
- return DdRumErrorTracking.getErrorMessage(param);
91
+ return (0, _errorUtils.getErrorMessage)(param);
93
92
  }
94
93
  }).join(' ');
95
94
 
@@ -98,42 +97,6 @@ class DdRumErrorTracking {
98
97
  });
99
98
  }
100
99
 
101
- static getErrorMessage(error) {
102
- let message = EMPTY_MESSAGE;
103
-
104
- if (error === undefined || error === null) {
105
- message = EMPTY_MESSAGE;
106
- } else if (typeof error === 'object' && 'message' in error) {
107
- message = String(error.message);
108
- } else {
109
- message = String(error);
110
- }
111
-
112
- return message;
113
- }
114
-
115
- static getErrorStackTrace(error) {
116
- let stack = EMPTY_STACK_TRACE;
117
-
118
- if (error === undefined || error === null) {
119
- stack = EMPTY_STACK_TRACE;
120
- } else if (typeof error === 'string') {
121
- stack = EMPTY_STACK_TRACE;
122
- } else if (typeof error === 'object') {
123
- if ('componentStack' in error) {
124
- stack = String(error.componentStack);
125
- } else if ('stacktrace' in error) {
126
- stack = String(error.stacktrace);
127
- } else if ('stack' in error) {
128
- stack = String(error.stack);
129
- } else if ('sourceURL' in error && 'line' in error && 'column' in error) {
130
- stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
131
- }
132
- }
133
-
134
- return stack;
135
- }
136
-
137
100
  }
138
101
 
139
102
  exports.DdRumErrorTracking = DdRumErrorTracking;
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","DdRum","addError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAAG,eA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BAMkD,CAAC6C,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1F9C,kB,yBAS4B,CAAC,GAAG+C,OAAJ,KAA2B,CAAG,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 { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","stacktrace","DdRum","addError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","EMPTY_STACK_TRACE","i","length","param","paramStack","map","join","CONSOLE","apply","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AAKA;;AACA;;;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GAAZ,CACI,wCADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAT,MAAAA,kBAAkB,CAACU,mBAAnB,GAAyCC,OAAO,CAACC,KAAjD;AAEAL,MAAAA,UAAU,CAACM,gBAAX,CAA4Bb,kBAAkB,CAACc,aAA/C;AACAH,MAAAA,OAAO,CAACC,KAAR,GAAgBZ,kBAAkB,CAACe,cAAnC;AAEAf,MAAAA,kBAAkB,CAACE,UAAnB,GAAgC,IAAhC;;AACAC,+BAAYC,GAAZ,CACI,gCADJ,EAEIC,2BAAaW,IAFjB;AAIH,KAZD,MAYO;AACHb,+BAAYC,GAAZ,CACI,4DADJ,EAEIC,2BAAaY,KAFjB;AAIH;AACJ,GA1C2B,CA4C5B;;;AACoB,SAAbH,aAAa,CAACF,KAAD,EAAaM,OAAb,EAAsC;AACtD,UAAMC,OAAO,GAAG,iCAAgBP,KAAhB,CAAhB;AACA,UAAMQ,UAAU,GAAG,oCAAm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B,KAAvC,CAA6C1B,OAA7C,EAAsDgB,MAAtD;AACH,KAFD;AAGH;;AAzF2B;;;;gBAAnB3B,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAACsC,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1FvC,kB,yBAS4B,CAAC,GAAGwC,OAAJ,KAA2B,CAAG,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} from '../../errorUtils';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = getErrorMessage(error);\n const stacktrace = getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n}\n"]}
@@ -11,6 +11,10 @@ var _InternalLog = require("../../InternalLog");
11
11
 
12
12
  var _SdkVerbosity = require("../../SdkVerbosity");
13
13
 
14
+ var _errorUtils = require("../../errorUtils");
15
+
16
+ var _foundation = require("../../foundation");
17
+
14
18
  var _DdEventsInterceptor = require("./DdEventsInterceptor");
15
19
 
16
20
  var _NoOpEventsInterceptor = _interopRequireDefault(require("./NoOpEventsInterceptor"));
@@ -55,7 +59,8 @@ class DdRumUserInteractionTracking {
55
59
  jsxRuntime.jsx = (...args) => {
56
60
  return this.patchCreateElementFunction(originaljsx, args);
57
61
  };
58
- } catch (e) {// TODO: Add telemetry
62
+ } catch (e) {
63
+ _foundation.DdSdk.telemetryDebug((0, _errorUtils.getErrorMessage)(e));
59
64
  }
60
65
 
61
66
  const originalMemo = _react.default.memo;
@@ -91,6 +96,12 @@ class DdRumUserInteractionTracking {
91
96
  _InternalLog.InternalLog.log('Datadog SDK is tracking interactions', _SdkVerbosity.SdkVerbosity.INFO);
92
97
  }
93
98
 
99
+ static stopTracking() {
100
+ _react.default.createElement = this.originalCreateElement;
101
+ _react.default.memo = this.originalMemo;
102
+ DdRumUserInteractionTracking.isTracking = false;
103
+ }
104
+
94
105
  }
95
106
 
96
107
  exports.DdRumUserInteractionTracking = DdRumUserInteractionTracking;
@@ -99,6 +110,10 @@ _defineProperty(DdRumUserInteractionTracking, "isTracking", false);
99
110
 
100
111
  _defineProperty(DdRumUserInteractionTracking, "eventsInterceptor", new _NoOpEventsInterceptor.default());
101
112
 
113
+ _defineProperty(DdRumUserInteractionTracking, "originalCreateElement", _react.default.createElement);
114
+
115
+ _defineProperty(DdRumUserInteractionTracking, "originalMemo", _react.default.memo);
116
+
102
117
  _defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
103
118
  if (props && typeof props.onPress === 'function') {
104
119
  const originalOnPress = props. // eslint-disable-next-line @typescript-eslint/ban-types