@datadog/mobile-react-native 1.0.0 → 1.1.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 (99) hide show
  1. package/DatadogSDKReactNative.podspec +2 -1
  2. package/android/build.gradle +73 -3
  3. package/android/gradle.properties +1 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +54 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +86 -0
  6. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdLogs.kt +27 -11
  7. package/android/src/main/kotlin/com/datadog/reactnative/DdRum.kt +305 -0
  8. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +280 -0
  9. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkBridgeExt.kt +2 -2
  10. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +29 -0
  11. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -4
  12. package/android/src/main/{java → kotlin}/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -0
  13. package/android/src/main/kotlin/com/datadog/reactnative/DdTrace.kt +86 -0
  14. package/android/src/main/kotlin/com/datadog/reactnative/GlobalState.kt +32 -0
  15. package/android/src/main/kotlin/com/datadog/reactnative/NoOpViewTrackingStrategy.kt +23 -0
  16. package/android/src/main/kotlin/com/datadog/reactnative/ProxyAuthenticator.kt +60 -0
  17. package/android/src/test/kotlin/com/datadog/reactnative/DdLogsTest.kt +170 -0
  18. package/android/src/test/kotlin/com/datadog/reactnative/DdRumTest.kt +408 -0
  19. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +1547 -0
  20. package/android/src/test/kotlin/com/datadog/reactnative/DdTraceTest.kt +306 -0
  21. package/android/src/test/kotlin/com/datadog/reactnative/GlobalStateTest.kt +118 -0
  22. package/android/src/test/kotlin/com/datadog/reactnative/ProxyAuthenticatorTest.kt +123 -0
  23. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +33 -0
  24. package/android/src/test/kotlin/com/datadog/tools/unit/GenericAssert.kt +43 -0
  25. package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +22 -0
  26. package/android/src/test/kotlin/com/datadog/tools/unit/ReflectUtils.kt +267 -0
  27. package/android/src/test/kotlin/com/datadog/tools/unit/forge/BaseConfigurator.kt +26 -0
  28. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +33 -0
  29. package/android/src/test/kotlin/com/datadog/tools/unit/forge/PackageInfoForgeryFactory.kt +20 -0
  30. package/android/src/test/kotlin/com/datadog/tools/unit/forge/Throwable.kt +31 -0
  31. package/android/src/test/kotlin/com/datadog/tools/unit/forge/ThrowableForgeryFactory.kt +21 -0
  32. package/android/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker +1 -0
  33. package/ios/Sources/AnyEncodable.swift +138 -0
  34. package/ios/Sources/Attributes.swift +101 -0
  35. package/ios/Sources/DdLogs.swift +35 -11
  36. package/ios/Sources/DdRum.m +3 -1
  37. package/ios/Sources/DdRum.swift +184 -22
  38. package/ios/Sources/DdSdk.swift +190 -10
  39. package/ios/Sources/DdSdkConfiguration.swift +51 -0
  40. package/ios/Sources/DdTrace.swift +41 -6
  41. package/ios/Sources/GlobalState.swift +28 -0
  42. package/ios/Sources/QueueHolder.swift +10 -0
  43. package/ios/Sources/RNDdSdkConfiguration.swift +5 -6
  44. package/lib/commonjs/DdSdkReactNative.js +14 -0
  45. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  46. package/lib/commonjs/DdSdkReactNativeConfiguration.js +24 -0
  47. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  48. package/lib/commonjs/foundation.js +36 -2
  49. package/lib/commonjs/foundation.js.map +1 -1
  50. package/lib/commonjs/nativeModulesTypes.js +36 -0
  51. package/lib/commonjs/nativeModulesTypes.js.map +1 -0
  52. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js +4 -17
  53. package/lib/commonjs/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  54. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +4 -4
  55. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  56. package/lib/commonjs/types.js +26 -1
  57. package/lib/commonjs/types.js.map +1 -1
  58. package/lib/commonjs/version.js +1 -1
  59. package/lib/commonjs/version.js.map +1 -1
  60. package/lib/module/DdSdkReactNative.js +14 -0
  61. package/lib/module/DdSdkReactNative.js.map +1 -1
  62. package/lib/module/DdSdkReactNativeConfiguration.js +24 -0
  63. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  64. package/lib/module/foundation.js +36 -2
  65. package/lib/module/foundation.js.map +1 -1
  66. package/lib/module/nativeModulesTypes.js +26 -0
  67. package/lib/module/nativeModulesTypes.js.map +1 -0
  68. package/lib/module/rum/instrumentation/DdEventsInterceptor.js +2 -14
  69. package/lib/module/rum/instrumentation/DdEventsInterceptor.js.map +1 -1
  70. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +3 -4
  71. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  72. package/lib/module/types.js +23 -0
  73. package/lib/module/types.js.map +1 -1
  74. package/lib/module/version.js +1 -1
  75. package/lib/module/version.js.map +1 -1
  76. package/lib/typescript/DdSdkReactNative.d.ts +2 -0
  77. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +20 -0
  78. package/lib/typescript/foundation.d.ts +3 -2
  79. package/lib/typescript/nativeModulesTypes.d.ts +168 -0
  80. package/lib/typescript/rum/instrumentation/DdEventsInterceptor.d.ts +0 -15
  81. package/lib/typescript/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +2 -1
  82. package/lib/typescript/types.d.ts +42 -7
  83. package/lib/typescript/version.d.ts +1 -1
  84. package/package.json +3 -3
  85. package/src/DdSdkReactNative.tsx +20 -0
  86. package/src/DdSdkReactNativeConfiguration.tsx +20 -0
  87. package/src/__tests__/DdSdkReactNative.test.tsx +76 -0
  88. package/src/__tests__/foundation.test.ts +79 -0
  89. package/src/__tests__/rum/instrumentation/DdEventsInterceptor.test.tsx +8 -8
  90. package/src/foundation.tsx +40 -11
  91. package/src/nativeModulesTypes.ts +258 -0
  92. package/src/rum/instrumentation/DdEventsInterceptor.tsx +2 -17
  93. package/src/rum/instrumentation/DdRumErrorTracking.tsx +3 -4
  94. package/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.ts +2 -1
  95. package/src/types.tsx +62 -7
  96. package/src/version.ts +1 -1
  97. package/android/src/main/java/com/datadog/reactnative/DdRum.kt +0 -142
  98. package/android/src/main/java/com/datadog/reactnative/DdSdk.kt +0 -67
  99. package/android/src/main/java/com/datadog/reactnative/DdTrace.kt +0 -51
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","TYPE_SOURCE","TYPE_CONSOLE","DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","DdRum","addError","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AACA,MAAMC,WAAW,GAAG,QAApB;AACA,MAAMC,YAAY,GAAG,SAArB;AAEA;AACA;AACA;;AACO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/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,CAACzB,KAAD,CAAhB;AACH;;AAED,WAAOO,OAAP;AACH;;AAEgC,SAAlBG,kBAAkB,CAACV,KAAD,EAAiC;AAC9D,QAAIgB,KAAK,GAAG/B,iBAAZ;;AAEA,QAAIe,KAAK,KAAKwB,SAAV,IAAuBxB,KAAK,KAAK,IAArC,EAA2C;AACvCgB,MAAAA,KAAK,GAAG/B,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOe,KAAP,KAAiB,QAArB,EAA+B;AAClCgB,MAAAA,KAAK,GAAG/B,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOe,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,oBAAoBA,KAAxB,EAA+B;AAC3BgB,QAAAA,KAAK,GAAGS,MAAM,CAACzB,KAAK,CAAC0B,cAAP,CAAd;AACH,OAFD,MAEO,IAAI,gBAAgB1B,KAApB,EAA2B;AAC9BgB,QAAAA,KAAK,GAAGS,MAAM,CAACzB,KAAK,CAACS,UAAP,CAAd;AACH,OAFM,MAEA,IAAI,WAAWT,KAAf,EAAsB;AACzBgB,QAAAA,KAAK,GAAGS,MAAM,CAACzB,KAAK,CAACgB,KAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAehB,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEgB,QAAAA,KAAK,GAAI,MAAKhB,KAAK,CAAC2B,SAAU,IAAG3B,KAAK,CAAC4B,IAAK,IAAG5B,KAAK,CAAC6B,MAAO,EAA5D;AACH;AACJ;;AAED,WAAOb,KAAP;AACH;;AAhI2B;;;;gBAAnB5B,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAAC0C,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1F3C,kB,yBAS4B,CAAC,GAAG4C,OAAJ,KAA2B,CAAG,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\nconst TYPE_SOURCE = 'SOURCE';\nconst TYPE_CONSOLE = 'CONSOLE';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, TYPE_SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, TYPE_CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["EMPTY_MESSAGE","EMPTY_STACK_TRACE","DdRumErrorTracking","startTracking","isTracking","InternalLog","log","SdkVerbosity","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","DdRum","addError","ErrorSource","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AAEA;AACA;AACA;;AACO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BC,+BAAYC,GAAZ,CACI,wCADJ,EAEIC,2BAAaC,IAFjB;;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAT,MAAAA,kBAAkB,CAACU,mBAAnB,GAAyCC,OAAO,CAACC,KAAjD;AAEAL,MAAAA,UAAU,CAACM,gBAAX,CAA4Bb,kBAAkB,CAACc,aAA/C;AACAH,MAAAA,OAAO,CAACC,KAAR,GAAgBZ,kBAAkB,CAACe,cAAnC;AAEAf,MAAAA,kBAAkB,CAACE,UAAnB,GAAgC,IAAhC;;AACAC,+BAAYC,GAAZ,CACI,gCADJ,EAEIC,2BAAaW,IAFjB;AAIH,KAZD,MAYO;AACHb,+BAAYC,GAAZ,CACI,4DADJ,EAEIC,2BAAaY,KAFjB;AAIH;AACJ,GA1C2B,CA4C5B;;;AACoB,SAAbH,aAAa,CAACF,KAAD,EAAaM,OAAb,EAAsC;AACtD,UAAMC,OAAO,GAAGnB,kBAAkB,CAACoB,eAAnB,CAAmCR,KAAnC,CAAhB;AACA,UAAMS,UAAU,GAAGrB,kBAAkB,CAACsB,kBAAnB,CAA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,IACH,eAAelB,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEkB,QAAAA,KAAK,GAAI,MAAKlB,KAAK,CAAC8B,SAAU,IAAG9B,KAAK,CAAC+B,IAAK,IAAG/B,KAAK,CAACgC,MAAO,EAA5D;AACH;AACJ;;AAED,WAAOd,KAAP;AACH;;AAhI2B;;;;gBAAnB9B,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAAC6C,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1F9C,kB,yBAS4B,CAAC,GAAG+C,OAAJ,KAA2B,CAAG,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.DdSdkConfiguration = void 0;
6
+ exports.ErrorSource = exports.RumActionType = exports.DdSdkConfiguration = void 0;
7
7
 
8
8
  /*
9
9
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
@@ -33,4 +33,29 @@ class DdSdkConfiguration {
33
33
 
34
34
 
35
35
  exports.DdSdkConfiguration = DdSdkConfiguration;
36
+
37
+ /**
38
+ * Describe the type of a RUM Action.
39
+ */
40
+ let RumActionType;
41
+ exports.RumActionType = RumActionType;
42
+
43
+ (function (RumActionType) {
44
+ RumActionType["TAP"] = "TAP";
45
+ RumActionType["SCROLL"] = "SCROLL";
46
+ RumActionType["SWIPE"] = "SWIPE";
47
+ RumActionType["BACK"] = "BACK";
48
+ RumActionType["CUSTOM"] = "CUSTOM";
49
+ })(RumActionType || (exports.RumActionType = RumActionType = {}));
50
+
51
+ let ErrorSource;
52
+ exports.ErrorSource = ErrorSource;
53
+
54
+ (function (ErrorSource) {
55
+ ErrorSource["NETWORK"] = "NETWORK";
56
+ ErrorSource["SOURCE"] = "SOURCE";
57
+ ErrorSource["CONSOLE"] = "CONSOLE";
58
+ ErrorSource["WEBVIEW"] = "WEBVIEW";
59
+ ErrorSource["CUSTOM"] = "CUSTOM";
60
+ })(ErrorSource || (exports.ErrorSource = ErrorSource = {}));
36
61
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;AACA;AACA","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(context?: object, timestampMs?: number): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, click, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: string,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, logger, …).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: string,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig","RumActionType","ErrorSource"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EAST;AAAA,SARWP,WAQX,GARWA,WAQX;AAAA,SAPWC,GAOX,GAPWA,GAOX;AAAA,SANWC,aAMX,GANWA,aAMX;AAAA,SALWC,wBAKX,GALWA,wBAKX;AAAA,SAJWC,UAIX,GAJWA,UAIX;AAAA,SAHWC,IAGX,GAHWA,IAGX;AAAA,SAFWC,eAEX,GAFWA,eAEX;AAAA,SADWC,gBACX,GADWA,gBACX;AAAE;;AAVwB;AAahC;AACA;AACA;;;;;AAqOA;AACA;AACA;IACYC,a;;;WAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,6BAAAA,a;;IA0BAC,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\n/**\n * A configuration object to initialize Datadog's features.\n */\nexport class DdSdkConfiguration {\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly nativeCrashReportEnabled: boolean,\n readonly sampleRate: number,\n readonly site: string,\n readonly trackingConsent: string,\n readonly additionalConfig: object\n ) {}\n}\n\n/**\n * The entry point to initialize Datadog's features.\n */\nexport type DdSdkType = {\n /**\n * Initializes Datadog's features.\n * @param configuration: The configuration to use.\n */\n initialize(configuration: DdSdkConfiguration): Promise<void>;\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n */\n setAttributes(attributes: object): Promise<void>;\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n */\n setUser(user: object): Promise<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, 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"]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '1.0.0';
8
+ const version = '1.1.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.0.0';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.1.0';\n"]}
@@ -64,6 +64,16 @@ export class DdSdkReactNative {
64
64
  configuration.additionalConfig[DdSdkReactNative.DD_SERVICE_NAME] = configuration.serviceName;
65
65
  }
66
66
 
67
+ if (configuration.version) {
68
+ configuration.additionalConfig[DdSdkReactNative.DD_VERSION] = `${configuration.version}${configuration.versionSuffix ? `-${configuration.versionSuffix}` : ''}`;
69
+ } // If both version and version suffix are provided, we merge them into the version field.
70
+ // To avoid adding it in again the native part, we only set it if the version isn't set.
71
+
72
+
73
+ if (configuration.versionSuffix && !configuration.version) {
74
+ configuration.additionalConfig[DdSdkReactNative.DD_VERSION_SUFFIX] = `-${configuration.versionSuffix}`;
75
+ }
76
+
67
77
  configuration.additionalConfig[DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;
68
78
  configuration.additionalConfig['_dd.first_party_hosts'] = configuration.firstPartyHosts;
69
79
  DdSdk.initialize(new DdSdkConfiguration(configuration.clientToken, configuration.env, configuration.applicationId, configuration.nativeCrashReportEnabled, configuration.sampleRate === undefined ? configuration.sessionSamplingRate : configuration.sampleRate, configuration.site, configuration.trackingConsent, configuration.additionalConfig)).then(() => {
@@ -141,6 +151,10 @@ _defineProperty(DdSdkReactNative, "DD_SDK_VERBOSITY_KEY", '_dd.sdk_verbosity');
141
151
 
142
152
  _defineProperty(DdSdkReactNative, "DD_NATIVE_VIEW_TRACKING_KEY", '_dd.native_view_tracking');
143
153
 
154
+ _defineProperty(DdSdkReactNative, "DD_VERSION", '_dd.version');
155
+
156
+ _defineProperty(DdSdkReactNative, "DD_VERSION_SUFFIX", '_dd.version_suffix');
157
+
144
158
  _defineProperty(DdSdkReactNative, "DD_PROXY_TYPE_KEY", '_dd.proxy.type');
145
159
 
146
160
  _defineProperty(DdSdkReactNative, "DD_PROXY_ADDRESS_KEY", '_dd.proxy.address');
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InternalLog","ProxyType","SdkVerbosity","DdSdk","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","log","WARN","verbosity","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","firstPartyHosts","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","then","INFO","enableFeatures","rejection","setAttributes","attributes","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","trackErrors"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,oDAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,OAAO,IAAIC,UAApB,QAAsC,WAAtC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAN,CAAuB;AAQ1B;;AAaA;AACJ;AACA;AACA;AACA;AACqB,SAAVC,UAAU,CACbC,aADa,EAEA;AACb,WAAO,IAAIC,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC1C,UAAIL,gBAAgB,CAACM,cAArB,EAAqC;AACjChB,QAAAA,WAAW,CAACiB,GAAZ,CACI,uDADJ,EAEIf,YAAY,CAACgB,IAFjB;AAIAJ,QAAAA,OAAO;AACP;AACH;;AAEDd,MAAAA,WAAW,CAACmB,SAAZ,GAAwBP,aAAa,CAACO,SAAtC;AAEAP,MAAAA,aAAa,CAACQ,gBAAd,CAA+BV,gBAAgB,CAACW,aAAhD,IACI,cADJ;AAEAT,MAAAA,aAAa,CAACQ,gBAAd,CACIV,gBAAgB,CAACY,cADrB,IAEIb,UAFJ;AAGAG,MAAAA,aAAa,CAACQ,gBAAd,CACIV,gBAAgB,CAACa,2BADrB,IAEIX,aAAa,CAACY,kBAFlB;;AAGA,UAAIZ,a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SAAlBC,kBAAkB,CAACC,OAAD,EAA0C;AAC/DlE,IAAAA,WAAW,CAACiB,GAAZ,CAAiB,mBAAkBiD,OAAQ,EAA3C,EAA8ChE,YAAY,CAAC4D,KAA3D;AACA,WAAO3D,KAAK,CAAC8D,kBAAN,CAAyBC,OAAzB,CAAP;AACH;;AAE4B,SAAdV,cAAc,CACzB5C,aADyB,EAE3B;AACE,QAAIA,aAAa,CAACuD,iBAAlB,EAAqC;AACjC9D,MAAAA,4BAA4B,CAAC+D,aAA7B;AACH;;AAED,QAAIxD,aAAa,CAACyD,cAAlB,EAAkC;AAC9B/D,MAAAA,qBAAqB,CAAC8D,aAAtB,CAAoC;AAChCE,QAAAA,mBAAmB,EAAE1D,aAAa,CAAC2D,2BADH;AAEhC3B,QAAAA,eAAe,EAAEhC,aAAa,CAACgC;AAFC,OAApC;AAIH;;AAED,QAAIhC,aAAa,CAAC4D,WAAlB,EAA+B;AAC3BpE,MAAAA,kBAAkB,CAACgE,aAAnB;AACH;AACJ;;AAnLyB;;gBAAjB1D,gB,mBAC+B,Y;;gBAD/BA,gB,oBAEgC,iB;;gBAFhCA,gB,qBAGiC,kB;;gBAHjCA,gB,0BAIsC,mB;;gBAJtCA,gB,iCAML,0B;;gBANKA,gB,uBASmC,gB;;gBATnCA,gB,0BAUsC,mB;;gBAVtCA,gB,uBAWmC,gB;;gBAXnCA,gB,2BAYuC,oB;;gBAZvCA,gB,2BAauC,oB;;gBAbvCA,gB,uCAgBL,yB;;gBAhBKA,gB,mCAiB+C,G;;gBAjB/CA,gB,oBAmBuB,K","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\nimport { DdSdkConfiguration } from './types';\nimport { version as sdkVersion } from './version';\n\n/**\n * This class initializes the Datadog SDK, and sets up communication with the server.\n */\nexport class DdSdkReactNative {\n private static readonly DD_SOURCE_KEY = '_dd.source';\n private static readonly DD_SDK_VERSION = '_dd.sdk_version';\n private static readonly DD_SERVICE_NAME = '_dd.service_name';\n private static readonly DD_SDK_VERBOSITY_KEY = '_dd.sdk_verbosity';\n private static readonly DD_NATIVE_VIEW_TRACKING_KEY =\n '_dd.native_view_tracking';\n\n // Proxy\n private static readonly DD_PROXY_TYPE_KEY = '_dd.proxy.type';\n private static readonly DD_PROXY_ADDRESS_KEY = '_dd.proxy.address';\n private static readonly DD_PROXY_PORT_KEY = '_dd.proxy.port';\n private static readonly DD_PROXY_USERNAME_KEY = '_dd.proxy.username';\n private static readonly DD_PROXY_PASSWORD_KEY = '_dd.proxy.password';\n\n private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =\n '_dd.long_task.threshold';\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;\n\n private static wasInitialized = false;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n resolve();\n return;\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[\n DdSdkReactNative.DD_PROXY_USERNAME_KEY\n ] = proxyConfig.username;\n additionalConfig[\n DdSdkReactNative.DD_PROXY_PASSWORD_KEY\n ] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SERVICE_NAME\n ] = configuration.serviceName;\n }\n\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY\n ] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(\n () => {\n InternalLog.log(\n 'Datadog SDK was initialized',\n SdkVerbosity.INFO\n );\n DdSdkReactNative.enableFeatures(configuration);\n DdSdkReactNative.wasInitialized = true;\n resolve();\n },\n rejection => {\n reject(rejection);\n }\n );\n });\n }\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setAttributes(attributes);\n }\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static enableFeatures(\n configuration: DdSdkReactNativeConfiguration\n ) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNative.tsx"],"names":["InternalLog","ProxyType","SdkVerbosity","DdSdk","DdRumErrorTracking","DdRumUserInteractionTracking","DdRumResourceTracking","DdSdkConfiguration","version","sdkVersion","DdSdkReactNative","initialize","configuration","Promise","resolve","reject","wasInitialized","log","WARN","verbosity","additionalConfig","DD_SOURCE_KEY","DD_SDK_VERSION","DD_NATIVE_VIEW_TRACKING_KEY","nativeViewTracking","DD_SDK_VERBOSITY_KEY","proxyConfig","DD_PROXY_TYPE_KEY","type","DD_PROXY_ADDRESS_KEY","address","DD_PROXY_PORT_KEY","port","username","password","SOCKS","console","warn","DD_PROXY_USERNAME_KEY","DD_PROXY_PASSWORD_KEY","serviceName","DD_SERVICE_NAME","DD_VERSION","versionSuffix","DD_VERSION_SUFFIX","DD_NATIVE_LONG_TASK_THRESHOLD_KEY","NATIVE_LONG_TASK_THRESHOLD_MS","firstPartyHosts","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","undefined","sessionSamplingRate","site","trackingConsent","then","INFO","enableFeatures","rejection","setAttributes","attributes","JSON","stringify","DEBUG","setUser","user","setTrackingConsent","consent","trackInteractions","startTracking","trackResources","tracingSamplingRate","resourceTracingSamplingRate","trackErrors"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,WAAT,QAA4B,eAA5B;AACA,SAASC,SAAT,QAA0B,sBAA1B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,kBAAT,QAAmC,0CAAnC;AACA,SAASC,4BAAT,QAA6C,oDAA7C;AACA,SAASC,qBAAT,QAAsC,8DAAtC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,OAAO,IAAIC,UAApB,QAAsC,WAAtC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAN,CAAuB;AAU1B;;AAaA;AACJ;AACA;AACA;AACA;AACqB,SAAVC,UAAU,CACbC,aADa,EAEA;AACb,WAAO,IAAIC,OAAJ,CAAkB,CAACC,OAAD,EAAUC,MAAV,KAAqB;AAC1C,UAAIL,gBAAgB,CAACM,cAArB,EAAqC;AACjChB,QAAAA,WAAW,CAACiB,GAAZ,CACI,uDADJ,EAEIf,YAAY,CAACgB,IAFjB;AAIAJ,QAAAA,OAAO;AACP;AACH;;AAEDd,MAAAA,WAAW,CAACmB,SAAZ,GAAwBP,aAAa,CAACO,SAAtC;A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;;AAED,QAAInC,aAAa,CAAC+D,WAAlB,EAA+B;AAC3BvE,MAAAA,kBAAkB,CAACmE,aAAnB;AACH;AACJ;;AAvMyB;;gBAAjB7D,gB,mBAC+B,Y;;gBAD/BA,gB,oBAEgC,iB;;gBAFhCA,gB,qBAGiC,kB;;gBAHjCA,gB,0BAIsC,mB;;gBAJtCA,gB,iCAML,0B;;gBANKA,gB,gBAO4B,a;;gBAP5BA,gB,uBAQmC,oB;;gBARnCA,gB,uBAWmC,gB;;gBAXnCA,gB,0BAYsC,mB;;gBAZtCA,gB,uBAamC,gB;;gBAbnCA,gB,2BAcuC,oB;;gBAdvCA,gB,2BAeuC,oB;;gBAfvCA,gB,uCAkBL,yB;;gBAlBKA,gB,mCAmB+C,G;;gBAnB/CA,gB,oBAqBuB,K","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { InternalLog } from './InternalLog';\nimport { ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport type { TrackingConsent } from './TrackingConsent';\nimport { DdSdk } from './foundation';\nimport { DdRumErrorTracking } from './rum/instrumentation/DdRumErrorTracking';\nimport { DdRumUserInteractionTracking } from './rum/instrumentation/DdRumUserInteractionTracking';\nimport { DdRumResourceTracking } from './rum/instrumentation/resourceTracking/DdRumResourceTracking';\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_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 readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY =\n '_dd.long_task.threshold';\n private static readonly NATIVE_LONG_TASK_THRESHOLD_MS = 200;\n\n private static wasInitialized = false;\n\n /**\n * Initializes the Datadog SDK.\n * @param configuration the configuration for the SDK library\n * @returns a Promise.\n */\n static initialize(\n configuration: DdSdkReactNativeConfiguration\n ): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (DdSdkReactNative.wasInitialized) {\n InternalLog.log(\n \"Can't initialize Datadog, SDK was already initialized\",\n SdkVerbosity.WARN\n );\n resolve();\n return;\n }\n\n InternalLog.verbosity = configuration.verbosity;\n\n configuration.additionalConfig[DdSdkReactNative.DD_SOURCE_KEY] =\n 'react-native';\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERSION\n ] = sdkVersion;\n configuration.additionalConfig[\n DdSdkReactNative.DD_NATIVE_VIEW_TRACKING_KEY\n ] = configuration.nativeViewTracking;\n if (configuration.verbosity) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SDK_VERBOSITY_KEY\n ] = configuration.verbosity;\n }\n\n if (configuration.proxyConfig) {\n const additionalConfig = configuration.additionalConfig;\n const proxyConfig = configuration.proxyConfig;\n\n additionalConfig[DdSdkReactNative.DD_PROXY_TYPE_KEY] =\n proxyConfig.type;\n additionalConfig[DdSdkReactNative.DD_PROXY_ADDRESS_KEY] =\n proxyConfig.address;\n additionalConfig[DdSdkReactNative.DD_PROXY_PORT_KEY] =\n proxyConfig.port;\n if (proxyConfig.username && proxyConfig.password) {\n if (proxyConfig.type === ProxyType.SOCKS) {\n console.warn(\n \"SOCKS proxy configuration doesn't support Basic authentication.\"\n );\n } else {\n additionalConfig[\n DdSdkReactNative.DD_PROXY_USERNAME_KEY\n ] = proxyConfig.username;\n additionalConfig[\n DdSdkReactNative.DD_PROXY_PASSWORD_KEY\n ] = proxyConfig.password;\n }\n }\n }\n\n if (configuration.serviceName) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_SERVICE_NAME\n ] = configuration.serviceName;\n }\n\n if (configuration.version) {\n configuration.additionalConfig[\n DdSdkReactNative.DD_VERSION\n ] = `${configuration.version}${\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 DdSdkReactNative.DD_NATIVE_LONG_TASK_THRESHOLD_KEY\n ] = DdSdkReactNative.NATIVE_LONG_TASK_THRESHOLD_MS;\n\n configuration.additionalConfig['_dd.first_party_hosts'] =\n configuration.firstPartyHosts;\n\n DdSdk.initialize(\n new DdSdkConfiguration(\n configuration.clientToken,\n configuration.env,\n configuration.applicationId,\n configuration.nativeCrashReportEnabled,\n configuration.sampleRate === undefined\n ? configuration.sessionSamplingRate\n : configuration.sampleRate,\n configuration.site,\n configuration.trackingConsent,\n configuration.additionalConfig\n )\n ).then(\n () => {\n InternalLog.log(\n 'Datadog SDK was initialized',\n SdkVerbosity.INFO\n );\n DdSdkReactNative.enableFeatures(configuration);\n DdSdkReactNative.wasInitialized = true;\n resolve();\n },\n rejection => {\n reject(rejection);\n }\n );\n });\n }\n\n /**\n * Sets the global context (set of attributes) attached with all future Logs, Spans and RUM events.\n * @param attributes: The global context attributes.\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setAttributes(attributes: object): Promise<void> {\n InternalLog.log(\n `Setting attributes ${JSON.stringify(attributes)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setAttributes(attributes);\n }\n\n /**\n * Set the user information.\n * @param user: The user object (use builtin attributes: 'id', 'email', 'name', and/or any custom attribute).\n * @returns a Promise.\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n static setUser(user: object): Promise<void> {\n InternalLog.log(\n `Setting user ${JSON.stringify(user)}`,\n SdkVerbosity.DEBUG\n );\n return DdSdk.setUser(user);\n }\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: One of TrackingConsent values.\n * @returns a Promise.\n */\n static setTrackingConsent(consent: TrackingConsent): Promise<void> {\n InternalLog.log(`Setting consent ${consent}`, SdkVerbosity.DEBUG);\n return DdSdk.setTrackingConsent(consent);\n }\n\n private static enableFeatures(\n configuration: DdSdkReactNativeConfiguration\n ) {\n if (configuration.trackInteractions) {\n DdRumUserInteractionTracking.startTracking();\n }\n\n if (configuration.trackResources) {\n DdRumResourceTracking.startTracking({\n tracingSamplingRate: configuration.resourceTracingSamplingRate,\n firstPartyHosts: configuration.firstPartyHosts\n });\n }\n\n if (configuration.trackErrors) {\n DdRumErrorTracking.startTracking();\n }\n }\n}\n"]}
@@ -23,6 +23,26 @@ export class DdSdkReactNativeConfiguration {
23
23
  /**
24
24
  * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.
25
25
  */
26
+
27
+ /**
28
+ * Overrides the reported version of the app.
29
+ * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
30
+ * Other special characters are converted to underscores.
31
+ *
32
+ * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.
33
+ *
34
+ * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.
35
+ */
36
+
37
+ /**
38
+ * Add a suffix to the reported version of the app.
39
+ * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
40
+ * Other special characters are converted to underscores.
41
+ *
42
+ * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.
43
+ *
44
+ * A dash (`-`) will be automatically added between the version and the suffix
45
+ */
26
46
  constructor(clientToken, env, applicationId, trackInteractions = false, trackResources = false, trackErrors = false, trackingConsent = TrackingConsent.GRANTED) {
27
47
  this.clientToken = clientToken;
28
48
  this.env = env;
@@ -52,6 +72,10 @@ export class DdSdkReactNativeConfiguration {
52
72
 
53
73
  _defineProperty(this, "firstPartyHosts", []);
54
74
 
75
+ _defineProperty(this, "version", void 0);
76
+
77
+ _defineProperty(this, "versionSuffix", void 0);
78
+
55
79
  _defineProperty(this, "additionalConfig", {});
56
80
  }
57
81
 
@@ -1 +1 @@
1
- {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","GRANTED","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;AAWIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGT,eAAe,CAACU,OAPrD,EAQT;AAAA,SAPWP,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDA9ByC,KA8BzC;;AAAA;;AAAA,iDAtBmC,KAsBnC;;AAAA,yDAlB2C,IAkB3C;;AAAA,kCAjBoB,IAiBpB;;AAAA,uCAhB2CE,SAgB3C;;AAAA,gDAfmC,KAenC;;AAAA,yCAdwCA,SAcxC;;AAAA,yCAb4BA,SAa5B;;AAAA,6CAZiC,EAYjC;;AAAA,8CAV8C,EAU9C;AAAE;;AA/BmC","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean = false;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = 100.0;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number = 20.0;\n public site: string = 'US';\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = false;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = [];\n\n public additionalConfig: { [k: string]: any } = {};\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED\n ) {}\n}\n"]}
1
+ {"version":3,"sources":["DdSdkReactNativeConfiguration.tsx"],"names":["TrackingConsent","DdSdkReactNativeConfiguration","constructor","clientToken","env","applicationId","trackInteractions","trackResources","trackErrors","trackingConsent","GRANTED","undefined"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAAN,CAAoC;AAEvC;AACJ;AACA;;AAEI;AACJ;AACA;;AAEI;AACJ;AACA;;AAQI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKIC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,iBAA0B,GAAG,KAJ/B,EAKEC,cAAuB,GAAG,KAL5B,EAMEC,WAAoB,GAAG,KANzB,EAOEC,eAAgC,GAAGT,eAAe,CAACU,OAPrD,EAQT;AAAA,SAPWP,WAOX,GAPWA,WAOX;AAAA,SANWC,GAMX,GANWA,GAMX;AAAA,SALWC,aAKX,GALWA,aAKX;AAAA,SAJWC,iBAIX,GAJWA,iBAIX;AAAA,SAHWC,cAGX,GAHWA,cAGX;AAAA,SAFWC,WAEX,GAFWA,WAEX;AAAA,SADWC,eACX,GADWA,eACX;;AAAA,sDAlDyC,KAkDzC;;AAAA;;AAAA,iDA1CmC,KA0CnC;;AAAA,yDAtC2C,IAsC3C;;AAAA,kCArCoB,IAqCpB;;AAAA,uCApC2CE,SAoC3C;;AAAA,gDAnCmC,KAmCnC;;AAAA,yCAlCwCA,SAkCxC;;AAAA,yCAjC4BA,SAiC5B;;AAAA,6CAhCiC,EAgCjC;;AAAA;;AAAA;;AAAA,8CAV8C,EAU9C;AAAE;;AAnDmC","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ProxyConfiguration } from './ProxyConfiguration';\nimport type { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\n\n/**\n * The SDK configuration class.\n * It will be used to configure the SDK functionality at initialization.\n */\nexport class DdSdkReactNativeConfiguration {\n public nativeCrashReportEnabled: boolean = false;\n /**\n * @deprecated `sampleRate` has been replaced by `sessionSamplingRate` to avoid confusion with `resourceTracingSamplingRate` and will be removed in a future release.\n */\n public sampleRate?: number;\n /**\n * Percentage of sampled RUM sessions. Range `0`-`100`.\n */\n public sessionSamplingRate: number = 100.0;\n /**\n * Percentage of tracing integrations for network calls between your app and your backend. Range `0`-`100`.\n */\n public resourceTracingSamplingRate: number = 20.0;\n public site: string = 'US';\n public verbosity: SdkVerbosity | undefined = undefined;\n public nativeViewTracking: boolean = false;\n public proxyConfig?: ProxyConfiguration = undefined;\n public serviceName?: string = undefined;\n public firstPartyHosts: string[] = [];\n /**\n * Overrides the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * Make sure you set it correctly, as it will have to match the one specified during the upload of your source maps and other mapping files.\n */\n public version?: string;\n /**\n * Add a suffix to the reported version of the app.\n * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.\n * Other special characters are converted to underscores.\n *\n * See https://docs.datadoghq.com/getting_started/tagging/#define-tags for more information on the format.\n *\n * A dash (`-`) will be automatically added between the version and the suffix\n */\n public versionSuffix?: string;\n\n public additionalConfig: { [k: string]: any } = {};\n\n constructor(\n readonly clientToken: string,\n readonly env: string,\n readonly applicationId: string,\n readonly trackInteractions: boolean = false,\n readonly trackResources: boolean = false,\n readonly trackErrors: boolean = false,\n readonly trackingConsent: TrackingConsent = TrackingConsent.GRANTED\n ) {}\n}\n"]}
@@ -57,9 +57,37 @@ class DdTraceWrapper {
57
57
 
58
58
  }
59
59
 
60
+ const isNewStopActionAPI = args => {
61
+ return typeof args[0] === 'string';
62
+ };
63
+
64
+ const isOldStopActionAPI = args => {
65
+ return typeof args[0] === 'object' || typeof args[0] === 'undefined';
66
+ };
67
+
60
68
  class DdRumWrapper {
61
69
  constructor() {
62
70
  _defineProperty(this, "nativeRum", NativeModules.DdRum);
71
+
72
+ _defineProperty(this, "lastActionData", void 0);
73
+
74
+ _defineProperty(this, "getStopActionNativeCall", args => {
75
+ if (isNewStopActionAPI(args)) {
76
+ return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now());
77
+ }
78
+
79
+ if (isOldStopActionAPI(args)) {
80
+ if (this.lastActionData) {
81
+ return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());
82
+ }
83
+
84
+ InternalLog.log("DdRum.startAction needs to be called before DdRum.stopAction", SdkVerbosity.WARN);
85
+ } else {
86
+ InternalLog.log("DdRum.stopAction was called with wrong arguments", SdkVerbosity.WARN);
87
+ }
88
+
89
+ return new Promise(resolve => resolve());
90
+ });
63
91
  }
64
92
 
65
93
  startView(key, name, context = {}, timestampMs = timeProvider.now()) {
@@ -74,12 +102,18 @@ class DdRumWrapper {
74
102
 
75
103
  startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
76
104
  InternalLog.log("Starting RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
105
+ this.lastActionData = {
106
+ type,
107
+ name
108
+ };
77
109
  return this.nativeRum.startAction(type, name, context, timestampMs);
78
110
  }
79
111
 
80
- stopAction(context = {}, timestampMs = timeProvider.now()) {
112
+ stopAction(...args) {
81
113
  InternalLog.log("Stopping current RUM Action", SdkVerbosity.DEBUG);
82
- return this.nativeRum.stopAction(context, timestampMs);
114
+ let returnPromise = this.getStopActionNativeCall(args);
115
+ this.lastActionData = undefined;
116
+ return returnPromise;
83
117
  }
84
118
 
85
119
  addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
@@ -1 +1 @@
1
- {"version":3,"sources":["foundation.tsx"],"names":["NativeModules","DdSdkConfiguration","InternalLog","SdkVerbosity","TimeProvider","timeProvider","DdLogsWrapper","DdLogs","debug","message","context","log","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","DdRumWrapper","DdRum","startView","key","name","nativeRum","stopView","startAction","type","stopAction","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AACA,SAASC,kBAAT,QAAkF,SAAlF;AACA,SAAQC,WAAR,QAA0B,eAA1B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AAEA,MAAMC,YAAY,GAAG,IAAID,YAAJ,EAArB;;AAEA,MAAME,aAAN,CAA0C;AAAA;AAAA,wCAELN,aAAa,CAACO,MAFT;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,yBAA0BF,OAA1B,GAAoC,GAApD,EAAyDN,YAAY,CAACS,KAAtE;AACA,WAAO,KAAKC,UAAL,CAAgBL,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDI,EAAAA,IAAI,CAACL,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,EAAwDN,YAAY,CAACS,KAArE;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBL,OAArB,EAA8BC,OAA9B,CAAP;AACH;;AAEDK,EAAAA,IAAI,CAACN,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,EAAwDN,YAAY,CAACS,KAArE;AACA,WAAO,KAAKC,UAAL,CA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,EAAkEW,WAAlE,CAAP;AACH;;AAEDuB,EAAAA,QAAQ,CAACnC,OAAD,EAAkBoC,MAAlB,EAAkCC,UAAlC,EAAsDpC,OAAe,GAAG,EAAxE,EAA4EW,WAAmB,GAAGhB,YAAY,CAACiB,GAAb,EAAlG,EAAqI;AACzIpB,IAAAA,WAAW,CAACS,GAAZ,CAAgB,uBAAuBF,OAAvB,GAAiC,GAAjD,EAAsDN,YAAY,CAACS,KAAnE;AACA,QAAImC,cAAmB,GAAGrC,OAA1B;AACAqC,IAAAA,cAAc,CAAC,uBAAD,CAAd,GAA0C,cAA1C;AACA,WAAO,KAAKhB,SAAL,CAAea,QAAf,CAAwBnC,OAAxB,EAAiCoC,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqE1B,WAArE,CAAP;AACH;;AAED2B,EAAAA,SAAS,CAAClB,IAAD,EAA8B;AACnC5B,IAAAA,WAAW,CAACS,GAAZ,CAAgB,oBAAoBmB,IAApB,GAA2B,eAA3C,EAA4D3B,YAAY,CAACS,KAAzE;AACA,WAAO,KAAKmB,SAAL,CAAeiB,SAAf,CAAyBlB,IAAzB,CAAP;AACH;;AAjDmC;;AAoDxC,MAAMmB,KAAgB,GAAGjD,aAAa,CAACiD,KAAvC;AACA,MAAM1C,MAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAMY,OAAoB,GAAG,IAAID,cAAJ,EAA7B;AACA,MAAMU,KAAgB,GAAG,IAAID,YAAJ,EAAzB;AAEA,SAASzB,kBAAT,EAA6BgD,KAA7B,EAAoC1C,MAApC,EAA4CW,OAA5C,EAAqDS,KAArD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdSdkType, DdLogsType, DdTraceType, DdRumType } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdRumType = NativeModules.DdRum;\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n return this.nativeRum.stopAction(context, timestampMs);\n }\n\n addAction(type: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: string, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: string, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
1
+ {"version":3,"sources":["foundation.tsx"],"names":["NativeModules","DdSdkConfiguration","InternalLog","SdkVerbosity","TimeProvider","timeProvider","DdLogsWrapper","DdLogs","debug","message","context","log","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming","DdSdk"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,cAA9B;AACA,SAASC,kBAAT,QAAiH,SAAjH;AACA,SAAQC,WAAR,QAA0B,eAA1B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AACA,SAAQC,YAAR,QAA2B,gBAA3B;AAGA,MAAMC,YAAY,GAAG,IAAID,YAAJ,EAArB;;AAEA,MAAME,aAAN,CAA0C;AAAA;AAAA,wCAECN,aAAa,CAACO,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,yBAA0BF,OAA1B,GAAoC,GAApD,EAAyDN,YAAY,CAACS,KAAtE;AACA,WAAO,KAAKC,UAAL,CAAgBL,KAAhB,CAAsBC,OAAtB,EAA+BC,OAA/B,CAAP;AACH;;AAEDI,EAAAA,IAAI,CAACL,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACvDR,IAAAA,WAAW,CAACS,GAAZ,CAAgB,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G,IAAID,YAAJ,EAAzB;AAEA,SAAS5B,kBAAT,EAA6B0D,KAA7B,EAAoCpD,MAApC,EAA4CW,OAA5C,EAAqDY,KAArD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { NativeModules } from 'react-native';\nimport { DdSdkConfiguration, DdLogsType, DdTraceType, DdRumType, RumActionType, ResourceKind, ErrorSource } from './types';\nimport {InternalLog} from \"./InternalLog\"\nimport {SdkVerbosity} from \"./SdkVerbosity\";\nimport {TimeProvider} from \"./TimeProvider\";\nimport type { DdNativeLogsType, DdNativeRumType, DdNativeSdkType, DdNativeTraceType } from './nativeModulesTypes';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return this.nativeTrace.finishSpan(spanId, context, timestampMs);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.startView(key, name, context, timestampMs);\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return this.nativeRum.stopView(key, context, timestampMs);\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return this.nativeRum.startAction(type, name, context, timestampMs);\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now())\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return this.nativeRum.addAction(type, name, context, timestampMs);\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return this.nativeRum.startResource(key, method, url, context, timestampMs);\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return this.nativeRum.addTiming(name);\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ /**
8
+ * A configuration object to initialize Datadog's features.
9
+ */
10
+ export class DdNativeSdkConfiguration {
11
+ constructor(clientToken, env, applicationId, nativeCrashReportEnabled, sampleRate, site, trackingConsent, additionalConfig) {
12
+ this.clientToken = clientToken;
13
+ this.env = env;
14
+ this.applicationId = applicationId;
15
+ this.nativeCrashReportEnabled = nativeCrashReportEnabled;
16
+ this.sampleRate = sampleRate;
17
+ this.site = site;
18
+ this.trackingConsent = trackingConsent;
19
+ this.additionalConfig = additionalConfig;
20
+ }
21
+
22
+ }
23
+ /**
24
+ * The entry point to initialize Datadog's features.
25
+ */
26
+ //# sourceMappingURL=nativeModulesTypes.js.map
@@ -0,0 +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<void>;\n\n /**\n * Set the tracking consent regarding the data collection.\n * @param trackingConsent: Consent, which can take one of the following values: 'pending', 'granted', 'not_granted'.\n */\n setTrackingConsent(trackingConsent: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
@@ -8,6 +8,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  import { InternalLog } from '../../InternalLog';
9
9
  import { SdkVerbosity } from '../../SdkVerbosity';
10
10
  import { DdRum } from '../../foundation';
11
+ import { RumActionType } from '../../types';
11
12
  export const UNKNOWN_TARGET_NAME = 'unknown_target';
12
13
  const DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;
13
14
  const HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;
@@ -36,7 +37,7 @@ export class DdEventsInterceptor {
36
37
  handleTargetEvent(targetNode) {
37
38
  if (targetNode) {
38
39
  const resolvedTargetName = this.resolveTargetName(targetNode);
39
- DdRum.addAction(RumActionType.TAP.valueOf(), resolvedTargetName);
40
+ DdRum.addAction(RumActionType.TAP, resolvedTargetName);
40
41
  }
41
42
  }
42
43
 
@@ -88,19 +89,6 @@ export class DdEventsInterceptor {
88
89
  }
89
90
 
90
91
  }
91
- /**
92
- * Describe the type of a RUM Action.
93
- */
94
92
 
95
93
  _defineProperty(DdEventsInterceptor, "ACTION_EVENT_DROPPED_WARN_MESSAGE", 'An action event was dropped because either the `onPress` method arguments' + ' were undefined or they were missing the target information.');
96
-
97
- export let RumActionType;
98
-
99
- (function (RumActionType) {
100
- RumActionType["TAP"] = "TAP";
101
- RumActionType["SCROLL"] = "SCROLL";
102
- RumActionType["SWIPE"] = "SWIPE";
103
- RumActionType["CLICK"] = "CLICK";
104
- RumActionType["CUSTOM"] = "CUSTOM";
105
- })(RumActionType || (RumActionType = {}));
106
94
  //# sourceMappingURL=DdEventsInterceptor.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","log","ACTION_EVENT_DROPPED_WARN_MESSAGE","WARN","resolvedTargetName","resolveTargetName","addAction","RumActionType","TAP","valueOf","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAIA,OAAO,MAAMC,mBAAmB,GAAG,gBAA5B;AACP,MAAMC,8BAA8B,GAAG,EAAvC;AACA,MAAMC,qCAAqC,GAAG,CAA9C;AACA,MAAMC,mBAAmB,GAAG,gBAA5B;AAEA,OAAO,MAAMC,mBAAN,CAAuD;AAAA;AAAA,wDAKrBC,MAAM,CAACC,SALc;AAAA;;AAO1DC,EAAAA,gBAAgB,CAAC,GAAGC,IAAJ,EAAuB;AACnC,QAAIA,IAAI,CAACC,MAAL,GAAc,CAAd,IAAmBD,IAAI,CAAC,CAAD,CAAvB,IAA8BA,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA1C,EAAuD;AACnD,YAAMC,WAAW,GAAGC,IAAI,CAACC,GAAL,EAApB;AACA,YAAMC,mBAAmB,GAAGC,IAAI,CAACC,GAAL,CACxBJ,IAAI,CAACC,GAAL,KAAa,KAAKI,0BADM,CAA5B;;AAGA,UAAIH,mBAAmB,GAAGb,8BAA1B,EAA0D;AACtD,cAAMiB,UAAU,GAAGV,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA3B;AACA,aAAKS,iBAAL,CA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AsB,CAACZ,UAAD,EAAiC;AAC3D,QAAImB,WAAW,GAAGnB,UAAlB;;AACA,WAAOmB,WAAP,EAAoB;AAChB,YAAMC,KAAK,GAAGD,WAAW,CAACL,aAA1B;;AACA,UAAIM,KAAK,IAAIA,KAAK,CAACnC,mBAAD,CAAlB,EAAyC;AACrC,eAAOmC,KAAK,CAACnC,mBAAD,CAAZ;AACH;;AACDkC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AAtEyD;AAyE9D;AACA;AACA;;gBA3EanC,mB,uCAEL,8EACA,8D;;AAyER,WAAYsB,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\n\nimport type EventsInterceptor from './EventsInterceptor';\n\nexport const UNKNOWN_TARGET_NAME = 'unknown_target';\nconst DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;\nconst HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;\nconst DD_ACTION_NAME_PROP = 'dd-action-name';\n\nexport class DdEventsInterceptor implements EventsInterceptor {\n static ACTION_EVENT_DROPPED_WARN_MESSAGE =\n 'An action event was dropped because either the `onPress` method arguments' +\n ' were undefined or they were missing the target information.';\n\n private debouncingStartedTimestamp = Number.MIN_VALUE;\n\n interceptOnPress(...args: any[]): void {\n if (args.length > 0 && args[0] && args[0]._targetInst) {\n const currentTime = Date.now();\n const timestampDifference = Math.abs(\n Date.now() - this.debouncingStartedTimestamp\n );\n if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {\n const targetNode = args[0]._targetInst;\n this.handleTargetEvent(targetNode);\n // we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function\n this.debouncingStartedTimestamp =\n currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;\n }\n } else {\n InternalLog.log(\n DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE,\n SdkVerbosity.WARN\n );\n }\n }\n\n private handleTargetEvent(targetNode: any | null) {\n if (targetNode) {\n const resolvedTargetName = this.resolveTargetName(targetNode);\n DdRum.addAction(RumActionType.TAP.valueOf(), resolvedTargetName);\n }\n }\n\n private resolveTargetName(targetNode: any): string {\n const closestActionLabel = this.findClosestActionLabel(targetNode);\n if (closestActionLabel != null) {\n return closestActionLabel;\n }\n const accessibilityLabel = targetNode.memoizedProps?.accessibilityLabel;\n if (accessibilityLabel != null) {\n return accessibilityLabel;\n }\n const elementTypeName = this.resolveElementTypeName(\n targetNode.elementType\n );\n return elementTypeName || UNKNOWN_TARGET_NAME;\n }\n\n private resolveElementTypeName(elementType: any): string | null {\n let elementTypeName = null;\n if (typeof elementType === 'string') {\n elementTypeName = elementType;\n } else if (elementType && typeof elementType.name === 'string') {\n elementTypeName = elementType.name;\n }\n return elementTypeName;\n }\n\n private findClosestActionLabel(targetNode: any): string | null {\n let currentNode = targetNode;\n while (currentNode) {\n const props = currentNode.memoizedProps;\n if (props && props[DD_ACTION_NAME_PROP]) {\n return props[DD_ACTION_NAME_PROP];\n }\n currentNode = currentNode.return;\n }\n return null;\n }\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 clicked on a widget (not used on Mobile). */\n CLICK = 'CLICK',\n /** A custom action. */\n CUSTOM = 'CUSTOM'\n}\n"]}
1
+ {"version":3,"sources":["DdEventsInterceptor.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","RumActionType","UNKNOWN_TARGET_NAME","DEBOUNCE_EVENT_THRESHOLD_IN_MS","HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS","DD_ACTION_NAME_PROP","DdEventsInterceptor","Number","MIN_VALUE","interceptOnPress","args","length","_targetInst","currentTime","Date","now","timestampDifference","Math","abs","debouncingStartedTimestamp","targetNode","handleTargetEvent","log","ACTION_EVENT_DROPPED_WARN_MESSAGE","WARN","resolvedTargetName","resolveTargetName","addAction","TAP","closestActionLabel","findClosestActionLabel","accessibilityLabel","memoizedProps","elementTypeName","resolveElementTypeName","elementType","name","currentNode","props","return"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,aAAT,QAA8B,aAA9B;AAIA,OAAO,MAAMC,mBAAmB,GAAG,gBAA5B;AACP,MAAMC,8BAA8B,GAAG,EAAvC;AACA,MAAMC,qCAAqC,GAAG,CAA9C;AACA,MAAMC,mBAAmB,GAAG,gBAA5B;AAEA,OAAO,MAAMC,mBAAN,CAAuD;AAAA;AAAA,wDAKrBC,MAAM,CAACC,SALc;AAAA;;AAO1DC,EAAAA,gBAAgB,CAAC,GAAGC,IAAJ,EAAuB;AACnC,QAAIA,IAAI,CAACC,MAAL,GAAc,CAAd,IAAmBD,IAAI,CAAC,CAAD,CAAvB,IAA8BA,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA1C,EAAuD;AACnD,YAAMC,WAAW,GAAGC,IAAI,CAACC,GAAL,EAApB;AACA,YAAMC,mBAAmB,GAAGC,IAAI,CAACC,GAAL,CACxBJ,IAAI,CAACC,GAAL,KAAa,KAAKI,0BADM,CAA5B;;AAGA,UAAIH,mBAAmB,GAAGb,8BAA1B,EAA0D;AACtD,cAAMiB,UAAU,GAAGV,IAAI,CAAC,CAAD,CAAJ,CAAQE,WAA3B;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sB,CAACV,UAAD,EAAiC;AAC3D,QAAIiB,WAAW,GAAGjB,UAAlB;;AACA,WAAOiB,WAAP,EAAoB;AAChB,YAAMC,KAAK,GAAGD,WAAW,CAACL,aAA1B;;AACA,UAAIM,KAAK,IAAIA,KAAK,CAACjC,mBAAD,CAAlB,EAAyC;AACrC,eAAOiC,KAAK,CAACjC,mBAAD,CAAZ;AACH;;AACDgC,MAAAA,WAAW,GAAGA,WAAW,CAACE,MAA1B;AACH;;AACD,WAAO,IAAP;AACH;;AAtEyD;;gBAAjDjC,mB,uCAEL,8EACA,8D","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\nimport { RumActionType } from '../../types';\n\nimport type EventsInterceptor from './EventsInterceptor';\n\nexport const UNKNOWN_TARGET_NAME = 'unknown_target';\nconst DEBOUNCE_EVENT_THRESHOLD_IN_MS = 10;\nconst HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS = 1;\nconst DD_ACTION_NAME_PROP = 'dd-action-name';\n\nexport class DdEventsInterceptor implements EventsInterceptor {\n static ACTION_EVENT_DROPPED_WARN_MESSAGE =\n 'An action event was dropped because either the `onPress` method arguments' +\n ' were undefined or they were missing the target information.';\n\n private debouncingStartedTimestamp = Number.MIN_VALUE;\n\n interceptOnPress(...args: any[]): void {\n if (args.length > 0 && args[0] && args[0]._targetInst) {\n const currentTime = Date.now();\n const timestampDifference = Math.abs(\n Date.now() - this.debouncingStartedTimestamp\n );\n if (timestampDifference > DEBOUNCE_EVENT_THRESHOLD_IN_MS) {\n const targetNode = args[0]._targetInst;\n this.handleTargetEvent(targetNode);\n // we add an approximated 1 millisecond for the execution time of the `handleTargetEvent` function\n this.debouncingStartedTimestamp =\n currentTime + HANDLE_EVENT_APP_EXECUTION_TIME_IN_MS;\n }\n } else {\n InternalLog.log(\n DdEventsInterceptor.ACTION_EVENT_DROPPED_WARN_MESSAGE,\n SdkVerbosity.WARN\n );\n }\n }\n\n private handleTargetEvent(targetNode: any | null) {\n if (targetNode) {\n const resolvedTargetName = this.resolveTargetName(targetNode);\n DdRum.addAction(RumActionType.TAP, resolvedTargetName);\n }\n }\n\n private resolveTargetName(targetNode: any): string {\n const closestActionLabel = this.findClosestActionLabel(targetNode);\n if (closestActionLabel != null) {\n return closestActionLabel;\n }\n const accessibilityLabel = targetNode.memoizedProps?.accessibilityLabel;\n if (accessibilityLabel != null) {\n return accessibilityLabel;\n }\n const elementTypeName = this.resolveElementTypeName(\n targetNode.elementType\n );\n return elementTypeName || UNKNOWN_TARGET_NAME;\n }\n\n private resolveElementTypeName(elementType: any): string | null {\n let elementTypeName = null;\n if (typeof elementType === 'string') {\n elementTypeName = elementType;\n } else if (elementType && typeof elementType.name === 'string') {\n elementTypeName = elementType.name;\n }\n return elementTypeName;\n }\n\n private findClosestActionLabel(targetNode: any): string | null {\n let currentNode = targetNode;\n while (currentNode) {\n const props = currentNode.memoizedProps;\n if (props && props[DD_ACTION_NAME_PROP]) {\n return props[DD_ACTION_NAME_PROP];\n }\n currentNode = currentNode.return;\n }\n return null;\n }\n}\n"]}
@@ -8,10 +8,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  import { InternalLog } from '../../InternalLog';
9
9
  import { SdkVerbosity } from '../../SdkVerbosity';
10
10
  import { DdRum } from '../../foundation';
11
+ import { ErrorSource } from '../../types';
11
12
  const EMPTY_MESSAGE = 'Unknown Error';
12
13
  const EMPTY_STACK_TRACE = '';
13
- const TYPE_SOURCE = 'SOURCE';
14
- const TYPE_CONSOLE = 'CONSOLE';
15
14
  /**
16
15
  * Provides RUM auto-instrumentation feature to track errors as RUM events.
17
16
  */
@@ -46,7 +45,7 @@ export class DdRumErrorTracking {
46
45
  static onGlobalError(error, isFatal) {
47
46
  const message = DdRumErrorTracking.getErrorMessage(error);
48
47
  const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
49
- DdRum.addError(message, TYPE_SOURCE, stacktrace, {
48
+ DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {
50
49
  '_dd.error.is_crash': isFatal,
51
50
  '_dd.error.raw': error
52
51
  }).then(() => {
@@ -84,7 +83,7 @@ export class DdRumErrorTracking {
84
83
  return DdRumErrorTracking.getErrorMessage(param);
85
84
  }
86
85
  }).join(' ');
87
- DdRum.addError(message, TYPE_CONSOLE, stack).then(() => {
86
+ DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {
88
87
  DdRumErrorTracking.defaultConsoleError.apply(console, params);
89
88
  });
90
89
  }