@datadog/mobile-react-native 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +4 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +6 -1
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdLogs.kt +162 -6
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +9 -0
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +4 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +5 -1
  9. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +4 -0
  10. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +242 -2
  11. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +10 -0
  12. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +6 -2
  13. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +2 -0
  14. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +2 -2
  15. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +3 -1
  16. package/ios/Sources/Attributes.swift +7 -0
  17. package/ios/Sources/DdLogs.m +31 -0
  18. package/ios/Sources/DdLogs.swift +84 -4
  19. package/ios/Sources/DdRum.m +3 -0
  20. package/ios/Sources/DdRum.swift +7 -0
  21. package/ios/Sources/DdSdk.swift +2 -0
  22. package/ios/Sources/DdSdkConfiguration.swift +7 -1
  23. package/ios/Sources/RNDdSdkConfiguration.swift +5 -1
  24. package/lib/commonjs/DdSdkReactNative.js +5 -1
  25. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  26. package/lib/commonjs/InternalLog.js +6 -2
  27. package/lib/commonjs/InternalLog.js.map +1 -1
  28. package/lib/commonjs/errorUtils.js +20 -1
  29. package/lib/commonjs/errorUtils.js.map +1 -1
  30. package/lib/commonjs/logs/DdLogs.js +102 -11
  31. package/lib/commonjs/logs/DdLogs.js.map +1 -1
  32. package/lib/commonjs/logs/eventMapper.js.map +1 -1
  33. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  34. package/lib/commonjs/rum/DdRum.js +6 -0
  35. package/lib/commonjs/rum/DdRum.js.map +1 -1
  36. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +60 -46
  37. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  38. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
  39. package/lib/commonjs/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  40. package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
  41. package/lib/commonjs/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
  42. package/lib/commonjs/rum/types.js.map +1 -1
  43. package/lib/commonjs/types.js.map +1 -1
  44. package/lib/commonjs/version.js +1 -1
  45. package/lib/commonjs/version.js.map +1 -1
  46. package/lib/module/DdSdkReactNative.js +5 -1
  47. package/lib/module/DdSdkReactNative.js.map +1 -1
  48. package/lib/module/InternalLog.js +2 -1
  49. package/lib/module/InternalLog.js.map +1 -1
  50. package/lib/module/errorUtils.js +15 -0
  51. package/lib/module/errorUtils.js.map +1 -1
  52. package/lib/module/logs/DdLogs.js +103 -12
  53. package/lib/module/logs/DdLogs.js.map +1 -1
  54. package/lib/module/logs/eventMapper.js.map +1 -1
  55. package/lib/module/nativeModulesTypes.js.map +1 -1
  56. package/lib/module/rum/DdRum.js +5 -0
  57. package/lib/module/rum/DdRum.js.map +1 -1
  58. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +61 -46
  59. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  60. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js +2 -2
  61. package/lib/module/rum/instrumentation/interactionTracking/DdEventsInterceptor.js.map +1 -1
  62. package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js +9 -1
  63. package/lib/module/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.js.map +1 -1
  64. package/lib/module/rum/types.js.map +1 -1
  65. package/lib/module/types.js.map +1 -1
  66. package/lib/module/version.js +1 -1
  67. package/lib/module/version.js.map +1 -1
  68. package/lib/typescript/InternalLog.d.ts +1 -0
  69. package/lib/typescript/errorUtils.d.ts +2 -0
  70. package/lib/typescript/logs/DdLogs.d.ts +13 -5
  71. package/lib/typescript/logs/eventMapper.d.ts +5 -5
  72. package/lib/typescript/logs/types.d.ts +34 -8
  73. package/lib/typescript/nativeModulesTypes.d.ts +44 -4
  74. package/lib/typescript/rum/DdRum.d.ts +1 -0
  75. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +3 -2
  76. package/lib/typescript/rum/instrumentation/interactionTracking/DdEventsInterceptor.d.ts +1 -1
  77. package/lib/typescript/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.d.ts +5 -2
  78. package/lib/typescript/rum/types.d.ts +4 -0
  79. package/lib/typescript/types.d.ts +4 -0
  80. package/lib/typescript/version.d.ts +1 -1
  81. package/package.json +2 -2
  82. package/src/DdSdkReactNative.tsx +6 -1
  83. package/src/InternalLog.tsx +3 -1
  84. package/src/__tests__/errorUtils.test.ts +49 -0
  85. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +14 -14
  86. package/src/__tests__/rum/instrumentation/DdRumErrorTracking.test.tsx +452 -109
  87. package/src/__tests__/rum/instrumentation/ShallowObjectEqualityChecker.test.ts +18 -0
  88. package/src/errorUtils.ts +15 -0
  89. package/src/logs/DdLogs.ts +166 -16
  90. package/src/logs/__tests__/DdLogs.test.ts +169 -0
  91. package/src/logs/__tests__/eventMapper.test.ts +34 -0
  92. package/src/logs/eventMapper.ts +15 -4
  93. package/src/logs/types.ts +36 -8
  94. package/src/nativeModulesTypes.ts +73 -4
  95. package/src/rum/DdRum.ts +5 -0
  96. package/src/rum/__tests__/DdRum.test.ts +12 -27
  97. package/src/rum/instrumentation/DdRumErrorTracking.tsx +41 -10
  98. package/src/rum/instrumentation/interactionTracking/DdEventsInterceptor.tsx +7 -4
  99. package/src/rum/instrumentation/interactionTracking/ShallowObjectEqualityChecker.ts +11 -3
  100. package/src/rum/types.ts +5 -0
  101. package/src/sdk/DatadogProvider/__tests__/initialization.test.tsx +2 -0
  102. package/src/types.tsx +2 -0
  103. package/src/version.ts +1 -1
@@ -12,9 +12,17 @@ exports.areObjectShallowEqual = void 0;
12
12
  */
13
13
 
14
14
  /**
15
- * Does a shallow comparison between 2 objects
15
+ * Does a shallow comparison between 2 objects.
16
+ *
17
+ * In some rare cases, one of the objects can be `undefined` or `null`.
18
+ * This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.
16
19
  */
17
20
  const areObjectShallowEqual = (objectA, objectB) => {
21
+ // Handle edge case when one object is `undefined` or `null`
22
+ if (!objectA || !objectB) {
23
+ return objectA === objectB;
24
+ }
25
+
18
26
  const keys = Object.keys(objectA);
19
27
 
20
28
  if (keys.length !== Object.keys(objectB).length) {
@@ -1 +1 @@
1
- {"version":3,"sources":["ShallowObjectEqualityChecker.ts"],"names":["areObjectShallowEqual","objectA","objectB","keys","Object","length","key"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAG,CACjCC,OADiC,EAEjCC,OAFiC,KAGvB;AACV,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYF,OAAZ,CAAb;;AACA,MAAIE,IAAI,CAACE,MAAL,KAAgBD,MAAM,CAACD,IAAP,CAAYD,OAAZ,EAAqBG,MAAzC,EAAiD;AAC7C,WAAO,KAAP;AACH;;AACD,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACpB,QAAIF,OAAO,CAACK,GAAD,CAAP,KAAiBJ,OAAO,CAACI,GAAD,CAA5B,EAAmC;AAC/B,aAAO,KAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,CAdM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * Does a shallow comparison between 2 objects\n */\nexport const areObjectShallowEqual = (\n objectA: Record<string, unknown>,\n objectB: Record<string, unknown>\n): boolean => {\n const keys = Object.keys(objectA);\n if (keys.length !== Object.keys(objectB).length) {\n return false;\n }\n for (const key of keys) {\n if (objectA[key] !== objectB[key]) {\n return false;\n }\n }\n return true;\n};\n"]}
1
+ {"version":3,"sources":["ShallowObjectEqualityChecker.ts"],"names":["areObjectShallowEqual","objectA","objectB","keys","Object","length","key"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAG,CACjCC,OADiC,EAEjCC,OAFiC,KAGvB;AACV;AACA,MAAI,CAACD,OAAD,IAAY,CAACC,OAAjB,EAA0B;AACtB,WAAOD,OAAO,KAAKC,OAAnB;AACH;;AAED,QAAMC,IAAI,GAAGC,MAAM,CAACD,IAAP,CAAYF,OAAZ,CAAb;;AACA,MAAIE,IAAI,CAACE,MAAL,KAAgBD,MAAM,CAACD,IAAP,CAAYD,OAAZ,EAAqBG,MAAzC,EAAiD;AAC7C,WAAO,KAAP;AACH;;AACD,OAAK,MAAMC,GAAX,IAAkBH,IAAlB,EAAwB;AACpB,QAAIF,OAAO,CAACK,GAAD,CAAP,KAAiBJ,OAAO,CAACI,GAAD,CAA5B,EAAmC;AAC/B,aAAO,KAAP;AACH;AACJ;;AACD,SAAO,IAAP;AACH,CAnBM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * Does a shallow comparison between 2 objects.\n *\n * In some rare cases, one of the objects can be `undefined` or `null`.\n * This is documented in https://github.com/DataDog/dd-sdk-reactnative/issues/419.\n */\nexport const areObjectShallowEqual = (\n objectA: Record<string, unknown> | undefined | null,\n objectB: Record<string, unknown> | undefined | null\n): boolean => {\n // Handle edge case when one object is `undefined` or `null`\n if (!objectA || !objectB) {\n return objectA === objectB;\n }\n\n const keys = Object.keys(objectA);\n if (keys.length !== Object.keys(objectB).length) {\n return false;\n }\n for (const key of keys) {\n if (objectA[key] !== objectB[key]) {\n return false;\n }\n }\n return true;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.ts"],"names":["RumActionType","ErrorSource","PropagatorType"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AA0IA;AACA;AACA;IACYA,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a;;IA0BAC,W;AAQZ;AACA;AACA;AACA;AACA;AACA;AACA;;;;WAdYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W;;IAeAC,c;;;WAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;GAAAA,c,8BAAAA,c","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n\n/**\n * Type of instrumentation on the host.\n * - DATADOG: Datadog’s propagator (`x-datadog-*`)\n * - TRACECONTEXT: W3C Trace Context (`traceparent`)\n * - B3: B3 single header (`b3`)\n * - B3MULTI: B3 multiple headers (`X-B3-*`)\n */\nexport enum PropagatorType {\n DATADOG = 'datadog',\n TRACECONTEXT = 'tracecontext',\n B3 = 'b3',\n B3MULTI = 'b3multi'\n}\n\nexport type FirstPartyHost = {\n match: string;\n propagatorTypes: PropagatorType[];\n};\n"]}
1
+ {"version":3,"sources":["types.ts"],"names":["RumActionType","ErrorSource","PropagatorType"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AA+IA;AACA;AACA;IACYA,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a;;IA0BAC,W;AAQZ;AACA;AACA;AACA;AACA;AACA;AACA;;;;WAdYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W;;IAeAC,c;;;WAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;AAAAA,EAAAA,c;GAAAA,c,8BAAAA,c","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n *\n * Warning: using this function signature can lead to inconsistent behaviors on iOS and Android when multiple actions are started in parallel.\n *\n * @deprecated add the `type` and `name` of the action as first two arguments.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: RumActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n};\n\n/**\n * Describe the type of a RUM Action.\n */\nexport enum RumActionType {\n /** User tapped on a widget. */\n TAP = 'TAP',\n /** User scrolled a view. */\n SCROLL = 'SCROLL',\n /** User swiped on a view. */\n SWIPE = 'SWIPE',\n /** User pressed hardware back button (Android only). */\n BACK = 'BACK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n\nexport type ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\nexport enum ErrorSource {\n NETWORK = 'NETWORK',\n SOURCE = 'SOURCE',\n CONSOLE = 'CONSOLE',\n WEBVIEW = 'WEBVIEW',\n CUSTOM = 'CUSTOM'\n}\n\n/**\n * Type of instrumentation on the host.\n * - DATADOG: Datadog’s propagator (`x-datadog-*`)\n * - TRACECONTEXT: W3C Trace Context (`traceparent`)\n * - B3: B3 single header (`b3`)\n * - B3MULTI: B3 multiple headers (`X-B3-*`)\n */\nexport enum PropagatorType {\n DATADOG = 'datadog',\n TRACECONTEXT = 'tracecontext',\n B3 = 'b3',\n B3MULTI = 'b3multi'\n}\n\nexport type FirstPartyHost = {\n match: string;\n propagatorTypes: PropagatorType[];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","configurationForTelemetry"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,yBALF,EAMEC,mBANF,EAOEC,UAPF,EAQEC,IARF,EASEC,eATF,EAUEC,gBAVF,EAWEC,mBAXF,EAYEC,qBAZF,EAaEC,iBAbF,EAcEC,yBAdF,EAoBT;AAAA,SAnBWb,WAmBX,GAnBWA,WAmBX;AAAA,SAlBWC,GAkBX,GAlBWA,GAkBX;AAAA,SAjBWC,aAiBX,GAjBWA,aAiBX;AAAA,SAhBWC,wBAgBX,GAhBWA,wBAgBX;AAAA,SAfWC,yBAeX,GAfWA,yBAeX;AAAA,SAdWC,mBAcX,GAdWA,mBAcX;AAAA,SAbWC,UAaX,GAbWA,UAaX;AAAA,SAZWC,IAYX,GAZWA,IAYX;AAAA,SAXWC,eAWX,GAXWA,eAWX;AAAA,SAVWC,gBAUX,GAVWA,gBAUX;AAAA,SATWC,mBASX,GATWA,mBASX;AAAA,SARWC,qBAQX,GARWA,qBAQX;AAAA,SAPWC,iBAOX,GAPWA,iBAOX;AAAA,SANWC,yBAMX,GANWA,yBAMX;AAAE;;AArBwB;AAwBhC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly nativeLongTaskThresholdMs: number,\n readonly longTaskThresholdMs: number,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object,\n readonly telemetrySampleRate: number,\n readonly vitalsUpdateFrequency: string,\n readonly trackFrustrations: boolean,\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n }\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","configurationForTelemetry"],"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,yBALF,EAMEC,mBANF,EAOEC,UAPF,EAQEC,IARF,EASEC,eATF,EAUEC,gBAVF,EAWEC,mBAXF,EAYEC,qBAZF,EAaEC,iBAbF,EAcEC,yBAdF,EAsBT;AAAA,SArBWb,WAqBX,GArBWA,WAqBX;AAAA,SApBWC,GAoBX,GApBWA,GAoBX;AAAA,SAnBWC,aAmBX,GAnBWA,aAmBX;AAAA,SAlBWC,wBAkBX,GAlBWA,wBAkBX;AAAA,SAjBWC,yBAiBX,GAjBWA,yBAiBX;AAAA,SAhBWC,mBAgBX,GAhBWA,mBAgBX;AAAA,SAfWC,UAeX,GAfWA,UAeX;AAAA,SAdWC,IAcX,GAdWA,IAcX;AAAA,SAbWC,eAaX,GAbWA,eAaX;AAAA,SAZWC,gBAYX,GAZWA,gBAYX;AAAA,SAXWC,mBAWX,GAXWA,mBAWX;AAAA,SAVWC,qBAUX,GAVWA,qBAUX;AAAA,SATWC,iBASX,GATWA,iBASX;AAAA,SARWC,yBAQX,GARWA,yBAQX;AAAE;;AAvBwB;AA0BhC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly nativeLongTaskThresholdMs: number,\n readonly longTaskThresholdMs: number,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object,\n readonly telemetrySampleRate: number,\n readonly vitalsUpdateFrequency: string,\n readonly trackFrustrations: boolean,\n readonly configurationForTelemetry: {\n initializationType: string;\n trackErrors: boolean;\n trackInteractions: boolean;\n trackNetworkRequests: boolean;\n reactVersion: string;\n reactNativeVersion: string;\n }\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n"]}
@@ -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.5.2';
8
+ const version = '1.6.0';
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,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.5.2';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.6.0';\n"]}
@@ -210,7 +210,11 @@ _defineProperty(DdSdkReactNative, "initializeNativeSDK", async (configuration, p
210
210
  initializationType: params.initializationModeForTelemetry,
211
211
  trackErrors: configuration.trackErrors,
212
212
  trackInteractions: configuration.trackInteractions,
213
- trackNetworkRequests: configuration.trackResources
213
+ trackNetworkRequests: configuration.trackResources,
214
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
215
+ reactNativeVersion: require('react-native/package.json').version,
216
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
217
+ reactVersion: require('react/package.json').version
214
218
  }));
215
219
  InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);
216
220
  DdSdkReactNative.wasInitialized = true;
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","formatFirstPartyHosts","InternalLog","ProxyType","SdkVerbosity","DdLogs","adaptLongTaskThreshold","DdRum","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","AttributesSingleton","BufferSingleton","DdSdk","UserInfoSingleton","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","log","JSON","stringify","DEBUG","getInstance","setUser","user","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","logEventMapper","registerLogEventMapper","errorEventMapper","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","initializationType","trackNetworkRequests","INFO","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","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_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,QAAmC,cAAnC;AAEA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,EAKIC,qBALJ,QAMO,iCANP;AAcA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA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AAEH;;AAED,MAAIxF,aAAa,CAACJ,OAAlB,EAA2B;AACvBI,IAAAA,aAAa,CAAC2D,gBAAd,CAA+B7D,gBAAgB,CAAC4F,UAAhD,IAA+D,GAC3D1F,aAAa,CAACJ,OACjB,GACGI,aAAa,CAAC2F,aAAd,GACO,IAAG3F,aAAa,CAAC2F,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAI3F,aAAa,CAAC2F,aAAd,IAA+B,CAAC3F,aAAa,CAACJ,OAAlD,EAA2D;AACvDI,IAAAA,aAAa,CAAC2D,gBAAd,CACI7D,gBAAgB,CAAC8F,iBADrB,IAEK,IAAG5F,aAAa,CAAC2F,aAAc,EAFpC;AAGH;;AAED3F,EAAAA,aAAa,CAAC2D,gBAAd,CACI,uBADJ,IAEI9E,qBAAqB,CAACmB,aAAa,CAAC8B,eAAf,CAFzB;AAGH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\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 private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\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 wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.trackFrustrations,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setAttributes(attributes: Attributes): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().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 async setUser(user: UserInfo): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(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 buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\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 configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\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[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n '_dd.first_party_hosts'\n ] = formatFirstPartyHosts(configuration.firstPartyHosts);\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InteractionManager","DdSdkReactNativeConfiguration","buildConfigurationFromPartialConfiguration","addDefaultValuesToAutoInstrumentationConfiguration","InitializationMode","formatFirstPartyHosts","InternalLog","ProxyType","SdkVerbosity","DdLogs","adaptLongTaskThreshold","DdRum","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","AttributesSingleton","BufferSingleton","DdSdk","UserInfoSingleton","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","initializeNativeSDK","initializationModeForTelemetry","enableFeatures","_initializeFromDatadogProvider","initializationMode","SYNC","ASYNC","runAfterInteractions","_enableFeaturesFromDatadogProvider","features","setAttributes","attributes","log","JSON","stringify","DEBUG","getInstance","setUser","user","setUserInfo","setTrackingConsent","consent","wasAutoInstrumented","WARN","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","firstPartyHosts","trackErrors","logEventMapper","registerLogEventMapper","errorEventMapper","registerErrorEventMapper","resourceEventMapper","registerResourceEventMapper","actionEventMapper","registerActionEventMapper","params","wasInitialized","__DEV__","telemetryDebug","Promise","resolve","verbosity","buildConfiguration","clientToken","env","applicationId","nativeCrashReportEnabled","nativeLongTaskThresholdMs","longTaskThresholdMs","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","additionalConfig","telemetrySampleRate","vitalsUpdateFrequency","trackFrustrations","initializationType","trackNetworkRequests","reactNativeVersion","require","reactVersion","INFO","onInitialization","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_NATIVE_INTERACTION_TRACKING_KEY","nativeInteractionTracking","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_VERSION","versionSuffix","DD_VERSION_SUFFIX"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kBAAT,QAAmC,cAAnC;AAEA,SACIC,6BADJ,EAEIC,0CAFJ,EAGIC,kDAHJ,EAIIC,kBAJJ,EAKIC,qBALJ,QAMO,iCANP;AAcA,SAASC,WAAT,QAA4B,eAA5B;AACA,S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W,CAACQ,QADhB;AAEH;AACJ;AACJ;;AAED,MAAIrF,aAAa,CAAC2F,WAAlB,EAA+B;AAC3B3F,IAAAA,aAAa,CAAC2D,gBAAd,CAA+B7D,gBAAgB,CAAC8F,eAAhD,IACI5F,aAAa,CAAC2F,WADlB;AAEH;;AAED,MAAI3F,aAAa,CAACJ,OAAlB,EAA2B;AACvBI,IAAAA,aAAa,CAAC2D,gBAAd,CAA+B7D,gBAAgB,CAAC+F,UAAhD,IAA+D,GAC3D7F,aAAa,CAACJ,OACjB,GACGI,aAAa,CAAC8F,aAAd,GACO,IAAG9F,aAAa,CAAC8F,aAAc,EADtC,GAEM,EACT,EAND;AAOH,GAxDA,CA0DD;AACA;;;AACA,MAAI9F,aAAa,CAAC8F,aAAd,IAA+B,CAAC9F,aAAa,CAACJ,OAAlD,EAA2D;AACvDI,IAAAA,aAAa,CAAC2D,gBAAd,CACI7D,gBAAgB,CAACiG,iBADrB,IAEK,IAAG/F,aAAa,CAAC8F,aAAc,EAFpC;AAGH;;AAED9F,EAAAA,aAAa,CAAC2D,gBAAd,CACI,uBADJ,IAEI9E,qBAAqB,CAACmB,aAAa,CAAC8B,eAAf,CAFzB;AAGH,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InteractionManager } from 'react-native';\n\nimport {\n DdSdkReactNativeConfiguration,\n buildConfigurationFromPartialConfiguration,\n addDefaultValuesToAutoInstrumentationConfiguration,\n InitializationMode,\n formatFirstPartyHosts\n} from './DdSdkReactNativeConfiguration';\nimport type {\n AutoInstrumentationParameters,\n DatadogProviderConfiguration,\n PartialInitializationConfiguration,\n AutoInstrumentationConfiguration,\n InitializationModeForTelemetry\n} from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdLogs } from './logs/DdLogs';\nimport { adaptLongTaskThreshold } from './longTasksUtils';\nimport { DdRum } from './rum/DdRum';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/interactionTracking/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { AttributesSingleton } from './sdk/AttributesSingleton/AttributesSingleton';\nimport type { Attributes } from './sdk/AttributesSingleton/types';\nimport { BufferSingleton } from './sdk/DatadogProvider/Buffer/BufferSingleton';\nimport { DdSdk } from './sdk/DdSdk';\nimport { UserInfoSingleton } from './sdk/UserInfoSingleton/UserInfoSingleton';\nimport type { UserInfo } from './sdk/UserInfoSingleton/types';\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 private static readonly DD_NATIVE_INTERACTION_TRACKING_KEY =\n '_dd.native_interaction_tracking';\n private static readonly DD_VERSION = '_dd.version';\n private static readonly DD_VERSION_SUFFIX = '_dd.version_suffix';\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 wasInitialized = false;\n private static wasAutoInstrumented = false;\n private static features?: AutoInstrumentationConfiguration;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static async initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n await DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'LEGACY'\n });\n DdSdkReactNative.enableFeatures(configuration);\n }\n\n private static initializeNativeSDK = async (\n configuration: DdSdkReactNativeConfiguration,\n params: {\n initializationModeForTelemetry: InitializationModeForTelemetry;\n }\n ): Promise<void> => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n if (!__DEV__) {\n DdSdk.telemetryDebug(\n 'RN SDK was already initialized in javascript'\n );\n }\n return new Promise(resolve => resolve());\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n DdSdkReactNative.buildConfiguration(configuration);\n\n await DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n adaptLongTaskThreshold(configuration.nativeLongTaskThresholdMs),\n adaptLongTaskThreshold(configuration.longTaskThresholdMs),\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig,\n configuration.telemetrySampleRate,\n configuration.vitalsUpdateFrequency,\n configuration.trackFrustrations,\n {\n initializationType: params.initializationModeForTelemetry,\n trackErrors: configuration.trackErrors,\n trackInteractions: configuration.trackInteractions,\n trackNetworkRequests: configuration.trackResources,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactNativeVersion: require('react-native/package.json')\n .version,\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n reactVersion: require('react/package.json').version\n }\n )\n );\n InternalLog.log('Datadog SDK was initialized', SdkVerbosity.INFO);\n DdSdkReactNative.wasInitialized = true;\n BufferSingleton.onInitialization();\n };\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _initializeFromDatadogProvider(\n configuration: DatadogProviderConfiguration\n ): Promise<void> {\n DdSdkReactNative.enableFeatures(configuration);\n if (configuration.initializationMode === InitializationMode.SYNC) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n if (configuration.initializationMode === InitializationMode.ASYNC) {\n return InteractionManager.runAfterInteractions(() => {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'ASYNC'\n });\n });\n }\n // TODO: Remove when DdSdkReactNativeConfiguration is deprecated\n if (configuration instanceof DdSdkReactNativeConfiguration) {\n return DdSdkReactNative.initializeNativeSDK(configuration, {\n initializationModeForTelemetry: 'SYNC'\n });\n }\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static async _enableFeaturesFromDatadogProvider(\n features: AutoInstrumentationConfiguration\n ): Promise<void> {\n DdSdkReactNative.features = features;\n DdSdkReactNative.enableFeatures(\n addDefaultValuesToAutoInstrumentationConfiguration(features)\n );\n }\n\n /**\n * FOR INTERNAL USE ONLY.\n */\n static _initializeFromDatadogProviderWithConfigurationAsync = async (\n configuration: PartialInitializationConfiguration\n ): Promise<void> => {\n if (!DdSdkReactNative.features) {\n InternalLog.log(\n \"Can't initialize Datadog, make sure the DatadogProvider component is mounted before calling this function\",\n SdkVerbosity.WARN\n );\n return new Promise(resolve => resolve());\n }\n\n return DdSdkReactNative.initializeNativeSDK(\n buildConfigurationFromPartialConfiguration(\n DdSdkReactNative.features,\n configuration\n ),\n { initializationModeForTelemetry: 'PARTIAL' }\n );\n };\n\n /**\n * Adds a set of attributes to the global context attached with all future Logs, Spans and RUM events.\n * To remove an attribute, set it to `undefined` in a call to `setAttributes`.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static async setAttributes(attributes: Attributes): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setAttributes(attributes);\n AttributesSingleton.getInstance().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 async setUser(user: UserInfo): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n await DdSdk.setUser(user);\n UserInfoSingleton.getInstance().setUserInfo(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 buildConfiguration = (\n configuration: DdSdkReactNativeConfiguration\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 configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_INTERACTION_TRACKING_KEY\n ] = configuration.nativeInteractionTracking;\n\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[DdSdkReactNative.DD_PROXY_USERNAME_KEY] =\n proxyConfig.username;\n additionalConfig[DdSdkReactNative.DD_PROXY_PASSWORD_KEY] =\n proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] =\n configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${\n configuration.version\n }${\n configuration.versionSuffix\n ? `-${configuration.versionSuffix}`\n : ''\n }`;\n }\n\n // If both version and version suffix are provided, we merge them into the version field.\n // To avoid adding it in again the native part, we only set it if the version isn't set.\n if (configuration.versionSuffix && !configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION_SUFFIX\n ] = `-${configuration.versionSuffix}`;\n }\n\n configuration.additionalConfig[\n '_dd.first_party_hosts'\n ] = formatFirstPartyHosts(configuration.firstPartyHosts);\n };\n\n private static enableFeatures(\n configuration: AutoInstrumentationParameters\n ) {\n if (DdSdkReactNative.wasAutoInstrumented) {\n InternalLog.log(\n \"Can't auto instrument Datadog, SDK was already instrumented\",\n SdkVerbosity.WARN\n );\n return;\n }\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: formatFirstPartyHosts(\n configuration.firstPartyHosts\n )\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n\n if (configuration.logEventMapper) {\n DdLogs.registerLogEventMapper(configuration.logEventMapper);\n }\n\n if (configuration.errorEventMapper) {\n DdRum.registerErrorEventMapper(configuration.errorEventMapper);\n }\n\n if (configuration.resourceEventMapper) {\n DdRum.registerResourceEventMapper(\n configuration.resourceEventMapper\n );\n }\n\n if (configuration.actionEventMapper) {\n DdRum.registerActionEventMapper(configuration.actionEventMapper);\n }\n\n DdSdkReactNative.wasAutoInstrumented = true;\n }\n}\n"]}
@@ -6,6 +6,7 @@ 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
+ export const DATADOG_MESSAGE_PREFIX = 'DATADOG:';
9
10
  /**
10
11
  * /!\ DO NOT USE THIS IN YOUR APP /!\\
11
12
  *
@@ -25,7 +26,7 @@ export class InternalLog {
25
26
  return;
26
27
  }
27
28
 
28
- const prefixedMessage = `DATADOG: ${message}`;
29
+ const prefixedMessage = `${DATADOG_MESSAGE_PREFIX} ${message}`;
29
30
 
30
31
  if (verbosity === SdkVerbosity.ERROR && requiredLevel >= allowedLevel) {
31
32
  console.error(prefixedMessage);
@@ -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,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
+ {"version":3,"sources":["InternalLog.tsx"],"names":["SdkVerbosity","DATADOG_MESSAGE_PREFIX","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,OAAO,MAAMC,sBAAsB,GAAG,UAA/B;AAEP;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,GAAEV,sBAAuB,IAAGG,OAAQ,EAA7D;;AACA,QAAIC,SAAS,KAAKL,YAAY,CAACY,KAA3B,IAAoCL,aAAa,IAAIG,YAAzD,EAAuE;AACnEG,MAAAA,OAAO,CAACC,KAAR,CAAcH,eAAd;AACH;;AAED,QAAIN,SAAS,KAAKL,YAAY,CAACe,IAA3B,IAAmCR,aAAa,IAAIG,YAAxD,EAAsE;AAClEG,MAAAA,OAAO,CAACG,IAAR,CAAaL,eAAb;AACH;;AAED,QAAIN,SAAS,KAAKL,YAAY,CAACiB,IAA3B,IAAmCV,aAAa,IAAIG,YAAxD,EAAsE;AAClEG,MAAAA,OAAO,CAACK,IAAR,CAAaP,eAAb;AACH;;AAED,QAAIN,SAAS,KAAKL,YAAY,CAACmB,KAA3B,IAAoCZ,aAAa,IAAIG,YAAzD,EAAuE;AACnEG,MAAAA,OAAO,CAACO,KAAR,CAAcT,eAAd;AACH;AACJ;;AAnCoB;;gBAAZT,W,cACiB,IAAImB,GAAJ,CAA8B,CACpD,CAACrB,YAAY,CAACmB,KAAd,EAAqB,CAArB,CADoD,EAEpD,CAACnB,YAAY,CAACiB,IAAd,EAAoB,CAApB,CAFoD,EAGpD,CAACjB,YAAY,CAACe,IAAd,EAAoB,CAApB,CAHoD,EAIpD,CAACf,YAAY,CAACY,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\nexport const DATADOG_MESSAGE_PREFIX = 'DATADOG:';\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_PREFIX} ${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"]}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export const EMPTY_MESSAGE = 'Unknown Error';
7
7
  export const EMPTY_STACK_TRACE = '';
8
+ export const DEFAULT_ERROR_NAME = 'Error';
8
9
  export const getErrorMessage = error => {
9
10
  let message = EMPTY_MESSAGE;
10
11
 
@@ -51,4 +52,18 @@ export const getErrorStackTrace = error => {
51
52
 
52
53
  return stack;
53
54
  };
55
+ export const getErrorName = error => {
56
+ try {
57
+ if (typeof error !== 'object' || error === null) {
58
+ return DEFAULT_ERROR_NAME;
59
+ }
60
+
61
+ if (typeof error.name === 'string') {
62
+ return error.name;
63
+ }
64
+ } catch (e) {// Do nothing
65
+ }
66
+
67
+ return DEFAULT_ERROR_NAME;
68
+ };
54
69
  //# sourceMappingURL=errorUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["errorUtils.ts"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","getErrorMessage","error","message","undefined","String","getErrorStackTrace","stack","stacktrace","componentStack","sourceURL","line","column","e"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,eAAtB;AACP,OAAO,MAAMC,iBAAiB,GAAG,EAA1B;AAEP,OAAO,MAAMC,eAAe,GAAIC,KAAD,IAAoC;AAC/D,MAAIC,OAAO,GAAGJ,aAAd;;AACA,MAAIG,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGJ,aAAV;AACH,GAFD,MAEO,IAAI,OAAOG,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXM;AAaP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,kBAAkB,GAAIJ,KAAD,IAAoC;AAClE,MAAIK,KAAK,GAAGP,iBAAZ;;AAEA,MAAI;AACA,QAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClCK,MAAAA,KAAK,GAAGP,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOE,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACM,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWN,KAAf,EAAsB;AACzBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACK,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBL,KAAxB,EAA+B;AAClCK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACO,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeP,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEK,QAAAA,KAAK,GAAI,MAAKL,KAAK,CAACQ,SAAU,IAAGR,KAAK,CAACS,IAAK,IAAGT,KAAK,CAACU,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOC,CAAP,EAAU,CACR;AACH;;AACD,SAAON,KAAP;AACH,CA3BM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const EMPTY_MESSAGE = 'Unknown Error';\nexport const EMPTY_STACK_TRACE = '';\n\nexport const getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\n/**\n * Will extract the stack from the error, taking the first key found among:\n * `stacktrace`, `stack`, `componentStack` (component tree for component errors,\n * which contains only native components names in production).\n *\n * In last resort and if `sourceURL`, `line` and `column` are present, it will\n * generate a stack from this information.\n */\nexport const getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
1
+ {"version":3,"sources":["errorUtils.ts"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","DEFAULT_ERROR_NAME","getErrorMessage","error","message","undefined","String","getErrorStackTrace","stack","stacktrace","componentStack","sourceURL","line","column","e","getErrorName","name"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,eAAtB;AACP,OAAO,MAAMC,iBAAiB,GAAG,EAA1B;AACP,OAAO,MAAMC,kBAAkB,GAAG,OAA3B;AAEP,OAAO,MAAMC,eAAe,GAAIC,KAAD,IAAoC;AAC/D,MAAIC,OAAO,GAAGL,aAAd;;AACA,MAAII,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGL,aAAV;AACH,GAFD,MAEO,IAAI,OAAOI,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXM;AAaP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,kBAAkB,GAAIJ,KAAD,IAAoC;AAClE,MAAIK,KAAK,GAAGR,iBAAZ;;AAEA,MAAI;AACA,QAAIG,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCK,MAAAA,KAAK,GAAGR,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOG,KAAP,KAAiB,QAArB,EAA+B;AAClCK,MAAAA,KAAK,GAAGR,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOG,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACM,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWN,KAAf,EAAsB;AACzBK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACK,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBL,KAAxB,EAA+B;AAClCK,QAAAA,KAAK,GAAGF,MAAM,CAACH,KAAK,CAACO,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeP,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEK,QAAAA,KAAK,GAAI,MAAKL,KAAK,CAACQ,SAAU,IAAGR,KAAK,CAACS,IAAK,IAAGT,KAAK,CAACU,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOC,CAAP,EAAU,CACR;AACH;;AACD,SAAON,KAAP;AACH,CA3BM;AA6BP,OAAO,MAAMO,YAAY,GAAIZ,KAAD,IAA4B;AACpD,MAAI;AACA,QAAI,OAAOA,KAAP,KAAiB,QAAjB,IAA6BA,KAAK,KAAK,IAA3C,EAAiD;AAC7C,aAAOF,kBAAP;AACH;;AACD,QAAI,OAAQE,KAAD,CAAea,IAAtB,KAA+B,QAAnC,EAA6C;AACzC,aAAQb,KAAD,CAAea,IAAtB;AACH;AACJ,GAPD,CAOE,OAAOF,CAAP,EAAU,CACR;AACH;;AACD,SAAOb,kBAAP;AACH,CAZM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const EMPTY_MESSAGE = 'Unknown Error';\nexport const EMPTY_STACK_TRACE = '';\nexport const DEFAULT_ERROR_NAME = 'Error';\n\nexport const getErrorMessage = (error: any | undefined): string => {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n};\n\n/**\n * Will extract the stack from the error, taking the first key found among:\n * `stacktrace`, `stack`, `componentStack` (component tree for component errors,\n * which contains only native components names in production).\n *\n * In last resort and if `sourceURL`, `line` and `column` are present, it will\n * generate a stack from this information.\n */\nexport const getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n\nexport const getErrorName = (error: unknown): string => {\n try {\n if (typeof error !== 'object' || error === null) {\n return DEFAULT_ERROR_NAME;\n }\n if (typeof (error as any).name === 'string') {\n return (error as any).name;\n }\n } catch (e) {\n // Do nothing\n }\n return DEFAULT_ERROR_NAME;\n};\n"]}
@@ -6,11 +6,21 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
8
  import { NativeModules } from 'react-native';
9
- import { InternalLog } from '../InternalLog';
9
+ import { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';
10
10
  import { SdkVerbosity } from '../SdkVerbosity';
11
11
  import { generateEventMapper } from './eventMapper';
12
+ const SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';
12
13
 
13
14
  const generateEmptyPromise = () => new Promise(resolve => resolve());
15
+ /**
16
+ * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,
17
+ * then the log contains an error.
18
+ */
19
+
20
+
21
+ const isLogWithError = args => {
22
+ return typeof args[1] === 'string' || typeof args[2] === 'string' || typeof args[3] === 'string' || typeof args[4] === 'object';
23
+ };
14
24
 
15
25
  class DdLogsWrapper {
16
26
  constructor() {
@@ -18,8 +28,21 @@ class DdLogsWrapper {
18
28
 
19
29
  _defineProperty(this, "logEventMapper", generateEventMapper(undefined));
20
30
 
21
- _defineProperty(this, "log", (message, context, status) => {
22
- InternalLog.log(`Tracking ${status} log “${message}”`, SdkVerbosity.DEBUG);
31
+ _defineProperty(this, "printLogDroppedSdkNotInitialized", (message, status) => {
32
+ if (__DEV__) {
33
+ console.warn(`${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: "${message}"`);
34
+ }
35
+ });
36
+
37
+ _defineProperty(this, "printlogDroppedByMapper", (message, status) => {
38
+ InternalLog.log(`${status} log dropped by log mapper: "${message}"`, SdkVerbosity.DEBUG);
39
+ });
40
+
41
+ _defineProperty(this, "printLogTracked", (message, status) => {
42
+ InternalLog.log(`Tracking ${status} log "${message}"`, SdkVerbosity.DEBUG);
43
+ });
44
+
45
+ _defineProperty(this, "log", async (message, context, status) => {
23
46
  const event = this.logEventMapper.applyEventMapper({
24
47
  message,
25
48
  context,
@@ -27,28 +50,96 @@ class DdLogsWrapper {
27
50
  });
28
51
 
29
52
  if (!event) {
53
+ this.printlogDroppedByMapper(message, status);
30
54
  return generateEmptyPromise();
31
55
  }
32
56
 
33
- return this.nativeLogs[status](event.message, event.context);
57
+ this.printLogTracked(event.message, status);
58
+
59
+ try {
60
+ return await this.nativeLogs[status](event.message, event.context);
61
+ } catch (error) {
62
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
63
+ // @ts-ignore
64
+ if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {
65
+ this.printLogDroppedSdkNotInitialized(message, status);
66
+ return generateEmptyPromise();
67
+ }
68
+
69
+ throw error;
70
+ }
71
+ });
72
+
73
+ _defineProperty(this, "logWithError", async (message, errorKind, errorMessage, stacktrace, context, status) => {
74
+ const event = this.logEventMapper.applyEventMapper({
75
+ message,
76
+ errorKind,
77
+ errorMessage,
78
+ stacktrace,
79
+ context,
80
+ status
81
+ });
82
+
83
+ if (!event) {
84
+ this.printlogDroppedByMapper(message, status);
85
+ return generateEmptyPromise();
86
+ }
87
+
88
+ this.printLogTracked(event.message, status);
89
+
90
+ try {
91
+ return await this.nativeLogs[`${status}WithError`](event.message, event.errorKind, event.errorMessage, event.stacktrace, { ...event.context,
92
+ '_dd.error.source_type': 'react-native'
93
+ });
94
+ } catch (error) {
95
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
96
+ // @ts-ignore
97
+ if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {
98
+ this.printLogDroppedSdkNotInitialized(message, status);
99
+ return generateEmptyPromise();
100
+ }
101
+
102
+ throw error;
103
+ }
34
104
  });
35
105
  }
36
106
 
37
- debug(message, context = {}) {
38
- return this.log(message, context, 'debug');
107
+ debug(...args) {
108
+ if (isLogWithError(args)) {
109
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'debug');
110
+ }
111
+
112
+ return this.log(args[0], args[1] || {}, 'debug');
39
113
  }
40
114
 
41
- info(message, context = {}) {
42
- return this.log(message, context, 'info');
115
+ info(...args) {
116
+ if (isLogWithError(args)) {
117
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'info');
118
+ }
119
+
120
+ return this.log(args[0], args[1] || {}, 'info');
43
121
  }
44
122
 
45
- warn(message, context = {}) {
46
- return this.log(message, context, 'warn');
123
+ warn(...args) {
124
+ if (isLogWithError(args)) {
125
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'warn');
126
+ }
127
+
128
+ return this.log(args[0], args[1] || {}, 'warn');
47
129
  }
48
130
 
49
- error(message, context = {}) {
50
- return this.log(message, context, 'error');
131
+ error(...args) {
132
+ if (isLogWithError(args)) {
133
+ return this.logWithError(args[0], args[1], args[2], args[3], args[4] || {}, 'error');
134
+ }
135
+
136
+ return this.log(args[0], args[1] || {}, 'error');
51
137
  }
138
+ /**
139
+ * Since the InternalLog does not have a verbosity set yet in this case,
140
+ * we use console.warn to warn the user in dev mode.
141
+ */
142
+
52
143
 
53
144
  registerLogEventMapper(logEventMapper) {
54
145
  this.logEventMapper = generateEventMapper(logEventMapper);
@@ -1 +1 @@
1
- {"version":3,"sources":["DdLogs.ts"],"names":["NativeModules","InternalLog","SdkVerbosity","generateEventMapper","generateEmptyPromise","Promise","resolve","DdLogsWrapper","DdLogs","undefined","message","context","status","log","DEBUG","event","logEventMapper","applyEventMapper","nativeLogs","debug","info","warn","error","registerLogEventMapper","unregisterLogEventMapper"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,WAAT,QAA4B,gBAA5B;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAGA,SAASC,mBAAT,QAAoC,eAApC;;AAGA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC,OAAO,IAAIA,OAAO,EAApC,CAAnC;;AAEA,MAAMC,aAAN,CAA0C;AAAA;AAAA,wCACCP,aAAa,CAACQ,MADf;;AAAA,4CAEbL,mBAAmB,CAACM,SAAD,CAFN;;AAAA,iCAoBxB,CACVC,OADU,EAEVC,OAFU,EAGVC,MAHU,KAIM;AAChBX,MAAAA,WAAW,CAACY,GAAZ,CACK,YAAWD,MAAO,SAAQF,OAAQ,GADvC,EAEIR,YAAY,CAACY,KAFjB;AAIA,YAAMC,KAAK,GAAG,KAAKC,cAAL,CAAoBC,gBAApB,CAAqC;AAC/CP,QAAAA,OAD+C;AAE/CC,QAAAA,OAF+C;AAG/CC,QAAAA;AAH+C,OAArC,CAAd;;AAKA,UAAI,CAACG,KAAL,EAAY;AACR,eAAOX,oBAAoB,EAA3B;AACH;;AACD,aAAO,KAAKc,UAAL,CAAgBN,MAAhB,EAAwBG,KAAK,CAACL,OAA9B,EAAuCK,KAAK,CAACJ,OAA7C,CAAP;AACH,KAtCqC;AAAA;;AAItCQ,EAAAA,KAAK,CAACT,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxD,WAAO,KAAKE,GAAL,CAASH,OAAT,EAAkBC,OAAlB,EAA2B,OAA3B,CAAP;AACH;;AAEDS,EAAAA,IAAI,CAACV,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvD,WAAO,KAAKE,GAAL,CAASH,OAAT,EAAkBC,OAAlB,EAA2B,MAA3B,CAAP;AACH;;AAEDU,EAAAA,IAAI,CAACX,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvD,WAAO,KAAKE,GAAL,CAASH,OAAT,EAAkBC,OAAlB,EAA2B,MAA3B,CAAP;AACH;;AAEDW,EAAAA,KAAK,CAACZ,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxD,WAAO,KAAKE,GAAL,CAASH,OAAT,EAAkBC,OAAlB,EAA2B,OAA3B,CAAP;AACH;;AAsBDY,EAAAA,sBAAsB,CAACP,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsBb,mBAAmB,CAACa,cAAD,CAAzC;AACH;;AAEDQ,EAAAA,wBAAwB,GAAG;AACvB,SAAKR,cAAL,GAAsBb,mBAAmB,CAACM,SAAD,CAAzC;AACH;;AA9CqC;;AAiD1C,OAAO,MAAMD,MAAM,GAAG,IAAID,aAAJ,EAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\n\nimport { InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type { DdLogsType, LogEventMapper } from './types';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\nclass DdLogsWrapper implements DdLogsType {\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n private logEventMapper = generateEventMapper(undefined);\n\n debug(message: string, context: object = {}): Promise<void> {\n return this.log(message, context, 'debug');\n }\n\n info(message: string, context: object = {}): Promise<void> {\n return this.log(message, context, 'info');\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n return this.log(message, context, 'warn');\n }\n\n error(message: string, context: object = {}): Promise<void> {\n return this.log(message, context, 'error');\n }\n\n private log = (\n message: string,\n context: object,\n status: keyof DdNativeLogsType\n ): Promise<void> => {\n InternalLog.log(\n `Tracking ${status} log “${message}”`,\n SdkVerbosity.DEBUG\n );\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n return generateEmptyPromise();\n }\n return this.nativeLogs[status](event.message, event.context);\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
1
+ {"version":3,"sources":["DdLogs.ts"],"names":["NativeModules","DATADOG_MESSAGE_PREFIX","InternalLog","SdkVerbosity","generateEventMapper","SDK_NOT_INITIALIZED_MESSAGE","generateEmptyPromise","Promise","resolve","isLogWithError","args","DdLogsWrapper","DdLogs","undefined","message","status","__DEV__","console","warn","log","DEBUG","context","event","logEventMapper","applyEventMapper","printlogDroppedByMapper","printLogTracked","nativeLogs","error","printLogDroppedSdkNotInitialized","errorKind","errorMessage","stacktrace","debug","logWithError","info","registerLogEventMapper","unregisterLogEventMapper"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AAEA,SAASC,sBAAT,EAAiCC,WAAjC,QAAoD,gBAApD;AACA,SAASC,YAAT,QAA6B,iBAA7B;AAGA,SAASC,mBAAT,QAAoC,eAApC;AASA,MAAMC,2BAA2B,GAAG,sCAApC;;AAEA,MAAMC,oBAAoB,GAAG,MAAM,IAAIC,OAAJ,CAAkBC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CADD,EAEHA,IAAI,CAAC,CAAD,CAFD,EAGHA,IAAI,CAAC,CAAD,CAHD,EAIHA,IAAI,CAAC,CAAD,CAJD,EAKHA,IAAI,CAAC,CAAD,CAAJ,IAAW,EALR,EAMH,MANG,CAAP;AAQH;;AACD,WAAO,KAAKS,GAAL,CAAST,IAAI,CAAC,CAAD,CAAb,EAAkBA,IAAI,CAAC,CAAD,CAAJ,IAAW,EAA7B,EAAiC,MAAjC,CAAP;AACH;;AAEDkB,EAAAA,KAAK,CAAC,GAAGlB,IAAJ,EAA+D;AAChE,QAAID,cAAc,CAACC,IAAD,CAAlB,EAA0B;AACtB,aAAO,KAAKwB,YAAL,CACHxB,IAAI,CAAC,CAAD,CADD,EAEHA,IAAI,CAAC,CAAD,CAFD,EAGHA,IAAI,CAAC,CAAD,CAHD,EAIHA,IAAI,CAAC,CAAD,CAJD,EAKHA,IAAI,CAAC,CAAD,CAAJ,IAAW,EALR,EAMH,OANG,CAAP;AAQH;;AACD,WAAO,KAAKS,GAAL,CAAST,IAAI,CAAC,CAAD,CAAb,EAAkBA,IAAI,CAAC,CAAD,CAAJ,IAAW,EAA7B,EAAiC,OAAjC,CAAP;AACH;AAED;AACJ;AACA;AACA;;;AAwGI0B,EAAAA,sBAAsB,CAACb,cAAD,EAAiC;AACnD,SAAKA,cAAL,GAAsBnB,mBAAmB,CAACmB,cAAD,CAAzC;AACH;;AAEDc,EAAAA,wBAAwB,GAAG;AACvB,SAAKd,cAAL,GAAsBnB,mBAAmB,CAACS,SAAD,CAAzC;AACH;;AA7KqC;;AAgL1C,OAAO,MAAMD,MAAM,GAAG,IAAID,aAAJ,EAAf","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\n\nimport { DATADOG_MESSAGE_PREFIX, InternalLog } from '../InternalLog';\nimport { SdkVerbosity } from '../SdkVerbosity';\nimport type { DdNativeLogsType } from '../nativeModulesTypes';\n\nimport { generateEventMapper } from './eventMapper';\nimport type {\n DdLogsType,\n LogArguments,\n LogEventMapper,\n LogWithErrorArguments,\n NativeLogWithError\n} from './types';\n\nconst SDK_NOT_INITIALIZED_MESSAGE = 'DD_INTERNAL_LOG_SENT_BEFORE_SDK_INIT';\n\nconst generateEmptyPromise = () => new Promise<void>(resolve => resolve());\n\n/**\n * We consider that if either one of `errorKind`, `errorMessage` or `stacktrace` is a string,\n * then the log contains an error.\n */\nconst isLogWithError = (\n args: LogArguments | LogWithErrorArguments\n): args is LogWithErrorArguments => {\n return (\n typeof args[1] === 'string' ||\n typeof args[2] === 'string' ||\n typeof args[3] === 'string' ||\n typeof args[4] === 'object'\n );\n};\n\nclass DdLogsWrapper implements DdLogsType {\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n private logEventMapper = generateEventMapper(undefined);\n\n debug(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'debug'\n );\n }\n return this.log(args[0], args[1] || {}, 'debug');\n }\n\n info(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'info'\n );\n }\n return this.log(args[0], args[1] || {}, 'info');\n }\n\n warn(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'warn'\n );\n }\n return this.log(args[0], args[1] || {}, 'warn');\n }\n\n error(...args: LogArguments | LogWithErrorArguments): Promise<void> {\n if (isLogWithError(args)) {\n return this.logWithError(\n args[0],\n args[1],\n args[2],\n args[3],\n args[4] || {},\n 'error'\n );\n }\n return this.log(args[0], args[1] || {}, 'error');\n }\n\n /**\n * Since the InternalLog does not have a verbosity set yet in this case,\n * we use console.warn to warn the user in dev mode.\n */\n private printLogDroppedSdkNotInitialized = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n if (__DEV__) {\n console.warn(\n `${DATADOG_MESSAGE_PREFIX} Dropping ${status} log as the SDK is not initialized yet: \"${message}\"`\n );\n }\n };\n\n private printlogDroppedByMapper = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `${status} log dropped by log mapper: \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private printLogTracked = (\n message: string,\n status: 'debug' | 'info' | 'warn' | 'error'\n ) => {\n InternalLog.log(\n `Tracking ${status} log \"${message}\"`,\n SdkVerbosity.DEBUG\n );\n };\n\n private log = async (\n message: string,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[status](event.message, event.context);\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n private logWithError = async (\n message: string,\n errorKind: string | undefined,\n errorMessage: string | undefined,\n stacktrace: string | undefined,\n context: object,\n status: 'debug' | 'info' | 'warn' | 'error'\n ): Promise<void> => {\n const event = this.logEventMapper.applyEventMapper({\n message,\n errorKind,\n errorMessage,\n stacktrace,\n context,\n status\n });\n if (!event) {\n this.printlogDroppedByMapper(message, status);\n return generateEmptyPromise();\n }\n\n this.printLogTracked(event.message, status);\n try {\n return await this.nativeLogs[`${status}WithError`](\n event.message,\n (event as NativeLogWithError).errorKind,\n (event as NativeLogWithError).errorMessage,\n (event as NativeLogWithError).stacktrace,\n { ...event.context, '_dd.error.source_type': 'react-native' }\n );\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (error.message === SDK_NOT_INITIALIZED_MESSAGE) {\n this.printLogDroppedSdkNotInitialized(message, status);\n return generateEmptyPromise();\n }\n\n throw error;\n }\n };\n\n registerLogEventMapper(logEventMapper: LogEventMapper) {\n this.logEventMapper = generateEventMapper(logEventMapper);\n }\n\n unregisterLogEventMapper() {\n this.logEventMapper = generateEventMapper(undefined);\n }\n}\n\nexport const DdLogs = new DdLogsWrapper();\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["eventMapper.ts"],"names":["EventMapper","formatLogEventToNativeLog","logEvent","formatRawLogToNativeEvent","rawLog","formatRawLogToLogEvent","additionalInformation","userInfo","attributes","generateEventMapper","logEventMapper"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,iCAA5B;AAKA,OAAO,MAAMC,yBAAyB,GAAIC,QAAD,IAAmC;AACxE,SAAOA,QAAP;AACH,CAFM;AAIP,OAAO,MAAMC,yBAAyB,GAAIC,MAAD,IAA+B;AACpE,SAAOA,MAAP;AACH,CAFM;AAIP,OAAO,MAAMC,sBAAsB,GAAG,CAClCD,MADkC,EAElCE,qBAFkC,KAMvB;AACX,SAAO,EACH,GAAGF,MADA;AAEHG,IAAAA,QAAQ,EAAED,qBAAqB,CAACC,QAF7B;AAGHC,IAAAA,UAAU,EAAEF,qBAAqB,CAACE;AAH/B,GAAP;AAKH,CAZM;AAcP,OAAO,MAAMC,mBAAmB,GAC5BC,cAD+B,IAG/B,IAAIV,WAAJ,CACIU,cADJ,EAEIL,sBAFJ,EAGIJ,yBAHJ,EAIIE,yBAJJ,CAHG","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { Attributes } from '../sdk/AttributesSingleton/types';\nimport { EventMapper } from '../sdk/EventMappers/EventMapper';\nimport type { UserInfo } from '../sdk/UserInfoSingleton/types';\n\nimport type { LogEvent, LogEventMapper, NativeLog, RawLog } from './types';\n\nexport const formatLogEventToNativeLog = (logEvent: LogEvent): NativeLog => {\n return logEvent;\n};\n\nexport const formatRawLogToNativeEvent = (rawLog: RawLog): NativeLog => {\n return rawLog;\n};\n\nexport const formatRawLogToLogEvent = (\n rawLog: RawLog,\n additionalInformation: {\n userInfo: UserInfo;\n attributes: Attributes;\n }\n): LogEvent => {\n return {\n ...rawLog,\n userInfo: additionalInformation.userInfo,\n attributes: additionalInformation.attributes\n };\n};\n\nexport const generateEventMapper = (\n logEventMapper: LogEventMapper | undefined\n) =>\n new EventMapper(\n logEventMapper,\n formatRawLogToLogEvent,\n formatLogEventToNativeLog,\n formatRawLogToNativeEvent\n );\n"]}
1
+ {"version":3,"sources":["eventMapper.ts"],"names":["EventMapper","formatLogEventToNativeLog","logEvent","formatRawLogToNativeEvent","rawLog","formatRawLogToLogEvent","additionalInformation","userInfo","attributes","generateEventMapper","logEventMapper"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,iCAA5B;AAYA,OAAO,MAAMC,yBAAyB,GAClCC,QADqC,IAEJ;AACjC,SAAOA,QAAP;AACH,CAJM;AAMP,OAAO,MAAMC,yBAAyB,GAClCC,MADqC,IAEJ;AACjC,SAAOA,MAAP;AACH,CAJM;AAMP,OAAO,MAAMC,sBAAsB,GAAG,CAClCD,MADkC,EAElCE,qBAFkC,KAMvB;AACX,SAAO,EACH,GAAGF,MADA;AAEHG,IAAAA,QAAQ,EAAED,qBAAqB,CAACC,QAF7B;AAGHC,IAAAA,UAAU,EAAEF,qBAAqB,CAACE;AAH/B,GAAP;AAKH,CAZM;AAcP,OAAO,MAAMC,mBAAmB,GAC5BC,cAD+B,IAG/B,IAAIV,WAAJ,CACIU,cADJ,EAEIL,sBAFJ,EAGIJ,yBAHJ,EAIIE,yBAJJ,CAHG","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { Attributes } from '../sdk/AttributesSingleton/types';\nimport { EventMapper } from '../sdk/EventMappers/EventMapper';\nimport type { UserInfo } from '../sdk/UserInfoSingleton/types';\n\nimport type {\n LogEvent,\n LogEventMapper,\n NativeLog,\n NativeLogWithError,\n RawLog,\n RawLogWithError\n} from './types';\n\nexport const formatLogEventToNativeLog = (\n logEvent: LogEvent\n): NativeLog | NativeLogWithError => {\n return logEvent;\n};\n\nexport const formatRawLogToNativeEvent = (\n rawLog: RawLog | RawLogWithError\n): NativeLog | NativeLogWithError => {\n return rawLog;\n};\n\nexport const formatRawLogToLogEvent = (\n rawLog: RawLog | RawLogWithError,\n additionalInformation: {\n userInfo: UserInfo;\n attributes: Attributes;\n }\n): LogEvent => {\n return {\n ...rawLog,\n userInfo: additionalInformation.userInfo,\n attributes: additionalInformation.attributes\n };\n};\n\nexport const generateEventMapper = (\n logEventMapper: LogEventMapper | undefined\n) =>\n new EventMapper(\n logEventMapper,\n formatRawLogToLogEvent,\n formatLogEventToNativeLog,\n formatRawLogToNativeEvent\n );\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
1
+ {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,wBAAN,CAA+B;AAClCC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAV8B;AAatC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdNativeSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdNativeSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdNativeSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<object>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n\n /**\n * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n\n /**\n * Send webview telemetry logs\n * @param message event description\n */\n consumeWebviewEvent(message: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with DEBUG level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with INFO level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with WARN level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with ERROR level.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log containing an error with DEBUG level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n debugWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with INDO level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n infoWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with WARN level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n warnWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n\n /**\n * Send a log containing an error with ERROR level.\n * @param message: The message to send.\n * @param errorKind: The error kind to send.\n * @param errorMessage: The error message to send.\n * @param stacktrace: The stack trace to send.\n * @param context: The additional context to send.\n */\n errorWithError(\n message: string,\n errorKind?: string,\n errorMessage?: string,\n stacktrace?: string,\n context?: object\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n\n /**\n * Stops the current RUM Session.\n */\n stopSession(): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}