@datadog/mobile-react-native 2.3.2 → 2.3.4

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 (106) hide show
  1. package/DatadogSDKReactNative.podspec +1 -0
  2. package/android/build.gradle +2 -0
  3. package/android/src/main/kotlin/com/datadog/reactnative/DdRumImplementation.kt +9 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +13 -2
  5. package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
  6. package/android/src/newarch/kotlin/com/datadog/reactnative/DdLogs.kt +3 -2
  7. package/android/src/newarch/kotlin/com/datadog/reactnative/DdRum.kt +36 -13
  8. package/android/src/newarch/kotlin/com/datadog/reactnative/DdSdk.kt +3 -2
  9. package/android/src/newarch/kotlin/com/datadog/reactnative/DdTrace.kt +4 -2
  10. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdLogs.kt +1 -1
  11. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdRum.kt +11 -2
  12. package/android/src/oldarch/kotlin/com/datadog/reactnative/DdTrace.kt +4 -2
  13. package/datadog-sourcemaps.gradle +13 -2
  14. package/ios/Sources/DdRum.mm +11 -0
  15. package/ios/Sources/DdRumImplementation.swift +7 -0
  16. package/ios/Sources/SdkVersion.swift +1 -1
  17. package/jest/mock.js +9 -1
  18. package/lib/commonjs/DdSdkReactNative.js +11 -4
  19. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  20. package/lib/commonjs/index.js +16 -0
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/rum/DdRum.js +26 -12
  23. package/lib/commonjs/rum/DdRum.js.map +1 -1
  24. package/lib/commonjs/rum/types.js.map +1 -1
  25. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js +14 -6
  26. package/lib/commonjs/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  27. package/lib/commonjs/specs/NativeDdRum.js.map +1 -1
  28. package/lib/commonjs/trace/DdTrace.js +2 -2
  29. package/lib/commonjs/trace/DdTrace.js.map +1 -1
  30. package/lib/commonjs/utils/Timer.js +4 -4
  31. package/lib/commonjs/utils/Timer.js.map +1 -1
  32. package/lib/commonjs/utils/time-provider/DefaultTimeProvider.js +41 -0
  33. package/lib/commonjs/utils/time-provider/DefaultTimeProvider.js.map +1 -0
  34. package/lib/commonjs/utils/{TimeProvider.js → time-provider/TimeProvider.js} +4 -25
  35. package/lib/commonjs/utils/time-provider/TimeProvider.js.map +1 -0
  36. package/lib/commonjs/version.js +1 -1
  37. package/lib/commonjs/version.js.map +1 -1
  38. package/lib/module/DdSdkReactNative.js +11 -4
  39. package/lib/module/DdSdkReactNative.js.map +1 -1
  40. package/lib/module/index.js +3 -1
  41. package/lib/module/index.js.map +1 -1
  42. package/lib/module/rum/DdRum.js +25 -11
  43. package/lib/module/rum/DdRum.js.map +1 -1
  44. package/lib/module/rum/types.js.map +1 -1
  45. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js +14 -6
  46. package/lib/module/sdk/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -1
  47. package/lib/module/specs/NativeDdRum.js.map +1 -1
  48. package/lib/module/trace/DdTrace.js +2 -2
  49. package/lib/module/trace/DdTrace.js.map +1 -1
  50. package/lib/module/utils/Timer.js +4 -4
  51. package/lib/module/utils/Timer.js.map +1 -1
  52. package/lib/module/utils/time-provider/DefaultTimeProvider.js +36 -0
  53. package/lib/module/utils/time-provider/DefaultTimeProvider.js.map +1 -0
  54. package/lib/module/utils/{TimeProvider.js → time-provider/TimeProvider.js} +4 -25
  55. package/lib/module/utils/time-provider/TimeProvider.js.map +1 -0
  56. package/lib/module/version.js +1 -1
  57. package/lib/module/version.js.map +1 -1
  58. package/lib/typescript/DdSdkReactNative.d.ts +5 -1
  59. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +7 -7
  60. package/lib/typescript/index.d.ts +5 -1
  61. package/lib/typescript/logs/types.d.ts +10 -10
  62. package/lib/typescript/nativeModulesTypes.d.ts +5 -5
  63. package/lib/typescript/rum/DdRum.d.ts +4 -0
  64. package/lib/typescript/rum/eventMappers/actionEventMapper.d.ts +4 -4
  65. package/lib/typescript/rum/eventMappers/errorEventMapper.d.ts +4 -4
  66. package/lib/typescript/rum/eventMappers/resourceEventMapper.d.ts +4 -4
  67. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/distributedTracing.d.ts +3 -3
  68. package/lib/typescript/rum/instrumentation/resourceTracking/distributedTracing/firstPartyHosts.d.ts +1 -1
  69. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/DatadogRumResource/ResourceReporter.d.ts +1 -1
  70. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RequestProxy.d.ts +1 -1
  71. package/lib/typescript/rum/instrumentation/resourceTracking/requestProxy/interfaces/RumResource.d.ts +1 -1
  72. package/lib/typescript/rum/types.d.ts +7 -3
  73. package/lib/typescript/sdk/AttributesSingleton/types.d.ts +1 -1
  74. package/lib/typescript/sdk/DatadogProvider/Buffer/BoundedBuffer.d.ts +2 -0
  75. package/lib/typescript/sdk/DatadogProvider/DatadogProvider.d.ts +2 -2
  76. package/lib/typescript/sdk/EventMappers/EventMapper.d.ts +1 -1
  77. package/lib/typescript/sdk/UserInfoSingleton/types.d.ts +1 -1
  78. package/lib/typescript/specs/NativeDdRum.d.ts +4 -0
  79. package/lib/typescript/types.d.ts +2 -2
  80. package/lib/typescript/utils/Timer.d.ts +1 -1
  81. package/lib/typescript/utils/time-provider/DefaultTimeProvider.d.ts +7 -0
  82. package/lib/typescript/utils/{TimeProvider.d.ts → time-provider/TimeProvider.d.ts} +5 -7
  83. package/lib/typescript/version.d.ts +1 -1
  84. package/package.json +2 -2
  85. package/src/DdSdkReactNative.tsx +10 -4
  86. package/src/__tests__/DdSdkReactNative.test.tsx +2 -2
  87. package/src/__tests__/mock.test.ts +1 -1
  88. package/src/index.tsx +7 -0
  89. package/src/rum/DdRum.ts +24 -12
  90. package/src/rum/__mocks__/MockTimeProvider.ts +26 -0
  91. package/src/rum/__tests__/DdRum.test.ts +39 -13
  92. package/src/rum/__tests__/DdRumTimeProvider.test.ts +23 -0
  93. package/src/rum/types.ts +5 -0
  94. package/src/sdk/DatadogProvider/Buffer/BoundedBuffer.ts +22 -14
  95. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +7 -6
  96. package/src/sdk/DatadogProvider/__tests__/initializationModes.test.tsx +5 -5
  97. package/src/specs/NativeDdRum.ts +5 -0
  98. package/src/trace/DdTrace.ts +2 -2
  99. package/src/utils/Timer.ts +5 -5
  100. package/src/utils/__tests__/TimeProvider.test.tsx +24 -7
  101. package/src/utils/__tests__/Timer.test.ts +38 -22
  102. package/src/utils/time-provider/DefaultTimeProvider.tsx +31 -0
  103. package/src/utils/{TimeProvider.tsx → time-provider/TimeProvider.tsx} +8 -27
  104. package/src/version.ts +1 -1
  105. package/lib/commonjs/utils/TimeProvider.js.map +0 -1
  106. package/lib/module/utils/TimeProvider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["NativeDdRum.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AA0IA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,OAA9B,CAAf","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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeRumType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\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(key: string, context: Object, timestampMs: number): 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: string,\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: string,\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: string,\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: string,\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: string,\n stacktrace: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an Object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: Object): Promise<void>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdRum');\n"]}
1
+ {"version":3,"sources":["NativeDdRum.ts"],"names":["TurboModuleRegistry","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AAEA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;;AA+IA,eAAeA,mBAAmB,CAACC,GAApB,CAA8B,OAA9B,CAAf","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/* eslint-disable @typescript-eslint/ban-types */\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * Do not import this Spec directly, use DdNativeRumType instead.\n */\nexport interface Spec extends TurboModule {\n readonly getConstants: () => {};\n\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(key: string, context: Object, timestampMs: number): 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: string,\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: string,\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: string,\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: string,\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: string,\n stacktrace: string,\n context: Object,\n timestampMs: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n\n /**\n * Adds the result of evaluating a feature flag with a given name and value to the view.\n * Feature flag evaluations are local to the active view and are cleared when the view is stopped.\n * @param name: The name of the feature flag\n * @param value: The value of the feature flag, encapsulated in an Object to accept all types\n */\n addFeatureFlagEvaluation(name: string, value: Object): Promise<void>;\n\n /**\n * Get current Session ID, or `undefined` if not available.\n */\n getCurrentSessionId(): Promise<string | undefined>;\n}\n\nexport default TurboModuleRegistry.get<Spec>('DdRum');\n"]}
@@ -8,8 +8,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  import { InternalLog } from '../InternalLog';
9
9
  import { SdkVerbosity } from '../SdkVerbosity';
10
10
  import { bufferNativeCallReturningId, bufferNativeCallWithId } from '../sdk/DatadogProvider/Buffer/bufferNativeCall';
11
- import { TimeProvider } from '../utils/TimeProvider';
12
- const timeProvider = new TimeProvider();
11
+ import { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';
12
+ const timeProvider = new DefaultTimeProvider();
13
13
 
14
14
  class DdTraceWrapper {
15
15
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"sources":["DdTrace.ts"],"names":["InternalLog","SdkVerbosity","bufferNativeCallReturningId","bufferNativeCallWithId","TimeProvider","timeProvider","DdTraceWrapper","require","default","operation","context","timestampMs","now","spanId","nativeTrace","startSpan","log","DEBUG","id","finishSpan","DdTrace"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SACIC,2BADJ,EAEIC,sBAFJ,QAGO,gDAHP;AAKA,SAASC,YAAT,QAA6B,uBAA7B;AAEA,MAAMC,YAAY,GAAG,IAAID,YAAJ,EAArB;;AAEA,MAAME,cAAN,CAA4C;AAAA;AAAA,yCAECC,OAAO,CAAC,wBAAD,CAAP,CACpCC,OAHmC;;AAAA,uCAK5B,CACRC,SADQ,EAERC,OAAe,GAAG,EAFV,EAGRC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHd,KAIU;AAClB,YAAMC,MAAM,GAAGX,2BAA2B,CAAC,MACvC,KAAKY,WAAL,CAAiBC,SAAjB,CAA2BN,SAA3B,EAAsCC,OAAtC,EAA+CC,WAA/C,CADsC,CAA1C;AAGAX,MAAAA,WAAW,CAACgB,GAAZ,CACK,kBAAiBP,SAAU,MAAKI,MAAO,EAD5C,EAEIZ,YAAY,CAACgB,KAFjB;AAIA,aAAOJ,MAAP;AACH,KAlBuC;;AAAA,wCAoB3B,CACTA,MADS,EAETH,OAAe,GAAG,EAFT,EAGTC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHb,KAIO;AAChBZ,MAAAA,WAAW,CAACgB,GAAZ,CAAiB,mBAAkBH,MAAO,EAA1C,EAA6CZ,YAAY,CAACgB,KAA1D;AACA,aAAOd,sBAAsB,CACzBe,EAAE,IAAI,KAAKJ,WAAL,CAAiBK,UAAjB,CAA4BD,EAA5B,EAAgCR,OAAhC,EAAyCC,WAAzC,CADmB,EAEzBE,MAFyB,CAA7B;AAIH,KA9BuC;AAAA;;AAAA;;AAiC5C,MAAMO,OAAoB,GAAG,IAAId,cAAJ,EAA7B;AAEA,SAASc,OAAT","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 { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeTraceType } from '../nativeModulesTypes';\nimport {\n bufferNativeCallReturningId,\n bufferNativeCallWithId\n} from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport type { DdTraceType } from '../types';\nimport { TimeProvider } from '../utils/TimeProvider';\n\nconst timeProvider = new TimeProvider();\n\nclass DdTraceWrapper implements DdTraceType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeTrace: DdNativeTraceType = require('../specs/NativeDdTrace')\n .default;\n\n startSpan = (\n operation: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<string> => {\n const spanId = bufferNativeCallReturningId(() =>\n this.nativeTrace.startSpan(operation, context, timestampMs)\n );\n InternalLog.log(\n `Starting span “${operation}” #${spanId}`,\n SdkVerbosity.DEBUG\n );\n return spanId;\n };\n\n finishSpan = (\n spanId: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(`Finishing span #${spanId}`, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId(\n id => this.nativeTrace.finishSpan(id, context, timestampMs),\n spanId\n );\n };\n}\n\nconst DdTrace: DdTraceType = new DdTraceWrapper();\n\nexport { DdTrace };\n"]}
1
+ {"version":3,"sources":["DdTrace.ts"],"names":["InternalLog","SdkVerbosity","bufferNativeCallReturningId","bufferNativeCallWithId","DefaultTimeProvider","timeProvider","DdTraceWrapper","require","default","operation","context","timestampMs","now","spanId","nativeTrace","startSpan","log","DEBUG","id","finishSpan","DdTrace"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAEA,SACIC,2BADJ,EAEIC,sBAFJ,QAGO,gDAHP;AAKA,SAASC,mBAAT,QAAoC,4CAApC;AAEA,MAAMC,YAAY,GAAG,IAAID,mBAAJ,EAArB;;AAEA,MAAME,cAAN,CAA4C;AAAA;AAAA,yCAECC,OAAO,CAAC,wBAAD,CAAP,CACpCC,OAHmC;;AAAA,uCAK5B,CACRC,SADQ,EAERC,OAAe,GAAG,EAFV,EAGRC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHd,KAIU;AAClB,YAAMC,MAAM,GAAGX,2BAA2B,CAAC,MACvC,KAAKY,WAAL,CAAiBC,SAAjB,CAA2BN,SAA3B,EAAsCC,OAAtC,EAA+CC,WAA/C,CADsC,CAA1C;AAGAX,MAAAA,WAAW,CAACgB,GAAZ,CACK,kBAAiBP,SAAU,MAAKI,MAAO,EAD5C,EAEIZ,YAAY,CAACgB,KAFjB;AAIA,aAAOJ,MAAP;AACH,KAlBuC;;AAAA,wCAoB3B,CACTA,MADS,EAETH,OAAe,GAAG,EAFT,EAGTC,WAAmB,GAAGN,YAAY,CAACO,GAAb,EAHb,KAIO;AAChBZ,MAAAA,WAAW,CAACgB,GAAZ,CAAiB,mBAAkBH,MAAO,EAA1C,EAA6CZ,YAAY,CAACgB,KAA1D;AACA,aAAOd,sBAAsB,CACzBe,EAAE,IAAI,KAAKJ,WAAL,CAAiBK,UAAjB,CAA4BD,EAA5B,EAAgCR,OAAhC,EAAyCC,WAAzC,CADmB,EAEzBE,MAFyB,CAA7B;AAIH,KA9BuC;AAAA;;AAAA;;AAiC5C,MAAMO,OAAoB,GAAG,IAAId,cAAJ,EAA7B;AAEA,SAASc,OAAT","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 { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeTraceType } from '../nativeModulesTypes';\nimport {\n bufferNativeCallReturningId,\n bufferNativeCallWithId\n} from '../sdk/DatadogProvider/Buffer/bufferNativeCall';\nimport type { DdTraceType } from '../types';\nimport { DefaultTimeProvider } from '../utils/time-provider/DefaultTimeProvider';\n\nconst timeProvider = new DefaultTimeProvider();\n\nclass DdTraceWrapper implements DdTraceType {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n private nativeTrace: DdNativeTraceType = require('../specs/NativeDdTrace')\n .default;\n\n startSpan = (\n operation: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<string> => {\n const spanId = bufferNativeCallReturningId(() =>\n this.nativeTrace.startSpan(operation, context, timestampMs)\n );\n InternalLog.log(\n `Starting span “${operation}” #${spanId}`,\n SdkVerbosity.DEBUG\n );\n return spanId;\n };\n\n finishSpan = (\n spanId: string,\n context: object = {},\n timestampMs: number = timeProvider.now()\n ): Promise<void> => {\n InternalLog.log(`Finishing span #${spanId}`, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId(\n id => this.nativeTrace.finishSpan(id, context, timestampMs),\n spanId\n );\n };\n}\n\nconst DdTrace: DdTraceType = new DdTraceWrapper();\n\nexport { DdTrace };\n"]}
@@ -5,7 +5,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
5
5
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
- import { TimeProvider } from './TimeProvider';
8
+ import { DefaultTimeProvider } from './time-provider/DefaultTimeProvider';
9
9
  const START_LABEL = '__start';
10
10
  const STOP_LABEL = '__stop';
11
11
  /**
@@ -14,7 +14,7 @@ const STOP_LABEL = '__stop';
14
14
  */
15
15
 
16
16
  export default class Timer {
17
- constructor(timeProvider = new TimeProvider()) {
17
+ constructor(timeProvider = new DefaultTimeProvider()) {
18
18
  _defineProperty(this, "timeProvider", void 0);
19
19
 
20
20
  _defineProperty(this, "times", {});
@@ -64,8 +64,8 @@ export default class Timer {
64
64
  }
65
65
 
66
66
  durationBetweenTicks(start, end) {
67
- if (start.react_native != null && end.react_native != null) {
68
- return end.react_native - start.react_native;
67
+ if (start.reactNative != null && end.reactNative != null) {
68
+ return end.reactNative - start.reactNative;
69
69
  }
70
70
 
71
71
  return end.unix - start.unix;
@@ -1 +1 @@
1
- {"version":3,"sources":["Timer.ts"],"names":["TimeProvider","START_LABEL","STOP_LABEL","Timer","constructor","timeProvider","startTime","times","unix","stopTime","durationBetween","start","recordTick","stop","label","getTimestamp","hasTickFor","startLabel","endLabel","checkLabelExists","startTick","endTick","durationBetweenTicks","timeAt","reset","end","react_native","Error"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,YAAT,QAA6B,gBAA7B;AAEA,MAAMC,WAAW,GAAG,SAApB;AACA,MAAMC,UAAU,GAAG,QAAnB;AAEA;AACA;AACA;AACA;;AACA,eAAe,MAAMC,KAAN,CAAY;AAIvBC,EAAAA,WAAW,CAACC,YAA0B,GAAG,IAAIL,YAAJ,EAA9B,EAAkD;AAAA;;AAAA,mCAFlB,EAEkB;;AACzD,SAAKK,YAAL,GAAoBA,YAApB;AACH;;AAEY,MAATC,SAAS,GAAW;AACpB,WAAO,KAAKC,KAAL,CAAWN,WAAX,EAAwBO,IAA/B;AACH;;AAEW,MAARC,QAAQ,GAAW;AACnB,WAAO,KAAKH,SAAL,GAAiB,KAAKI,eAAL,CAAqBT,WAArB,EAAkCC,UAAlC,CAAxB;AACH;;AAEDS,EAAAA,KAAK,GAAS;AACV,SAAKC,UAAL,CAAgBX,WAAhB;AACH;;AAEDY,EAAAA,IAAI,GAAS;AACT,SAAKD,UAAL,CAAgBV,UAAhB;AACH;;AAEDU,EAAAA,UAAU,CAACE,KAAD,EAAsB;AAC5B,SAAKP,KAAL,CAAWO,KAAX,IAAoB,KAAKT,YAAL,CAAkBU,YAAlB,EAApB;AACH;;AAEDC,EAAAA,UAAU,CAACF,KAAD,EAAyB;AAC/B,WAAOA,KAAK,IAAI,KAAKP,KAArB;AACH;;AAEDG,EAAAA,eAAe,CAACO,UAAD,EAAqBC,QAArB,EAA+C;AAC1D,SAAKC,gBAAL,CAAsBF,UAAtB;AACA,SAAKE,gBAAL,CAAsBD,QAAtB;AAEA,UAAME,SAAS,GAAG,KAAKb,KAAL,CAAWU,UAAX,CAAlB;AACA,UAAMI,OAAO,GAAG,KAAKd,KAAL,CAAWW,QAAX,CAAhB;AAEA,WAAO,KAAKI,oBAAL,CAA0BF,SAA1B,EAAqCC,OAArC,CAAP;AACH;;AAEDE,EAAAA,MAAM,CAACT,KAAD,EAAwB;AAC1B,SAAKK,gBAAL,CAAsBL,KAAtB;AAEA,WAAO,KAAKR,SAAL,GAAiB,KAAKI,eAAL,CAAqBT,WAArB,EAAkCa,KAAlC,CAAxB;AACH;;AAEDU,EAAAA,KAAK,GAAS;AACV,SAAKjB,KAAL,GAAa,EAAb;AACH;;AAEOe,EAAAA,oBAAoB,CAACX,KAAD,EAAmBc,GAAnB,EAA2C;AACnE,QAAId,KAAK,CAACe,YAAN,IAAsB,IAAtB,IAA8BD,GAAG,CAACC,YAAJ,IAAoB,IAAtD,EAA4D;AACxD,aAAOD,GAAG,CAACC,YAAJ,GAAmBf,KAAK,CAACe,YAAhC;AACH;;AACD,WAAOD,GAAG,CAACjB,IAAJ,GAAWG,KAAK,CAACH,IAAxB;AACH;;AAEOW,EAAAA,gBAAgB,CAACL,KAAD,EAAgB;AACpC,QAAI,CAAC,KAAKE,UAAL,CAAgBF,KAAhB,CAAL,EAA6B;AACzB,YAAM,IAAIa,KAAJ,CAAW,SAAQb,KAAM,oBAAzB,CAAN;AACH;AACJ;;AA/DsB","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 { Timestamp } from './TimeProvider';\nimport { TimeProvider } from './TimeProvider';\n\nconst START_LABEL = '__start';\nconst STOP_LABEL = '__stop';\n\n/**\n * Simple timer which records time ticks. Shouldn't be re-used once stopped.\n * All timestamps/durations returned are in milliseconds.\n */\nexport default class Timer {\n private timeProvider: TimeProvider;\n private times: Record<string, Timestamp> = {};\n\n constructor(timeProvider: TimeProvider = new TimeProvider()) {\n this.timeProvider = timeProvider;\n }\n\n get startTime(): number {\n return this.times[START_LABEL].unix;\n }\n\n get stopTime(): number {\n return this.startTime + this.durationBetween(START_LABEL, STOP_LABEL);\n }\n\n start(): void {\n this.recordTick(START_LABEL);\n }\n\n stop(): void {\n this.recordTick(STOP_LABEL);\n }\n\n recordTick(label: string): void {\n this.times[label] = this.timeProvider.getTimestamp();\n }\n\n hasTickFor(label: string): boolean {\n return label in this.times;\n }\n\n durationBetween(startLabel: string, endLabel: string): number {\n this.checkLabelExists(startLabel);\n this.checkLabelExists(endLabel);\n\n const startTick = this.times[startLabel];\n const endTick = this.times[endLabel];\n\n return this.durationBetweenTicks(startTick, endTick);\n }\n\n timeAt(label: string): number {\n this.checkLabelExists(label);\n\n return this.startTime + this.durationBetween(START_LABEL, label);\n }\n\n reset(): void {\n this.times = {};\n }\n\n private durationBetweenTicks(start: Timestamp, end: Timestamp): number {\n if (start.react_native != null && end.react_native != null) {\n return end.react_native - start.react_native;\n }\n return end.unix - start.unix;\n }\n\n private checkLabelExists(label: string) {\n if (!this.hasTickFor(label)) {\n throw new Error(`Label ${label} is not registered`);\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["Timer.ts"],"names":["DefaultTimeProvider","START_LABEL","STOP_LABEL","Timer","constructor","timeProvider","startTime","times","unix","stopTime","durationBetween","start","recordTick","stop","label","getTimestamp","hasTickFor","startLabel","endLabel","checkLabelExists","startTick","endTick","durationBetweenTicks","timeAt","reset","end","reactNative","Error"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,mBAAT,QAAoC,qCAApC;AAGA,MAAMC,WAAW,GAAG,SAApB;AACA,MAAMC,UAAU,GAAG,QAAnB;AAEA;AACA;AACA;AACA;;AACA,eAAe,MAAMC,KAAN,CAAY;AAIvBC,EAAAA,WAAW,CAACC,YAA0B,GAAG,IAAIL,mBAAJ,EAA9B,EAAyD;AAAA;;AAAA,mCAFzB,EAEyB;;AAChE,SAAKK,YAAL,GAAoBA,YAApB;AACH;;AAEY,MAATC,SAAS,GAAW;AACpB,WAAO,KAAKC,KAAL,CAAWN,WAAX,EAAwBO,IAA/B;AACH;;AAEW,MAARC,QAAQ,GAAW;AACnB,WAAO,KAAKH,SAAL,GAAiB,KAAKI,eAAL,CAAqBT,WAArB,EAAkCC,UAAlC,CAAxB;AACH;;AAEDS,EAAAA,KAAK,GAAS;AACV,SAAKC,UAAL,CAAgBX,WAAhB;AACH;;AAEDY,EAAAA,IAAI,GAAS;AACT,SAAKD,UAAL,CAAgBV,UAAhB;AACH;;AAEDU,EAAAA,UAAU,CAACE,KAAD,EAAsB;AAC5B,SAAKP,KAAL,CAAWO,KAAX,IAAoB,KAAKT,YAAL,CAAkBU,YAAlB,EAApB;AACH;;AAEDC,EAAAA,UAAU,CAACF,KAAD,EAAyB;AAC/B,WAAOA,KAAK,IAAI,KAAKP,KAArB;AACH;;AAEDG,EAAAA,eAAe,CAACO,UAAD,EAAqBC,QAArB,EAA+C;AAC1D,SAAKC,gBAAL,CAAsBF,UAAtB;AACA,SAAKE,gBAAL,CAAsBD,QAAtB;AAEA,UAAME,SAAS,GAAG,KAAKb,KAAL,CAAWU,UAAX,CAAlB;AACA,UAAMI,OAAO,GAAG,KAAKd,KAAL,CAAWW,QAAX,CAAhB;AAEA,WAAO,KAAKI,oBAAL,CAA0BF,SAA1B,EAAqCC,OAArC,CAAP;AACH;;AAEDE,EAAAA,MAAM,CAACT,KAAD,EAAwB;AAC1B,SAAKK,gBAAL,CAAsBL,KAAtB;AAEA,WAAO,KAAKR,SAAL,GAAiB,KAAKI,eAAL,CAAqBT,WAArB,EAAkCa,KAAlC,CAAxB;AACH;;AAEDU,EAAAA,KAAK,GAAS;AACV,SAAKjB,KAAL,GAAa,EAAb;AACH;;AAEOe,EAAAA,oBAAoB,CAACX,KAAD,EAAmBc,GAAnB,EAA2C;AACnE,QAAId,KAAK,CAACe,WAAN,IAAqB,IAArB,IAA6BD,GAAG,CAACC,WAAJ,IAAmB,IAApD,EAA0D;AACtD,aAAOD,GAAG,CAACC,WAAJ,GAAkBf,KAAK,CAACe,WAA/B;AACH;;AACD,WAAOD,GAAG,CAACjB,IAAJ,GAAWG,KAAK,CAACH,IAAxB;AACH;;AAEOW,EAAAA,gBAAgB,CAACL,KAAD,EAAgB;AACpC,QAAI,CAAC,KAAKE,UAAL,CAAgBF,KAAhB,CAAL,EAA6B;AACzB,YAAM,IAAIa,KAAJ,CAAW,SAAQb,KAAM,oBAAzB,CAAN;AACH;AACJ;;AA/DsB","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 { DefaultTimeProvider } from './time-provider/DefaultTimeProvider';\nimport type { TimeProvider, Timestamp } from './time-provider/TimeProvider';\n\nconst START_LABEL = '__start';\nconst STOP_LABEL = '__stop';\n\n/**\n * Simple timer which records time ticks. Shouldn't be re-used once stopped.\n * All timestamps/durations returned are in milliseconds.\n */\nexport default class Timer {\n private timeProvider: TimeProvider;\n private times: Record<string, Timestamp> = {};\n\n constructor(timeProvider: TimeProvider = new DefaultTimeProvider()) {\n this.timeProvider = timeProvider;\n }\n\n get startTime(): number {\n return this.times[START_LABEL].unix;\n }\n\n get stopTime(): number {\n return this.startTime + this.durationBetween(START_LABEL, STOP_LABEL);\n }\n\n start(): void {\n this.recordTick(START_LABEL);\n }\n\n stop(): void {\n this.recordTick(STOP_LABEL);\n }\n\n recordTick(label: string): void {\n this.times[label] = this.timeProvider.getTimestamp();\n }\n\n hasTickFor(label: string): boolean {\n return label in this.times;\n }\n\n durationBetween(startLabel: string, endLabel: string): number {\n this.checkLabelExists(startLabel);\n this.checkLabelExists(endLabel);\n\n const startTick = this.times[startLabel];\n const endTick = this.times[endLabel];\n\n return this.durationBetweenTicks(startTick, endTick);\n }\n\n timeAt(label: string): number {\n this.checkLabelExists(label);\n\n return this.startTime + this.durationBetween(START_LABEL, label);\n }\n\n reset(): void {\n this.times = {};\n }\n\n private durationBetweenTicks(start: Timestamp, end: Timestamp): number {\n if (start.reactNative != null && end.reactNative != null) {\n return end.reactNative - start.reactNative;\n }\n return end.unix - start.unix;\n }\n\n private checkLabelExists(label: string) {\n if (!this.hasTickFor(label)) {\n throw new Error(`Label ${label} is not registered`);\n }\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ 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; }
2
+
3
+ /*
4
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
5
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
6
+ * Copyright 2016-Present Datadog, Inc.
7
+ */
8
+ import { TimeProvider } from './TimeProvider';
9
+ export class DefaultTimeProvider extends TimeProvider {
10
+ constructor(...args) {
11
+ super(...args);
12
+
13
+ _defineProperty(this, "canUsePerformanceNow", // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
+ // @ts-ignore
15
+ global.performance && typeof performance.now === 'function');
16
+ }
17
+
18
+ getTimestamp() {
19
+ return {
20
+ unix: Date.now(),
21
+ reactNative: this.performanceNow()
22
+ };
23
+ }
24
+
25
+ performanceNow() {
26
+ if (this.canUsePerformanceNow) {
27
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
+ // @ts-ignore
29
+ return performance.now();
30
+ }
31
+
32
+ return null;
33
+ }
34
+
35
+ }
36
+ //# sourceMappingURL=DefaultTimeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DefaultTimeProvider.tsx"],"names":["TimeProvider","DefaultTimeProvider","global","performance","now","getTimestamp","unix","Date","reactNative","performanceNow","canUsePerformanceNow"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,YAAT,QAA6B,gBAA7B;AAGA,OAAO,MAAMC,mBAAN,SAAkCD,YAAlC,CAA+C;AAAA;AAAA;;AAAA,kDAE9C;AACA;AACAE,IAAAA,MAAM,CAACC,WAAP,IAAsB,OAAOA,WAAW,CAACC,GAAnB,KAA2B,UAJH;AAAA;;AAMlDC,EAAAA,YAAY,GAAc;AACtB,WAAO;AACHC,MAAAA,IAAI,EAAEC,IAAI,CAACH,GAAL,EADH;AAEHI,MAAAA,WAAW,EAAE,KAAKC,cAAL;AAFV,KAAP;AAIH;;AAEOA,EAAAA,cAAc,GAAkB;AACpC,QAAI,KAAKC,oBAAT,EAA+B;AAC3B;AACA;AACA,aAAOP,WAAW,CAACC,GAAZ,EAAP;AACH;;AACD,WAAO,IAAP;AACH;;AApBiD","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 { TimeProvider } from './TimeProvider';\nimport type { Timestamp } from './TimeProvider';\n\nexport class DefaultTimeProvider extends TimeProvider {\n private canUsePerformanceNow =\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n global.performance && typeof performance.now === 'function';\n\n getTimestamp(): Timestamp {\n return {\n unix: Date.now(),\n reactNative: this.performanceNow()\n };\n }\n\n private performanceNow(): number | null {\n if (this.canUsePerformanceNow) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return performance.now();\n }\n return null;\n }\n}\n"]}
@@ -17,47 +17,26 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
17
17
  export class TimeProvider {
18
18
  /** Keeps an average offset between the unix time and the provided timestamp. */
19
19
  constructor() {
20
- _defineProperty(this, "canUsePerformanceNow", // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21
- // @ts-ignore
22
- global.performance && typeof performance.now === 'function');
23
-
24
20
  _defineProperty(this, "baseOffset", void 0);
25
21
 
26
22
  const timestamp = this.getTimestamp();
27
23
 
28
- if (timestamp.react_native == null) {
24
+ if (timestamp.reactNative == null) {
29
25
  this.baseOffset = 0;
30
26
  } else {
31
- this.baseOffset = timestamp.unix - timestamp.react_native;
27
+ this.baseOffset = timestamp.unix - timestamp.reactNative;
32
28
  }
33
29
  }
34
30
 
35
- getTimestamp() {
36
- return {
37
- unix: Date.now(),
38
- react_native: this.performanceNow()
39
- };
40
- }
41
-
42
31
  now() {
43
32
  const timestamp = this.getTimestamp();
44
33
 
45
- if (timestamp.react_native == null) {
34
+ if (timestamp.reactNative == null) {
46
35
  return timestamp.unix;
47
36
  } else {
48
- return this.baseOffset + timestamp.react_native;
37
+ return this.baseOffset + timestamp.reactNative;
49
38
  }
50
39
  }
51
40
 
52
- performanceNow() {
53
- if (this.canUsePerformanceNow) {
54
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
55
- // @ts-ignore
56
- return performance.now();
57
- }
58
-
59
- return null;
60
- }
61
-
62
41
  }
63
42
  //# sourceMappingURL=TimeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TimeProvider.tsx"],"names":["TimeProvider","constructor","timestamp","getTimestamp","reactNative","baseOffset","unix","now"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA,OAAO,MAAeA,YAAf,CAA4B;AAC/B;AAGAC,EAAAA,WAAW,GAAG;AAAA;;AACV,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;;AACA,QAAID,SAAS,CAACE,WAAV,IAAyB,IAA7B,EAAmC;AAC/B,WAAKC,UAAL,GAAkB,CAAlB;AACH,KAFD,MAEO;AACH,WAAKA,UAAL,GAAkBH,SAAS,CAACI,IAAV,GAAiBJ,SAAS,CAACE,WAA7C;AACH;AACJ;;AAIDG,EAAAA,GAAG,GAAW;AACV,UAAML,SAAS,GAAG,KAAKC,YAAL,EAAlB;;AACA,QAAID,SAAS,CAACE,WAAV,IAAyB,IAA7B,EAAmC;AAC/B,aAAOF,SAAS,CAACI,IAAjB;AACH,KAFD,MAEO;AACH,aAAO,KAAKD,UAAL,GAAkBH,SAAS,CAACE,WAAnC;AACH;AACJ;;AAtB8B","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 Timestamp structure holding the\n */\nexport type Timestamp = {\n // Result of Date API. Unix timestamp in ms.\n unix: number;\n // Result of performance.now API. Timestamp in ms (with microsecond precision)\n // since JS context start.\n reactNative: number | null;\n};\n\n/**\n * Simple class providing timestamps in milliseconds.\n * If available, it will use the `performance.now()` method, and will fallback on `Date.now()` otherwise.\n */\nexport abstract class TimeProvider {\n /** Keeps an average offset between the unix time and the provided timestamp. */\n protected baseOffset: number;\n\n constructor() {\n const timestamp = this.getTimestamp();\n if (timestamp.reactNative == null) {\n this.baseOffset = 0;\n } else {\n this.baseOffset = timestamp.unix - timestamp.reactNative;\n }\n }\n\n abstract getTimestamp(): Timestamp;\n\n now(): number {\n const timestamp = this.getTimestamp();\n if (timestamp.reactNative == null) {\n return timestamp.unix;\n } else {\n return this.baseOffset + timestamp.reactNative;\n }\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '2.3.2';
2
+ export const version = '2.3.4';
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 = '2.3.2';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '2.3.4';\n"]}
@@ -11,9 +11,9 @@ export declare class DdSdkReactNative {
11
11
  private static readonly DD_SDK_VERSION;
12
12
  private static readonly DD_VERSION;
13
13
  private static readonly DD_VERSION_SUFFIX;
14
- private static wasInitialized;
15
14
  private static wasAutoInstrumented;
16
15
  private static features?;
16
+ private static _isInitialized;
17
17
  /**
18
18
  * Initializes the Datadog SDK.
19
19
  * @param configuration the configuration for the SDK library
@@ -57,6 +57,10 @@ export declare class DdSdkReactNative {
57
57
  * @returns a Promise
58
58
  */
59
59
  static clearAllData: () => Promise<void>;
60
+ /**
61
+ * Returns `true` if the SDK was initialized, `false` otherwise.
62
+ */
63
+ static isInitialized(): boolean;
60
64
  private static buildConfiguration;
61
65
  private static enableFeatures;
62
66
  }
@@ -40,9 +40,9 @@ export declare enum BatchSize {
40
40
  */
41
41
  SMALL = "SMALL"
42
42
  }
43
- export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
44
- export declare type LegacyFirstPartyHost = string;
45
- export declare type CustomEndpoints = {
43
+ export type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
44
+ export type LegacyFirstPartyHost = string;
45
+ export type CustomEndpoints = {
46
46
  rum?: string;
47
47
  logs?: string;
48
48
  trace?: string;
@@ -243,7 +243,7 @@ export declare class DdSdkReactNativeConfiguration {
243
243
  * Auto Instrumentation configuration passed to DatadogProvider.
244
244
  * Does not include default values.
245
245
  */
246
- export declare type AutoInstrumentationConfiguration = {
246
+ export type AutoInstrumentationConfiguration = {
247
247
  readonly trackInteractions: boolean;
248
248
  readonly trackResources: boolean;
249
249
  readonly firstPartyHosts?: FirstPartyHostsConfiguration;
@@ -258,7 +258,7 @@ export declare type AutoInstrumentationConfiguration = {
258
258
  /**
259
259
  * Parameters needed to start auto instrumentation. Includes default values.
260
260
  */
261
- export declare type AutoInstrumentationParameters = {
261
+ export type AutoInstrumentationParameters = {
262
262
  readonly trackInteractions: boolean;
263
263
  readonly trackResources: boolean;
264
264
  readonly firstPartyHosts: FirstPartyHostsConfiguration;
@@ -275,7 +275,7 @@ export declare type AutoInstrumentationParameters = {
275
275
  * the older android jsc that can still be used.
276
276
  */
277
277
  export declare const addDefaultValuesToAutoInstrumentationConfiguration: (features: AutoInstrumentationConfiguration) => AutoInstrumentationParameters;
278
- export declare type PartialInitializationConfiguration = {
278
+ export type PartialInitializationConfiguration = {
279
279
  readonly clientToken: string;
280
280
  readonly env: string;
281
281
  readonly applicationId: string;
@@ -313,4 +313,4 @@ export declare enum InitializationMode {
313
313
  SYNC = "SYNC",
314
314
  ASYNC = "ASYNC"
315
315
  }
316
- export declare type InitializationModeForTelemetry = 'LEGACY' | 'SYNC' | 'ASYNC' | 'PARTIAL' | 'FILE';
316
+ export type InitializationModeForTelemetry = 'LEGACY' | 'SYNC' | 'ASYNC' | 'PARTIAL' | 'FILE';
@@ -11,4 +11,8 @@ import { RumActionType, ErrorSource, PropagatorType } from './rum/types';
11
11
  import { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';
12
12
  import { FileBasedConfiguration } from './sdk/FileBasedConfiguration/FileBasedConfiguration';
13
13
  import { DdTrace } from './trace/DdTrace';
14
- export { DatadogProvider, DatadogProviderConfiguration, FileBasedConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType, UploadFrequency, BatchSize, DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, DATADOG_GRAPH_QL_VARIABLES_HEADER };
14
+ import { DefaultTimeProvider } from './utils/time-provider/DefaultTimeProvider';
15
+ import { TimeProvider } from './utils/time-provider/TimeProvider';
16
+ import type { Timestamp } from './utils/time-provider/TimeProvider';
17
+ export { DatadogProvider, DatadogProviderConfiguration, FileBasedConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType, UploadFrequency, BatchSize, TimeProvider, DefaultTimeProvider, DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, DATADOG_GRAPH_QL_VARIABLES_HEADER };
18
+ export type { Timestamp };
@@ -2,7 +2,7 @@ import type { UserInfo } from '../sdk/UserInfoSingleton/types';
2
2
  /**
3
3
  * The entry point to use Datadog's Logs feature.
4
4
  */
5
- export declare type DdLogsType = {
5
+ export type DdLogsType = {
6
6
  /**
7
7
  * Send a log with debug level.
8
8
  * @param message: The message to send.
@@ -31,12 +31,12 @@ export declare type DdLogsType = {
31
31
  /**
32
32
  * Log input from developers
33
33
  */
34
- export declare type RawLog = {
34
+ export type RawLog = {
35
35
  message: string;
36
36
  context: object;
37
37
  status: LogStatus;
38
38
  };
39
- export declare type RawLogWithError = {
39
+ export type RawLogWithError = {
40
40
  message: string;
41
41
  errorKind: string;
42
42
  errorMessage: string;
@@ -47,19 +47,19 @@ export declare type RawLogWithError = {
47
47
  /**
48
48
  * Log input for native SDKs
49
49
  */
50
- export declare type NativeLog = {
50
+ export type NativeLog = {
51
51
  message: string;
52
52
  context: object;
53
53
  };
54
- export declare type NativeLogWithError = {
54
+ export type NativeLogWithError = {
55
55
  message: string;
56
56
  errorKind: string;
57
57
  errorMessage: string;
58
58
  stacktrace: string;
59
59
  context: object;
60
60
  };
61
- export declare type LogStatus = 'debug' | 'info' | 'warn' | 'error';
62
- export declare type LogEvent = {
61
+ export type LogStatus = 'debug' | 'info' | 'warn' | 'error';
62
+ export type LogEvent = {
63
63
  message: string;
64
64
  context: object;
65
65
  errorKind?: string;
@@ -69,9 +69,9 @@ export declare type LogEvent = {
69
69
  readonly userInfo: UserInfo;
70
70
  readonly attributes?: object;
71
71
  };
72
- export declare type LogEventMapper = (logEvent: LogEvent) => LogEvent | null;
73
- export declare type LogArguments = [message: string, context?: object];
74
- export declare type LogWithErrorArguments = [
72
+ export type LogEventMapper = (logEvent: LogEvent) => LogEvent | null;
73
+ export type LogArguments = [message: string, context?: object];
74
+ export type LogWithErrorArguments = [
75
75
  message: string,
76
76
  errorKind?: string,
77
77
  errorMessage?: string,
@@ -9,11 +9,11 @@ import type { Spec as NativeDdTrace } from './specs/NativeDdTrace';
9
9
  /**
10
10
  * The entry point to use Datadog's Logs feature.
11
11
  */
12
- export declare type DdNativeLogsType = NativeDdLogs;
12
+ export type DdNativeLogsType = NativeDdLogs;
13
13
  /**
14
14
  * The entry point to use Datadog's Trace feature.
15
15
  */
16
- export declare type DdNativeTraceType = NativeDdTrace;
16
+ export type DdNativeTraceType = NativeDdTrace;
17
17
  /**
18
18
  * A configuration object to initialize Datadog's features.
19
19
  */
@@ -38,9 +38,9 @@ export interface DdNativeSdkType extends NativeDdSdk {
38
38
  */
39
39
  initialize(configuration: DdNativeSdkConfiguration): Promise<void>;
40
40
  }
41
- declare type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
42
- declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
43
- declare type ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';
41
+ type ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';
42
+ type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
43
+ type ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';
44
44
  /**
45
45
  * The entry point to use Datadog's RUM feature.
46
46
  */
@@ -1,4 +1,5 @@
1
1
  import type { GestureResponderEvent } from 'react-native';
2
+ import type { TimeProvider } from '../utils/time-provider/TimeProvider';
2
3
  import type { ActionEventMapper } from './eventMappers/actionEventMapper';
3
4
  import type { ErrorEventMapper } from './eventMappers/errorEventMapper';
4
5
  import type { ResourceEventMapper } from './eventMappers/resourceEventMapper';
@@ -9,6 +10,7 @@ declare class DdRumWrapper implements DdRumType {
9
10
  private errorEventMapper;
10
11
  private resourceEventMapper;
11
12
  private actionEventMapper;
13
+ private timeProvider;
12
14
  startView: (key: string, name: string, context?: object, timestampMs?: number) => Promise<void>;
13
15
  stopView: (key: string, context?: object, timestampMs?: number) => Promise<void>;
14
16
  startAction: (type: RumActionType, name: string, context?: object, timestampMs?: number) => Promise<void>;
@@ -18,6 +20,7 @@ declare class DdRumWrapper implements DdRumType {
18
20
  context?: object,
19
21
  timestampMs?: number
20
22
  ] | [context?: object, timestampMs?: number]) => Promise<void>;
23
+ setTimeProvider: (timeProvider: TimeProvider) => void;
21
24
  private callNativeStopAction;
22
25
  private getStopActionNativeCallArgs;
23
26
  addAction: (type: RumActionType, name: string, context?: object, timestampMs?: number, actionContext?: GestureResponderEvent) => Promise<void>;
@@ -27,6 +30,7 @@ declare class DdRumWrapper implements DdRumType {
27
30
  addTiming: (name: string) => Promise<void>;
28
31
  stopSession: () => Promise<void>;
29
32
  addFeatureFlagEvaluation: (name: string, value: unknown) => Promise<void>;
33
+ getCurrentSessionId(): Promise<string | undefined>;
30
34
  registerErrorEventMapper(errorEventMapper: ErrorEventMapper): void;
31
35
  unregisterErrorEventMapper(): void;
32
36
  registerResourceEventMapper(resourceEventMapper: ResourceEventMapper): void;
@@ -2,20 +2,20 @@ import type { GestureResponderEvent } from 'react-native';
2
2
  import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
3
3
  import { EventMapper } from '../../sdk/EventMappers/EventMapper';
4
4
  import type { RumActionType } from '../types';
5
- declare type RawAction = {
5
+ type RawAction = {
6
6
  readonly type: RumActionType;
7
7
  readonly name: string;
8
8
  context: object;
9
9
  readonly timestampMs: number;
10
10
  actionContext?: GestureResponderEvent;
11
11
  };
12
- declare type ActionEvent = RawAction & AdditionalEventDataForMapper;
13
- declare type NativeAction = {
12
+ type ActionEvent = RawAction & AdditionalEventDataForMapper;
13
+ type NativeAction = {
14
14
  type: RumActionType;
15
15
  name: string;
16
16
  context: object;
17
17
  timestampMs: number;
18
18
  };
19
- export declare type ActionEventMapper = (event: ActionEvent) => ActionEvent | null;
19
+ export type ActionEventMapper = (event: ActionEvent) => ActionEvent | null;
20
20
  export declare const generateActionEventMapper: (eventMapper: ActionEventMapper | undefined) => EventMapper<RawAction, ActionEvent, NativeAction>;
21
21
  export {};
@@ -1,21 +1,21 @@
1
1
  import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
2
2
  import { EventMapper } from '../../sdk/EventMappers/EventMapper';
3
3
  import type { ErrorSource } from '../types';
4
- declare type RawError = {
4
+ type RawError = {
5
5
  message: string;
6
6
  source: ErrorSource;
7
7
  stacktrace: string;
8
8
  context: object;
9
9
  timestampMs: number;
10
10
  };
11
- declare type ErrorEvent = RawError & AdditionalEventDataForMapper;
12
- declare type NativeError = {
11
+ type ErrorEvent = RawError & AdditionalEventDataForMapper;
12
+ type NativeError = {
13
13
  message: string;
14
14
  source: ErrorSource;
15
15
  stacktrace: string;
16
16
  context: object;
17
17
  timestampMs: number;
18
18
  };
19
- export declare type ErrorEventMapper = (event: ErrorEvent) => ErrorEvent | null;
19
+ export type ErrorEventMapper = (event: ErrorEvent) => ErrorEvent | null;
20
20
  export declare const generateErrorEventMapper: (eventMapper: ErrorEventMapper | undefined) => EventMapper<RawError, ErrorEvent, NativeError>;
21
21
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
2
2
  import { EventMapper } from '../../sdk/EventMappers/EventMapper';
3
3
  import type { ResourceKind } from '../types';
4
- declare type RawResource = {
4
+ type RawResource = {
5
5
  readonly key: string;
6
6
  readonly statusCode: number;
7
7
  readonly kind: ResourceKind;
@@ -10,8 +10,8 @@ declare type RawResource = {
10
10
  readonly timestampMs: number;
11
11
  resourceContext: XMLHttpRequest | undefined;
12
12
  };
13
- declare type ResourceEvent = RawResource & AdditionalEventDataForMapper;
14
- declare type NativeResource = {
13
+ type ResourceEvent = RawResource & AdditionalEventDataForMapper;
14
+ type NativeResource = {
15
15
  key: string;
16
16
  statusCode: number;
17
17
  kind: ResourceKind;
@@ -19,6 +19,6 @@ declare type NativeResource = {
19
19
  context: object;
20
20
  timestampMs: number;
21
21
  };
22
- export declare type ResourceEventMapper = (event: ResourceEvent) => ResourceEvent | null;
22
+ export type ResourceEventMapper = (event: ResourceEvent) => ResourceEvent | null;
23
23
  export declare const generateResourceEventMapper: (eventMapper: ResourceEventMapper | undefined) => EventMapper<RawResource, ResourceEvent, NativeResource>;
24
24
  export {};
@@ -1,7 +1,7 @@
1
1
  import type { PropagatorType } from '../../../types';
2
2
  import type { RegexMap } from '../requestProxy/interfaces/RequestProxy';
3
3
  import type { Hostname } from './firstPartyHosts';
4
- export declare type DdRumResourceTracingAttributes = {
4
+ export type DdRumResourceTracingAttributes = {
5
5
  tracingStrategy: 'KEEP';
6
6
  traceId: TraceId;
7
7
  spanId: SpanId;
@@ -23,10 +23,10 @@ export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegexMap,
23
23
  * Using branded types will ensure we don't accidentally use
24
24
  * traceId for spanId when generating headers.
25
25
  */
26
- export declare type TraceId = TraceIdentifier & {
26
+ export type TraceId = TraceIdentifier & {
27
27
  _brand: 'traceId';
28
28
  };
29
- export declare type SpanId = TraceIdentifier & {
29
+ export type SpanId = TraceIdentifier & {
30
30
  _brand: 'spanId';
31
31
  };
32
32
  export declare class TraceIdentifier {
@@ -1,6 +1,6 @@
1
1
  import type { FirstPartyHost, PropagatorType } from '../../../types';
2
2
  import type { RegexMap } from '../requestProxy/interfaces/RequestProxy';
3
- export declare type Hostname = {
3
+ export type Hostname = {
4
4
  _type: 'Hostname';
5
5
  } & string;
6
6
  export declare const NO_MATCH_REGEX: RegExp;
@@ -1,5 +1,5 @@
1
1
  import type { RUMResource } from '../../interfaces/RumResource';
2
- declare type ResourceMapper = (resource: RUMResource) => RUMResource | null;
2
+ type ResourceMapper = (resource: RUMResource) => RUMResource | null;
3
3
  export declare class ResourceReporter {
4
4
  private mappers;
5
5
  constructor(resourceMappers: ResourceMapper[]);
@@ -3,7 +3,7 @@ export interface RequestProxyOptions {
3
3
  tracingSamplingRate: number;
4
4
  firstPartyHostsRegexMap: RegexMap;
5
5
  }
6
- export declare type RegexMap = {
6
+ export type RegexMap = {
7
7
  regex: RegExp;
8
8
  propagatorType: PropagatorType;
9
9
  }[];
@@ -20,7 +20,7 @@ export interface RUMResource {
20
20
  };
21
21
  resourceContext?: XMLHttpRequest;
22
22
  }
23
- export declare type DdRumResourceGraphqlAttributes = {
23
+ export type DdRumResourceGraphqlAttributes = {
24
24
  operationType?: string;
25
25
  operationName?: string;
26
26
  variables?: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The entry point to use Datadog's RUM feature.
3
3
  */
4
- export declare type DdRumType = {
4
+ export type DdRumType = {
5
5
  /**
6
6
  * Start tracking a RUM View.
7
7
  * @param key: The view unique key identifier.
@@ -88,6 +88,10 @@ export declare type DdRumType = {
88
88
  * Stops the current RUM Session.
89
89
  */
90
90
  stopSession(): Promise<void>;
91
+ /**
92
+ * Returns current session ID, or undefined if unavailable.
93
+ */
94
+ getCurrentSessionId(): Promise<string | undefined>;
91
95
  };
92
96
  /**
93
97
  * Describe the type of a RUM Action.
@@ -104,7 +108,7 @@ export declare enum RumActionType {
104
108
  /** A custom action. */
105
109
  CUSTOM = "CUSTOM"
106
110
  }
107
- export declare type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
111
+ export type ResourceKind = 'image' | 'xhr' | 'beacon' | 'css' | 'document' | 'fetch' | 'font' | 'js' | 'media' | 'other' | 'native';
108
112
  export declare enum ErrorSource {
109
113
  NETWORK = "NETWORK",
110
114
  SOURCE = "SOURCE",
@@ -125,7 +129,7 @@ export declare enum PropagatorType {
125
129
  B3 = "b3",
126
130
  B3MULTI = "b3multi"
127
131
  }
128
- export declare type FirstPartyHost = {
132
+ export type FirstPartyHost = {
129
133
  match: string;
130
134
  propagatorTypes: PropagatorType[];
131
135
  };
@@ -1,3 +1,3 @@
1
- export declare type Attributes = {
1
+ export type Attributes = {
2
2
  readonly [key: string]: unknown;
3
3
  };
@@ -9,6 +9,8 @@ export declare class BoundedBuffer extends DatadogBuffer {
9
9
  addCallbackReturningId: (callback: () => Promise<string>) => Promise<string>;
10
10
  addCallbackWithId: (callback: (id: string) => Promise<void>, bufferId: string) => Promise<void>;
11
11
  drain: () => Promise<void>;
12
+ private logBufferOverflow;
13
+ private logRandomIdGenerationError;
12
14
  private generateRandomBufferId;
13
15
  private addTelemetryEvent;
14
16
  private drainTelemetry;