@datadog/mobile-react-native 1.0.0-rc5 → 1.0.0-rc8

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 (128) hide show
  1. package/DatadogSDKReactNative.podspec +1 -1
  2. package/README.md +48 -17
  3. package/android/build.gradle +1 -1
  4. package/android/gradle.properties +4 -4
  5. package/ios/Sources/DdSdk.swift +6 -3
  6. package/lib/commonjs/DdSdkReactNative.js +35 -31
  7. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  8. package/lib/commonjs/DdSdkReactNativeConfiguration.js +20 -7
  9. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  10. package/lib/commonjs/InternalLog.js +10 -5
  11. package/lib/commonjs/InternalLog.js.map +1 -1
  12. package/lib/commonjs/ProxyConfiguration.js.map +1 -1
  13. package/lib/commonjs/SdkVerbosity.js.map +1 -1
  14. package/lib/commonjs/TimeProvider.js +72 -0
  15. package/lib/commonjs/TimeProvider.js.map +1 -0
  16. package/lib/commonjs/Timer.js +10 -23
  17. package/lib/commonjs/Timer.js.map +1 -1
  18. package/lib/commonjs/TrackingConsent.js.map +1 -1
  19. package/lib/commonjs/foundation.js +19 -54
  20. package/lib/commonjs/foundation.js.map +1 -1
  21. package/lib/commonjs/index.js +27 -19
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +16 -11
  24. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  25. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +19 -23
  26. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  27. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js +118 -42
  28. package/lib/commonjs/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
  29. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +46 -19
  30. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  31. package/lib/commonjs/rum/instrumentation/DdRumXhr.js +0 -4
  32. package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js +1 -1
  33. package/lib/commonjs/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
  34. package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js +34 -0
  35. package/lib/commonjs/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
  36. package/lib/commonjs/rum/instrumentation/TraceIdentifier.js.map +1 -1
  37. package/lib/commonjs/rum/instrumentation/URLHostParser.js +33 -0
  38. package/lib/commonjs/rum/instrumentation/URLHostParser.js.map +1 -0
  39. package/lib/commonjs/types.js.map +1 -1
  40. package/lib/commonjs/version.js +1 -1
  41. package/lib/commonjs/version.js.map +1 -1
  42. package/lib/module/DdSdkReactNative.js +33 -29
  43. package/lib/module/DdSdkReactNative.js.map +1 -1
  44. package/lib/module/DdSdkReactNativeConfiguration.js +21 -8
  45. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  46. package/lib/module/InternalLog.js +11 -5
  47. package/lib/module/InternalLog.js.map +1 -1
  48. package/lib/module/ProxyConfiguration.js.map +1 -1
  49. package/lib/module/SdkVerbosity.js.map +1 -1
  50. package/lib/module/TimeProvider.js +63 -0
  51. package/lib/module/TimeProvider.js.map +1 -0
  52. package/lib/module/Timer.js +14 -23
  53. package/lib/module/Timer.js.map +1 -1
  54. package/lib/module/TrackingConsent.js.map +1 -1
  55. package/lib/module/foundation.js +16 -39
  56. package/lib/module/foundation.js.map +1 -1
  57. package/lib/module/index.js +4 -3
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/rum/instrumentation/DdEventsInterceptor.js +12 -10
  60. package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  61. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +19 -23
  62. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  63. package/lib/module/rum/instrumentation/DdRumResourceTracking.js +113 -39
  64. package/lib/module/rum/instrumentation/DdRumResourceTracking.js.map +1 -1
  65. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +44 -17
  66. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  67. package/lib/module/rum/instrumentation/DdRumXhr.js +1 -1
  68. package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js +1 -1
  69. package/lib/module/rum/instrumentation/NoOpEventsInterceptor.js.map +1 -1
  70. package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js +25 -0
  71. package/lib/module/rum/instrumentation/ShallowObjectEqualityChecker.js.map +1 -0
  72. package/lib/module/rum/instrumentation/TraceIdentifier.js.map +1 -1
  73. package/lib/module/rum/instrumentation/URLHostParser.js +24 -0
  74. package/lib/module/rum/instrumentation/URLHostParser.js.map +1 -0
  75. package/lib/module/types.js.map +1 -1
  76. package/lib/module/version.js +1 -1
  77. package/lib/module/version.js.map +1 -1
  78. package/lib/typescript/DdSdkReactNative.d.ts +6 -6
  79. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +15 -3
  80. package/lib/typescript/InternalLog.d.ts +5 -0
  81. package/lib/typescript/TimeProvider.d.ts +20 -0
  82. package/lib/typescript/Timer.d.ts +3 -2
  83. package/lib/typescript/index.d.ts +4 -3
  84. package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +1 -0
  85. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +2 -2
  86. package/lib/typescript/rum/instrumentation/DdRumResourceTracking.d.ts +19 -9
  87. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -3
  88. package/lib/typescript/rum/instrumentation/DdRumXhr.d.ts +13 -3
  89. package/lib/typescript/rum/instrumentation/ShallowObjectEqualityChecker.d.ts +4 -0
  90. package/lib/typescript/rum/instrumentation/URLHostParser.d.ts +6 -0
  91. package/lib/typescript/version.d.ts +1 -1
  92. package/package.json +6 -3
  93. package/src/DdSdkReactNative.tsx +116 -70
  94. package/src/DdSdkReactNativeConfiguration.tsx +22 -13
  95. package/src/InternalLog.tsx +18 -16
  96. package/src/ProxyConfiguration.tsx +5 -5
  97. package/src/SdkVerbosity.tsx +4 -4
  98. package/src/TimeProvider.tsx +64 -0
  99. package/src/Timer.ts +20 -35
  100. package/src/TrackingConsent.tsx +3 -3
  101. package/src/__mocks__/InternalLog.tsx +9 -0
  102. package/src/__tests__/DdRumWrapper.test.tsx +40 -33
  103. package/src/__tests__/DdSdkReactNative.test.tsx +712 -513
  104. package/src/__tests__/InternalLog.test.tsx +114 -117
  105. package/src/__tests__/TimeProvider.test.tsx +75 -0
  106. package/src/__tests__/Timer.test.ts +148 -57
  107. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +151 -92
  108. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +168 -116
  109. package/src/__tests__/rum/instrumentation/DdRumResourceTracking.test.tsx +789 -644
  110. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +239 -85
  111. package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +31 -0
  112. package/src/__tests__/rum/instrumentation/TraceIdentifier.test.tsx +13 -15
  113. package/src/__tests__/rum/instrumentation/URLHostParser.test.ts +40 -0
  114. package/src/__tests__/rum/instrumentation/__utils__/XMLHttpRequestMock.ts +97 -0
  115. package/src/foundation.tsx +13 -10
  116. package/src/index.tsx +15 -4
  117. package/src/rum/instrumentation/DdEventsInterceptor.tsx +51 -35
  118. package/src/rum/instrumentation/DdRumErrorTracking.tsx +49 -44
  119. package/src/rum/instrumentation/DdRumResourceTracking.tsx +369 -234
  120. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +72 -29
  121. package/src/rum/instrumentation/DdRumXhr.tsx +21 -11
  122. package/src/rum/instrumentation/EventsInterceptor.tsx +3 -3
  123. package/src/rum/instrumentation/NoOpEventsInterceptor.tsx +2 -2
  124. package/src/rum/instrumentation/ShallowObjectEqualityChecker.ts +24 -0
  125. package/src/rum/instrumentation/TraceIdentifier.tsx +19 -19
  126. package/src/rum/instrumentation/URLHostParser.ts +23 -0
  127. package/src/types.tsx +199 -158
  128. package/src/version.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["TraceIdentifier.tsx"],"names":["generateTraceId","radix","MAX_32_BITS_NUMBER","low","Math","floor","random","high","str","modH","temp","digit","toString"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAEO,SAASA,eAAT,GAAmC;AACxC,QAAMC,KAAK,GAAG,EAAd;AACA,QAAMC,kBAAkB,GAAG,UAA3B,CAFwC,CAEF;;AACtC,MAAIC,GAAW,GAAGC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBJ,kBAA3B,CAAlB;AACA,MAAIK,IAAY,GAAGH,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBJ,kBAA3B,CAAnB;AACA,MAAIM,GAAG,GAAG,EAAV;;AAEA,SAAOD,IAAI,GAAG,CAAP,IAAYJ,GAAG,GAAG,CAAzB,EAA4B;AAC1B;AACA;AACA,UAAMM,IAAI,GAAGF,IAAI,GAAGN,KAApB;AACA,UAAMS,IAAI,GAAG,CAAED,IAAD,IAAU,EAAX,IAAiBN,GAA9B;AACA,UAAMQ,KAAK,GAAGD,IAAI,GAAGT,KAArB,CAL0B,CAO1B;;AACAM,IAAAA,IAAI,GAAG,CAACA,IAAI,GAAGE,IAAR,IAAgBR,KAAvB,CAR0B,CAQG;AAC7B;;AACAE,IAAAA,GAAG,GAAG,CAACO,IAAI,GAAGC,KAAR,IAAiBV,KAAvB,CAV0B,CAUG;AAE7B;;AACAO,IAAAA,GAAG,GAAGG,KAAK,CAACC,QAAN,KAAmBJ,GAAzB;AACD;;AACD,SAAOA,GAAP;AACD","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 * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)\n */\n\nexport function generateTraceId(): string {\n const radix = 10\n const MAX_32_BITS_NUMBER = 4294967295 // 2^32-1\n let low: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER)\n let high: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER)\n let str = ''\n\n while (high > 0 && low > 0) {\n // Create an intermediate value with the same modulo as the combined high and low value\n // but requiring 36 bits max (32 for the low value + 4 for the high part)\n const modH = high % radix\n const temp = ((modH) << 32) + low\n const digit = temp % radix\n\n // update the high value\n high = (high - modH) / radix // we reuse the modH to avoid the need of a floor op\n // the low value reuses the previous temp value to account for the \"missing mod\" in the high update\n low = (temp - digit) / radix // we reuse the digit to avoid the need of a floor op\n\n // update the string from right to left\n str = digit.toString() + str\n }\n return str\n}\n"]}
1
+ {"version":3,"sources":["TraceIdentifier.tsx"],"names":["generateTraceId","radix","MAX_32_BITS_NUMBER","low","Math","floor","random","high","str","modH","temp","digit","toString"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AAEO,SAASA,eAAT,GAAmC;AACtC,QAAMC,KAAK,GAAG,EAAd;AACA,QAAMC,kBAAkB,GAAG,UAA3B,CAFsC,CAEC;;AACvC,MAAIC,GAAW,GAAGC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBJ,kBAA3B,CAAlB;AACA,MAAIK,IAAY,GAAGH,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgBJ,kBAA3B,CAAnB;AACA,MAAIM,GAAG,GAAG,EAAV;;AAEA,SAAOD,IAAI,GAAG,CAAP,IAAYJ,GAAG,GAAG,CAAzB,EAA4B;AACxB;AACA;AACA,UAAMM,IAAI,GAAGF,IAAI,GAAGN,KAApB;AACA,UAAMS,IAAI,GAAG,CAACD,IAAI,IAAI,EAAT,IAAeN,GAA5B;AACA,UAAMQ,KAAK,GAAGD,IAAI,GAAGT,KAArB,CALwB,CAOxB;;AACAM,IAAAA,IAAI,GAAG,CAACA,IAAI,GAAGE,IAAR,IAAgBR,KAAvB,CARwB,CAQM;AAC9B;;AACAE,IAAAA,GAAG,GAAG,CAACO,IAAI,GAAGC,KAAR,IAAiBV,KAAvB,CAVwB,CAUM;AAE9B;;AACAO,IAAAA,GAAG,GAAGG,KAAK,CAACC,QAAN,KAAmBJ,GAAzB;AACH;;AACD,SAAOA,GAAP;AACH","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/*\n * This code was inspired from browser-sdk at (https://github.com/DataDog/browser-sdk/blob/master/packages/rum-core/src/domain/tracing/tracer.ts#L107)\n */\n\nexport function generateTraceId(): string {\n const radix = 10;\n const MAX_32_BITS_NUMBER = 4294967295; // 2^32-1\n let low: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let high: number = Math.floor(Math.random() * MAX_32_BITS_NUMBER);\n let str = '';\n\n while (high > 0 && low > 0) {\n // Create an intermediate value with the same modulo as the combined high and low value\n // but requiring 36 bits max (32 for the low value + 4 for the high part)\n const modH = high % radix;\n const temp = (modH << 32) + low;\n const digit = temp % radix;\n\n // update the high value\n high = (high - modH) / radix; // we reuse the modH to avoid the need of a floor op\n // the low value reuses the previous temp value to account for the \"missing mod\" in the high update\n low = (temp - digit) / radix; // we reuse the digit to avoid the need of a floor op\n\n // update the string from right to left\n str = digit.toString() + str;\n }\n return str;\n}\n"]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.URLHostParser = 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
+ // matches what is between the first "://" and the next "/", ":" or whitespace
14
+ const hostRegex = '^.+://([^:/\\s]+)';
15
+ /**
16
+ * Returns the host from an URL.
17
+ * @returns the host (without the port)
18
+ * @throws if URL is not well formatted
19
+ */
20
+
21
+ const URLHostParser = url => {
22
+ const matchedHost = url.match(hostRegex);
23
+
24
+ if (matchedHost === null) {
25
+ throw new Error(`${url} is not a correctly formatted URL`);
26
+ } // [0] is the input, [1] is the captured group
27
+
28
+
29
+ return matchedHost[1];
30
+ };
31
+
32
+ exports.URLHostParser = URLHostParser;
33
+ //# sourceMappingURL=URLHostParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["URLHostParser.ts"],"names":["hostRegex","URLHostParser","url","matchedHost","match","Error"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,SAAS,GAAG,mBAAlB;AAEA;AACA;AACA;AACA;AACA;;AACO,MAAMC,aAAa,GAAIC,GAAD,IAAyB;AAClD,QAAMC,WAAW,GAAGD,GAAG,CAACE,KAAJ,CAAUJ,SAAV,CAApB;;AACA,MAAIG,WAAW,KAAK,IAApB,EAA0B;AACtB,UAAM,IAAIE,KAAJ,CAAW,GAAEH,GAAI,mCAAjB,CAAN;AACH,GAJiD,CAMlD;;;AACA,SAAOC,WAAW,CAAC,CAAD,CAAlB;AACH,CARM","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// matches what is between the first \"://\" and the next \"/\", \":\" or whitespace\nconst hostRegex = '^.+://([^:/\\\\s]+)';\n\n/**\n * Returns the host from an URL.\n * @returns the host (without the port)\n * @throws if URL is not well formatted\n */\nexport const URLHostParser = (url: string): string => {\n const matchedHost = url.match(hostRegex);\n if (matchedHost === null) {\n throw new Error(`${url} is not a correctly formatted URL`);\n }\n\n // [0] is the input, [1] is the captured group\n return matchedHost[1];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC9BC,EAAAA,WAAW,CACAC,WADA,EAEAC,GAFA,EAGAC,aAHA,EAIAC,wBAJA,EAKAC,UALA,EAMAC,IANA,EAOAC,eAPA,EAQAC,gBARA,EAST;AAAA,SARSP,WAQT,GARSA,WAQT;AAAA,SAPSC,GAOT,GAPSA,GAOT;AAAA,SANSC,aAMT,GANSA,aAMT;AAAA,SALSC,wBAKT,GALSA,wBAKT;AAAA,SAJSC,UAIT,GAJSA,UAIT;AAAA,SAHSC,IAGT,GAHSA,IAGT;AAAA,SAFSC,eAET,GAFSA,eAET;AAAA,SADSC,gBACT,GADSA,gBACT;AAAE;;AAV0B;AAahC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(operation: string, context?: object, timestampMs?: number): 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(spanId: string, context?: object, timestampMs?: number): Promise<void>;\n\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(key: string, name: string, context?: object, timestampMs?: number): 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, click, 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(type: string, name: string, context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, 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(type: string, name: string, context?: object, timestampMs?: number): 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(key: string, method: string, url: string, context?: object, timestampMs?: number): 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(key: string, statusCode: number, kind: string, size?: number, context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, logger, …).\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(message: string, source: string, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n};\n\n"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, 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 context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, 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, logger, …).\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"]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '1.0.0-rc5';
8
+ const version = '1.0.0-rc8';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc5';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc8';\n"]}
@@ -5,15 +5,15 @@ 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 { DdSdkConfiguration } from "./types";
9
- import { DdSdk } from "./foundation";
10
- import { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';
8
+ import { InternalLog } from './InternalLog';
9
+ import { ProxyType } from './ProxyConfiguration';
10
+ import { SdkVerbosity } from './SdkVerbosity';
11
+ import { DdSdk } from './foundation';
11
12
  import { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';
12
13
  import { DdRumResourceTracking } from './rum/instrumentation/DdRumResourceTracking';
13
- import { ProxyType } from "./ProxyConfiguration";
14
+ import { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';
15
+ import { DdSdkConfiguration } from './types';
14
16
  import { version as sdkVersion } from './version';
15
- import { InternalLog } from "./InternalLog";
16
- import { SdkVerbosity } from "./SdkVerbosity";
17
17
  /**
18
18
  * This class initializes the Datadog SDK, and sets up communication with the server.
19
19
  */
@@ -22,10 +22,10 @@ export class DdSdkReactNative {
22
22
  // Proxy
23
23
 
24
24
  /**
25
- * Initializes the Datadog SDK.
26
- * @param configuration the configuration for the SDK library
27
- * @returns a Promise.
28
- */
25
+ * Initializes the Datadog SDK.
26
+ * @param configuration the configuration for the SDK library
27
+ * @returns a Promise.
28
+ */
29
29
  static initialize(configuration) {
30
30
  return new Promise((resolve, reject) => {
31
31
  if (DdSdkReactNative.wasInitialized) {
@@ -39,7 +39,7 @@ export class DdSdkReactNative {
39
39
  configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERSION] = sdkVersion;
40
40
  configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY] = configuration.nativeViewTracking;
41
41
 
42
- if (configuration.verbosity != undefined) {
42
+ if (configuration.verbosity) {
43
43
  configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERBOSITY_KEY] = configuration.verbosity;
44
44
  }
45
45
 
@@ -51,7 +51,7 @@ export class DdSdkReactNative {
51
51
  additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;
52
52
 
53
53
  if (proxyConfig.username && proxyConfig.password) {
54
- if (proxyConfig.type == ProxyType.SOCKS) {
54
+ if (proxyConfig.type === ProxyType.SOCKS) {
55
55
  console.warn("SOCKS proxy configuration doesn't support Basic authentication.");
56
56
  } else {
57
57
  additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;
@@ -65,8 +65,9 @@ export class DdSdkReactNative {
65
65
  }
66
66
 
67
67
  configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
68
- DdSdk.initialize(new DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig)).then(() => {
69
- InternalLog.log("Datadog SDK was initialized", SdkVerbosity.INFO);
68
+ configuration.additionalConfig['_dd.first_party_hosts'] = configuration.firstPartyHosts;
69
+ DdSdk.initialize(new DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig)).then(() => {
70
+ InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);
70
71
  DdSdkReactNative.enableFeatures(configuration);
71
72
  DdSdkReactNative.wasInitialized = true;
72
73
  resolve();
@@ -84,7 +85,7 @@ export class DdSdkReactNative {
84
85
 
85
86
 
86
87
  static setAttributes(attributes) {
87
- InternalLog.log("Setting attributes " + JSON.stringify(attributes), SdkVerbosity.DEBUG);
88
+ InternalLog.log(`Setting attributes ${JSON.stringify(attributes)}`, SdkVerbosity.DEBUG);
88
89
  return DdSdk.setAttributes(attributes);
89
90
  }
90
91
  /**
@@ -96,7 +97,7 @@ export class DdSdkReactNative {
96
97
 
97
98
 
98
99
  static setUser(user) {
99
- InternalLog.log("Setting user " + JSON.stringify(user), SdkVerbosity.DEBUG);
100
+ InternalLog.log(`Setting user ${JSON.stringify(user)}`, SdkVerbosity.DEBUG);
100
101
  return DdSdk.setUser(user);
101
102
  }
102
103
  /**
@@ -107,7 +108,7 @@ export class DdSdkReactNative {
107
108
 
108
109
 
109
110
  static setTrackingConsent(consent) {
110
- InternalLog.log("Setting consent " + consent, SdkVerbosity.DEBUG);
111
+ InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);
111
112
  return DdSdk.setTrackingConsent(consent);
112
113
  }
113
114
 
@@ -117,7 +118,10 @@ export class DdSdkReactNative {
117
118
  }
118
119
 
119
120
  if (configuration.trackResources) {
120
- DdRumResourceTracking.startTracking();
121
+ DdRumResourceTracking.startTracking({
122
+ tracingSamplingRate: configuration.resourceTracingSamplingRate,
123
+ firstPartyHosts: configuration.firstPartyHosts
124
+ });
121
125
  }
122
126
 
123
127
  if (configuration.trackErrors) {
@@ -127,27 +131,27 @@ export class DdSdkReactNative {
127
131
 
128
132
  }
129
133
 
130
- _defineProperty(DdSdkReactNative, "DD_SOURCE_KEY", "_dd.source");
134
+ _defineProperty(DdSdkReactNative, "DD_SOURCE_KEY", '_dd.source');
131
135
 
132
- _defineProperty(DdSdkReactNative, "DD_SDK_VERSION", "_dd.sdk_version");
136
+ _defineProperty(DdSdkReactNative, "DD_SDK_VERSION", '_dd.sdk_version');
133
137
 
134
- _defineProperty(DdSdkReactNative, "DD_SERVICE_NAME", "_dd.service_name");
138
+ _defineProperty(DdSdkReactNative, "DD_SERVICE_NAME", '_dd.service_name');
135
139
 
136
- _defineProperty(DdSdkReactNative, "DD_SDK_VERBOSITY_KEY", "_dd.sdk_verbosity");
140
+ _defineProperty(DdSdkReactNative, "DD_SDK_VERBOSITY_KEY", '_dd.sdk_verbosity');
137
141
 
138
- _defineProperty(DdSdkReactNative, "DD_NATIVE_VIEW_TRACKING_KEY", "_dd.native_view_tracking");
142
+ _defineProperty(DdSdkReactNative, "DD_NATIVE_VIEW_TRACKING_KEY", '_dd.native_view_tracking');
139
143
 
140
- _defineProperty(DdSdkReactNative, "DD_PROXY_TYPE_KEY", "_dd.proxy.type");
144
+ _defineProperty(DdSdkReactNative, "DD_PROXY_TYPE_KEY", '_dd.proxy.type');
141
145
 
142
- _defineProperty(DdSdkReactNative, "DD_PROXY_ADDRESS_KEY", "_dd.proxy.address");
146
+ _defineProperty(DdSdkReactNative, "DD_PROXY_ADDRESS_KEY", '_dd.proxy.address');
143
147
 
144
- _defineProperty(DdSdkReactNative, "DD_PROXY_PORT_KEY", "_dd.proxy.port");
148
+ _defineProperty(DdSdkReactNative, "DD_PROXY_PORT_KEY", '_dd.proxy.port');
145
149
 
146
- _defineProperty(DdSdkReactNative, "DD_PROXY_USERNAME_KEY", "_dd.proxy.username");
150
+ _defineProperty(DdSdkReactNative, "DD_PROXY_USERNAME_KEY", '_dd.proxy.username');
147
151
 
148
- _defineProperty(DdSdkReactNative, "DD_PROXY_PASSWORD_KEY", "_dd.proxy.password");
152
+ _defineProperty(DdSdkReactNative, "DD_PROXY_PASSWORD_KEY", '_dd.proxy.password');
149
153
 
150
- _defineProperty(DdSdkReactNative, "DD_NATIVE_LONG_TASK_THRESHOLD_KEY", "_dd.long_task.threshold");
154
+ _defineProperty(DdSdkReactNative, "DD_NATIVE_LONG_TASK_THRESHOLD_KEY", '_dd.long_task.threshold');
151
155
 
152
156
  _defineProperty(DdSdkReactNative, "NATIVE_LONG_TASK_THRESHOLD_MS", 200);
153
157
 
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["DdSdkConfiguration","DdSdk","DdRumUserInteractionTracking","DdRumErrorTracking","DdRumResourceTracking","ProxyType","version","sdkVersion","InternalLog","SdkVerbosity","DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","log","WARN","verbosity","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","undefined","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","then","INFO","enableFeatures","rejection","setAttributes","attributes","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","trackInteractions","startTracking","trackResources","trackErrors"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAAQA,kBAAR,QAAiC,SAAjC;AACA,SAAQC,KAAR,QAAoB,cAApB;AACA,SAAQC,4BAAR,QAA2C,oDAA3C;AACA,SAAQC,kBAAR,QAAiC,0CAAjC;AACA,SAAQC,qBAAR,QAAoC,6CAApC;AAEA,SAAQC,SAAR,QAAwB,sBAAxB;AACA,SAAQC,OAAO,IAAIC,UAAnB,QAAoC,WAApC;AACA,SAAQC,WAAR,QAA0B,eAA1B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAN,CAAuB;AAQ1B;;AAaA;AACJ;AACA;AACA;AACA;AACqB,SAAVC,UAAU,CAACC,aAAD,EAA8D;AAC3E,WAAO,IAAIC,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC1C,UAAIL,gBAAgB,CAACM,cAArB,EAAqC;AACjCR,QAAAA,WAAW,CAACS,GAAZ,CAAgB,uDAAhB,EAAyER,YAAY,CAACS,IAAtF;AACAJ,QAAAA,OAAO;AACP;AACH;;AAEDN,MAAAA,WAAW,CAACW,SAAZ,GAAwBP,aAAa,CAACO,SAAtC;AAEAP,MAAAA,aAAa,CAACQ,gBAAd,CAA+BV,gBAAgB,CAACW,aAAhD,IAAiE,cAAjE;AACAT,MAAAA,aAAa,CAACQ,gBAAd,CAA+BV,gBAAgB,CAACY,cAAhD,IAAkEf,UAAlE;AACAK,MAAAA,aAAa,CAACQ,gBAAd,CAA+BV,gBAAgB,CAACa,2BAAhD,IAA+EX,aAAa,CAACY,kBAA7F;;AACA,UAAIZ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A3D;AACA,WAAO3D,KAAK,CAAC8D,kBAAN,CAAyBC,OAAzB,CAAP;AACH;;AAE4B,SAAdV,cAAc,CAAC1C,aAAD,EAA+C;AACxE,QAAIA,aAAa,CAACqD,iBAAlB,EAAqC;AACjC/D,MAAAA,4BAA4B,CAACgE,aAA7B;AACH;;AAED,QAAItD,aAAa,CAACuD,cAAlB,EAAkC;AAC9B/D,MAAAA,qBAAqB,CAAC8D,aAAtB;AACH;;AAED,QAAItD,aAAa,CAACwD,WAAlB,EAA+B;AAC3BjE,MAAAA,kBAAkB,CAAC+D,aAAnB;AACH;AACJ;;AArIyB;;gBAAjBxD,gB,mBAE+B,Y;;gBAF/BA,gB,oBAGgC,iB;;gBAHhCA,gB,qBAIiC,kB;;gBAJjCA,gB,0BAKsC,mB;;gBALtCA,gB,iCAM6C,0B;;gBAN7CA,gB,uBASmC,gB;;gBATnCA,gB,0BAUsC,mB;;gBAVtCA,gB,uBAWmC,gB;;gBAXnCA,gB,2BAYuC,oB;;gBAZvCA,gB,2BAauC,oB;;gBAbvCA,gB,uCAemD,yB;;gBAfnDA,gB,mCAgB+C,G;;gBAhB/CA,gB,oBAmBuB,K","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 {DdSdkReactNativeConfiguration} from \"./DdSdkReactNativeConfiguration\"\nimport {DdSdkConfiguration} from \"./types\"\nimport {DdSdk} from \"./foundation\"\nimport {DdRumUserInteractionTracking} from './rum/instrumentation/DdRumUserInteractionTracking'\nimport {DdRumErrorTracking} from './rum/instrumentation/DdRumErrorTracking'\nimport {DdRumResourceTracking} from './rum/instrumentation/DdRumResourceTracking'\nimport type {TrackingConsent} from \"./TrackingConsent\"\nimport {ProxyType} from \"./ProxyConfiguration\"\nimport {version as sdkVersion} from './version';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n\n private static readonly DD_SOURCE_KEY = \"_dd.source\";\n private static readonly DD_SDK_VERSION = \"_dd.sdk_version\";\n private static readonly DD_SERVICE_NAME = \"_dd.service_name\";\n private static readonly DD_SDK_VERBOSITY_KEY = \"_dd.sdk_verbosity\";\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY = \"_dd.native_view_tracking\";\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = \"_dd.proxy.type\";\n private static readonly DD_PROXY_ADDRESS_KEY = \"_dd.proxy.address\";\n private static readonly DD_PROXY_PORT_KEY = \"_dd.proxy.port\";\n private static readonly DD_PROXY_USERNAME_KEY = \"_dd.proxy.username\";\n private static readonly DD_PROXY_PASSWORD_KEY = \"_dd.proxy.password\";\n\n private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY = \"_dd.long_task.threshold\"\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200\n\n\n private static wasInitialized = false\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(configuration: DdSdkReactNativeConfiguration): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\"Can't initialize Datadog, SDK was already initialized\", SdkVerbosity.WARN);\n resolve()\n return\n }\n\n InternalLog.verbosity = configuration.verbosity\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] = 'react-native';\n configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERSION] = sdkVersion;\n configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY] = configuration.nativeViewTracking;\n if (configuration.verbosity != undefined) {\n configuration.additionalConfig[DdSdkReactNative.DD_SDK_VERBOSITY_KEY] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] = proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] = proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] = proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type == ProxyType.SOCKS) {\n console.warn(\"SOCKS proxy configuration doesn't support Basic authentication.\")\n } else {\n additionalConfig[DdSdkReactNative.DD_PROXY_USERNAME_KEY] = proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;\n }\n\n configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY]\n = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(() => {\n InternalLog.log(\"Datadog SDK was initialized\", SdkVerbosity.INFO);\n DdSdkReactNative.enableFeatures(configuration)\n DdSdkReactNative.wasInitialized = true\n resolve()\n }, (rejection) => {\n reject(rejection)\n })\n })\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\"Setting attributes \" + JSON.stringify(attributes), SdkVerbosity.DEBUG);\n return DdSdk.setAttributes(attributes)\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n InternalLog.log(\"Setting user \" + JSON.stringify(user), SdkVerbosity.DEBUG);\n return DdSdk.setUser(user)\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(\"Setting consent \" + consent, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent)\n }\n\n private static enableFeatures(configuration: DdSdkReactNativeConfiguration) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking();\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}"]}
1
+ {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InternalLog","ProxyType","SdkVerbosity","DdSdk","DdRumErrorTracking","DdRumResourceTracking","DdRumUserInteractionTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","log","WARN","verbosity","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","firstPartyHosts","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","then","INFO","enableFeatures","rejection","setAttributes","attributes","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","trackErrors"],"mappings":";;AAAA;AAC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IA,aAAa,CAACuD,iBAAlB,EAAqC;AACjC7D,MAAAA,4BAA4B,CAAC8D,aAA7B;AACH;;AAED,QAAIxD,aAAa,CAACyD,cAAlB,EAAkC;AAC9BhE,MAAAA,qBAAqB,CAAC+D,aAAtB,CAAoC;AAChCE,QAAAA,mBAAmB,EAAE1D,aAAa,CAAC2D,2BADH;AAEhC3B,QAAAA,eAAe,EAAEhC,aAAa,CAACgC;AAFC,OAApC;AAIH;;AAED,QAAIhC,aAAa,CAAC4D,WAAlB,EAA+B;AAC3BpE,MAAAA,kBAAkB,CAACgE,aAAnB;AACH;AACJ;;AAnLyB;;gBAAjB1D,gB,mBAC+B,Y;;gBAD/BA,gB,oBAEgC,iB;;gBAFhCA,gB,qBAGiC,kB;;gBAHjCA,gB,0BAIsC,mB;;gBAJtCA,gB,iCAML,0B;;gBANKA,gB,uBASmC,gB;;gBATnCA,gB,0BAUsC,mB;;gBAVtCA,gB,uBAWmC,gB;;gBAXnCA,gB,2BAYuC,oB;;gBAZvCA,gB,2BAauC,oB;;gBAbvCA,gB,uCAgBL,yB;;gBAhBKA,gB,mCAiB+C,G;;gBAjB/CA,gB,oBAmBuB,K","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 { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/DdRumResourceTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =\n '_dd.long_task.threshold';\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;\n\n private static wasInitialized = false;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n resolve();\n return;\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[\n DdSdkReactNative.DD_PROXY_USERNAME_KEY\n ] = proxyConfig.username;\n additionalConfig[\n DdSdkReactNative.DD_PROXY_PASSWORD_KEY\n ] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SERVICE_NAME\n ] = configuration.serviceName;\n }\n\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY\n ] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(\n () => {\n InternalLog.log(\n 'Datadog SDK was initialized',\n SdkVerbosity.INFO\n );\n DdSdkReactNative.enableFeatures(configuration);\n DdSdkReactNative.wasInitialized = true;\n resolve();\n },\n rejection => {\n reject(rejection);\n }\n );\n });\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setAttributes(attributes);\n }\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 * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static enableFeatures(\n configuration: DdSdkReactNativeConfiguration\n ) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}\n"]}
@@ -6,17 +6,24 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
8
  import { TrackingConsent } from './TrackingConsent';
9
-
10
9
  /**
11
10
  * The SDK configuration class.
12
11
  * It will be used to configure the SDK functionality at initialization.
13
12
  */
13
+
14
14
  export class DdSdkReactNativeConfiguration {
15
- constructor(clientToken, env, applicationId) {
16
- let trackInteractions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
17
- let trackResources = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
18
- let trackErrors = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
19
- let trackingConsent = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : TrackingConsent.GRANTED;
15
+ /**
16
+ * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.
17
+ */
18
+
19
+ /**
20
+ * Percentage of sampled RUM sessions. Range `0`-`100`.
21
+ */
22
+
23
+ /**
24
+ * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.
25
+ */
26
+ constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = TrackingConsent.GRANTED) {
20
27
  this.clientToken = clientToken;
21
28
  this.env = env;
22
29
  this.applicationId = applicationId;
@@ -27,9 +34,13 @@ export class DdSdkReactNativeConfiguration {
27
34
 
28
35
  _defineProperty(this, "nativeCrashReportEnabled", false);
29
36
 
30
- _defineProperty(this, "sampleRate", 100.0);
37
+ _defineProperty(this, "sampleRate", void 0);
38
+
39
+ _defineProperty(this, "sessionSamplingRate", 100.0);
31
40
 
32
- _defineProperty(this, "site", "US");
41
+ _defineProperty(this, "resourceTracingSamplingRate", 20.0);
42
+
43
+ _defineProperty(this, "site", 'US');
33
44
 
34
45
  _defineProperty(this, "verbosity", undefined);
35
46
 
@@ -39,6 +50,8 @@ export class DdSdkReactNativeConfiguration {
39
50
 
40
51
  _defineProperty(this, "serviceName", undefined);
41
52
 
53
+ _defineProperty(this, "firstPartyHosts", []);
54
+
42
55
  _defineProperty(this, "additionalConfig", {});
43
56
  }
44
57
 
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","GRANTED","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,eAAT,QAAgC,mBAAhC;;AAIA;AACA;AACA;AACA;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAYvCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAQT;AAAA,QAJWC,iBAIX,uEAJwC,KAIxC;AAAA,QAHWC,cAGX,uEAHqC,KAGrC;AAAA,QAFWC,WAEX,uEAFkC,KAElC;AAAA,QADWC,eACX,uEAD8CT,eAAe,CAACU,OAC9D;AAAA,SAPWP,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,sDAlByC,KAkBzC;;AAAA,wCAjB0B,KAiB1B;;AAAA,kCAhBoB,IAgBpB;;AAAA,uCAfyCE,SAezC;;AAAA,gDAdmC,KAcnC;;AAAA,yCAbwCA,SAaxC;;AAAA,yCAZ4BA,SAY5B;;AAAA,8CAV4C,EAU5C;AAED;;AAtBsC","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 { TrackingConsent } from './TrackingConsent'\nimport type { SdkVerbosity } from './SdkVerbosity'\nimport type { ProxyConfiguration } from './ProxyConfiguration';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n\n public nativeCrashReportEnabled: boolean = false;\n public sampleRate: number = 100.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\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 }\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","GRANTED","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;AAWIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGT,eAAe,CAACU,OAPrD,EAQT;AAAA,SAPWP,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,sDA9ByC,KA8BzC;;AAAA;;AAAA,iDAtBmC,KAsBnC;;AAAA,yDAlB2C,IAkB3C;;AAAA,kCAjBoB,IAiBpB;;AAAA,uCAhB2CE,SAgB3C;;AAAA,gDAfmC,KAenC;;AAAA,yCAdwCA,SAcxC;;AAAA,yCAb4BA,SAa5B;;AAAA,6CAZiC,EAYjC;;AAAA,8CAV8C,EAU9C;AAAE;;AA/BmC","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 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"]}
@@ -6,6 +6,12 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
8
  import { SdkVerbosity } from './SdkVerbosity';
9
+ /**
10
+ * /!\ DO NOT USE THIS IN YOUR APP /!\\
11
+ *
12
+ * This logger is only for debugging the Datadog SDK.
13
+ */
14
+
9
15
  export class InternalLog {
10
16
  static log(message, verbosity) {
11
17
  if (InternalLog.verbosity === undefined) {
@@ -19,21 +25,21 @@ export class InternalLog {
19
25
  return;
20
26
  }
21
27
 
22
- const prefixedMessage = "DATADOG: " + message;
28
+ const prefixedMessage = `DATADOG: ${message}`;
23
29
 
24
- if (verbosity == SdkVerbosity.ERROR && requiredLevel >= allowedLevel) {
30
+ if (verbosity === SdkVerbosity.ERROR && requiredLevel >= allowedLevel) {
25
31
  console.error(prefixedMessage);
26
32
  }
27
33
 
28
- if (verbosity == SdkVerbosity.WARN && requiredLevel >= allowedLevel) {
34
+ if (verbosity === SdkVerbosity.WARN && requiredLevel >= allowedLevel) {
29
35
  console.warn(prefixedMessage);
30
36
  }
31
37
 
32
- if (verbosity == SdkVerbosity.INFO && requiredLevel >= allowedLevel) {
38
+ if (verbosity === SdkVerbosity.INFO && requiredLevel >= allowedLevel) {
33
39
  console.info(prefixedMessage);
34
40
  }
35
41
 
36
- if (verbosity == SdkVerbosity.DEBUG && requiredLevel >= allowedLevel) {
42
+ if (verbosity === SdkVerbosity.DEBUG && requiredLevel >= allowedLevel) {
37
43
  console.debug(prefixedMessage);
38
44
  }
39
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["InternalLog.tsx"],"names":["SdkVerbosity","InternalLog","log","message","verbosity","undefined","requiredLevel","levelMap","get","allowedLevel","prefixedMessage","ERROR","console","error","WARN","warn","INFO","info","DEBUG","debug","Map"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAAQA,YAAR,QAA2B,gBAA3B;AAEA,OAAO,MAAMC,WAAN,CAAkB;AAWJ,SAAHC,GAAG,CAAEC,OAAF,EAAmBC,SAAnB,EAAkD;AAC/D,QAAIH,WAAW,CAACG,SAAZ,KAA0BC,SAA9B,EAAyC;AACrC;AACH;;AACD,UAAMC,aAAa,GAAGL,WAAW,CAACM,QAAZ,CAAqBC,GAArB,CAAyBJ,SAAzB,CAAtB;AACA,UAAMK,YAAY,GAAGR,WAAW,CAACM,QAAZ,CAAqBC,GAArB,CAAyBP,WAAW,CAACG,SAArC,CAArB;;AACA,QAAIK,YAAY,KAAKJ,SAAjB,IAA8BC,aAAa,KAAKD,SAApD,EAA+D;AAC3D;AACH;;AACD,UAAMK,eAAe,GAAG,cAAcP,OAAtC;;AACA,QAAIC,SAAS,IAAIJ,YAAY,CAACW,KAA1B,IAAoCL,aAAa,IAAIG,YAAzD,EAAwE;AACpEG,MAAAA,OAAO,CAACC,KAAR,CAAcH,eAAd;AACH;;AAED,QAAIN,SAAS,IAAIJ,YAAY,CAACc,IAA1B,IAAmCR,aAAa,IAAIG,YAAxD,EAAuE;AACnEG,MAAAA,OAAO,CAACG,IAAR,CAAaL,eAAb;AACH;;AAED,QAAIN,SAAS,IAAIJ,YAAY,CAACgB,IAA1B,IAAmCV,aAAa,IAAIG,YAAxD,EAAuE;AACnEG,MAAAA,OAAO,CAACK,IAAR,CAAaP,eAAb;AACH;;AAED,QAAIN,SAAS,IAAIJ,YAAY,CAACkB,KAA1B,IAAoCZ,aAAa,IAAIG,YAAzD,EAAwE;AACpEG,MAAAA,OAAO,CAACO,KAAR,CAAcT,eAAd;AACH;AACJ;;AApCoB;;gBAAZT,W,cAEiB,IAAImB,GAAJ,CAA8B,CACpD,CAACpB,YAAY,CAACkB,KAAd,EAAqB,CAArB,CADoD,EAEpD,CAAClB,YAAY,CAACgB,IAAd,EAAoB,CAApB,CAFoD,EAGpD,CAAChB,YAAY,CAACc,IAAd,EAAoB,CAApB,CAHoD,EAIpD,CAACd,YAAY,CAACW,KAAd,EAAqB,CAArB,CAJoD,CAA9B,C;;gBAFjBV,W,eASyCI,S","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 {SdkVerbosity} from './SdkVerbosity'\n\nexport class InternalLog {\n\n private static levelMap = new Map<SdkVerbosity, number>([\n [SdkVerbosity.DEBUG, 1],\n [SdkVerbosity.INFO, 2],\n [SdkVerbosity.WARN, 3],\n [SdkVerbosity.ERROR, 4]\n ]);\n\n public static verbosity: SdkVerbosity|undefined = undefined\n\n public static log (message: string, verbosity: SdkVerbosity): void {\n if (InternalLog.verbosity === undefined) {\n return;\n }\n const requiredLevel = InternalLog.levelMap.get(verbosity);\n const allowedLevel = InternalLog.levelMap.get(InternalLog.verbosity);\n if (allowedLevel === undefined || requiredLevel === undefined) {\n return;\n }\n const prefixedMessage = \"DATADOG: \" + message\n if (verbosity == SdkVerbosity.ERROR && (requiredLevel >= allowedLevel)) {\n console.error(prefixedMessage)\n }\n\n if (verbosity == SdkVerbosity.WARN && (requiredLevel >= allowedLevel)) {\n console.warn(prefixedMessage)\n }\n\n if (verbosity == SdkVerbosity.INFO && (requiredLevel >= allowedLevel)) {\n console.info(prefixedMessage)\n }\n\n if (verbosity == SdkVerbosity.DEBUG && (requiredLevel >= allowedLevel)) {\n console.debug(prefixedMessage)\n }\n }\n\n\n}"]}
1
+ {"version":3,"sources":["InternalLog.tsx"],"names":["SdkVerbosity","InternalLog","log","message","verbosity","undefined","requiredLevel","levelMap","get","allowedLevel","prefixedMessage","ERROR","console","error","WARN","warn","INFO","info","DEBUG","debug","Map"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAN,CAAkB;AAUJ,SAAHC,GAAG,CAACC,OAAD,EAAkBC,SAAlB,EAAiD;AAC9D,QAAIH,WAAW,CAACG,SAAZ,KAA0BC,SAA9B,EAAyC;AACrC;AACH;;AACD,UAAMC,aAAa,GAAGL,WAAW,CAACM,QAAZ,CAAqBC,GAArB,CAAyBJ,SAAzB,CAAtB;AACA,UAAMK,YAAY,GAAGR,WAAW,CAACM,QAAZ,CAAqBC,GAArB,CAAyBP,WAAW,CAACG,SAArC,CAArB;;AACA,QAAIK,YAAY,KAAKJ,SAAjB,IAA8BC,aAAa,KAAKD,SAApD,EAA+D;AAC3D;AACH;;AACD,UAAMK,eAAe,GAAI,YAAWP,OAAQ,EAA5C;;AACA,QAAIC,SAAS,KAAKJ,YAAY,CAACW,KAA3B,IAAoCL,aAAa,IAAIG,YAAzD,EAAuE;AACnEG,MAAAA,OAAO,CAACC,KAAR,CAAcH,eAAd;AACH;;AAED,QAAIN,SAAS,KAAKJ,YAAY,CAACc,IAA3B,IAAmCR,aAAa,IAAIG,YAAxD,EAAsE;AAClEG,MAAAA,OAAO,CAACG,IAAR,CAAaL,eAAb;AACH;;AAED,QAAIN,SAAS,KAAKJ,YAAY,CAACgB,IAA3B,IAAmCV,aAAa,IAAIG,YAAxD,EAAsE;AAClEG,MAAAA,OAAO,CAACK,IAAR,CAAaP,eAAb;AACH;;AAED,QAAIN,SAAS,KAAKJ,YAAY,CAACkB,KAA3B,IAAoCZ,aAAa,IAAIG,YAAzD,EAAuE;AACnEG,MAAAA,OAAO,CAACO,KAAR,CAAcT,eAAd;AACH;AACJ;;AAnCoB;;gBAAZT,W,cACiB,IAAImB,GAAJ,CAA8B,CACpD,CAACpB,YAAY,CAACkB,KAAd,EAAqB,CAArB,CADoD,EAEpD,CAAClB,YAAY,CAACgB,IAAd,EAAoB,CAApB,CAFoD,EAGpD,CAAChB,YAAY,CAACc,IAAd,EAAoB,CAApB,CAHoD,EAIpD,CAACd,YAAY,CAACW,KAAd,EAAqB,CAArB,CAJoD,CAA9B,C;;gBADjBV,W,eAQ2CI,S","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 { SdkVerbosity } from './SdkVerbosity';\n\n/**\n * /!\\ DO NOT USE THIS IN YOUR APP /!\\\\\n *\n * This logger is only for debugging the Datadog SDK.\n */\nexport class InternalLog {\n private static levelMap = new Map<SdkVerbosity, number>([\n [SdkVerbosity.DEBUG, 1],\n [SdkVerbosity.INFO, 2],\n [SdkVerbosity.WARN, 3],\n [SdkVerbosity.ERROR, 4]\n ]);\n\n public static verbosity: SdkVerbosity | undefined = undefined;\n\n public static log(message: string, verbosity: SdkVerbosity): void {\n if (InternalLog.verbosity === undefined) {\n return;\n }\n const requiredLevel = InternalLog.levelMap.get(verbosity);\n const allowedLevel = InternalLog.levelMap.get(InternalLog.verbosity);\n if (allowedLevel === undefined || requiredLevel === undefined) {\n return;\n }\n const prefixedMessage = `DATADOG: ${message}`;\n if (verbosity === SdkVerbosity.ERROR && requiredLevel >= allowedLevel) {\n console.error(prefixedMessage);\n }\n\n if (verbosity === SdkVerbosity.WARN && requiredLevel >= allowedLevel) {\n console.warn(prefixedMessage);\n }\n\n if (verbosity === SdkVerbosity.INFO && requiredLevel >= allowedLevel) {\n console.info(prefixedMessage);\n }\n\n if (verbosity === SdkVerbosity.DEBUG && requiredLevel >= allowedLevel) {\n console.debug(prefixedMessage);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["ProxyConfiguration.tsx"],"names":["ProxyConfiguration","constructor","type","address","port","username","password","ProxyType"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,kBAAN,CAAyB;AACrBC,EAAAA,WAAW;AACP;AACR;AACA;AACiBC,EAAAA,IAJF;AAKP;AACR;AACA;AACiBC,EAAAA,OARF;AASP;AACR;AACA;AACiBC,EAAAA,IAZF;AAaP;AACR;AACA;AACA;AACA;AACiBC,EAAAA,QAlBF;AAmBP;AACR;AACA;AACiBC,EAAAA,QAtBF,EAuBT;AAAA,SAnBWJ,IAmBX,GAnBWA,IAmBX;AAAA,SAfWC,OAeX,GAfWA,OAeX;AAAA,SAXWC,IAWX,GAXWA,IAWX;AAAA,SALWC,QAKX,GALWA,QAKX;AAAA,SADWC,QACX,GADWA,QACX;AAAG;;AAxBgB;;IA2BpBC,S;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAML,SAASP,kBAAT,EAA6BO,SAA7B","sourcesContent":["/**\n * Proxy server configuration.\n */\nclass ProxyConfiguration {\n constructor(\n /**\n * Proxy type.\n */\n readonly type: ProxyType,\n /**\n * Proxy address. Can be either in the IP address format, ex. \"1.1.1.1\", or hostname, ex. \"example.com\".\n */\n readonly address: string,\n /**\n * Proxy port.\n */\n readonly port: number,\n /**\n * Username for Basic authentication scheme.\n *\n * Note: \"SOCKS + authentication\" scheme is not supported.\n */\n readonly username?: string,\n /**\n * Password for Basic authentication scheme.\n */\n readonly password?: string\n ) { }\n}\n\nenum ProxyType {\n HTTP = \"http\",\n HTTPS = \"https\",\n SOCKS = \"socks\"\n}\n\nexport { ProxyConfiguration, ProxyType }\n"]}
1
+ {"version":3,"sources":["ProxyConfiguration.tsx"],"names":["ProxyConfiguration","constructor","type","address","port","username","password","ProxyType"],"mappings":"AAAA;AACA;AACA;AACA,MAAMA,kBAAN,CAAyB;AACrBC,EAAAA,WAAW;AACP;AACR;AACA;AACiBC,EAAAA,IAJF;AAKP;AACR;AACA;AACiBC,EAAAA,OARF;AASP;AACR;AACA;AACiBC,EAAAA,IAZF;AAaP;AACR;AACA;AACA;AACA;AACiBC,EAAAA,QAlBF;AAmBP;AACR;AACA;AACiBC,EAAAA,QAtBF,EAuBT;AAAA,SAnBWJ,IAmBX,GAnBWA,IAmBX;AAAA,SAfWC,OAeX,GAfWA,OAeX;AAAA,SAXWC,IAWX,GAXWA,IAWX;AAAA,SALWC,QAKX,GALWA,QAKX;AAAA,SADWC,QACX,GADWA,QACX;AAAE;;AAxBiB;;IA2BpBC,S;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAML,SAASP,kBAAT,EAA6BO,SAA7B","sourcesContent":["/**\n * Proxy server configuration.\n */\nclass ProxyConfiguration {\n constructor(\n /**\n * Proxy type.\n */\n readonly type: ProxyType,\n /**\n * Proxy address. Can be either in the IP address format, ex. \"1.1.1.1\", or hostname, ex. \"example.com\".\n */\n readonly address: string,\n /**\n * Proxy port.\n */\n readonly port: number,\n /**\n * Username for Basic authentication scheme.\n *\n * Note: \"SOCKS + authentication\" scheme is not supported.\n */\n readonly username?: string,\n /**\n * Password for Basic authentication scheme.\n */\n readonly password?: string\n ) {}\n}\n\nenum ProxyType {\n HTTP = 'http',\n HTTPS = 'https',\n SOCKS = 'socks'\n}\n\nexport { ProxyConfiguration, ProxyType };\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["SdkVerbosity.tsx"],"names":["SdkVerbosity"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAYA,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;GAAAA,Y,KAAAA,Y","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 * Enum specifying possible log levels for DD SDK.\n */\nexport enum SdkVerbosity {\n DEBUG = \"debug\",\n INFO = \"info\",\n WARN = \"warn\",\n ERROR = \"error\"\n}\n"]}
1
+ {"version":3,"sources":["SdkVerbosity.tsx"],"names":["SdkVerbosity"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,WAAYA,YAAZ;;WAAYA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;AAAAA,EAAAA,Y;GAAAA,Y,KAAAA,Y","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 * Enum specifying possible log levels for DD SDK.\n */\nexport enum SdkVerbosity {\n DEBUG = 'debug',\n INFO = 'info',\n WARN = 'warn',\n ERROR = 'error'\n}\n"]}
@@ -0,0 +1,63 @@
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
+
9
+ /**
10
+ * A Timestamp structure holding the
11
+ */
12
+
13
+ /**
14
+ * Simple class providing timestamps in milliseconds.
15
+ * If available, it will use the `performance.now()` method, and will fallback on `Date.now()` otherwise.
16
+ */
17
+ export class TimeProvider {
18
+ /** Keeps an average offset between the unix time and the provided timestamp. */
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
+ _defineProperty(this, "baseOffset", void 0);
25
+
26
+ const timestamp = this.getTimestamp();
27
+
28
+ if (timestamp.react_native == null) {
29
+ this.baseOffset = 0;
30
+ } else {
31
+ this.baseOffset = timestamp.unix - timestamp.react_native;
32
+ }
33
+ }
34
+
35
+ getTimestamp() {
36
+ return {
37
+ unix: Date.now(),
38
+ react_native: this.performanceNow()
39
+ };
40
+ }
41
+
42
+ now() {
43
+ const timestamp = this.getTimestamp();
44
+
45
+ if (timestamp.react_native == null) {
46
+ return timestamp.unix;
47
+ } else {
48
+ return this.baseOffset + timestamp.react_native;
49
+ }
50
+ }
51
+
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
+ }
63
+ //# sourceMappingURL=TimeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["TimeProvider.tsx"],"names":["TimeProvider","constructor","global","performance","now","timestamp","getTimestamp","react_native","baseOffset","unix","Date","performanceNow","canUsePerformanceNow"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA,OAAO,MAAMA,YAAN,CAAmB;AAMtB;AAGAC,EAAAA,WAAW,GAAG;AAAA,kDAPV;AACA;AACAC,IAAAA,MAAM,CAACC,WAAP,IAAsB,OAAOA,WAAW,CAACC,GAAnB,KAA2B,UAKvC;;AAAA;;AACV,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;;AACA,QAAID,SAAS,CAACE,YAAV,IAA0B,IAA9B,EAAoC;AAChC,WAAKC,UAAL,GAAkB,CAAlB;AACH,KAFD,MAEO;AACH,WAAKA,UAAL,GAAkBH,SAAS,CAACI,IAAV,GAAiBJ,SAAS,CAACE,YAA7C;AACH;AACJ;;AAEDD,EAAAA,YAAY,GAAc;AACtB,WAAO;AACHG,MAAAA,IAAI,EAAEC,IAAI,CAACN,GAAL,EADH;AAEHG,MAAAA,YAAY,EAAE,KAAKI,cAAL;AAFX,KAAP;AAIH;;AAEDP,EAAAA,GAAG,GAAW;AACV,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;;AACA,QAAID,SAAS,CAACE,YAAV,IAA0B,IAA9B,EAAoC;AAChC,aAAOF,SAAS,CAACI,IAAjB;AACH,KAFD,MAEO;AACH,aAAO,KAAKD,UAAL,GAAkBH,SAAS,CAACE,YAAnC;AACH;AACJ;;AAEOI,EAAAA,cAAc,GAAkB;AACpC,QAAI,KAAKC,oBAAT,EAA+B;AAC3B;AACA;AACA,aAAOT,WAAW,CAACC,GAAZ,EAAP;AACH;;AACD,WAAO,IAAP;AACH;;AAzCqB","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 react_native: 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 class 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 /** Keeps an average offset between the unix time and the provided timestamp. */\n private baseOffset: number;\n\n constructor() {\n const timestamp = this.getTimestamp();\n if (timestamp.react_native == null) {\n this.baseOffset = 0;\n } else {\n this.baseOffset = timestamp.unix - timestamp.react_native;\n }\n }\n\n getTimestamp(): Timestamp {\n return {\n unix: Date.now(),\n react_native: this.performanceNow()\n };\n }\n\n now(): number {\n const timestamp = this.getTimestamp();\n if (timestamp.react_native == null) {\n return timestamp.unix;\n } else {\n return this.baseOffset + timestamp.react_native;\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"]}