@datadog/mobile-react-native-webview 1.8.5 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NativeDdSdk = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ /*
11
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
12
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
13
+ * Copyright 2016-Present Datadog, Inc.
14
+ */
15
+ const NativeDdSdk = _reactNative.TurboModuleRegistry.get('DdSdk');
16
+
17
+ exports.NativeDdSdk = NativeDdSdk;
18
+ //# sourceMappingURL=NativeDdSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["NativeDdSdk.ts"],"names":["NativeDdSdk","TurboModuleRegistry","get"],"mappings":";;;;;;;AAOA;;AAPA;AACA;AACA;AACA;AACA;AAaO,MAAMA,WAAW,GAAGC,iCAAoBC,GAApB,CACvB,OADuB,CAApB","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 { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * We have to redefine the spec for the Native SDK here to be able to use the new architecture.\n * We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.\n */\ninterface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n}\nexport const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>(\n 'DdSdk'\n);\n"]}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.formatAllowedHosts = formatAllowedHosts;
7
7
 
8
- var _reactNative = require("react-native");
8
+ var _NativeDdSdk = require("../NativeDdSdk");
9
9
 
10
10
  /*
11
11
  * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
@@ -16,8 +16,8 @@ function formatAllowedHosts(allowedHosts) {
16
16
  try {
17
17
  return `'${JSON.stringify(allowedHosts)}'`;
18
18
  } catch (e) {
19
- if (_reactNative.NativeModules.DdSdk && _reactNative.NativeModules.DdSdk.telemetryError) {
20
- _reactNative.NativeModules.DdSdk.telemetryError(getErrorMessage(e), getErrorStackTrace(e), 'AllowedHostsError');
19
+ if (_NativeDdSdk.NativeDdSdk) {
20
+ _NativeDdSdk.NativeDdSdk.telemetryError(getErrorMessage(e), getErrorStackTrace(e), 'AllowedHostsError');
21
21
  }
22
22
 
23
23
  return "'[]'";
@@ -1 +1 @@
1
- {"version":3,"sources":["formatAllowedHosts.ts"],"names":["formatAllowedHosts","allowedHosts","JSON","stringify","e","NativeModules","DdSdk","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"mappings":";;;;;;;AAKA;;AALA;AACA;AACA;AACA;AACA;AAGO,SAASA,kBAAT,CAA4BC,YAA5B,EAA6D;AAChE,MAAI;AACA,WAAQ,IAAGC,IAAI,CAACC,SAAL,CAAeF,YAAf,CAA6B,GAAxC;AACH,GAFD,CAEE,OAAOG,CAAP,EAAe;AACb,QAAIC,2BAAcC,KAAd,IAAuBD,2BAAcC,KAAd,CAAoBC,cAA/C,EAA+D;AAC3DF,iCAAcC,KAAd,CAAoBC,cAApB,CACIC,eAAe,CAACJ,CAAD,CADnB,EAEIK,kBAAkB,CAACL,CAAD,CAFtB,EAGI,mBAHJ;AAKH;;AACD,WAAO,MAAP;AACH;AACJ;AAED;AACA;AACA;;;AAEA,MAAMM,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMH,eAAe,GAAII,KAAD,IAAoC;AACxD,MAAIC,OAAO,GAAGH,aAAd;;AACA,MAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGH,aAAV;AACH,GAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXD;;AAaA,MAAMJ,kBAAkB,GAAIG,KAAD,IAAoC;AAC3D,MAAII,KAAK,GAAGL,iBAAZ;;AAEA,MAAI;AACA,QAAIC,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWL,KAAf,EAAsB;AACzBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBJ,KAAxB,EAA+B;AAClCI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeN,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEI,QAAAA,KAAK,GAAI,MAAKJ,KAAK,CAACO,SAAU,IAAGP,KAAK,CAACQ,IAAK,IAAGR,KAAK,CAACS,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOjB,CAAP,EAAU,CACR;AACH;;AACD,SAAOY,KAAP;AACH,CA3BD","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 */\nimport { NativeModules } from 'react-native';\n\nexport function formatAllowedHosts(allowedHosts?: string[]): string {\n try {\n return `'${JSON.stringify(allowedHosts)}'`;\n } catch (e: any) {\n if (NativeModules.DdSdk && NativeModules.DdSdk.telemetryError) {\n NativeModules.DdSdk.telemetryError(\n getErrorMessage(e),\n getErrorStackTrace(e),\n 'AllowedHostsError'\n );\n }\n return \"'[]'\";\n }\n}\n\n/**\n * The next section is copied from packages/core/src/errorUtils\n */\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\nconst 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\nconst getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
1
+ {"version":3,"sources":["formatAllowedHosts.ts"],"names":["formatAllowedHosts","allowedHosts","JSON","stringify","e","NativeDdSdk","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"mappings":";;;;;;;AAKA;;AALA;AACA;AACA;AACA;AACA;AAGO,SAASA,kBAAT,CAA4BC,YAA5B,EAA6D;AAChE,MAAI;AACA,WAAQ,IAAGC,IAAI,CAACC,SAAL,CAAeF,YAAf,CAA6B,GAAxC;AACH,GAFD,CAEE,OAAOG,CAAP,EAAe;AACb,QAAIC,wBAAJ,EAAiB;AACbA,+BAAYC,cAAZ,CACIC,eAAe,CAACH,CAAD,CADnB,EAEII,kBAAkB,CAACJ,CAAD,CAFtB,EAGI,mBAHJ;AAKH;;AACD,WAAO,MAAP;AACH;AACJ;AAED;AACA;AACA;;;AAEA,MAAMK,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMH,eAAe,GAAII,KAAD,IAAoC;AACxD,MAAIC,OAAO,GAAGH,aAAd;;AACA,MAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGH,aAAV;AACH,GAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXD;;AAaA,MAAMJ,kBAAkB,GAAIG,KAAD,IAAoC;AAC3D,MAAII,KAAK,GAAGL,iBAAZ;;AAEA,MAAI;AACA,QAAIC,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWL,KAAf,EAAsB;AACzBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBJ,KAAxB,EAA+B;AAClCI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeN,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEI,QAAAA,KAAK,GAAI,MAAKJ,KAAK,CAACO,SAAU,IAAGP,KAAK,CAACQ,IAAK,IAAGR,KAAK,CAACS,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOhB,CAAP,EAAU,CACR;AACH;;AACD,SAAOW,KAAP;AACH,CA3BD","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 */\nimport { NativeDdSdk } from '../NativeDdSdk';\n\nexport function formatAllowedHosts(allowedHosts?: string[]): string {\n try {\n return `'${JSON.stringify(allowedHosts)}'`;\n } catch (e: any) {\n if (NativeDdSdk) {\n NativeDdSdk.telemetryError(\n getErrorMessage(e),\n getErrorStackTrace(e),\n 'AllowedHostsError'\n );\n }\n return \"'[]'\";\n }\n}\n\n/**\n * The next section is copied from packages/core/src/errorUtils\n */\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\nconst 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\nconst getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
@@ -7,10 +7,10 @@ exports.default = exports.WebView = void 0;
7
7
 
8
8
  var _reactNativeWebview = require("react-native-webview");
9
9
 
10
- var _reactNative = require("react-native");
11
-
12
10
  var _react = _interopRequireWildcard(require("react"));
13
11
 
12
+ var _NativeDdSdk = require("./NativeDdSdk");
13
+
14
14
  var _getInjectedJavaScriptBeforeContentLoaded = require("./__utils__/getInjectedJavaScriptBeforeContentLoaded");
15
15
 
16
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -25,7 +25,7 @@ const WebViewComponent = (props, ref) => {
25
25
  const message = event.nativeEvent.data;
26
26
 
27
27
  if (message.startsWith(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX)) {
28
- NativeDdSdk === null || NativeDdSdk === void 0 ? void 0 : NativeDdSdk.consumeWebviewEvent(message.substring(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX.length + 1));
28
+ _NativeDdSdk.NativeDdSdk === null || _NativeDdSdk.NativeDdSdk === void 0 ? void 0 : _NativeDdSdk.NativeDdSdk.consumeWebviewEvent(message.substring(_getInjectedJavaScriptBeforeContentLoaded.DATADOG_MESSAGE_PREFIX.length + 1));
29
29
  } else {
30
30
  userDefinedOnMessage === null || userDefinedOnMessage === void 0 ? void 0 : userDefinedOnMessage(event);
31
31
  }
@@ -40,12 +40,5 @@ const WebViewComponent = (props, ref) => {
40
40
  const WebView = /*#__PURE__*/(0, _react.forwardRef)(WebViewComponent);
41
41
  exports.WebView = WebView;
42
42
  var _default = WebView;
43
- /**
44
- * We have to redefine the spec for the Native SDK here to be able to use the new architecture.
45
- * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.
46
- */
47
-
48
43
  exports.default = _default;
49
-
50
- const NativeDdSdk = _reactNative.TurboModuleRegistry.get('DdSdk');
51
44
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","DATADOG_MESSAGE_PREFIX","NativeDdSdk","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded","WebView","TurboModuleRegistry","get"],"mappings":";;;;;;;AAMA;;AAEA;;AACA;;AAEA;;;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CAACC,KAAD,EAAeC,GAAf,KAAoD;AACzE,QAAMC,oBAAoB,GAAGF,KAAK,CAACG,SAAnC;AACA,QAAMA,SAAS,GAAG,wBACbC,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBC,gEAAnB,CAAJ,EAAgD;AAC5CC,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEC,mBAAb,CACIN,OAAO,CAACO,SAAR,CAAkBH,iEAAuBI,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHX,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVa,EAWd,CAACF,oBAAD,CAXc,CAAlB;AAaA,sBACI,6BAAC,2BAAD,eACQF,KADR;AAEI,IAAA,SAAS,EAAEG,SAFf;AAGI,IAAA,qCAAqC,EAAE,wFACnCH,KAAK,CAACc,YAD6B,EAEnCd,KAAK,CAACe,qCAF6B,CAH3C;AAOI,IAAA,GAAG,EAAEd;AAPT,KADJ;AAWH,CA1BD;;AA4BO,MAAMe,OAAO,gBAAG,uBAAWjB,gBAAX,CAAhB;;eAEQiB,O;AAEf;AACA;AACA;AACA;;;;AAIA,MAAMN,WAAW,GAAGO,iCAAoBC,GAApB,CAAgD,OAAhD,CAApB","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 */\nimport type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';\nimport { WebView as RNWebView } from 'react-native-webview';\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\nimport React, { forwardRef, useCallback } from 'react';\n\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nconst WebViewComponent = (props: Props, ref: React.Ref<RNWebView<Props>>) => {\n const userDefinedOnMessage = props.onMessage;\n const onMessage = useCallback(\n (event: WebViewMessageEvent) => {\n const message = event.nativeEvent.data;\n if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {\n NativeDdSdk?.consumeWebviewEvent(\n message.substring(DATADOG_MESSAGE_PREFIX.length + 1)\n );\n } else {\n userDefinedOnMessage?.(event);\n }\n },\n [userDefinedOnMessage]\n );\n return (\n <RNWebView\n {...props}\n onMessage={onMessage}\n injectedJavaScriptBeforeContentLoaded={getInjectedJavaScriptBeforeContentLoaded(\n props.allowedHosts,\n props.injectedJavaScriptBeforeContentLoaded\n )}\n ref={ref}\n />\n );\n};\n\nexport const WebView = forwardRef(WebViewComponent);\n\nexport default WebView;\n\n/**\n * We have to redefine the spec for the Native SDK here to be able to use the new architecture.\n * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.\n */\ninterface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n}\nconst NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>('DdSdk');\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","DATADOG_MESSAGE_PREFIX","NativeDdSdk","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded","WebView"],"mappings":";;;;;;;AAMA;;AACA;;AAEA;;AACA;;;;;;;;AAUA,MAAMA,gBAAgB,GAAG,CAACC,KAAD,EAAeC,GAAf,KAAoD;AACzE,QAAMC,oBAAoB,GAAGF,KAAK,CAACG,SAAnC;AACA,QAAMA,SAAS,GAAG,wBACbC,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBC,gEAAnB,CAAJ,EAAgD;AAC5CC,mHAAaC,mBAAb,CACIN,OAAO,CAACO,SAAR,CAAkBH,iEAAuBI,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHX,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVa,EAWd,CAACF,oBAAD,CAXc,CAAlB;AAaA,sBACI,6BAAC,2BAAD,eACQF,KADR;AAEI,IAAA,SAAS,EAAEG,SAFf;AAGI,IAAA,qCAAqC,EAAE,wFACnCH,KAAK,CAACc,YAD6B,EAEnCd,KAAK,CAACe,qCAF6B,CAH3C;AAOI,IAAA,GAAG,EAAEd;AAPT,KADJ;AAWH,CA1BD;;AA4BO,MAAMe,OAAO,gBAAG,uBAAWjB,gBAAX,CAAhB;;eAEQiB,O","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 */\nimport type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';\nimport { WebView as RNWebView } from 'react-native-webview';\nimport React, { forwardRef, useCallback } from 'react';\n\nimport { NativeDdSdk } from './NativeDdSdk';\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nconst WebViewComponent = (props: Props, ref: React.Ref<RNWebView<Props>>) => {\n const userDefinedOnMessage = props.onMessage;\n const onMessage = useCallback(\n (event: WebViewMessageEvent) => {\n const message = event.nativeEvent.data;\n if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {\n NativeDdSdk?.consumeWebviewEvent(\n message.substring(DATADOG_MESSAGE_PREFIX.length + 1)\n );\n } else {\n userDefinedOnMessage?.(event);\n }\n },\n [userDefinedOnMessage]\n );\n return (\n <RNWebView\n {...props}\n onMessage={onMessage}\n injectedJavaScriptBeforeContentLoaded={getInjectedJavaScriptBeforeContentLoaded(\n props.allowedHosts,\n props.injectedJavaScriptBeforeContentLoaded\n )}\n ref={ref}\n />\n );\n};\n\nexport const WebView = forwardRef(WebViewComponent);\n\nexport default WebView;\n"]}
@@ -0,0 +1,13 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+ import { TurboModuleRegistry } from 'react-native';
7
+ /**
8
+ * We have to redefine the spec for the Native SDK here to be able to use the new architecture.
9
+ * We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.
10
+ */
11
+
12
+ export const NativeDdSdk = TurboModuleRegistry.get('DdSdk');
13
+ //# sourceMappingURL=NativeDdSdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["NativeDdSdk.ts"],"names":["TurboModuleRegistry","NativeDdSdk","get"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAGA,SAASA,mBAAT,QAAoC,cAApC;AAEA;AACA;AACA;AACA;;AAKA,OAAO,MAAMC,WAAW,GAAGD,mBAAmB,CAACE,GAApB,CACvB,OADuB,CAApB","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 { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\n\n/**\n * We have to redefine the spec for the Native SDK here to be able to use the new architecture.\n * We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.\n */\ninterface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n telemetryError(message: string, stack: string, kind: string): Promise<void>;\n}\nexport const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>(\n 'DdSdk'\n);\n"]}
@@ -3,13 +3,13 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
- import { NativeModules } from 'react-native';
6
+ import { NativeDdSdk } from '../NativeDdSdk';
7
7
  export function formatAllowedHosts(allowedHosts) {
8
8
  try {
9
9
  return `'${JSON.stringify(allowedHosts)}'`;
10
10
  } catch (e) {
11
- if (NativeModules.DdSdk && NativeModules.DdSdk.telemetryError) {
12
- NativeModules.DdSdk.telemetryError(getErrorMessage(e), getErrorStackTrace(e), 'AllowedHostsError');
11
+ if (NativeDdSdk) {
12
+ NativeDdSdk.telemetryError(getErrorMessage(e), getErrorStackTrace(e), 'AllowedHostsError');
13
13
  }
14
14
 
15
15
  return "'[]'";
@@ -1 +1 @@
1
- {"version":3,"sources":["formatAllowedHosts.ts"],"names":["NativeModules","formatAllowedHosts","allowedHosts","JSON","stringify","e","DdSdk","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,cAA9B;AAEA,OAAO,SAASC,kBAAT,CAA4BC,YAA5B,EAA6D;AAChE,MAAI;AACA,WAAQ,IAAGC,IAAI,CAACC,SAAL,CAAeF,YAAf,CAA6B,GAAxC;AACH,GAFD,CAEE,OAAOG,CAAP,EAAe;AACb,QAAIL,aAAa,CAACM,KAAd,IAAuBN,aAAa,CAACM,KAAd,CAAoBC,cAA/C,EAA+D;AAC3DP,MAAAA,aAAa,CAACM,KAAd,CAAoBC,cAApB,CACIC,eAAe,CAACH,CAAD,CADnB,EAEII,kBAAkB,CAACJ,CAAD,CAFtB,EAGI,mBAHJ;AAKH;;AACD,WAAO,MAAP;AACH;AACJ;AAED;AACA;AACA;;AAEA,MAAMK,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMH,eAAe,GAAII,KAAD,IAAoC;AACxD,MAAIC,OAAO,GAAGH,aAAd;;AACA,MAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGH,aAAV;AACH,GAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXD;;AAaA,MAAMJ,kBAAkB,GAAIG,KAAD,IAAoC;AAC3D,MAAII,KAAK,GAAGL,iBAAZ;;AAEA,MAAI;AACA,QAAIC,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWL,KAAf,EAAsB;AACzBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBJ,KAAxB,EAA+B;AAClCI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeN,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEI,QAAAA,KAAK,GAAI,MAAKJ,KAAK,CAACO,SAAU,IAAGP,KAAK,CAACQ,IAAK,IAAGR,KAAK,CAACS,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOhB,CAAP,EAAU,CACR;AACH;;AACD,SAAOW,KAAP;AACH,CA3BD","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 */\nimport { NativeModules } from 'react-native';\n\nexport function formatAllowedHosts(allowedHosts?: string[]): string {\n try {\n return `'${JSON.stringify(allowedHosts)}'`;\n } catch (e: any) {\n if (NativeModules.DdSdk && NativeModules.DdSdk.telemetryError) {\n NativeModules.DdSdk.telemetryError(\n getErrorMessage(e),\n getErrorStackTrace(e),\n 'AllowedHostsError'\n );\n }\n return \"'[]'\";\n }\n}\n\n/**\n * The next section is copied from packages/core/src/errorUtils\n */\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\nconst 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\nconst getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
1
+ {"version":3,"sources":["formatAllowedHosts.ts"],"names":["NativeDdSdk","formatAllowedHosts","allowedHosts","JSON","stringify","e","telemetryError","getErrorMessage","getErrorStackTrace","EMPTY_MESSAGE","EMPTY_STACK_TRACE","error","message","undefined","String","stack","stacktrace","componentStack","sourceURL","line","column"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,gBAA5B;AAEA,OAAO,SAASC,kBAAT,CAA4BC,YAA5B,EAA6D;AAChE,MAAI;AACA,WAAQ,IAAGC,IAAI,CAACC,SAAL,CAAeF,YAAf,CAA6B,GAAxC;AACH,GAFD,CAEE,OAAOG,CAAP,EAAe;AACb,QAAIL,WAAJ,EAAiB;AACbA,MAAAA,WAAW,CAACM,cAAZ,CACIC,eAAe,CAACF,CAAD,CADnB,EAEIG,kBAAkB,CAACH,CAAD,CAFtB,EAGI,mBAHJ;AAKH;;AACD,WAAO,MAAP;AACH;AACJ;AAED;AACA;AACA;;AAEA,MAAMI,aAAa,GAAG,eAAtB;AACA,MAAMC,iBAAiB,GAAG,EAA1B;;AAEA,MAAMH,eAAe,GAAII,KAAD,IAAoC;AACxD,MAAIC,OAAO,GAAGH,aAAd;;AACA,MAAIE,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCC,IAAAA,OAAO,GAAGH,aAAV;AACH,GAFD,MAEO,IAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6B,aAAaA,KAA9C,EAAqD;AACxDC,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAK,CAACC,OAAP,CAAhB;AACH,GAFM,MAEA;AACHA,IAAAA,OAAO,GAAGE,MAAM,CAACH,KAAD,CAAhB;AACH;;AAED,SAAOC,OAAP;AACH,CAXD;;AAaA,MAAMJ,kBAAkB,GAAIG,KAAD,IAAoC;AAC3D,MAAII,KAAK,GAAGL,iBAAZ;;AAEA,MAAI;AACA,QAAIC,KAAK,KAAKE,SAAV,IAAuBF,KAAK,KAAK,IAArC,EAA2C;AACvCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFD,MAEO,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClCI,MAAAA,KAAK,GAAGL,iBAAR;AACH,KAFM,MAEA,IAAI,OAAOC,KAAP,KAAiB,QAArB,EAA+B;AAClC,UAAI,gBAAgBA,KAApB,EAA2B;AACvBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACK,UAAP,CAAd;AACH,OAFD,MAEO,IAAI,WAAWL,KAAf,EAAsB;AACzBI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACI,KAAP,CAAd;AACH,OAFM,MAEA,IAAI,oBAAoBJ,KAAxB,EAA+B;AAClCI,QAAAA,KAAK,GAAGD,MAAM,CAACH,KAAK,CAACM,cAAP,CAAd;AACH,OAFM,MAEA,IACH,eAAeN,KAAf,IACA,UAAUA,KADV,IAEA,YAAYA,KAHT,EAIL;AACEI,QAAAA,KAAK,GAAI,MAAKJ,KAAK,CAACO,SAAU,IAAGP,KAAK,CAACQ,IAAK,IAAGR,KAAK,CAACS,MAAO,EAA5D;AACH;AACJ;AACJ,GApBD,CAoBE,OAAOf,CAAP,EAAU,CACR;AACH;;AACD,SAAOU,KAAP;AACH,CA3BD","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 */\nimport { NativeDdSdk } from '../NativeDdSdk';\n\nexport function formatAllowedHosts(allowedHosts?: string[]): string {\n try {\n return `'${JSON.stringify(allowedHosts)}'`;\n } catch (e: any) {\n if (NativeDdSdk) {\n NativeDdSdk.telemetryError(\n getErrorMessage(e),\n getErrorStackTrace(e),\n 'AllowedHostsError'\n );\n }\n return \"'[]'\";\n }\n}\n\n/**\n * The next section is copied from packages/core/src/errorUtils\n */\n\nconst EMPTY_MESSAGE = 'Unknown Error';\nconst EMPTY_STACK_TRACE = '';\n\nconst 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\nconst getErrorStackTrace = (error: any | undefined): string => {\n let stack = EMPTY_STACK_TRACE;\n\n try {\n if (error === undefined || error === null) {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'string') {\n stack = EMPTY_STACK_TRACE;\n } else if (typeof error === 'object') {\n if ('stacktrace' in error) {\n stack = String(error.stacktrace);\n } else if ('stack' in error) {\n stack = String(error.stack);\n } else if ('componentStack' in error) {\n stack = String(error.componentStack);\n } else if (\n 'sourceURL' in error &&\n 'line' in error &&\n 'column' in error\n ) {\n stack = `at ${error.sourceURL}:${error.line}:${error.column}`;\n }\n }\n } catch (e) {\n // Do nothing\n }\n return stack;\n};\n"]}
@@ -6,8 +6,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
6
6
  * Copyright 2016-Present Datadog, Inc.
7
7
  */
8
8
  import { WebView as RNWebView } from 'react-native-webview';
9
- import { TurboModuleRegistry } from 'react-native';
10
9
  import React, { forwardRef, useCallback } from 'react';
10
+ import { NativeDdSdk } from './NativeDdSdk';
11
11
  import { DATADOG_MESSAGE_PREFIX, getInjectedJavaScriptBeforeContentLoaded } from './__utils__/getInjectedJavaScriptBeforeContentLoaded';
12
12
 
13
13
  const WebViewComponent = (props, ref) => {
@@ -30,10 +30,4 @@ const WebViewComponent = (props, ref) => {
30
30
 
31
31
  export const WebView = /*#__PURE__*/forwardRef(WebViewComponent);
32
32
  export default WebView;
33
- /**
34
- * We have to redefine the spec for the Native SDK here to be able to use the new architecture.
35
- * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.
36
- */
37
-
38
- const NativeDdSdk = TurboModuleRegistry.get('DdSdk');
39
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["WebView","RNWebView","TurboModuleRegistry","React","forwardRef","useCallback","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","NativeDdSdk","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded","get"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,OAAO,IAAIC,SAApB,QAAqC,sBAArC;AAEA,SAASC,mBAAT,QAAoC,cAApC;AACA,OAAOC,KAAP,IAAgBC,UAAhB,EAA4BC,WAA5B,QAA+C,OAA/C;AAEA,SACIC,sBADJ,EAEIC,wCAFJ,QAGO,sDAHP;;AAUA,MAAMC,gBAAgB,GAAG,CAACC,KAAD,EAAeC,GAAf,KAAoD;AACzE,QAAMC,oBAAoB,GAAGF,KAAK,CAACG,SAAnC;AACA,QAAMA,SAAS,GAAGP,WAAW,CACxBQ,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBX,sBAAnB,CAAJ,EAAgD;AAC5CY,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEC,mBAAb,CACIL,OAAO,CAACM,SAAR,CAAkBd,sBAAsB,CAACe,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHV,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVwB,EAWzB,CAACF,oBAAD,CAXyB,CAA7B;AAaA,sBACI,oBAAC,SAAD,eACQF,KADR;AAEI,IAAA,SAAS,EAAEG,SAFf;AAGI,IAAA,qCAAqC,EAAEL,wCAAwC,CAC3EE,KAAK,CAACa,YADqE,EAE3Eb,KAAK,CAACc,qCAFqE,CAHnF;AAOI,IAAA,GAAG,EAAEb;AAPT,KADJ;AAWH,CA1BD;;AA4BA,OAAO,MAAMV,OAAO,gBAAGI,UAAU,CAACI,gBAAD,CAA1B;AAEP,eAAeR,OAAf;AAEA;AACA;AACA;AACA;;AAIA,MAAMkB,WAAW,GAAGhB,mBAAmB,CAACsB,GAApB,CAAgD,OAAhD,CAApB","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 */\nimport type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';\nimport { WebView as RNWebView } from 'react-native-webview';\nimport type { TurboModule } from 'react-native';\nimport { TurboModuleRegistry } from 'react-native';\nimport React, { forwardRef, useCallback } from 'react';\n\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nconst WebViewComponent = (props: Props, ref: React.Ref<RNWebView<Props>>) => {\n const userDefinedOnMessage = props.onMessage;\n const onMessage = useCallback(\n (event: WebViewMessageEvent) => {\n const message = event.nativeEvent.data;\n if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {\n NativeDdSdk?.consumeWebviewEvent(\n message.substring(DATADOG_MESSAGE_PREFIX.length + 1)\n );\n } else {\n userDefinedOnMessage?.(event);\n }\n },\n [userDefinedOnMessage]\n );\n return (\n <RNWebView\n {...props}\n onMessage={onMessage}\n injectedJavaScriptBeforeContentLoaded={getInjectedJavaScriptBeforeContentLoaded(\n props.allowedHosts,\n props.injectedJavaScriptBeforeContentLoaded\n )}\n ref={ref}\n />\n );\n};\n\nexport const WebView = forwardRef(WebViewComponent);\n\nexport default WebView;\n\n/**\n * We have to redefine the spec for the Native SDK here to be able to use the new architecture.\n * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.\n */\ninterface PartialNativeDdSdkSpec extends TurboModule {\n consumeWebviewEvent(message: string): Promise<void>;\n}\nconst NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>('DdSdk');\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["WebView","RNWebView","React","forwardRef","useCallback","NativeDdSdk","DATADOG_MESSAGE_PREFIX","getInjectedJavaScriptBeforeContentLoaded","WebViewComponent","props","ref","userDefinedOnMessage","onMessage","event","message","nativeEvent","data","startsWith","consumeWebviewEvent","substring","length","allowedHosts","injectedJavaScriptBeforeContentLoaded"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,OAAO,IAAIC,SAApB,QAAqC,sBAArC;AACA,OAAOC,KAAP,IAAgBC,UAAhB,EAA4BC,WAA5B,QAA+C,OAA/C;AAEA,SAASC,WAAT,QAA4B,eAA5B;AACA,SACIC,sBADJ,EAEIC,wCAFJ,QAGO,sDAHP;;AAUA,MAAMC,gBAAgB,GAAG,CAACC,KAAD,EAAeC,GAAf,KAAoD;AACzE,QAAMC,oBAAoB,GAAGF,KAAK,CAACG,SAAnC;AACA,QAAMA,SAAS,GAAGR,WAAW,CACxBS,KAAD,IAAgC;AAC5B,UAAMC,OAAO,GAAGD,KAAK,CAACE,WAAN,CAAkBC,IAAlC;;AACA,QAAIF,OAAO,CAACG,UAAR,CAAmBX,sBAAnB,CAAJ,EAAgD;AAC5CD,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEa,mBAAb,CACIJ,OAAO,CAACK,SAAR,CAAkBb,sBAAsB,CAACc,MAAvB,GAAgC,CAAlD,CADJ;AAGH,KAJD,MAIO;AACHT,MAAAA,oBAAoB,SAApB,IAAAA,oBAAoB,WAApB,YAAAA,oBAAoB,CAAGE,KAAH,CAApB;AACH;AACJ,GAVwB,EAWzB,CAACF,oBAAD,CAXyB,CAA7B;AAaA,sBACI,oBAAC,SAAD,eACQF,KADR;AAEI,IAAA,SAAS,EAAEG,SAFf;AAGI,IAAA,qCAAqC,EAAEL,wCAAwC,CAC3EE,KAAK,CAACY,YADqE,EAE3EZ,KAAK,CAACa,qCAFqE,CAHnF;AAOI,IAAA,GAAG,EAAEZ;AAPT,KADJ;AAWH,CA1BD;;AA4BA,OAAO,MAAMV,OAAO,gBAAGG,UAAU,CAACK,gBAAD,CAA1B;AAEP,eAAeR,OAAf","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 */\nimport type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';\nimport { WebView as RNWebView } from 'react-native-webview';\nimport React, { forwardRef, useCallback } from 'react';\n\nimport { NativeDdSdk } from './NativeDdSdk';\nimport {\n DATADOG_MESSAGE_PREFIX,\n getInjectedJavaScriptBeforeContentLoaded\n} from './__utils__/getInjectedJavaScriptBeforeContentLoaded';\n\ntype Props = WebViewProps & {\n allowedHosts?: string[];\n injectedJavaScriptBeforeContentLoaded?: string;\n};\n\nconst WebViewComponent = (props: Props, ref: React.Ref<RNWebView<Props>>) => {\n const userDefinedOnMessage = props.onMessage;\n const onMessage = useCallback(\n (event: WebViewMessageEvent) => {\n const message = event.nativeEvent.data;\n if (message.startsWith(DATADOG_MESSAGE_PREFIX)) {\n NativeDdSdk?.consumeWebviewEvent(\n message.substring(DATADOG_MESSAGE_PREFIX.length + 1)\n );\n } else {\n userDefinedOnMessage?.(event);\n }\n },\n [userDefinedOnMessage]\n );\n return (\n <RNWebView\n {...props}\n onMessage={onMessage}\n injectedJavaScriptBeforeContentLoaded={getInjectedJavaScriptBeforeContentLoaded(\n props.allowedHosts,\n props.injectedJavaScriptBeforeContentLoaded\n )}\n ref={ref}\n />\n );\n};\n\nexport const WebView = forwardRef(WebViewComponent);\n\nexport default WebView;\n"]}
@@ -0,0 +1,11 @@
1
+ import type { TurboModule } from 'react-native';
2
+ /**
3
+ * We have to redefine the spec for the Native SDK here to be able to use the new architecture.
4
+ * We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.
5
+ */
6
+ interface PartialNativeDdSdkSpec extends TurboModule {
7
+ consumeWebviewEvent(message: string): Promise<void>;
8
+ telemetryError(message: string, stack: string, kind: string): Promise<void>;
9
+ }
10
+ export declare const NativeDdSdk: PartialNativeDdSdkSpec | null;
11
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-webview",
3
- "version": "1.8.5",
3
+ "version": "1.9.0",
4
4
  "description": "A client-side React Native module to interact with react-native-webview and Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -71,5 +71,5 @@
71
71
  ]
72
72
  ]
73
73
  },
74
- "gitHead": "f2333b854e3a8b6e0bc36d62b3ea9759fac9f56d"
74
+ "gitHead": "83bae8e19d5a0a84fd57bdeea2b0b49009cdbeb5"
75
75
  }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import type { TurboModule } from 'react-native';
8
+ import { TurboModuleRegistry } from 'react-native';
9
+
10
+ /**
11
+ * We have to redefine the spec for the Native SDK here to be able to use the new architecture.
12
+ * We don't declare it in a spec file so we don't end up with a duplicate definition of the native module.
13
+ */
14
+ interface PartialNativeDdSdkSpec extends TurboModule {
15
+ consumeWebviewEvent(message: string): Promise<void>;
16
+ telemetryError(message: string, stack: string, kind: string): Promise<void>;
17
+ }
18
+ export const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>(
19
+ 'DdSdk'
20
+ );
@@ -3,14 +3,14 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
- import { NativeModules } from 'react-native';
6
+ import { NativeDdSdk } from '../NativeDdSdk';
7
7
 
8
8
  export function formatAllowedHosts(allowedHosts?: string[]): string {
9
9
  try {
10
10
  return `'${JSON.stringify(allowedHosts)}'`;
11
11
  } catch (e: any) {
12
- if (NativeModules.DdSdk && NativeModules.DdSdk.telemetryError) {
13
- NativeModules.DdSdk.telemetryError(
12
+ if (NativeDdSdk) {
13
+ NativeDdSdk.telemetryError(
14
14
  getErrorMessage(e),
15
15
  getErrorStackTrace(e),
16
16
  'AllowedHostsError'
package/src/index.tsx CHANGED
@@ -5,10 +5,9 @@
5
5
  */
6
6
  import type { WebViewMessageEvent, WebViewProps } from 'react-native-webview';
7
7
  import { WebView as RNWebView } from 'react-native-webview';
8
- import type { TurboModule } from 'react-native';
9
- import { TurboModuleRegistry } from 'react-native';
10
8
  import React, { forwardRef, useCallback } from 'react';
11
9
 
10
+ import { NativeDdSdk } from './NativeDdSdk';
12
11
  import {
13
12
  DATADOG_MESSAGE_PREFIX,
14
13
  getInjectedJavaScriptBeforeContentLoaded
@@ -50,12 +49,3 @@ const WebViewComponent = (props: Props, ref: React.Ref<RNWebView<Props>>) => {
50
49
  export const WebView = forwardRef(WebViewComponent);
51
50
 
52
51
  export default WebView;
53
-
54
- /**
55
- * We have to redefine the spec for the Native SDK here to be able to use the new architecture.
56
- * We don't declare it in a separate file so we don't end up with a duplicate definition of the native module.
57
- */
58
- interface PartialNativeDdSdkSpec extends TurboModule {
59
- consumeWebviewEvent(message: string): Promise<void>;
60
- }
61
- const NativeDdSdk = TurboModuleRegistry.get<PartialNativeDdSdkSpec>('DdSdk');