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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/README.md +18 -14
  2. package/android/src/main/kotlin/com/datadog/reactnative/DatadogSDKWrapper.kt +8 -0
  3. package/android/src/main/kotlin/com/datadog/reactnative/DatadogWrapper.kt +10 -0
  4. package/android/src/main/kotlin/com/datadog/reactnative/DdSdk.kt +25 -0
  5. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +2 -0
  6. package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +2 -0
  7. package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +52 -0
  8. package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +7 -0
  9. package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +1 -0
  10. package/ios/Sources/DdSdk.m +10 -0
  11. package/ios/Sources/DdSdk.swift +17 -0
  12. package/ios/Sources/DdSdkConfiguration.swift +4 -0
  13. package/ios/Sources/RNDdSdkConfiguration.swift +2 -0
  14. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js +173 -0
  15. package/lib/commonjs/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  16. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js +32 -0
  17. package/lib/commonjs/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  18. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js +29 -0
  19. package/lib/commonjs/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  20. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js +28 -0
  21. package/lib/commonjs/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  22. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js +32 -0
  23. package/lib/commonjs/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  24. package/lib/commonjs/DatadogProvider/DatadogProvider.js +101 -0
  25. package/lib/commonjs/DatadogProvider/DatadogProvider.js.map +1 -0
  26. package/lib/commonjs/DdSdkReactNative.js +138 -56
  27. package/lib/commonjs/DdSdkReactNative.js.map +1 -1
  28. package/lib/commonjs/DdSdkReactNativeConfiguration.js +102 -9
  29. package/lib/commonjs/DdSdkReactNativeConfiguration.js.map +1 -1
  30. package/lib/commonjs/errorUtils.js +60 -0
  31. package/lib/commonjs/errorUtils.js.map +1 -0
  32. package/lib/commonjs/foundation.js +19 -12
  33. package/lib/commonjs/foundation.js.map +1 -1
  34. package/lib/commonjs/index.js +20 -0
  35. package/lib/commonjs/index.js.map +1 -1
  36. package/lib/commonjs/nativeModulesTypes.js.map +1 -1
  37. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js +8 -45
  38. package/lib/commonjs/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  39. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js +16 -1
  40. package/lib/commonjs/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  41. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js +1 -1
  42. package/lib/commonjs/rum/instrumentation/getJsxRuntime.js.map +1 -1
  43. package/lib/commonjs/types.js +2 -1
  44. package/lib/commonjs/types.js.map +1 -1
  45. package/lib/commonjs/version.js +1 -1
  46. package/lib/commonjs/version.js.map +1 -1
  47. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js +163 -0
  48. package/lib/module/DatadogProvider/Buffer/BoundedBuffer.js.map +1 -0
  49. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js +26 -0
  50. package/lib/module/DatadogProvider/Buffer/BufferSingleton.js.map +1 -0
  51. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js +20 -0
  52. package/lib/module/DatadogProvider/Buffer/DatadogBuffer.js.map +1 -0
  53. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js +23 -0
  54. package/lib/module/DatadogProvider/Buffer/PassThroughBuffer.js.map +1 -0
  55. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js +16 -0
  56. package/lib/module/DatadogProvider/Buffer/bufferNativeCall.js.map +1 -0
  57. package/lib/module/DatadogProvider/DatadogProvider.js +82 -0
  58. package/lib/module/DatadogProvider/DatadogProvider.js.map +1 -0
  59. package/lib/module/DdSdkReactNative.js +130 -54
  60. package/lib/module/DdSdkReactNative.js.map +1 -1
  61. package/lib/module/DdSdkReactNativeConfiguration.js +91 -8
  62. package/lib/module/DdSdkReactNativeConfiguration.js.map +1 -1
  63. package/lib/module/errorUtils.js +45 -0
  64. package/lib/module/errorUtils.js.map +1 -0
  65. package/lib/module/foundation.js +18 -12
  66. package/lib/module/foundation.js.map +1 -1
  67. package/lib/module/index.js +3 -2
  68. package/lib/module/index.js.map +1 -1
  69. package/lib/module/nativeModulesTypes.js.map +1 -1
  70. package/lib/module/rum/instrumentation/DdRumErrorTracking.js +5 -42
  71. package/lib/module/rum/instrumentation/DdRumErrorTracking.js.map +1 -1
  72. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js +14 -1
  73. package/lib/module/rum/instrumentation/DdRumUserInteractionTracking.js.map +1 -1
  74. package/lib/module/rum/instrumentation/getJsxRuntime.js +1 -1
  75. package/lib/module/rum/instrumentation/getJsxRuntime.js.map +1 -1
  76. package/lib/module/types.js +2 -1
  77. package/lib/module/types.js.map +1 -1
  78. package/lib/module/version.js +1 -1
  79. package/lib/module/version.js.map +1 -1
  80. package/lib/typescript/DatadogProvider/Buffer/BoundedBuffer.d.ts +15 -0
  81. package/lib/typescript/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -0
  82. package/lib/typescript/DatadogProvider/Buffer/DatadogBuffer.d.ts +20 -0
  83. package/lib/typescript/DatadogProvider/Buffer/PassThroughBuffer.d.ts +7 -0
  84. package/lib/typescript/DatadogProvider/Buffer/bufferNativeCall.d.ts +3 -0
  85. package/lib/typescript/DatadogProvider/DatadogProvider.d.ts +26 -0
  86. package/lib/typescript/DdSdkReactNative.d.ts +23 -1
  87. package/lib/typescript/DdSdkReactNativeConfiguration.d.ts +63 -0
  88. package/lib/typescript/errorUtils.d.ts +4 -0
  89. package/lib/typescript/index.d.ts +3 -2
  90. package/lib/typescript/nativeModulesTypes.d.ts +12 -0
  91. package/lib/typescript/rum/instrumentation/DdRumErrorTracking.d.ts +0 -2
  92. package/lib/typescript/rum/instrumentation/DdRumUserInteractionTracking.d.ts +3 -0
  93. package/lib/typescript/types.d.ts +2 -1
  94. package/lib/typescript/version.d.ts +1 -1
  95. package/package.json +2 -2
  96. package/src/DatadogProvider/Buffer/BoundedBuffer.ts +209 -0
  97. package/src/DatadogProvider/Buffer/BufferSingleton.ts +26 -0
  98. package/src/DatadogProvider/Buffer/DatadogBuffer.ts +34 -0
  99. package/src/DatadogProvider/Buffer/PassThroughBuffer.ts +16 -0
  100. package/src/DatadogProvider/Buffer/__tests__/BoundedBuffer.test.ts +202 -0
  101. package/src/DatadogProvider/Buffer/__tests__/BufferSingleton.test.ts +50 -0
  102. package/src/DatadogProvider/Buffer/bufferNativeCall.ts +24 -0
  103. package/src/DatadogProvider/DatadogProvider.tsx +122 -0
  104. package/src/DatadogProvider/__tests__/__utils__/renderWithProvider.tsx +111 -0
  105. package/src/DatadogProvider/__tests__/initialization.test.tsx +174 -0
  106. package/src/DatadogProvider/__tests__/initializationModes.test.tsx +174 -0
  107. package/src/DdSdkReactNative.tsx +205 -105
  108. package/src/DdSdkReactNativeConfiguration.tsx +160 -8
  109. package/src/__tests__/DdRumWrapper.test.tsx +3 -27
  110. package/src/__tests__/DdSdkReactNative.test.tsx +1 -0
  111. package/src/__tests__/DdSdkReactNativeConfiguration.test.ts +168 -0
  112. package/src/__tests__/foundation.test.ts +11 -2
  113. package/src/__tests__/rum/instrumentation/DdRumUserInteractionTracking.test.tsx +18 -4
  114. package/src/errorUtils.ts +50 -0
  115. package/src/foundation.tsx +15 -12
  116. package/src/index.tsx +9 -1
  117. package/src/nativeModulesTypes.ts +14 -0
  118. package/src/rum/instrumentation/DdRumErrorTracking.tsx +9 -46
  119. package/src/rum/instrumentation/DdRumUserInteractionTracking.tsx +11 -1
  120. package/src/rum/instrumentation/getJsxRuntime.ts +1 -1
  121. package/src/rum/instrumentation/resourceTracking/__tests__/DdRumResourceTracking.test.ts +2 -0
  122. package/src/rum/instrumentation/resourceTracking/implementation/DatadogRumResource/__tests__/ResourceReporter.test.ts +2 -0
  123. package/src/rum/instrumentation/resourceTracking/implementation/__tests__/XHRProxy.test.ts +3 -0
  124. package/src/types.tsx +2 -1
  125. package/src/version.ts +1 -1
@@ -10,6 +10,7 @@ import { DdSdkConfiguration } from './types';
10
10
  import { InternalLog } from "./InternalLog";
11
11
  import { SdkVerbosity } from "./SdkVerbosity";
12
12
  import { TimeProvider } from "./TimeProvider";
13
+ import { bufferNativeCallReturningId, bufferNativeCallWithId, bufferVoidNativeCall } from './DatadogProvider/Buffer/bufferNativeCall';
13
14
  const timeProvider = new TimeProvider();
14
15
 
15
16
  class DdLogsWrapper {
@@ -45,14 +46,14 @@ class DdTraceWrapper {
45
46
  }
46
47
 
47
48
  startSpan(operation, context = {}, timestampMs = timeProvider.now()) {
48
- let spanId = this.nativeTrace.startSpan(operation, context, timestampMs);
49
+ let spanId = bufferNativeCallReturningId(() => this.nativeTrace.startSpan(operation, context, timestampMs));
49
50
  InternalLog.log("Starting span “" + operation + "” #" + spanId, SdkVerbosity.DEBUG);
50
51
  return spanId;
51
52
  }
52
53
 
53
54
  finishSpan(spanId, context = {}, timestampMs = timeProvider.now()) {
54
55
  InternalLog.log("Finishing span #" + spanId, SdkVerbosity.DEBUG);
55
- return this.nativeTrace.finishSpan(spanId, context, timestampMs);
56
+ return bufferNativeCallWithId(id => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);
56
57
  }
57
58
 
58
59
  }
@@ -73,12 +74,17 @@ class DdRumWrapper {
73
74
 
74
75
  _defineProperty(this, "getStopActionNativeCall", args => {
75
76
  if (isNewStopActionAPI(args)) {
76
- return this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now());
77
+ return bufferVoidNativeCall(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()));
77
78
  }
78
79
 
79
80
  if (isOldStopActionAPI(args)) {
80
81
  if (this.lastActionData) {
81
- return this.nativeRum.stopAction(this.lastActionData.type, this.lastActionData.name, args[0] || {}, args[1] || timeProvider.now());
82
+ DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature');
83
+ const {
84
+ type,
85
+ name
86
+ } = this.lastActionData;
87
+ return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));
82
88
  }
83
89
 
84
90
  InternalLog.log("DdRum.startAction needs to be called before DdRum.stopAction", SdkVerbosity.WARN);
@@ -92,12 +98,12 @@ class DdRumWrapper {
92
98
 
93
99
  startView(key, name, context = {}, timestampMs = timeProvider.now()) {
94
100
  InternalLog.log("Starting RUM View “" + name + "” #" + key, SdkVerbosity.DEBUG);
95
- return this.nativeRum.startView(key, name, context, timestampMs);
101
+ return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));
96
102
  }
97
103
 
98
104
  stopView(key, context = {}, timestampMs = timeProvider.now()) {
99
105
  InternalLog.log("Stopping RUM View #" + key, SdkVerbosity.DEBUG);
100
- return this.nativeRum.stopView(key, context, timestampMs);
106
+ return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));
101
107
  }
102
108
 
103
109
  startAction(type, name, context = {}, timestampMs = timeProvider.now()) {
@@ -106,7 +112,7 @@ class DdRumWrapper {
106
112
  type,
107
113
  name
108
114
  };
109
- return this.nativeRum.startAction(type, name, context, timestampMs);
115
+ return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));
110
116
  }
111
117
 
112
118
  stopAction(...args) {
@@ -118,29 +124,29 @@ class DdRumWrapper {
118
124
 
119
125
  addAction(type, name, context = {}, timestampMs = timeProvider.now()) {
120
126
  InternalLog.log("Adding RUM Action “" + name + "” (" + type + ")", SdkVerbosity.DEBUG);
121
- return this.nativeRum.addAction(type, name, context, timestampMs);
127
+ return bufferVoidNativeCall(() => this.nativeRum.addAction(type, name, context, timestampMs));
122
128
  }
123
129
 
124
130
  startResource(key, method, url, context = {}, timestampMs = timeProvider.now()) {
125
131
  InternalLog.log("Starting RUM Resource #" + key + " " + method + ": " + url, SdkVerbosity.DEBUG);
126
- return this.nativeRum.startResource(key, method, url, context, timestampMs);
132
+ return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));
127
133
  }
128
134
 
129
135
  stopResource(key, statusCode, kind, size = -1, context = {}, timestampMs = timeProvider.now()) {
130
136
  InternalLog.log("Stopping RUM Resource #" + key + " status:" + statusCode, SdkVerbosity.DEBUG);
131
- return this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs);
137
+ return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));
132
138
  }
133
139
 
134
140
  addError(message, source, stacktrace, context = {}, timestampMs = timeProvider.now()) {
135
141
  InternalLog.log("Adding RUM Error “" + message + "”", SdkVerbosity.DEBUG);
136
142
  let updatedContext = context;
137
143
  updatedContext["_dd.error.source_type"] = "react-native";
138
- return this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs);
144
+ return bufferVoidNativeCall(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));
139
145
  }
140
146
 
141
147
  addTiming(name) {
142
148
  InternalLog.log("Adding timing “" + name + "” to RUM View", SdkVerbosity.DEBUG);
143
- return this.nativeRum.addTiming(name);
149
+ return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));
144
150
  }
145
151
 
146
152
  }
@@ -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","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,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,GAAm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B,EAAiCW,UAAjC,EAA6CC,IAA7C,EAAmDC,IAAnD,EAAyD3C,OAAzD,EAAkEW,WAAlE,CAAP;AACH;;AAEDiC,EAAAA,QAAQ,CAAC7C,OAAD,EAAkB8C,MAAlB,EAAuCC,UAAvC,EAA2D9C,OAAe,GAAG,EAA7E,EAAiFW,WAAmB,GAAGhB,YAAY,CAACiB,GAAb,EAAvG,EAA0I;AAC9IpB,IAAAA,WAAW,CAACS,GAAZ,CAAgB,uBAAuBF,OAAvB,GAAiC,GAAjD,EAAsDN,YAAY,CAACS,KAAnE;AACA,QAAI6C,cAAmB,GAAG/C,OAA1B;AACA+C,IAAAA,cAAc,CAAC,uBAAD,CAAd,GAA0C,cAA1C;AACA,WAAO,KAAK1B,SAAL,CAAeuB,QAAf,CAAwB7C,OAAxB,EAAiC8C,MAAjC,EAAyCC,UAAzC,EAAqDC,cAArD,EAAqEpC,WAArE,CAAP;AACH;;AAEDqC,EAAAA,SAAS,CAACvB,IAAD,EAA8B;AACnCjC,IAAAA,WAAW,CAACS,GAAZ,CAAgB,oBAAoBwB,IAApB,GAA2B,eAA3C,EAA4DhC,YAAY,CAACS,KAAzE;AACA,WAAO,KAAKmB,SAAL,CAAe2B,SAAf,CAAyBvB,IAAzB,CAAP;AACH;;AArEmC;;AAwExC,MAAMwB,KAAsB,GAAG3D,aAAa,CAAC2D,KAA7C;AACA,MAAMpD,MAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAMY,OAAoB,GAAG,IAAID,cAAJ,EAA7B;AACA,MAAMa,KAAgB,GAAG,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"]}
1
+ {"version":3,"sources":["foundation.tsx"],"names":["NativeModules","DdSdkConfiguration","InternalLog","SdkVerbosity","TimeProvider","bufferNativeCallReturningId","bufferNativeCallWithId","bufferVoidNativeCall","timeProvider","DdLogsWrapper","DdLogs","debug","message","context","log","DEBUG","nativeLogs","info","warn","error","DdTraceWrapper","DdTrace","startSpan","operation","timestampMs","now","spanId","nativeTrace","finishSpan","id","isNewStopActionAPI","args","isOldStopActionAPI","DdRumWrapper","DdRum","nativeRum","stopAction","lastActionData","DdSdk","telemetryDebug","type","name","WARN","Promise","resolve","startView","key","stopView","startAction","returnPromise","getStopActionNativeCall","undefined","addAction","startResource","method","url","stopResource","statusCode","kind","size","addError","source","stacktrace","updatedContext","addTiming"],"mappings":";;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;AAEA,SAASC,2BAAT,EAAsCC,sBAAtC,EAA8DC,oBAA9D,QAA0F,2CAA1F;AAEA,MAAMC,YAAY,GAAG,IAAIJ,YAAJ,EAArB;;AAEA,MAAMK,aAAN,CAA0C;AAAA;AAAA,wCAECT,aAAa,CAACU,MAFf;AAAA;;AAItCC,EAAAA,KAAK,CAACC,OAAD,EAAkBC,OAAe,GAAG,EAApC,EAAuD;AACxDX,IAAAA,WAAW,CAACY,GAAZ,CAAgB,yBAA0BF,OAA1B,GAAoC,GAApD,EAAyDT,YAAY,CAACY,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;AACvDX,IAAAA,WAAW,CAACY,GAAZ,CAAgB,wBAAyBF,OAAzB,GAAmC,GAAnD,EAAwDT,YAAY,CAACY,KAArE;AACA,WAAO,KAAKC,UAAL,CAAgBC,IAAhB,CAAqBL,OA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Y,GAAZ,CAAgB,oBAAoB2B,IAApB,GAA2B,eAA3C,EAA4DtC,YAAY,CAACY,KAAzE;AACA,WAAOR,oBAAoB,CAAC,MAAM,KAAK4B,SAAL,CAAe6B,SAAf,CAAyBvB,IAAzB,CAAP,CAA3B;AACH;;AAvEmC;;AA0ExC,MAAMH,KAAsB,GAAGtC,aAAa,CAACsC,KAA7C;AACA,MAAM5B,MAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAMY,OAAoB,GAAG,IAAID,cAAJ,EAA7B;AACA,MAAMc,KAAgB,GAAG,IAAID,YAAJ,EAAzB;AAEA,SAAShC,kBAAT,EAA6BqC,KAA7B,EAAoC5B,MAApC,EAA4CW,OAA5C,EAAqDa,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';\nimport { bufferNativeCallReturningId, bufferNativeCallWithId, bufferVoidNativeCall } from './DatadogProvider/Buffer/bufferNativeCall';\n\nconst timeProvider = new TimeProvider();\n\nclass DdLogsWrapper implements DdLogsType {\n\n private nativeLogs: DdNativeLogsType = NativeModules.DdLogs;\n\n debug(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking debug log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.debug(message, context);\n }\n\n info(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking info log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.info(message, context);\n }\n\n warn(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking warn log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.warn(message, context);\n }\n\n error(message: string, context: object = {}): Promise<void> {\n InternalLog.log(\"Tracking error log “\" + message + \"”\", SdkVerbosity.DEBUG);\n return this.nativeLogs.error(message, context);\n }\n\n}\n\nclass DdTraceWrapper implements DdTraceType {\n\n private nativeTrace: DdNativeTraceType = NativeModules.DdTrace;\n\n startSpan(operation: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<string> {\n let spanId = bufferNativeCallReturningId(() =>this.nativeTrace.startSpan(operation, context, timestampMs));\n InternalLog.log(\"Starting span “\" + operation + \"” #\" + spanId, SdkVerbosity.DEBUG);\n return spanId\n }\n\n finishSpan(spanId: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Finishing span #\" + spanId, SdkVerbosity.DEBUG);\n return bufferNativeCallWithId((id) => this.nativeTrace.finishSpan(id, context, timestampMs), spanId);\n }\n}\n\nconst isNewStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [type: RumActionType, name: string, context?: object, timestampMs?: number] => {\n return typeof args[0] === 'string'\n}\n\nconst isOldStopActionAPI = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): args is [context?: object, timestampMs?: number] => {\n return typeof args[0] === 'object' || typeof args[0] === 'undefined' \n}\n\nclass DdRumWrapper implements DdRumType {\n\n private nativeRum: DdNativeRumType = NativeModules.DdRum;\n private lastActionData?: {type: RumActionType, name: string}\n\n startView(key: string, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM View “\" + name + \"” #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startView(key, name, context, timestampMs));\n }\n\n stopView(key: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM View #\" + key, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopView(key, context, timestampMs));\n }\n\n startAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n this.lastActionData={type, name}\n return bufferVoidNativeCall(() => this.nativeRum.startAction(type, name, context, timestampMs));\n }\n\n stopAction(...args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> {\n InternalLog.log(\"Stopping current RUM Action\", SdkVerbosity.DEBUG);\n let returnPromise = this.getStopActionNativeCall(args)\n this.lastActionData = undefined\n return returnPromise\n }\n\n private getStopActionNativeCall = (args: [type: RumActionType, name: string, context?: object, timestampMs?: number] | [context?: object, timestampMs?: number]): Promise<void> => {\n if (isNewStopActionAPI(args)) {\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(args[0], args[1], args[2] || {}, args[3] || timeProvider.now()))\n }\n if (isOldStopActionAPI(args)) {\n if (this.lastActionData) {\n DdSdk.telemetryDebug('DDdRum.stopAction called with the old signature')\n const {type, name} = this.lastActionData;\n return bufferVoidNativeCall(() => this.nativeRum.stopAction(type, name, args[0] || {}, args[1] || timeProvider.now()));\n } \n InternalLog.log(\"DdRum.startAction needs to be called before DdRum.stopAction\", SdkVerbosity.WARN);\n } else {\n InternalLog.log(\"DdRum.stopAction was called with wrong arguments\", SdkVerbosity.WARN);\n }\n\n return new Promise<void>(resolve => resolve())\n }\n\n addAction(type: RumActionType, name: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Action “\" + name + \"” (\" + type + \")\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addAction(type, name, context, timestampMs));\n }\n\n startResource(key: string, method: string, url: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Starting RUM Resource #\" + key + \" \" + method + \": \" + url, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.startResource(key, method, url, context, timestampMs));\n }\n\n stopResource(key: string, statusCode: number, kind: ResourceKind, size: number = -1, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Stopping RUM Resource #\" + key + \" status:\" + statusCode, SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.stopResource(key, statusCode, kind, size, context, timestampMs));\n }\n\n addError(message: string, source: ErrorSource, stacktrace: string, context: object = {}, timestampMs: number = timeProvider.now()): Promise<void> {\n InternalLog.log(\"Adding RUM Error “\" + message + \"”\", SdkVerbosity.DEBUG);\n let updatedContext: any = context;\n updatedContext[\"_dd.error.source_type\"] = \"react-native\";\n return bufferVoidNativeCall(() => this.nativeRum.addError(message, source, stacktrace, updatedContext, timestampMs));\n }\n\n addTiming(name: string): Promise<void> {\n InternalLog.log(\"Adding timing “\" + name + \"” to RUM View\", SdkVerbosity.DEBUG);\n return bufferVoidNativeCall(() => this.nativeRum.addTiming(name));\n }\n}\n\nconst DdSdk: DdNativeSdkType = NativeModules.DdSdk;\nconst DdLogs: DdLogsType = new DdLogsWrapper();\nconst DdTrace: DdTraceType = new DdTraceWrapper();\nconst DdRum: DdRumType = new DdRumWrapper();\n\nexport { DdSdkConfiguration, DdSdk, DdLogs, DdTrace, DdRum };\n"]}
@@ -3,7 +3,8 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
- import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
6
+ import { DatadogProvider } from './DatadogProvider/DatadogProvider';
7
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
7
8
  import { DdSdkReactNative } from './DdSdkReactNative';
8
9
  import { InternalLog } from './InternalLog';
9
10
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -11,5 +12,5 @@ import { SdkVerbosity } from './SdkVerbosity';
11
12
  import { TrackingConsent } from './TrackingConsent';
12
13
  import { DdLogs, DdTrace, DdRum } from './foundation';
13
14
  import { RumActionType, ErrorSource } from './types';
14
- export { DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
15
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["DdSdkReactNativeConfiguration","DdSdkReactNative","InternalLog","ProxyConfiguration","ProxyType","SdkVerbosity","TrackingConsent","DdLogs","DdTrace","DdRum","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,6BAAT,QAA8C,iCAA9C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,sBAA9C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,cAAvC;AACA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,SAA3C;AAEA,SACIJ,MADJ,EAEIC,OAFJ,EAGIC,KAHJ,EAIIC,aAJJ,EAKIC,WALJ,EAMIX,6BANJ,EAOIC,gBAPJ,EAQIC,WARJ,EASIC,kBATJ,EAUIC,SAVJ,EAWIE,eAXJ,EAYID,YAZJ","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["DatadogProvider","DatadogProviderConfiguration","DdSdkReactNativeConfiguration","InitializationMode","DdSdkReactNative","InternalLog","ProxyConfiguration","ProxyType","SdkVerbosity","TrackingConsent","DdLogs","DdTrace","DdRum","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,eAAT,QAAgC,mCAAhC;AACA,SACIC,4BADJ,EAEIC,6BAFJ,EAGIC,kBAHJ,QAIO,iCAJP;AAKA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,kBAAT,EAA6BC,SAA7B,QAA8C,sBAA9C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,KAA1B,QAAuC,cAAvC;AACA,SAASC,aAAT,EAAwBC,WAAxB,QAA2C,SAA3C;AAEA,SACId,eADJ,EAEIC,4BAFJ,EAGIE,kBAHJ,EAIIO,MAJJ,EAKIC,OALJ,EAMIC,KANJ,EAOIC,aAPJ,EAQIC,WARJ,EASIZ,6BATJ,EAUIE,gBAVJ,EAWIC,WAXJ,EAYIC,kBAZJ,EAaIC,SAbJ,EAcIE,eAdJ,EAeID,YAfJ","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DatadogProvider } from './DatadogProvider/DatadogProvider';\nimport {\n DatadogProviderConfiguration,\n DdSdkReactNativeConfiguration,\n InitializationMode\n} from './DdSdkReactNativeConfiguration';\nimport { DdSdkReactNative } from './DdSdkReactNative';\nimport { InternalLog } from './InternalLog';\nimport { ProxyConfiguration, ProxyType } from './ProxyConfiguration';\nimport { SdkVerbosity } from './SdkVerbosity';\nimport { TrackingConsent } from './TrackingConsent';\nimport { DdLogs, DdTrace, DdRum } from './foundation';\nimport { RumActionType, ErrorSource } from './types';\n\nexport {\n DatadogProvider,\n DatadogProviderConfiguration,\n InitializationMode,\n DdLogs,\n DdTrace,\n DdRum,\n RumActionType,\n ErrorSource,\n DdSdkReactNativeConfiguration,\n DdSdkReactNative,\n InternalLog,\n ProxyConfiguration,\n ProxyType,\n TrackingConsent,\n SdkVerbosity\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["nativeModulesTypes.ts"],"names":["DdNativeSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;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"]}
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 * Sends internal telemetry debug message\n * @param message debug message\n */\n telemetryDebug(message: string): Promise<void>;\n\n /**\n * Sends internal telemetry error\n * @param message error message\n * @param stack error stack\n * @param kind error kind\n */\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Logs feature.\n */\nexport type DdNativeLogsType = {\n /**\n * Send a log with level debug.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n debug(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level info.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n info(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level warn.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n warn(message: string, context?: object): Promise<void>;\n\n /**\n * Send a log with level error.\n * @param message: The message to send.\n * @param context: The additional context to send.\n */\n error(message: string, context?: object): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's Trace feature.\n */\nexport type DdNativeTraceType = {\n /**\n * Start a span, and returns a unique identifier for the span.\n * @param operation: The operation name of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.\n */\n startSpan(\n operation: string,\n context?: object,\n timestampMs?: number\n ): Promise<string>;\n\n /**\n * Finish a started span.\n * @param spanId: The unique identifier of the span.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n finishSpan(\n spanId: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n};\n\n/**\n * The entry point to use Datadog's RUM feature.\n */\nexport type DdNativeRumType = {\n /**\n * Start tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param name: The view name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.\n */\n startView(\n key: string,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM View.\n * @param key: The view unique key identifier.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopView(\n key: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.\n */\n startAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking the ongoing RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Action.\n * @param type: The action type (tap, scroll, swipe, back, custom).\n * @param name: The action name.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addAction(\n type: ActionType,\n name: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Start tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param method: The resource method (GET, POST, …).\n * @param url: The resource url.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.\n */\n startResource(\n key: string,\n method: string,\n url: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Stop tracking a RUM Resource.\n * @param key: The resource unique key identifier.\n * @param statusCode: The resource status code.\n * @param kind: The resource's kind (xhr, document, image, css, font, …).\n * @param size: The resource size in bytes. If size is unknown, use -1.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.\n */\n stopResource(\n key: string,\n statusCode: number,\n kind: ResourceKind,\n size?: number,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Add a RUM Error.\n * @param message: The error message.\n * @param source: The error source (network, source, console, webview, custom).\n * @param stacktrace: The error stacktrace.\n * @param context: The additional context to send.\n * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.\n */\n addError(\n message: string,\n source: ErrorSource,\n stacktrace: string,\n context?: object,\n timestampMs?: number\n ): Promise<void>;\n\n /**\n * Adds a specific timing in the active View. The timing duration will be computed as the difference between the time the View was started and the time this function was called.\n * @param name: The name of the new custom timing attribute. Timings can be nested up to 8 levels deep. Names using more than 8 levels will be sanitized by SDK.\n */\n addTiming(name: string): Promise<void>;\n};\n\ntype ActionType = 'TAP' | 'SCROLL' | 'SWIPE' | 'BACK' | 'CUSTOM';\n\ntype ResourceKind =\n | 'image'\n | 'xhr'\n | 'beacon'\n | 'css'\n | 'document'\n | 'fetch'\n | 'font'\n | 'js'\n | 'media'\n | 'other'\n | 'native';\n\ntype ErrorSource = 'NETWORK' | 'SOURCE' | 'CONSOLE' | 'WEBVIEW' | 'CUSTOM';\n"]}
@@ -7,10 +7,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  */
8
8
  import { InternalLog } from '../../InternalLog';
9
9
  import { SdkVerbosity } from '../../SdkVerbosity';
10
+ import { getErrorMessage, getErrorStackTrace, EMPTY_STACK_TRACE } from '../../errorUtils';
10
11
  import { DdRum } from '../../foundation';
11
12
  import { ErrorSource } from '../../types';
12
- const EMPTY_MESSAGE = 'Unknown Error';
13
- const EMPTY_STACK_TRACE = '';
14
13
  /**
15
14
  * Provides RUM auto-instrumentation feature to track errors as RUM events.
16
15
  */
@@ -43,8 +42,8 @@ export class DdRumErrorTracking {
43
42
 
44
43
 
45
44
  static onGlobalError(error, isFatal) {
46
- const message = DdRumErrorTracking.getErrorMessage(error);
47
- const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);
45
+ const message = getErrorMessage(error);
46
+ const stacktrace = getErrorStackTrace(error);
48
47
  DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {
49
48
  '_dd.error.is_crash': isFatal,
50
49
  '_dd.error.raw': error
@@ -68,7 +67,7 @@ export class DdRumErrorTracking {
68
67
 
69
68
  for (let i = 0; i < params.length; i += 1) {
70
69
  const param = params[i];
71
- const paramStack = DdRumErrorTracking.getErrorStackTrace(param);
70
+ const paramStack = getErrorStackTrace(param);
72
71
 
73
72
  if (paramStack !== EMPTY_STACK_TRACE) {
74
73
  stack = paramStack;
@@ -80,7 +79,7 @@ export class DdRumErrorTracking {
80
79
  if (typeof param === 'string') {
81
80
  return param;
82
81
  } else {
83
- return DdRumErrorTracking.getErrorMessage(param);
82
+ return getErrorMessage(param);
84
83
  }
85
84
  }).join(' ');
86
85
  DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {
@@ -88,42 +87,6 @@ export class DdRumErrorTracking {
88
87
  });
89
88
  }
90
89
 
91
- static getErrorMessage(error) {
92
- let message = EMPTY_MESSAGE;
93
-
94
- if (error === undefined || error === null) {
95
- message = EMPTY_MESSAGE;
96
- } else if (typeof error === 'object' && 'message' in error) {
97
- message = String(error.message);
98
- } else {
99
- message = String(error);
100
- }
101
-
102
- return message;
103
- }
104
-
105
- static getErrorStackTrace(error) {
106
- let stack = EMPTY_STACK_TRACE;
107
-
108
- if (error === undefined || error === null) {
109
- stack = EMPTY_STACK_TRACE;
110
- } else if (typeof error === 'string') {
111
- stack = EMPTY_STACK_TRACE;
112
- } else if (typeof error === 'object') {
113
- if ('componentStack' in error) {
114
- stack = String(error.componentStack);
115
- } else if ('stacktrace' in error) {
116
- stack = String(error.stacktrace);
117
- } else if ('stack' in error) {
118
- stack = String(error.stack);
119
- } else if ('sourceURL' in error && 'line' in error && 'column' in error) {
120
- stack = `at ${error.sourceURL}:${error.line}:${error.column}`;
121
- }
122
- }
123
-
124
- return stack;
125
- }
126
-
127
90
  }
128
91
 
129
92
  _defineProperty(DdRumErrorTracking, "isTracking", false);
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["InternalLog","SdkVerbosity","DdRum","ErrorSource","EMPTY_MESSAGE","EMPTY_STACK_TRACE","DdRumErrorTracking","startTracking","isTracking","log","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","getErrorMessage","stacktrace","getErrorStackTrace","addError","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","undefined","String","componentStack","sourceURL","line","column","_error","_isFatal","_params"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAIA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,WAAT,QAA4B,aAA5B;AAEA,MAAMC,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,kBAAN,CAAyB;AAK5B;AAGA;;AAGA;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kBAAkB,CAACE,UAAvB,EAAmC;AAC/BR,MAAAA,WAAW,CAACS,GAAZ,CACI,wCADJ,EAEIR,YAAY,CAACS,IAFjB;AAIA;AACH;;AAED,QAAIC,UAAJ,EAAgB;AACZL,MAAAA,kBAAkB,CAACM,mBAAnB,GAAyCD,UAAU,CAACE,gBAAX,EAAzC;AACAP,MAAAA,kBAAkB,CAACQ,mBAAnB,GAAyCC,OAAO,CAAC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KAAK,KAAKyB,SAAV,IAAuBzB,KAAK,KAAK,IAArC,EAA2C;AACvCgB,MAAAA,KAAK,GAAG3B,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOW,KAAP,KAAiB,QAArB,EAA+B;AAClCgB,MAAAA,KAAK,GAAG3B,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOW,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,oBAAoBA,KAAxB,EAA+B;AAC3BgB,QAAAA,KAAK,GAAGU,MAAM,CAAC1B,KAAK,CAAC2B,cAAP,CAAd;AACH,OAFD,MAEO,IAAI,gBAAgB3B,KAApB,EAA2B;AAC9BgB,QAAAA,KAAK,GAAGU,MAAM,CAAC1B,KAAK,CAACS,UAAP,CAAd;AACH,OAFM,MAEA,IAAI,WAAWT,KAAf,EAAsB;AACzBgB,QAAAA,KAAK,GAAGU,MAAM,CAAC1B,KAAK,CAACgB,KAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAehB,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEgB,QAAAA,KAAK,GAAI,MAAKhB,KAAK,CAAC4B,SAAU,IAAG5B,KAAK,CAAC6B,IAAK,IAAG7B,KAAK,CAAC8B,MAAO,EAA5D;AACH;AACJ;;AAED,WAAOd,KAAP;AACH;;AAhI2B;;gBAAnB1B,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAACyC,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1F1C,kB,yBAS4B,CAAC,GAAG2C,OAAJ,KAA2B,CAAG,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = DdRumErrorTracking.getErrorMessage(error);\n const stacktrace = DdRumErrorTracking.getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = DdRumErrorTracking.getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return DdRumErrorTracking.getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n\n private static getErrorMessage(error: any | undefined): string {\n let message = EMPTY_MESSAGE;\n if (error === undefined || error === null) {\n message = EMPTY_MESSAGE;\n } else if (typeof error === 'object' && 'message' in error) {\n message = String(error.message);\n } else {\n message = String(error);\n }\n\n return message;\n }\n\n private static getErrorStackTrace(error: any | undefined): string {\n let stack = EMPTY_STACK_TRACE;\n\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n\n return stack;\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumErrorTracking.tsx"],"names":["InternalLog","SdkVerbosity","getErrorMessage","getErrorStackTrace","EMPTY_STACK_TRACE","DdRum","ErrorSource","DdRumErrorTracking","startTracking","isTracking","log","WARN","ErrorUtils","defaultErrorHandler","getGlobalHandler","defaultConsoleError","console","error","setGlobalHandler","onGlobalError","onConsoleError","INFO","ERROR","isFatal","message","stacktrace","addError","SOURCE","then","isInDefaultErrorHandler","params","stack","i","length","param","paramStack","map","join","CONSOLE","apply","_error","_isFatal","_params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H,KAFD;AAGH;;AAzF2B;;gBAAnBvB,kB,gBACmB,K;;gBADnBA,kB,6BAGgC,K;;gBAHhCA,kB,yBAMkD,CAACiC,MAAD,EAAcC,QAAd,KAAqC,CAAG,C;;gBAN1FlC,kB,yBAS4B,CAAC,GAAGmC,OAAJ,KAA2B,CAAG,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport type { ErrorHandlerCallback } from 'react-native';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport {\n getErrorMessage,\n getErrorStackTrace,\n EMPTY_STACK_TRACE\n} from '../../errorUtils';\nimport { DdRum } from '../../foundation';\nimport { ErrorSource } from '../../types';\n\n/**\n * Provides RUM auto-instrumentation feature to track errors as RUM events.\n */\nexport class DdRumErrorTracking {\n private static isTracking = false;\n\n private static isInDefaultErrorHandler = false;\n\n // eslint-disable-next-line\n private static defaultErrorHandler: ErrorHandlerCallback = (_error: any, _isFatal?: boolean) => { }\n\n // eslint-disable-next-line\n private static defaultConsoleError = (..._params: unknown[]) => { }\n\n /**\n * Starts tracking errors and sends a RUM Error event every time an error is detected.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping the Error handler twice\n if (DdRumErrorTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking errors',\n SdkVerbosity.WARN\n );\n return;\n }\n\n if (ErrorUtils) {\n DdRumErrorTracking.defaultErrorHandler = ErrorUtils.getGlobalHandler();\n DdRumErrorTracking.defaultConsoleError = console.error;\n\n ErrorUtils.setGlobalHandler(DdRumErrorTracking.onGlobalError);\n console.error = DdRumErrorTracking.onConsoleError;\n\n DdRumErrorTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking errors',\n SdkVerbosity.INFO\n );\n } else {\n InternalLog.log(\n 'Datadog SDK cannot track errors, ErrorUtils is not defined',\n SdkVerbosity.ERROR\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n static onGlobalError(error: any, isFatal?: boolean): void {\n const message = getErrorMessage(error);\n const stacktrace = getErrorStackTrace(error);\n DdRum.addError(message, ErrorSource.SOURCE, stacktrace, {\n '_dd.error.is_crash': isFatal,\n '_dd.error.raw': error\n }).then(() => {\n DdRumErrorTracking.isInDefaultErrorHandler = true;\n try {\n DdRumErrorTracking.defaultErrorHandler(error, isFatal);\n } finally {\n DdRumErrorTracking.isInDefaultErrorHandler = false;\n }\n });\n }\n\n static onConsoleError(...params: unknown[]): void {\n if (DdRumErrorTracking.isInDefaultErrorHandler) {\n return;\n }\n\n let stack: string = EMPTY_STACK_TRACE;\n for (let i = 0; i < params.length; i += 1) {\n const param = params[i];\n const paramStack = getErrorStackTrace(param);\n if (paramStack !== EMPTY_STACK_TRACE) {\n stack = paramStack;\n break;\n }\n }\n\n const message = params\n .map(param => {\n if (typeof param === 'string') {\n return param;\n } else {\n return getErrorMessage(param);\n }\n })\n .join(' ');\n\n DdRum.addError(message, ErrorSource.CONSOLE, stack).then(() => {\n DdRumErrorTracking.defaultConsoleError.apply(console, params);\n });\n }\n}\n"]}
@@ -8,6 +8,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  import React from 'react';
9
9
  import { InternalLog } from '../../InternalLog';
10
10
  import { SdkVerbosity } from '../../SdkVerbosity';
11
+ import { getErrorMessage } from '../../errorUtils';
12
+ import { DdSdk } from '../../foundation';
11
13
  import { DdEventsInterceptor } from './DdEventsInterceptor';
12
14
  import NoOpEventsInterceptor from './NoOpEventsInterceptor';
13
15
  import { areObjectShallowEqual } from './ShallowObjectEqualityChecker';
@@ -44,7 +46,8 @@ export class DdRumUserInteractionTracking {
44
46
  jsxRuntime.jsx = (...args) => {
45
47
  return this.patchCreateElementFunction(originaljsx, args);
46
48
  };
47
- } catch (e) {// TODO: Add telemetry
49
+ } catch (e) {
50
+ DdSdk.telemetryDebug(getErrorMessage(e));
48
51
  }
49
52
 
50
53
  const originalMemo = React.memo;
@@ -79,12 +82,22 @@ export class DdRumUserInteractionTracking {
79
82
  InternalLog.log('Datadog SDK is tracking interactions', SdkVerbosity.INFO);
80
83
  }
81
84
 
85
+ static stopTracking() {
86
+ React.createElement = this.originalCreateElement;
87
+ React.memo = this.originalMemo;
88
+ DdRumUserInteractionTracking.isTracking = false;
89
+ }
90
+
82
91
  }
83
92
 
84
93
  _defineProperty(DdRumUserInteractionTracking, "isTracking", false);
85
94
 
86
95
  _defineProperty(DdRumUserInteractionTracking, "eventsInterceptor", new NoOpEventsInterceptor());
87
96
 
97
+ _defineProperty(DdRumUserInteractionTracking, "originalCreateElement", React.createElement);
98
+
99
+ _defineProperty(DdRumUserInteractionTracking, "originalMemo", React.memo);
100
+
88
101
  _defineProperty(DdRumUserInteractionTracking, "patchCreateElementFunction", (originalFunction, [element, props, ...rest]) => {
89
102
  if (props && typeof props.onPress === 'function') {
90
103
  const originalOnPress = props. // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,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GGP,sCAHH,GAG4CS,eAH5C;AAIH;;AACD,SAAOJ,gBAAgB,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,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 React from 'react';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n // TODO: Add telemetry\n }\n\n const originalMemo = React.memo;\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["DdRumUserInteractionTracking.tsx"],"names":["React","InternalLog","SdkVerbosity","getErrorMessage","DdSdk","DdEventsInterceptor","NoOpEventsInterceptor","areObjectShallowEqual","getJsxRuntime","DdRumUserInteractionTracking","startTracking","isTracking","log","WARN","eventsInterceptor","original","createElement","args","patchCreateElementFunction","jsxRuntime","originaljsx","jsx","e","telemetryDebug","originalMemo","memo","component","propsAreEqual","prev","next","onPress","_prevOnPress","partialPrevProps","prevProps","__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__","_nextOnPress","partialNextProps","nextProps","INFO","stopTracking","originalCreateElement","originalFunction","element","props","rest","originalOnPress","interceptOnPress"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,eAAT,QAAgC,kBAAhC;AACA,SAASC,KAAT,QAAsB,kBAAtB;AAEA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAOC,qBAAP,MAAkC,yBAAlC;AACA,SAASC,qBAAT,QAAsC,gCAAtC;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,4BAAN,CAAmC;AA+BtC;AACJ;AACA;AACA;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,4BAA4B,CAACE,UAAjC,EAA6C;AACzCV,MAAAA,WAAW,CAACW,GAAZ,CACI,8CADJ,EAEIV,YAAY,CAACW,IAFjB;AAIA;AACH;;AACDJ,IAAAA,4BAA4B,CAACK,iBAA7B,GAAiD,IAAIT,mBAAJ,EAAjD;AAEA,UAAMU,QAAQ,GAAGf,KAAK,CAACgB,aAAvB;;AACAhB,IAAAA,KAAK,CAACgB,aAAN,GAAsB,CAClB,GAAGC,IADe,KAEZ;AACN,aAAO,KAAKC,0BAAL,CAAgCH,QAAhC,EAA0CE,IAA1C,CAAP;AACH,KAJD;;AAMA,QAAI;AACA,YAAME,UAAU,GAAGX,aAAa,EAAhC;AACA,YAAMY,WAAW,GAAGD,UAAU,CAACE,GAA/B;;AACAF,MAAAA,UAAU,CAACE,GAAX,GAAiB,CACb,GAAGJ,IADU,KAE4B;AACzC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IH;;AAEkB,SAAZC,YAAY,GAAG;AAClBvC,IAAAA,KAAK,CAACgB,aAAN,GAAsB,KAAKwB,qBAA3B;AACAxC,IAAAA,KAAK,CAACyB,IAAN,GAAa,KAAKD,YAAlB;AACAf,IAAAA,4BAA4B,CAACE,UAA7B,GAA0C,KAA1C;AACH;;AA5GqC;;gBAA7BF,4B,gBACmB,K;;gBADnBA,4B,uBAE6C,IAAIH,qBAAJ,E;;gBAF7CG,4B,2BAG8BT,KAAK,CAACgB,a;;gBAHpCP,4B,kBAIqBT,KAAK,CAACyB,I;;gBAJ3BhB,4B,gCAMmC,CACxCgC,gBADwC,EAExC,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAFwC,KAGC;AACzC,MACID,KAAK,IACL,OAAQA,KAAD,CAAmCb,OAA1C,KAAsD,UAF1D,EAGE;AACE,UAAMe,eAAe,GAAIF,KAAD,EAAmC;AACtDb,IAAAA,OADL;;AAECa,IAAAA,KAAD,CAAmCb,OAAnC,GAA6C,CAAC,GAAGb,IAAJ,KAAoB;AAC7DR,MAAAA,4BAA4B,CAACK,iBAA7B,CAA+CgC,gBAA/C,CACI,GAAG7B,IADP;AAGA,aAAO4B,eAAe,CAAC,GAAG5B,IAAJ,CAAtB;AACH,KALD,CAHF,CASE;;;AACC0B,IAAAA,KAAD,CAGGT,sCAHH,GAG4CW,eAH5C;AAIH;;AACD,SAAOJ,gBAAgB,CAACC,OAAD,EAAUC,KAAV,EAAiB,GAAGC,IAApB,CAAvB;AACH,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 React from 'react';\n\nimport { InternalLog } from '../../InternalLog';\nimport { SdkVerbosity } from '../../SdkVerbosity';\nimport { getErrorMessage } from '../../errorUtils';\nimport { DdSdk } from '../../foundation';\n\nimport { DdEventsInterceptor } from './DdEventsInterceptor';\nimport type EventsInterceptor from './EventsInterceptor';\nimport NoOpEventsInterceptor from './NoOpEventsInterceptor';\nimport { areObjectShallowEqual } from './ShallowObjectEqualityChecker';\nimport { getJsxRuntime } from './getJsxRuntime';\n\n/**\n * Provides RUM auto-instrumentation feature to track user interaction as RUM events.\n * For now we are only covering the \"onPress\" events.\n */\nexport class DdRumUserInteractionTracking {\n private static isTracking = false;\n private static eventsInterceptor: EventsInterceptor = new NoOpEventsInterceptor();\n private static originalCreateElement = React.createElement;\n private static originalMemo = React.memo;\n\n private static patchCreateElementFunction = (\n originalFunction: typeof React.createElement,\n [element, props, ...rest]: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n if (\n props &&\n typeof (props as Record<string, unknown>).onPress === 'function'\n ) {\n const originalOnPress = (props as Record<string, unknown>) // eslint-disable-next-line @typescript-eslint/ban-types\n .onPress as Function;\n (props as Record<string, unknown>).onPress = (...args: any[]) => {\n DdRumUserInteractionTracking.eventsInterceptor.interceptOnPress(\n ...args\n );\n return originalOnPress(...args);\n };\n // we store the original onPress prop so we can keep memoization working\n (props as Record<\n string,\n unknown\n >).__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__ = originalOnPress;\n }\n return originalFunction(element, props, ...rest);\n };\n\n /**\n * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.\n * Please note that we are only considering as valid - for - tracking only the user interactions that have\n * a visible output (either an UI state change or a Resource request)\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumUserInteractionTracking.isTracking) {\n InternalLog.log(\n 'Datadog SDK is already tracking interactions',\n SdkVerbosity.WARN\n );\n return;\n }\n DdRumUserInteractionTracking.eventsInterceptor = new DdEventsInterceptor();\n\n const original = React.createElement;\n React.createElement = (\n ...args: Parameters<typeof React.createElement>\n ): any => {\n return this.patchCreateElementFunction(original, args);\n };\n\n try {\n const jsxRuntime = getJsxRuntime();\n const originaljsx = jsxRuntime.jsx;\n jsxRuntime.jsx = (\n ...args: Parameters<typeof React.createElement>\n ): ReturnType<typeof React.createElement> => {\n return this.patchCreateElementFunction(originaljsx, args);\n };\n } catch (e) {\n DdSdk.telemetryDebug(getErrorMessage(e));\n }\n\n const originalMemo = React.memo;\n React.memo = (\n component: any,\n propsAreEqual?: (prevProps: any, newProps: any) => boolean\n ) => {\n return originalMemo(component, (prev, next) => {\n if (!next.onPress || !prev.onPress) {\n return propsAreEqual\n ? propsAreEqual(prev, next)\n : areObjectShallowEqual(prev, next);\n }\n // we replace \"our\" onPress from the props by the original for comparison\n const { onPress: _prevOnPress, ...partialPrevProps } = prev;\n const prevProps = {\n ...partialPrevProps,\n onPress: prev.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n const { onPress: _nextOnPress, ...partialNextProps } = next;\n const nextProps = {\n ...partialNextProps,\n onPress: next.__DATADOG_INTERNAL_ORIGINAL_ON_PRESS__\n };\n\n // if no comparison function is provided we do shallow comparison\n return propsAreEqual\n ? propsAreEqual(prevProps, nextProps)\n : areObjectShallowEqual(nextProps, prevProps);\n });\n };\n\n DdRumUserInteractionTracking.isTracking = true;\n InternalLog.log(\n 'Datadog SDK is tracking interactions',\n SdkVerbosity.INFO\n );\n }\n\n static stopTracking() {\n React.createElement = this.originalCreateElement;\n React.memo = this.originalMemo;\n DdRumUserInteractionTracking.isTracking = false;\n }\n}\n"]}
@@ -22,7 +22,7 @@ export const getJsxRuntime = () => {
22
22
  const jsxRuntime = require(jsxRuntimePackage);
23
23
 
24
24
  if (!jsxRuntime.jsx) {
25
- throw new Error('React version does not support new jsx transform');
25
+ throw new Error('React jsx runtime does not export new jsx transform');
26
26
  }
27
27
 
28
28
  return jsxRuntime.jsx;
@@ -1 +1 @@
1
- {"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntimePackage","jsxRuntime","jsx","Number"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;;;AACA,QAAMC,iBAAiB,GAAGF,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAA3B,GACpB,mBADoB,GAEpB,OAFN,CAZ+B,CAgB/B;AACA;;AACA,QAAMO,UAAU,GAAGN,OAAO,CAACK,iBAAD,CAA1B;;AACA,MAAI,CAACC,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIH,KAAJ,CAAU,kDAAV,CAAN;AACH;;AACD,SAAOE,UAAU,CAACC,GAAlB;AACH,CAvBM;AAyBP;AACA;AACA;;AACA,MAAMJ,2BAA2B,GAAG,CAACL,KAAD,EAAgBC,KAAhB,KAA2C;AAC3E,MAAIS,MAAM,CAACV,KAAD,CAAN,GAAgB,EAApB,EAAwB;AACpB,WAAO,IAAP;AACH;;AACD,MAAIU,MAAM,CAACV,KAAD,CAAN,KAAkB,EAAlB,IAAwBU,MAAM,CAACT,KAAD,CAAN,GAAgB,EAA5C,EAAgD;AAC5C,WAAO,IAAP;AACH;;AACD,SAAO,KAAP;AACH,CARD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const getJsxRuntime = () => {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const [major, minor] = require('react/package.json').version.split('.');\n // We need to check on the version of React before calling require('react/jsx-runtime') as\n // it might crash other exports if the export does not exist (even if there is a try/catch).\n // See: https://github.com/facebook/metro/issues/836\n if (!isJsxExportedInReactVersion(major, minor)) {\n throw new Error('React version does not support new jsx transform');\n }\n\n // React Native does some premature optimizations if the require target is a static string, by making\n // it dynamic we prevent RN from trying to resolve react/jsx-runtime before the function is called\n const jsxRuntimePackage = isJsxExportedInReactVersion(major, minor)\n ? 'react/jsx-runtime'\n : 'react';\n\n // We have to use inline require here because older React versions (below 17) don't have jsx-runtime\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires, import/no-dynamic-require\n const jsxRuntime = require(jsxRuntimePackage);\n if (!jsxRuntime.jsx) {\n throw new Error('React version does not support new jsx transform');\n }\n return jsxRuntime.jsx;\n};\n\n/**\n * JSX Transform is available for React 16.14.0 (last React 16 version) and above\n */\nconst isJsxExportedInReactVersion = (major: string, minor: string): boolean => {\n if (Number(major) > 16) {\n return true;\n }\n if (Number(major) === 16 && Number(minor) > 13) {\n return true;\n }\n return false;\n};\n"]}
1
+ {"version":3,"sources":["getJsxRuntime.ts"],"names":["getJsxRuntime","major","minor","require","version","split","isJsxExportedInReactVersion","Error","jsxRuntimePackage","jsxRuntime","jsx","Number"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,aAAa,GAAG,MAAM;AAC/B;AACA,QAAM,CAACC,KAAD,EAAQC,KAAR,IAAiBC,OAAO,CAAC,oBAAD,CAAP,CAA8BC,OAA9B,CAAsCC,KAAtC,CAA4C,GAA5C,CAAvB,CAF+B,CAG/B;AACA;AACA;;;AACA,MAAI,CAACC,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAAhC,EAAgD;AAC5C,UAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACH,GAR8B,CAU/B;AACA;;;AACA,QAAMC,iBAAiB,GAAGF,2BAA2B,CAACL,KAAD,EAAQC,KAAR,CAA3B,GACpB,mBADoB,GAEpB,OAFN,CAZ+B,CAgB/B;AACA;;AACA,QAAMO,UAAU,GAAGN,OAAO,CAACK,iBAAD,CAA1B;;AACA,MAAI,CAACC,UAAU,CAACC,GAAhB,EAAqB;AACjB,UAAM,IAAIH,KAAJ,CAAU,qDAAV,CAAN;AACH;;AACD,SAAOE,UAAU,CAACC,GAAlB;AACH,CAvBM;AAyBP;AACA;AACA;;AACA,MAAMJ,2BAA2B,GAAG,CAACL,KAAD,EAAgBC,KAAhB,KAA2C;AAC3E,MAAIS,MAAM,CAACV,KAAD,CAAN,GAAgB,EAApB,EAAwB;AACpB,WAAO,IAAP;AACH;;AACD,MAAIU,MAAM,CAACV,KAAD,CAAN,KAAkB,EAAlB,IAAwBU,MAAM,CAACT,KAAD,CAAN,GAAgB,EAA5C,EAAgD;AAC5C,WAAO,IAAP;AACH;;AACD,SAAO,KAAP;AACH,CARD","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nexport const getJsxRuntime = () => {\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires\n const [major, minor] = require('react/package.json').version.split('.');\n // We need to check on the version of React before calling require('react/jsx-runtime') as\n // it might crash other exports if the export does not exist (even if there is a try/catch).\n // See: https://github.com/facebook/metro/issues/836\n if (!isJsxExportedInReactVersion(major, minor)) {\n throw new Error('React version does not support new jsx transform');\n }\n\n // React Native does some premature optimizations if the require target is a static string, by making\n // it dynamic we prevent RN from trying to resolve react/jsx-runtime before the function is called\n const jsxRuntimePackage = isJsxExportedInReactVersion(major, minor)\n ? 'react/jsx-runtime'\n : 'react';\n\n // We have to use inline require here because older React versions (below 17) don't have jsx-runtime\n // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires, import/no-dynamic-require\n const jsxRuntime = require(jsxRuntimePackage);\n if (!jsxRuntime.jsx) {\n throw new Error('React jsx runtime does not export new jsx transform');\n }\n return jsxRuntime.jsx;\n};\n\n/**\n * JSX Transform is available for React 16.14.0 (last React 16 version) and above\n */\nconst isJsxExportedInReactVersion = (major: string, minor: string): boolean => {\n if (Number(major) > 16) {\n return true;\n }\n if (Number(major) === 16 && Number(minor) > 13) {\n return true;\n }\n return false;\n};\n"]}
@@ -8,7 +8,7 @@
8
8
  * A configuration object to initialize Datadog's features.
9
9
  */
10
10
  export class DdSdkConfiguration {
11
- constructor(clientToken, env, applicationId, nativeCrashReportEnabled, sampleRate, site, trackingConsent, additionalConfig) {
11
+ constructor(clientToken, env, applicationId, nativeCrashReportEnabled, sampleRate, site, trackingConsent, additionalConfig, telemetrySampleRate) {
12
12
  this.clientToken = clientToken;
13
13
  this.env = env;
14
14
  this.applicationId = applicationId;
@@ -17,6 +17,7 @@ export class DdSdkConfiguration {
17
17
  this.site = site;
18
18
  this.trackingConsent = trackingConsent;
19
19
  this.additionalConfig = additionalConfig;
20
+ this.telemetrySampleRate = telemetrySampleRate;
20
21
  }
21
22
 
22
23
  }
@@ -1 +1 @@
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;AACA,OAAO,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;AACA,WAAYC,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a;;AA0BZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,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"]}
1
+ {"version":3,"sources":["types.tsx"],"names":["DdSdkConfiguration","constructor","clientToken","env","applicationId","nativeCrashReportEnabled","sampleRate","site","trackingConsent","additionalConfig","telemetrySampleRate","RumActionType","ErrorSource"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,OAAO,MAAMA,kBAAN,CAAyB;AAC5BC,EAAAA,WAAW,CACEC,WADF,EAEEC,GAFF,EAGEC,aAHF,EAIEC,wBAJF,EAKEC,UALF,EAMEC,IANF,EAOEC,eAPF,EAQEC,gBARF,EASEC,mBATF,EAUT;AAAA,SATWR,WASX,GATWA,WASX;AAAA,SARWC,GAQX,GARWA,GAQX;AAAA,SAPWC,aAOX,GAPWA,aAOX;AAAA,SANWC,wBAMX,GANWA,wBAMX;AAAA,SALWC,UAKX,GALWA,UAKX;AAAA,SAJWC,IAIX,GAJWA,IAIX;AAAA,SAHWC,eAGX,GAHWA,eAGX;AAAA,SAFWC,gBAEX,GAFWA,gBAEX;AAAA,SADWC,mBACX,GADWA,mBACX;AAAE;;AAXwB;AAchC;AACA;AACA;;AAqOA;AACA;AACA;AACA,WAAYC,aAAZ;;WAAYA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;AAAAA,EAAAA,a;GAAAA,a,KAAAA,a;;AA0BZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,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 readonly telemetrySampleRate: number\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"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '1.1.4';
2
+ export const version = '1.2.0-beta1';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.1.4';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,aAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.2.0-beta1';\n"]}