@datadog/mobile-react-native-navigation 1.0.0-beta4 → 1.0.0-rc4

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 (27) hide show
  1. package/README.md +38 -1
  2. package/lib/commonjs/index.js +8 -4
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/rum/instrumentation/DdRumReactNativeNavigationTracking.js +20 -6
  5. package/lib/commonjs/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
  6. package/lib/module/index.js +2 -2
  7. package/lib/module/index.js.map +1 -1
  8. package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js +19 -6
  9. package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
  10. package/lib/typescript/core/src/DdSdkReactNative.d.ts +11 -0
  11. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +6 -0
  12. package/lib/typescript/core/src/NativeSdkVerbosity.d.ts +9 -0
  13. package/lib/typescript/core/src/ProxyConfiguration.d.ts +56 -0
  14. package/lib/typescript/core/src/Timer.d.ts +20 -0
  15. package/lib/typescript/core/src/index.d.ts +2 -1
  16. package/lib/typescript/core/src/rum/instrumentation/DdEventsInterceptor.d.ts +2 -0
  17. package/lib/typescript/core/src/rum/instrumentation/DdRumErrorTracking.d.ts +2 -0
  18. package/lib/typescript/core/src/rum/instrumentation/DdRumResourceTracking.d.ts +4 -0
  19. package/lib/typescript/core/src/rum/instrumentation/DdRumXhr.d.ts +2 -2
  20. package/lib/typescript/core/src/types.d.ts +25 -24
  21. package/lib/typescript/core/src/version.d.ts +1 -0
  22. package/lib/typescript/react-native-navigation/src/index.d.ts +2 -2
  23. package/lib/typescript/react-native-navigation/src/rum/instrumentation/DdRumReactNativeNavigationTracking.d.ts +5 -2
  24. package/package.json +6 -10
  25. package/src/__tests__/rum/instrumentation/DdRumReactNativeNavigationTracking.test.tsx +161 -0
  26. package/src/index.tsx +2 -2
  27. package/src/rum/instrumentation/DdRumReactNativeNavigationTracking.tsx +13 -6
package/README.md CHANGED
@@ -1 +1,38 @@
1
- DataDog React Native SDK `react-native-navigation` support component
1
+ # React-Native Monitoring for `react-native-navigation` components
2
+
3
+ Datadog *Real User Monitoring (RUM)* enables you to visualize and analyze the real-time performance and user journeys of your application’s individual users. This specific package adds support to the [`react-native-navigation`][1] library.
4
+
5
+ ## Setup
6
+
7
+ **Note**: This package is an integration for [`react-native-navigation`][1] library, please make sure you first install and setup the core [`mobile-react-native`][2] SDK.
8
+
9
+ To install with NPM, run:
10
+
11
+ ```sh
12
+ npm install @datadog/mobile-react-native-navigation
13
+ ```
14
+
15
+ To install with Yarn, run:
16
+
17
+ ```sh
18
+ yarn add @datadog/mobile-react-native-navigation
19
+ ```
20
+
21
+ ### Track view navigation
22
+
23
+ In order to start tracking your navigation events, simply call the add the following lines before setting up your navigation. You can use the optional `ViewNamePredicate` callback to replace the automatically detected View name with something more relevant to your use case, based on the [`ComponentDidAppearEvent`][3].
24
+
25
+ ```js
26
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from '@datadog/mobile-react-native-navigation';
27
+ import { ComponentDidAppearEvent } from 'react-native-navigation';
28
+
29
+ const viewNamePredicate: ViewNamePredicate = function customViewNamePredicate(event: ComponentDidAppearEvent, trackedName: string) {
30
+ return "My custom View Name"
31
+ }
32
+
33
+ DdRumReactNativeNavigationTracking.startTracking(viewNamePredicate);
34
+ ```
35
+
36
+ [1]: https://github.com/wix/react-native-navigation
37
+ [2]: https://github.com/DataDog/dd-sdk-reactnative/tree/main/packages/core
38
+ [3]: https://wix.github.io/react-native-navigation/api/events/#componentdidappear
@@ -6,11 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "DdRumReactNativeNavigationTracking", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _DdRumReactNativeNavigationTracking.default;
9
+ return _DdRumReactNativeNavigationTracking.DdRumReactNativeNavigationTracking;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ViewNamePredicate", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _DdRumReactNativeNavigationTracking.ViewNamePredicate;
10
16
  }
11
17
  });
12
18
 
13
- var _DdRumReactNativeNavigationTracking = _interopRequireDefault(require("./rum/instrumentation/DdRumReactNativeNavigationTracking"));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ var _DdRumReactNativeNavigationTracking = require("./rum/instrumentation/DdRumReactNativeNavigationTracking");
16
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAMA","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 DdRumReactNativeNavigationTracking from './rum/instrumentation/DdRumReactNativeNavigationTracking';\n\nexport { DdRumReactNativeNavigationTracking };\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA","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 { DdRumReactNativeNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNativeNavigationTracking';\n\nexport { DdRumReactNativeNavigationTracking, ViewNamePredicate };\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.DdRumReactNativeNavigationTracking = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -22,7 +22,9 @@ class DdRumReactNativeNavigationTracking {
22
22
  /**
23
23
  * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
24
24
  */
25
- static startTracking() {
25
+ static startTracking(viewNamePredicate = function (_event, trackedName) {
26
+ return trackedName;
27
+ }) {
26
28
  // extra safety to avoid wrapping more than 1 time this function
27
29
  if (DdRumReactNativeNavigationTracking.isTracking) {
28
30
  return;
@@ -32,15 +34,20 @@ class DdRumReactNativeNavigationTracking {
32
34
  DdRumReactNativeNavigationTracking.originalCreateElement = original;
33
35
 
34
36
  _react.default.createElement = (element, props, ...children) => {
35
- if (props.componentId != undefined && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)) {
37
+ if (props && props.componentId != undefined && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)) {
36
38
  const componentId = props.componentId;
37
39
 
38
40
  _reactNativeNavigation.Navigation.events().registerComponentListener({
39
41
  componentDidAppear: event => {
40
- _mobileReactNative.DdRum.startView(componentId, event.componentName, Date.now(), {});
42
+ var _predicate;
43
+
44
+ const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;
45
+ const screenName = (_predicate = predicate(event, event.componentName)) !== null && _predicate !== void 0 ? _predicate : event.componentName;
46
+
47
+ _mobileReactNative.DdRum.startView(componentId, screenName);
41
48
  },
42
49
  componentDidDisappear: () => {
43
- _mobileReactNative.DdRum.stopView(componentId, Date.now(), {});
50
+ _mobileReactNative.DdRum.stopView(componentId);
44
51
  }
45
52
  }, componentId);
46
53
 
@@ -51,6 +58,7 @@ class DdRumReactNativeNavigationTracking {
51
58
  };
52
59
 
53
60
  DdRumReactNativeNavigationTracking.isTracking = true;
61
+ DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;
54
62
  }
55
63
  /**
56
64
  * Stops tracking Navigation.
@@ -68,15 +76,21 @@ class DdRumReactNativeNavigationTracking {
68
76
 
69
77
  DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length);
70
78
  DdRumReactNativeNavigationTracking.isTracking = false;
79
+
80
+ DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event, trackedName) {
81
+ return trackedName;
82
+ };
71
83
  }
72
84
 
73
85
  }
74
86
 
75
- exports.default = DdRumReactNativeNavigationTracking;
87
+ exports.DdRumReactNativeNavigationTracking = DdRumReactNativeNavigationTracking;
76
88
 
77
89
  _defineProperty(DdRumReactNativeNavigationTracking, "isTracking", false);
78
90
 
79
91
  _defineProperty(DdRumReactNativeNavigationTracking, "trackedComponentIds", []);
80
92
 
81
93
  _defineProperty(DdRumReactNativeNavigationTracking, "originalCreateElement", undefined);
94
+
95
+ _defineProperty(DdRumReactNativeNavigationTracking, "viewNamePredicate", void 0);
82
96
  //# sourceMappingURL=DdRumReactNativeNavigationTracking.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["DdRumReactNativeNavigationTracking","startTracking","isTracking","original","React","createElement","originalCreateElement","element","props","children","componentId","undefined","trackedComponentIds","includes","Navigation","events","registerComponentListener","componentDidAppear","event","DdRum","startView","componentName","Date","now","componentDidDisappear","stopView","push","stopTracking","splice","length"],"mappings":";;;;;;;AAMA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACe,MAAMA,kCAAN,CAAyC;AAMpD;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kCAAkC,CAACE,UAAvC,EAAmD;AAC/C;AACH;;AACD,UAAMC,QAAQ,GAAGC,eAAMC,aAAvB;AACAL,IAAAA,kCAAkC,CAACM,qBAAnC,GAA2DH,QAA3D;;AACAC,mBAAMC,aAAN,GAAsB,CAACE,OAAD,EAAeC,KAAf,EAA2B,GAAGC,QAA9B,KAAqD;AACvE,UACID,KAAK,CAACE,WAAN,IAAqBC,SAArB,IACG,CAACX,kCAAkC,CAACY,mBAAnC,CAAuDC,QAAvD,CAAgEL,KAAK,CAACE,WAAtE,CAFR,EAGE;AACE,cAAMA,WAAW,GAAGF,KAAK,CAACE,WAA1B;;AACAI,0CAAWC,MAAX,GAAoBC,yBAApB,CACI;AACIC,UAAAA,kBAAkB,EAAGC,KAAD,IAAoC;AACpDC,qCAAMC,SAAN,CAAgBV,WAAhB,EAA6BQ,KAAK,CAACG,aAAnC,EAAkDC,IAAI,CAACC,GAAL,EAAlD,EAA8D,EAA9D;AACH,WAHL;AAIIC,UAAAA,qBAAqB,EAAE,MAAM;AACzBL,qCAAMM,QAAN,CAAef,WAAf,EAA4BY,IAAI,CAACC,GAAL,EAA5B,EAAwC,EAAxC;AACH;AANL,SADJ,EASIb,WATJ;;AAWAV,QAAAA,kCAAkC,CAACY,mBAAnC,CAAuDc,IAAvD,CAA4DhB,WAA5D;AACH;;AAED,aAAOP,QAAQ,CAACI,OAAD,EAAUC,KAAV,EAAiB,GAAGC,QAApB,CAAf;AACH,KArBD;;AAsBAT,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,IAAhD;AACH;AAED;AACJ;AACA;;;AACuB,SAAZyB,YAAY,GAAS;AACxB,QAAI,CAAC3B,kCAAkC,CAACE,UAAxC,EAAoD;AAChD;AACH;;AACD,QAAIF,kCAAkC,CAACM,qBAAnC,IAA4DK,SAAhE,EAA2E;AACvEP,qBAAMC,aAAN,GAAsBL,kCAAkC,CAACM,qBAAzD;AACH;;AACDN,IAAAA,kCAAkC,CAACY,mBAAnC,CAAuDgB,MAAvD,CAA8D,CAA9D,EAAiE5B,kCAAkC,CAACY,mBAAnC,CAAuDiB,MAAxH;AACA7B,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,KAAhD;AACH;;AArDmD;;;;gBAAnCF,kC,gBAEW,K;;gBAFXA,kC,yBAGiC,E;;gBAHjCA,kC,2BAI2BW,S","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport React from 'react'\nimport { ComponentDidAppearEvent, Navigation } from 'react-native-navigation';\nimport { DdRum } from '@datadog/mobile-react-native';\n\n/**\n* Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n*/\nexport default class DdRumReactNativeNavigationTracking {\n\n private static isTracking = false\n private static trackedComponentIds : Array<any> = [];\n private static originalCreateElement: any = undefined\n\n /**\n * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n const original = React.createElement\n DdRumReactNativeNavigationTracking.originalCreateElement = original\n React.createElement = (element: any, props: any, ...children: any): any => {\n if (\n props.componentId != undefined \n && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)\n ) {\n const componentId = props.componentId\n Navigation.events().registerComponentListener(\n {\n componentDidAppear: (event: ComponentDidAppearEvent) => {\n DdRum.startView(componentId, event.componentName, Date.now(), {});\n },\n componentDidDisappear: () => {\n DdRum.stopView(componentId, Date.now(), {});\n },\n },\n componentId\n );\n DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);\n }\n\n return original(element, props, ...children)\n }\n DdRumReactNativeNavigationTracking.isTracking = true\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n if (DdRumReactNativeNavigationTracking.originalCreateElement != undefined) {\n React.createElement = DdRumReactNativeNavigationTracking.originalCreateElement;\n }\n DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length)\n DdRumReactNativeNavigationTracking.isTracking = false\n }\n}"]}
1
+ {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["DdRumReactNativeNavigationTracking","startTracking","viewNamePredicate","_event","trackedName","isTracking","original","React","createElement","originalCreateElement","element","props","children","componentId","undefined","trackedComponentIds","includes","Navigation","events","registerComponentListener","componentDidAppear","event","predicate","screenName","componentName","DdRum","startView","componentDidDisappear","stopView","push","stopTracking","splice","length"],"mappings":";;;;;;;AAMA;;AACA;;AACA;;;;;;AAIA;AACA;AACA;AACO,MAAMA,kCAAN,CAAyC;AAQ5C;AACJ;AACA;AACwB,SAAbC,aAAa,CAACC,iBAAoC,GAAG,UAAUC,MAAV,EAA2CC,WAA3C,EAAgE;AAAE,WAAOA,WAAP;AAAqB,GAA/H,EAAuI;AACvJ;AACA,QAAIJ,kCAAkC,CAACK,UAAvC,EAAmD;AAC/C;AACH;;AACD,UAAMC,QAAQ,GAAGC,eAAMC,aAAvB;AACAR,IAAAA,kCAAkC,CAACS,qBAAnC,GAA2DH,QAA3D;;AACAC,mBAAMC,aAAN,GAAsB,CAACE,OAAD,EAAeC,KAAf,EAA2B,GAAGC,QAA9B,KAAqD;AACvE,UAAID,KAAK,IAAIA,KAAK,CAACE,WAAN,IAAqBC,SAA9B,IACG,CAACd,kCAAkC,CAACe,mBAAnC,CAAuDC,QAAvD,CAAgEL,KAAK,CAACE,WAAtE,CADR,EAEE;AACE,cAAMA,WAAW,GAAGF,KAAK,CAACE,WAA1B;;AACAI,0CAAWC,MAAX,GAAoBC,yBAApB,CACI;AACIC,UAAAA,kBAAkB,EAAGC,KAAD,IAAoC;AAAA;;AACpD,kBAAMC,SAAS,GAAGtB,kCAAkC,CAACE,iBAArD;AACA,kBAAMqB,UAAU,iBAAGD,SAAS,CAACD,KAAD,EAAQA,KAAK,CAACG,aAAd,CAAZ,mDAA4CH,KAAK,CAACG,aAAlE;;AACAC,qCAAMC,SAAN,CAAgBb,WAAhB,EAA6BU,UAA7B;AACH,WALL;AAMII,UAAAA,qBAAqB,EAAE,MAAM;AACzBF,qCAAMG,QAAN,CAAef,WAAf;AACH;AARL,SADJ,EAWIA,WAXJ;;AAaAb,QAAAA,kCAAkC,CAACe,mBAAnC,CAAuDc,IAAvD,CAA4DhB,WAA5D;AACH;;AAED,aAAOP,QAAQ,CAACI,OAAD,EAAUC,KAAV,EAAiB,GAAGC,QAApB,CAAf;AACH,KAtBD;;AAuBAZ,IAAAA,kCAAkC,CAACK,UAAnC,GAAgD,IAAhD;AACAL,IAAAA,kCAAkC,CAACE,iBAAnC,GAAuDA,iBAAvD;AACH;AAED;AACJ;AACA;;;AACuB,SAAZ4B,YAAY,GAAS;AACxB,QAAI,CAAC9B,kCAAkC,CAACK,UAAxC,EAAoD;AAChD;AACH;;AACD,QAAIL,kCAAkC,CAACS,qBAAnC,IAA4DK,SAAhE,EAA2E;AACvEP,qBAAMC,aAAN,GAAsBR,kCAAkC,CAACS,qBAAzD;AACH;;AACDT,IAAAA,kCAAkC,CAACe,mBAAnC,CAAuDgB,MAAvD,CAA8D,CAA9D,EAAiE/B,kCAAkC,CAACe,mBAAnC,CAAuDiB,MAAxH;AACAhC,IAAAA,kCAAkC,CAACK,UAAnC,GAAgD,KAAhD;;AACAL,IAAAA,kCAAkC,CAACE,iBAAnC,GAAuD,UAAUC,MAAV,EAA2CC,WAA3C,EAAgE;AAAE,aAAOA,WAAP;AAAqB,KAA9I;AACH;;AA1D2C;;;;gBAAnCJ,kC,gBAEmB,K;;gBAFnBA,kC,yBAGyC,E;;gBAHzCA,kC,2BAImCc,S;;gBAJnCd,kC","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'\nimport { ComponentDidAppearEvent, Navigation } from 'react-native-navigation';\nimport { DdRum } from '@datadog/mobile-react-native';\n\nexport type ViewNamePredicate = (event: ComponentDidAppearEvent, trackedName: string) => string\n\n/**\n* Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n*/\nexport class DdRumReactNativeNavigationTracking {\n\n private static isTracking = false\n private static trackedComponentIds : Array<any> = [];\n private static originalCreateElement: any = undefined\n\n private static viewNamePredicate: ViewNamePredicate;\n\n /**\n * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.\n */\n static startTracking(viewNamePredicate: ViewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n const original = React.createElement\n DdRumReactNativeNavigationTracking.originalCreateElement = original\n React.createElement = (element: any, props: any, ...children: any): any => {\n if (props && props.componentId != undefined \n && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)\n ) {\n const componentId = props.componentId\n Navigation.events().registerComponentListener(\n {\n componentDidAppear: (event: ComponentDidAppearEvent) => {\n const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;\n const screenName = predicate(event, event.componentName) ?? event.componentName;\n DdRum.startView(componentId, screenName);\n },\n componentDidDisappear: () => {\n DdRum.stopView(componentId);\n },\n },\n componentId\n );\n DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);\n }\n\n return original(element, props, ...children)\n }\n DdRumReactNativeNavigationTracking.isTracking = true\n DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n if (DdRumReactNativeNavigationTracking.originalCreateElement != undefined) {\n React.createElement = DdRumReactNativeNavigationTracking.originalCreateElement;\n }\n DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length)\n DdRumReactNativeNavigationTracking.isTracking = false\n DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }\n }\n}"]}
@@ -3,6 +3,6 @@
3
3
  * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
- import DdRumReactNativeNavigationTracking from './rum/instrumentation/DdRumReactNativeNavigationTracking';
7
- export { DdRumReactNativeNavigationTracking };
6
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNativeNavigationTracking';
7
+ export { DdRumReactNativeNavigationTracking, ViewNamePredicate };
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["DdRumReactNativeNavigationTracking"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,kCAAP,MAA+C,0DAA/C;AAEA,SAASA,kCAAT","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 DdRumReactNativeNavigationTracking from './rum/instrumentation/DdRumReactNativeNavigationTracking';\n\nexport { DdRumReactNativeNavigationTracking };\n"]}
1
+ {"version":3,"sources":["index.tsx"],"names":["DdRumReactNativeNavigationTracking","ViewNamePredicate"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,kCAAT,EAA6CC,iBAA7C,QAAsE,0DAAtE;AAEA,SAASD,kCAAT,EAA6CC,iBAA7C","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 { DdRumReactNativeNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNativeNavigationTracking';\n\nexport { DdRumReactNativeNavigationTracking, ViewNamePredicate };\n"]}
@@ -8,15 +8,17 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
8
8
  import React from 'react';
9
9
  import { Navigation } from 'react-native-navigation';
10
10
  import { DdRum } from '@datadog/mobile-react-native';
11
+
11
12
  /**
12
13
  * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.
13
14
  */
14
-
15
- export default class DdRumReactNativeNavigationTracking {
15
+ export class DdRumReactNativeNavigationTracking {
16
16
  /**
17
17
  * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
18
18
  */
19
- static startTracking() {
19
+ static startTracking(viewNamePredicate = function (_event, trackedName) {
20
+ return trackedName;
21
+ }) {
20
22
  // extra safety to avoid wrapping more than 1 time this function
21
23
  if (DdRumReactNativeNavigationTracking.isTracking) {
22
24
  return;
@@ -26,14 +28,18 @@ export default class DdRumReactNativeNavigationTracking {
26
28
  DdRumReactNativeNavigationTracking.originalCreateElement = original;
27
29
 
28
30
  React.createElement = (element, props, ...children) => {
29
- if (props.componentId != undefined && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)) {
31
+ if (props && props.componentId != undefined && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)) {
30
32
  const componentId = props.componentId;
31
33
  Navigation.events().registerComponentListener({
32
34
  componentDidAppear: event => {
33
- DdRum.startView(componentId, event.componentName, Date.now(), {});
35
+ var _predicate;
36
+
37
+ const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;
38
+ const screenName = (_predicate = predicate(event, event.componentName)) !== null && _predicate !== void 0 ? _predicate : event.componentName;
39
+ DdRum.startView(componentId, screenName);
34
40
  },
35
41
  componentDidDisappear: () => {
36
- DdRum.stopView(componentId, Date.now(), {});
42
+ DdRum.stopView(componentId);
37
43
  }
38
44
  }, componentId);
39
45
  DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);
@@ -43,6 +49,7 @@ export default class DdRumReactNativeNavigationTracking {
43
49
  };
44
50
 
45
51
  DdRumReactNativeNavigationTracking.isTracking = true;
52
+ DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;
46
53
  }
47
54
  /**
48
55
  * Stops tracking Navigation.
@@ -60,6 +67,10 @@ export default class DdRumReactNativeNavigationTracking {
60
67
 
61
68
  DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length);
62
69
  DdRumReactNativeNavigationTracking.isTracking = false;
70
+
71
+ DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event, trackedName) {
72
+ return trackedName;
73
+ };
63
74
  }
64
75
 
65
76
  }
@@ -69,4 +80,6 @@ _defineProperty(DdRumReactNativeNavigationTracking, "isTracking", false);
69
80
  _defineProperty(DdRumReactNativeNavigationTracking, "trackedComponentIds", []);
70
81
 
71
82
  _defineProperty(DdRumReactNativeNavigationTracking, "originalCreateElement", undefined);
83
+
84
+ _defineProperty(DdRumReactNativeNavigationTracking, "viewNamePredicate", void 0);
72
85
  //# sourceMappingURL=DdRumReactNativeNavigationTracking.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["React","Navigation","DdRum","DdRumReactNativeNavigationTracking","startTracking","isTracking","original","createElement","originalCreateElement","element","props","children","componentId","undefined","trackedComponentIds","includes","events","registerComponentListener","componentDidAppear","event","startView","componentName","Date","now","componentDidDisappear","stopView","push","stopTracking","splice","length"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAkCC,UAAlC,QAAoD,yBAApD;AACA,SAASC,KAAT,QAAsB,8BAAtB;AAEA;AACA;AACA;;AACA,eAAe,MAAMC,kCAAN,CAAyC;AAMpD;AACJ;AACA;AACwB,SAAbC,aAAa,GAAS;AACzB;AACA,QAAID,kCAAkC,CAACE,UAAvC,EAAmD;AAC/C;AACH;;AACD,UAAMC,QAAQ,GAAGN,KAAK,CAACO,aAAvB;AACAJ,IAAAA,kCAAkC,CAACK,qBAAnC,GAA2DF,QAA3D;;AACAN,IAAAA,KAAK,CAACO,aAAN,GAAsB,CAACE,OAAD,EAAeC,KAAf,EAA2B,GAAGC,QAA9B,KAAqD;AACvE,UACID,KAAK,CAACE,WAAN,IAAqBC,SAArB,IACG,CAACV,kCAAkC,CAACW,mBAAnC,CAAuDC,QAAvD,CAAgEL,KAAK,CAACE,WAAtE,CAFR,EAGE;AACE,cAAMA,WAAW,GAAGF,KAAK,CAACE,WAA1B;AACAX,QAAAA,UAAU,CAACe,MAAX,GAAoBC,yBAApB,CACI;AACIC,UAAAA,kBAAkB,EAAGC,KAAD,IAAoC;AACpDjB,YAAAA,KAAK,CAACkB,SAAN,CAAgBR,WAAhB,EAA6BO,KAAK,CAACE,aAAnC,EAAkDC,IAAI,CAACC,GAAL,EAAlD,EAA8D,EAA9D;AACH,WAHL;AAIIC,UAAAA,qBAAqB,EAAE,MAAM;AACzBtB,YAAAA,KAAK,CAACuB,QAAN,CAAeb,WAAf,EAA4BU,IAAI,CAACC,GAAL,EAA5B,EAAwC,EAAxC;AACH;AANL,SADJ,EASIX,WATJ;AAWAT,QAAAA,kCAAkC,CAACW,mBAAnC,CAAuDY,IAAvD,CAA4Dd,WAA5D;AACH;;AAED,aAAON,QAAQ,CAACG,OAAD,EAAUC,KAAV,EAAiB,GAAGC,QAApB,CAAf;AACH,KArBD;;AAsBAR,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,IAAhD;AACH;AAED;AACJ;AACA;;;AACuB,SAAZsB,YAAY,GAAS;AACxB,QAAI,CAACxB,kCAAkC,CAACE,UAAxC,EAAoD;AAChD;AACH;;AACD,QAAIF,kCAAkC,CAACK,qBAAnC,IAA4DK,SAAhE,EAA2E;AACvEb,MAAAA,KAAK,CAACO,aAAN,GAAsBJ,kCAAkC,CAACK,qBAAzD;AACH;;AACDL,IAAAA,kCAAkC,CAACW,mBAAnC,CAAuDc,MAAvD,CAA8D,CAA9D,EAAiEzB,kCAAkC,CAACW,mBAAnC,CAAuDe,MAAxH;AACA1B,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,KAAhD;AACH;;AArDmD;;gBAAnCF,kC,gBAEW,K;;gBAFXA,kC,yBAGiC,E;;gBAHjCA,kC,2BAI2BU,S","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport React from 'react'\nimport { ComponentDidAppearEvent, Navigation } from 'react-native-navigation';\nimport { DdRum } from '@datadog/mobile-react-native';\n\n/**\n* Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n*/\nexport default class DdRumReactNativeNavigationTracking {\n\n private static isTracking = false\n private static trackedComponentIds : Array<any> = [];\n private static originalCreateElement: any = undefined\n\n /**\n * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.\n */\n static startTracking(): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n const original = React.createElement\n DdRumReactNativeNavigationTracking.originalCreateElement = original\n React.createElement = (element: any, props: any, ...children: any): any => {\n if (\n props.componentId != undefined \n && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)\n ) {\n const componentId = props.componentId\n Navigation.events().registerComponentListener(\n {\n componentDidAppear: (event: ComponentDidAppearEvent) => {\n DdRum.startView(componentId, event.componentName, Date.now(), {});\n },\n componentDidDisappear: () => {\n DdRum.stopView(componentId, Date.now(), {});\n },\n },\n componentId\n );\n DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);\n }\n\n return original(element, props, ...children)\n }\n DdRumReactNativeNavigationTracking.isTracking = true\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n if (DdRumReactNativeNavigationTracking.originalCreateElement != undefined) {\n React.createElement = DdRumReactNativeNavigationTracking.originalCreateElement;\n }\n DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length)\n DdRumReactNativeNavigationTracking.isTracking = false\n }\n}"]}
1
+ {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["React","Navigation","DdRum","DdRumReactNativeNavigationTracking","startTracking","viewNamePredicate","_event","trackedName","isTracking","original","createElement","originalCreateElement","element","props","children","componentId","undefined","trackedComponentIds","includes","events","registerComponentListener","componentDidAppear","event","predicate","screenName","componentName","startView","componentDidDisappear","stopView","push","stopTracking","splice","length"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAAkCC,UAAlC,QAAoD,yBAApD;AACA,SAASC,KAAT,QAAsB,8BAAtB;;AAIA;AACA;AACA;AACA,OAAO,MAAMC,kCAAN,CAAyC;AAQ5C;AACJ;AACA;AACwB,SAAbC,aAAa,CAACC,iBAAoC,GAAG,UAAUC,MAAV,EAA2CC,WAA3C,EAAgE;AAAE,WAAOA,WAAP;AAAqB,GAA/H,EAAuI;AACvJ;AACA,QAAIJ,kCAAkC,CAACK,UAAvC,EAAmD;AAC/C;AACH;;AACD,UAAMC,QAAQ,GAAGT,KAAK,CAACU,aAAvB;AACAP,IAAAA,kCAAkC,CAACQ,qBAAnC,GAA2DF,QAA3D;;AACAT,IAAAA,KAAK,CAACU,aAAN,GAAsB,CAACE,OAAD,EAAeC,KAAf,EAA2B,GAAGC,QAA9B,KAAqD;AACvE,UAAID,KAAK,IAAIA,KAAK,CAACE,WAAN,IAAqBC,SAA9B,IACG,CAACb,kCAAkC,CAACc,mBAAnC,CAAuDC,QAAvD,CAAgEL,KAAK,CAACE,WAAtE,CADR,EAEE;AACE,cAAMA,WAAW,GAAGF,KAAK,CAACE,WAA1B;AACAd,QAAAA,UAAU,CAACkB,MAAX,GAAoBC,yBAApB,CACI;AACIC,UAAAA,kBAAkB,EAAGC,KAAD,IAAoC;AAAA;;AACpD,kBAAMC,SAAS,GAAGpB,kCAAkC,CAACE,iBAArD;AACA,kBAAMmB,UAAU,iBAAGD,SAAS,CAACD,KAAD,EAAQA,KAAK,CAACG,aAAd,CAAZ,mDAA4CH,KAAK,CAACG,aAAlE;AACAvB,YAAAA,KAAK,CAACwB,SAAN,CAAgBX,WAAhB,EAA6BS,UAA7B;AACH,WALL;AAMIG,UAAAA,qBAAqB,EAAE,MAAM;AACzBzB,YAAAA,KAAK,CAAC0B,QAAN,CAAeb,WAAf;AACH;AARL,SADJ,EAWIA,WAXJ;AAaAZ,QAAAA,kCAAkC,CAACc,mBAAnC,CAAuDY,IAAvD,CAA4Dd,WAA5D;AACH;;AAED,aAAON,QAAQ,CAACG,OAAD,EAAUC,KAAV,EAAiB,GAAGC,QAApB,CAAf;AACH,KAtBD;;AAuBAX,IAAAA,kCAAkC,CAACK,UAAnC,GAAgD,IAAhD;AACAL,IAAAA,kCAAkC,CAACE,iBAAnC,GAAuDA,iBAAvD;AACH;AAED;AACJ;AACA;;;AACuB,SAAZyB,YAAY,GAAS;AACxB,QAAI,CAAC3B,kCAAkC,CAACK,UAAxC,EAAoD;AAChD;AACH;;AACD,QAAIL,kCAAkC,CAACQ,qBAAnC,IAA4DK,SAAhE,EAA2E;AACvEhB,MAAAA,KAAK,CAACU,aAAN,GAAsBP,kCAAkC,CAACQ,qBAAzD;AACH;;AACDR,IAAAA,kCAAkC,CAACc,mBAAnC,CAAuDc,MAAvD,CAA8D,CAA9D,EAAiE5B,kCAAkC,CAACc,mBAAnC,CAAuDe,MAAxH;AACA7B,IAAAA,kCAAkC,CAACK,UAAnC,GAAgD,KAAhD;;AACAL,IAAAA,kCAAkC,CAACE,iBAAnC,GAAuD,UAAUC,MAAV,EAA2CC,WAA3C,EAAgE;AAAE,aAAOA,WAAP;AAAqB,KAA9I;AACH;;AA1D2C;;gBAAnCJ,kC,gBAEmB,K;;gBAFnBA,kC,yBAGyC,E;;gBAHzCA,kC,2BAImCa,S;;gBAJnCb,kC","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'\nimport { ComponentDidAppearEvent, Navigation } from 'react-native-navigation';\nimport { DdRum } from '@datadog/mobile-react-native';\n\nexport type ViewNamePredicate = (event: ComponentDidAppearEvent, trackedName: string) => string\n\n/**\n* Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n*/\nexport class DdRumReactNativeNavigationTracking {\n\n private static isTracking = false\n private static trackedComponentIds : Array<any> = [];\n private static originalCreateElement: any = undefined\n\n private static viewNamePredicate: ViewNamePredicate;\n\n /**\n * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.\n */\n static startTracking(viewNamePredicate: ViewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n const original = React.createElement\n DdRumReactNativeNavigationTracking.originalCreateElement = original\n React.createElement = (element: any, props: any, ...children: any): any => {\n if (props && props.componentId != undefined \n && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)\n ) {\n const componentId = props.componentId\n Navigation.events().registerComponentListener(\n {\n componentDidAppear: (event: ComponentDidAppearEvent) => {\n const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;\n const screenName = predicate(event, event.componentName) ?? event.componentName;\n DdRum.startView(componentId, screenName);\n },\n componentDidDisappear: () => {\n DdRum.stopView(componentId);\n },\n },\n componentId\n );\n DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);\n }\n\n return original(element, props, ...children)\n }\n DdRumReactNativeNavigationTracking.isTracking = true\n DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return\n }\n if (DdRumReactNativeNavigationTracking.originalCreateElement != undefined) {\n React.createElement = DdRumReactNativeNavigationTracking.originalCreateElement;\n }\n DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length)\n DdRumReactNativeNavigationTracking.isTracking = false\n DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }\n }\n}"]}
@@ -5,6 +5,17 @@ import type { TrackingConsent } from "./TrackingConsent";
5
5
  */
6
6
  export declare class DdSdkReactNative {
7
7
  private static readonly DD_SOURCE_KEY;
8
+ private static readonly DD_SDK_VERSION;
9
+ private static readonly DD_SERVICE_NAME;
10
+ private static readonly DD_SDK_VERBOSITY_KEY;
11
+ private static readonly DD_NATIVE_VIEW_TRACKING_KEY;
12
+ private static readonly DD_PROXY_TYPE_KEY;
13
+ private static readonly DD_PROXY_ADDRESS_KEY;
14
+ private static readonly DD_PROXY_PORT_KEY;
15
+ private static readonly DD_PROXY_USERNAME_KEY;
16
+ private static readonly DD_PROXY_PASSWORD_KEY;
17
+ private static readonly DD_NATIVE_LONG_TASK_THRESHOLD_KEY;
18
+ private static readonly NATIVE_LONG_TASK_THRESHOLD_MS;
8
19
  private static wasInitialized;
9
20
  /**
10
21
  * Initializes the Datadog SDK.
@@ -1,4 +1,6 @@
1
1
  import { TrackingConsent } from './TrackingConsent';
2
+ import type { NativeSdkVerbosity } from './NativeSdkVerbosity';
3
+ import type { ProxyConfiguration } from './ProxyConfiguration';
2
4
  /**
3
5
  * The SDK configuration class.
4
6
  * It will be used to configure the SDK functionality at initialization.
@@ -14,6 +16,10 @@ export declare class DdSdkReactNativeConfiguration {
14
16
  nativeCrashReportEnabled: boolean;
15
17
  sampleRate: number;
16
18
  site: string;
19
+ verbosity: NativeSdkVerbosity | undefined;
20
+ nativeViewTracking: boolean;
21
+ proxyConfig?: ProxyConfiguration;
22
+ serviceName?: string;
17
23
  additionalConfig: {
18
24
  [k: string]: any;
19
25
  };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Enum specifying possible consent options for DD SDK.
3
+ */
4
+ export declare enum NativeSdkVerbosity {
5
+ DEBUG = "debug",
6
+ INFO = "info",
7
+ WARN = "warn",
8
+ ERROR = "error"
9
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Proxy server configuration.
3
+ */
4
+ declare class ProxyConfiguration {
5
+ /**
6
+ * Proxy type.
7
+ */
8
+ readonly type: ProxyType;
9
+ /**
10
+ * Proxy address. Can be either in the IP address format, ex. "1.1.1.1", or hostname, ex. "example.com".
11
+ */
12
+ readonly address: string;
13
+ /**
14
+ * Proxy port.
15
+ */
16
+ readonly port: number;
17
+ /**
18
+ * Username for Basic authentication scheme.
19
+ *
20
+ * Note: "SOCKS + authentication" scheme is not supported.
21
+ */
22
+ readonly username?: string | undefined;
23
+ /**
24
+ * Password for Basic authentication scheme.
25
+ */
26
+ readonly password?: string | undefined;
27
+ constructor(
28
+ /**
29
+ * Proxy type.
30
+ */
31
+ type: ProxyType,
32
+ /**
33
+ * Proxy address. Can be either in the IP address format, ex. "1.1.1.1", or hostname, ex. "example.com".
34
+ */
35
+ address: string,
36
+ /**
37
+ * Proxy port.
38
+ */
39
+ port: number,
40
+ /**
41
+ * Username for Basic authentication scheme.
42
+ *
43
+ * Note: "SOCKS + authentication" scheme is not supported.
44
+ */
45
+ username?: string | undefined,
46
+ /**
47
+ * Password for Basic authentication scheme.
48
+ */
49
+ password?: string | undefined);
50
+ }
51
+ declare enum ProxyType {
52
+ HTTP = "http",
53
+ HTTPS = "https",
54
+ SOCKS = "socks"
55
+ }
56
+ export { ProxyConfiguration, ProxyType };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Simple timer which records time ticks. Shouldn't be re-used once stopped.
3
+ * All timestamps/durations returned are in milliseconds.
4
+ */
5
+ export default class Timer {
6
+ private times;
7
+ get startTime(): number;
8
+ get stopTime(): number;
9
+ start(): void;
10
+ stop(): void;
11
+ recordTick(label: string): void;
12
+ hasTickFor(label: string): boolean;
13
+ durationBetween(startLabel: string, endLabel: string): number;
14
+ timeAt(label: string): number;
15
+ reset(): void;
16
+ private durationBetweenTicks;
17
+ private performanceNow;
18
+ private canUsePerformanceNow;
19
+ private checkLabelExists;
20
+ }
@@ -1,5 +1,6 @@
1
1
  import { DdLogs, DdTrace, DdRum } from './foundation';
2
2
  import { DdSdkReactNativeConfiguration } from './DdSdkReactNativeConfiguration';
3
3
  import { DdSdkReactNative } from './DdSdkReactNative';
4
+ import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
4
5
  import { TrackingConsent } from './TrackingConsent';
5
- export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, TrackingConsent };
6
+ export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, ProxyConfiguration, ProxyType, TrackingConsent };
@@ -5,6 +5,8 @@ export declare class DdEventsInterceptor implements EventsInterceptor {
5
5
  interceptOnPress(...args: any[]): void;
6
6
  private handleTargetEvent;
7
7
  private resolveTargetName;
8
+ private resolveElementTypeName;
9
+ private findClosestActionLabel;
8
10
  }
9
11
  /**
10
12
  * Describe the type of a RUM Action.
@@ -3,6 +3,7 @@
3
3
  */
4
4
  export declare class DdRumErrorTracking {
5
5
  private static isTracking;
6
+ private static isInDefaultErrorHandler;
6
7
  private static defaultErrorHandler;
7
8
  private static defaultConsoleError;
8
9
  /**
@@ -11,5 +12,6 @@ export declare class DdRumErrorTracking {
11
12
  static startTracking(): void;
12
13
  static onGlobalError(error: any, isFatal?: boolean): void;
13
14
  static onConsoleError(...params: unknown[]): void;
15
+ private static getErrorMessage;
14
16
  private static getErrorStackTrace;
15
17
  }
@@ -1,7 +1,11 @@
1
+ /// <reference types="react-native" />
1
2
  export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
2
3
  export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
3
4
  export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
5
+ export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
6
+ export declare const SAMPLED_HEADER_KEY = "x-datadog-sampled";
4
7
  export declare const ORIGIN_RUM = "rum";
8
+ export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
5
9
  /**
6
10
  * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
7
11
  */
@@ -1,13 +1,13 @@
1
1
  /// <reference types="react-native" />
2
+ import type Timer from "../../Timer";
2
3
  export interface DdRumXhr extends XMLHttpRequest {
3
4
  _datadog_xhr: DdRumXhrContext;
4
5
  }
5
6
  export interface DdRumXhrContext {
6
7
  method: string;
7
8
  url: string;
8
- startTime: number;
9
- responseStartTime: number;
10
9
  reported: boolean;
10
+ timer: Timer;
11
11
  spanId: string;
12
12
  traceId: string;
13
13
  }
@@ -46,25 +46,25 @@ export declare type DdLogsType = {
46
46
  * @param message: The message to send.
47
47
  * @param context: The additional context to send.
48
48
  */
49
- debug(message: string, context: object): Promise<void>;
49
+ debug(message: string, context?: object): Promise<void>;
50
50
  /**
51
51
  * Send a log with level info.
52
52
  * @param message: The message to send.
53
53
  * @param context: The additional context to send.
54
54
  */
55
- info(message: string, context: object): Promise<void>;
55
+ info(message: string, context?: object): Promise<void>;
56
56
  /**
57
57
  * Send a log with level warn.
58
58
  * @param message: The message to send.
59
59
  * @param context: The additional context to send.
60
60
  */
61
- warn(message: string, context: object): Promise<void>;
61
+ warn(message: string, context?: object): Promise<void>;
62
62
  /**
63
63
  * Send a log with level error.
64
64
  * @param message: The message to send.
65
65
  * @param context: The additional context to send.
66
66
  */
67
- error(message: string, context: object): Promise<void>;
67
+ error(message: string, context?: object): Promise<void>;
68
68
  };
69
69
  /**
70
70
  * The entry point to use Datadog's Trace feature.
@@ -73,17 +73,17 @@ export declare type DdTraceType = {
73
73
  /**
74
74
  * Start a span, and returns a unique identifier for the span.
75
75
  * @param operation: The operation name of the span.
76
- * @param timestampMs: The timestamp when the operation started (in milliseconds).
77
76
  * @param context: The additional context to send.
77
+ * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
78
78
  */
79
- startSpan(operation: string, timestampMs: number, context: object): Promise<string>;
79
+ startSpan(operation: string, context?: object, timestampMs?: number): Promise<string>;
80
80
  /**
81
81
  * Finish a started span.
82
82
  * @param spanId: The unique identifier of the span.
83
- * @param timestampMs: The timestamp when the operation stopped (in milliseconds).
84
83
  * @param context: The additional context to send.
84
+ * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
85
85
  */
86
- finishSpan(spanId: string, timestampMs: number, context: object): Promise<void>;
86
+ finishSpan(spanId: string, context?: object, timestampMs?: number): Promise<void>;
87
87
  };
88
88
  /**
89
89
  * The entry point to use Datadog's RUM feature.
@@ -93,66 +93,67 @@ export declare type DdRumType = {
93
93
  * Start tracking a RUM View.
94
94
  * @param key: The view unique key identifier.
95
95
  * @param name: The view name.
96
- * @param timestampMs: The timestamp when the view started (in milliseconds).
97
96
  * @param context: The additional context to send.
97
+ * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
98
98
  */
99
- startView(key: string, name: string, timestampMs: number, context: object): Promise<void>;
99
+ startView(key: string, name: string, context?: object, timestampMs?: number): Promise<void>;
100
100
  /**
101
101
  * Stop tracking a RUM View.
102
102
  * @param key: The view unique key identifier.
103
- * @param timestampMs: The timestamp when the view stopped (in milliseconds).
104
103
  * @param context: The additional context to send.
104
+ * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
105
105
  */
106
- stopView(key: string, timestampMs: number, context: object): Promise<void>;
106
+ stopView(key: string, context?: object, timestampMs?: number): Promise<void>;
107
107
  /**
108
108
  * Start tracking a RUM Action.
109
109
  * @param type: The action type (tap, scroll, swipe, click, custom).
110
110
  * @param name: The action name.
111
- * @param timestampMs: The timestamp when the action started (in milliseconds).
112
111
  * @param context: The additional context to send.
112
+ * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
113
113
  */
114
- startAction(type: string, name: string, timestampMs: number, context: object): Promise<void>;
114
+ startAction(type: string, name: string, context?: object, timestampMs?: number): Promise<void>;
115
115
  /**
116
116
  * Stop tracking the ongoing RUM Action.
117
- * @param timestampMs: The timestamp when the action stopped (in milliseconds).
118
117
  * @param context: The additional context to send.
118
+ * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
119
119
  */
120
- stopAction(timestampMs: number, context: object): Promise<void>;
120
+ stopAction(context?: object, timestampMs?: number): Promise<void>;
121
121
  /**
122
122
  * Add a RUM Action.
123
123
  * @param type: The action type (tap, scroll, swipe, click, custom).
124
124
  * @param name: The action name.
125
- * @param timestampMs: The timestamp when the action occurred (in milliseconds).
126
125
  * @param context: The additional context to send.
126
+ * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
127
127
  */
128
- addAction(type: string, name: string, timestampMs: number, context: object): Promise<void>;
128
+ addAction(type: string, name: string, context?: object, timestampMs?: number): Promise<void>;
129
129
  /**
130
130
  * Start tracking a RUM Resource.
131
131
  * @param key: The resource unique key identifier.
132
132
  * @param method: The resource method (GET, POST, …).
133
133
  * @param url: The resource url.
134
- * @param timestampMs: The timestamp when the resource started (in milliseconds).
135
134
  * @param context: The additional context to send.
135
+ * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
136
136
  */
137
- startResource(key: string, method: string, url: string, timestampMs: number, context: object): Promise<void>;
137
+ startResource(key: string, method: string, url: string, context?: object, timestampMs?: number): Promise<void>;
138
138
  /**
139
139
  * Stop tracking a RUM Resource.
140
140
  * @param key: The resource unique key identifier.
141
141
  * @param statusCode: The resource status code.
142
142
  * @param kind: The resource's kind (xhr, document, image, css, font, …).
143
- * @param timestampMs: The timestamp when the resource stopped (in milliseconds).
143
+ * @param size: The resource size in bytes. If size is unknown, use -1.
144
144
  * @param context: The additional context to send.
145
+ * @param timestampMs: The timestamp when the resource stopped (in milliseconds). If not provided, current timestamp will be used.
145
146
  */
146
- stopResource(key: string, statusCode: number, kind: string, timestampMs: number, context: object): Promise<void>;
147
+ stopResource(key: string, statusCode: number, kind: string, size?: number, context?: object, timestampMs?: number): Promise<void>;
147
148
  /**
148
149
  * Add a RUM Error.
149
150
  * @param message: The error message.
150
151
  * @param source: The error source (network, source, console, logger, …).
151
152
  * @param stacktrace: The error stacktrace.
152
- * @param timestampMs: The timestamp when the error occurred (in milliseconds).
153
153
  * @param context: The additional context to send.
154
+ * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
154
155
  */
155
- addError(message: string, source: string, stacktrace: string, timestampMs: number, context: object): Promise<void>;
156
+ addError(message: string, source: string, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
156
157
  /**
157
158
  * 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.
158
159
  * @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.
@@ -0,0 +1 @@
1
+ export declare const version = "1.0.0-rc4";
@@ -1,2 +1,2 @@
1
- import DdRumReactNativeNavigationTracking from './rum/instrumentation/DdRumReactNativeNavigationTracking';
2
- export { DdRumReactNativeNavigationTracking };
1
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNativeNavigationTracking';
2
+ export { DdRumReactNativeNavigationTracking, ViewNamePredicate };
@@ -1,14 +1,17 @@
1
+ import { ComponentDidAppearEvent } from 'react-native-navigation';
2
+ export declare type ViewNamePredicate = (event: ComponentDidAppearEvent, trackedName: string) => string;
1
3
  /**
2
4
  * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.
3
5
  */
4
- export default class DdRumReactNativeNavigationTracking {
6
+ export declare class DdRumReactNativeNavigationTracking {
5
7
  private static isTracking;
6
8
  private static trackedComponentIds;
7
9
  private static originalCreateElement;
10
+ private static viewNamePredicate;
8
11
  /**
9
12
  * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
10
13
  */
11
- static startTracking(): void;
14
+ static startTracking(viewNamePredicate?: ViewNamePredicate): void;
12
15
  /**
13
16
  * Stops tracking Navigation.
14
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-navigation",
3
- "version": "1.0.0-beta4",
3
+ "version": "1.0.0-rc4",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -21,11 +21,7 @@
21
21
  "main": "lib/commonjs/index",
22
22
  "files": [
23
23
  "src",
24
- "lib",
25
- "!lib/typescript/example",
26
- "!**/__tests__",
27
- "!**/__fixtures__",
28
- "!**/__mocks__"
24
+ "lib"
29
25
  ],
30
26
  "types": "lib/typescript/react-native-navigation/src/index.d.ts",
31
27
  "react-native": "src/index",
@@ -40,14 +36,14 @@
40
36
  "prepare": "bob build"
41
37
  },
42
38
  "devDependencies": {
43
- "@datadog/mobile-react-native": "^1.0.0-beta4",
39
+ "@datadog/mobile-react-native": "^1.0.0-rc4",
44
40
  "react-native-gesture-handler": "1.10.3",
45
41
  "react-native-navigation": "7.13.0"
46
42
  },
47
43
  "peerDependencies": {
48
44
  "@datadog/mobile-react-native": "^1.0.0-beta4",
49
- "react": "^16.13.1",
50
- "react-native": "^0.63.4",
45
+ "react": ">=16.13.1",
46
+ "react-native": ">=0.63.4 <1.0",
51
47
  "react-native-navigation": "^7.5.0"
52
48
  },
53
49
  "jest": {
@@ -74,5 +70,5 @@
74
70
  ]
75
71
  ]
76
72
  },
77
- "gitHead": "7087bb49f594e4125a4884dfbbe96265abd8a86a"
73
+ "gitHead": "c1bd4e6ded0b84298ca011eba679027ae7fe7841"
78
74
  }
@@ -0,0 +1,161 @@
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 React from 'react';
8
+ import { DdRum } from '@datadog/mobile-react-native';
9
+ import { ComponentDidAppearEvent } from 'react-native-navigation';
10
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from '../../../rum/instrumentation/DdRumReactNativeNavigationTracking';
11
+
12
+ jest.mock('@datadog/mobile-react-native', () => {
13
+ return {
14
+ DdRum: {
15
+ startView: jest.fn().mockImplementation(() => { }),
16
+ stopView: jest.fn().mockImplementation(() => { })
17
+ },
18
+ };
19
+ });
20
+ jest.useFakeTimers();
21
+
22
+ let mockRegisterComponentListener = jest.fn().mockImplementation(() => { })
23
+ jest.mock('react-native-navigation', () => {
24
+ return {
25
+ Navigation: {
26
+ events: jest.fn().mockImplementation(() => {
27
+ return {
28
+ registerComponentListener: mockRegisterComponentListener
29
+ }
30
+ })
31
+ }
32
+ }
33
+ });
34
+
35
+
36
+ let originalCreateMethod: Function
37
+
38
+ beforeEach(() => {
39
+
40
+ jest.setTimeout(20000);
41
+ DdRum.startView.mockClear();
42
+ DdRum.stopView.mockClear();
43
+ mockRegisterComponentListener.mockClear();
44
+
45
+ DdRumReactNativeNavigationTracking['trackedComponentIds'] = [];
46
+ DdRumReactNativeNavigationTracking['isTracking'] = false;
47
+ originalCreateMethod = React.createElement
48
+ })
49
+
50
+ afterEach(() => {
51
+ React.createElement = originalCreateMethod
52
+ })
53
+
54
+ // Unit tests
55
+
56
+ it('M not register W props are missing + startTracking()', async () => {
57
+ // GIVEN
58
+ DdRumReactNativeNavigationTracking.startTracking();
59
+
60
+ // WHEN
61
+ const testInstance = React.createElement('View', null);
62
+
63
+ // THEN
64
+ expect(mockRegisterComponentListener).toBeCalledTimes(0);
65
+ })
66
+
67
+ it('M not register W componentId is missing + startTracking()', async () => {
68
+ // GIVEN
69
+ DdRumReactNativeNavigationTracking.startTracking();
70
+
71
+ // WHEN
72
+ const testInstance = React.createElement('View', { 'foo': 'bar' });
73
+
74
+ // THEN
75
+ expect(mockRegisterComponentListener).toBeCalledTimes(0);
76
+ })
77
+
78
+ it('M register only once W startTracking()', async () => {
79
+ // GIVEN
80
+ let componentId = "component42"
81
+ DdRumReactNativeNavigationTracking.startTracking();
82
+
83
+ // WHEN
84
+ const testInstance = React.createElement('View', { 'componentId': componentId });
85
+ const otherTestInstance = React.createElement('View', { 'componentId': componentId, 'something': 'else' });
86
+
87
+ // THEN
88
+ expect(mockRegisterComponentListener.mock.calls.length).toBe(1);
89
+ })
90
+
91
+ it('M restore original createElement method W stopTracking()', async () => {
92
+ // GIVEN
93
+ let componentId = "component42"
94
+ DdRumReactNativeNavigationTracking.startTracking();
95
+
96
+ // WHEN
97
+ DdRumReactNativeNavigationTracking.stopTracking();
98
+ const testInstance = React.createElement('View', { 'componentId': componentId });
99
+
100
+ // THEN
101
+ expect(mockRegisterComponentListener.mock.calls.length).toBe(0);
102
+ })
103
+
104
+ it('M send a RUM ViewEvent W startTracking() componentDidAppear', async () => {
105
+ // GIVEN
106
+ let componentId = "component42"
107
+ DdRumReactNativeNavigationTracking.startTracking();
108
+
109
+ // WHEN
110
+ const testInstance = React.createElement('View', { 'componentId': componentId });
111
+ const listener = mockRegisterComponentListener.mock.calls[0][0];
112
+ const componentName = "some-name";
113
+ listener.componentDidAppear({ componentName: componentName });
114
+
115
+ // THEN
116
+ expect(DdRum.startView.mock.calls.length).toBe(1);
117
+ expect(DdRum.startView.mock.calls[0][0]).toBe(componentId);
118
+ expect(DdRum.startView.mock.calls[0][1]).toBe(componentName);
119
+ expect(DdRum.startView.mock.calls[0][2]).toBeUndefined();
120
+ })
121
+
122
+
123
+
124
+ it('M send a RUM ViewEvent W startTracking() componentDidAppear { custom viewPredicate }', async () => {
125
+ // GIVEN
126
+ let componentId = "component42"
127
+ const customViewName = "custom_view_name"
128
+ const predicate: ViewNamePredicate = function (_event: ComponentDidAppearEvent, _trackedName: string) {
129
+ return customViewName
130
+ };
131
+ DdRumReactNativeNavigationTracking.startTracking(predicate);
132
+
133
+ // WHEN
134
+ const testInstance = React.createElement('View', { 'componentId': componentId });
135
+ const listener = mockRegisterComponentListener.mock.calls[0][0];
136
+ const componentName = "some-name";
137
+ listener.componentDidAppear({ componentName: componentName });
138
+
139
+ // THEN
140
+ expect(DdRum.startView.mock.calls.length).toBe(1);
141
+ expect(DdRum.startView.mock.calls[0][0]).toBe(componentId);
142
+ expect(DdRum.startView.mock.calls[0][1]).toBe(customViewName);
143
+ expect(DdRum.startView.mock.calls[0][2]).toBeUndefined();
144
+ })
145
+
146
+ it('M send a RUM ViewEvent W startTracking() componentDidDisappear', async () => {
147
+
148
+ // GIVEN
149
+ let componentId = "component42"
150
+ DdRumReactNativeNavigationTracking.startTracking();
151
+
152
+ // WHEN
153
+ const testInstance = React.createElement('View', { 'componentId': componentId });
154
+ const listener = mockRegisterComponentListener.mock.calls[0][0];
155
+ listener.componentDidDisappear();
156
+
157
+ // THEN
158
+ expect(DdRum.stopView.mock.calls.length).toBe(1);
159
+ expect(DdRum.stopView.mock.calls[0][0]).toBe(componentId);
160
+ expect(DdRum.stopView.mock.calls[0][1]).toBeUndefined();
161
+ })
package/src/index.tsx CHANGED
@@ -4,6 +4,6 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- import DdRumReactNativeNavigationTracking from './rum/instrumentation/DdRumReactNativeNavigationTracking';
7
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from './rum/instrumentation/DdRumReactNativeNavigationTracking';
8
8
 
9
- export { DdRumReactNativeNavigationTracking };
9
+ export { DdRumReactNativeNavigationTracking, ViewNamePredicate };
@@ -8,19 +8,23 @@ import React from 'react'
8
8
  import { ComponentDidAppearEvent, Navigation } from 'react-native-navigation';
9
9
  import { DdRum } from '@datadog/mobile-react-native';
10
10
 
11
+ export type ViewNamePredicate = (event: ComponentDidAppearEvent, trackedName: string) => string
12
+
11
13
  /**
12
14
  * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.
13
15
  */
14
- export default class DdRumReactNativeNavigationTracking {
16
+ export class DdRumReactNativeNavigationTracking {
15
17
 
16
18
  private static isTracking = false
17
19
  private static trackedComponentIds : Array<any> = [];
18
20
  private static originalCreateElement: any = undefined
19
21
 
22
+ private static viewNamePredicate: ViewNamePredicate;
23
+
20
24
  /**
21
25
  * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
22
26
  */
23
- static startTracking(): void {
27
+ static startTracking(viewNamePredicate: ViewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }): void {
24
28
  // extra safety to avoid wrapping more than 1 time this function
25
29
  if (DdRumReactNativeNavigationTracking.isTracking) {
26
30
  return
@@ -28,18 +32,19 @@ export default class DdRumReactNativeNavigationTracking {
28
32
  const original = React.createElement
29
33
  DdRumReactNativeNavigationTracking.originalCreateElement = original
30
34
  React.createElement = (element: any, props: any, ...children: any): any => {
31
- if (
32
- props.componentId != undefined
35
+ if (props && props.componentId != undefined
33
36
  && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)
34
37
  ) {
35
38
  const componentId = props.componentId
36
39
  Navigation.events().registerComponentListener(
37
40
  {
38
41
  componentDidAppear: (event: ComponentDidAppearEvent) => {
39
- DdRum.startView(componentId, event.componentName, Date.now(), {});
42
+ const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;
43
+ const screenName = predicate(event, event.componentName) ?? event.componentName;
44
+ DdRum.startView(componentId, screenName);
40
45
  },
41
46
  componentDidDisappear: () => {
42
- DdRum.stopView(componentId, Date.now(), {});
47
+ DdRum.stopView(componentId);
43
48
  },
44
49
  },
45
50
  componentId
@@ -50,6 +55,7 @@ export default class DdRumReactNativeNavigationTracking {
50
55
  return original(element, props, ...children)
51
56
  }
52
57
  DdRumReactNativeNavigationTracking.isTracking = true
58
+ DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate
53
59
  }
54
60
 
55
61
  /**
@@ -64,5 +70,6 @@ export default class DdRumReactNativeNavigationTracking {
64
70
  }
65
71
  DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length)
66
72
  DdRumReactNativeNavigationTracking.isTracking = false
73
+ DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }
67
74
  }
68
75
  }