@datadog/mobile-react-native-navigation 1.0.0-rc2 → 1.0.0-rc5

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 (28) hide show
  1. package/README.md +9 -3
  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 +24 -4
  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 +23 -4
  9. package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
  10. package/lib/typescript/core/src/DdSdkReactNative.d.ts +9 -0
  11. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +5 -2
  12. package/lib/typescript/core/src/InternalLog.d.ts +6 -0
  13. package/lib/typescript/core/src/ProxyConfiguration.d.ts +56 -0
  14. package/lib/typescript/core/src/SdkVerbosity.d.ts +9 -0
  15. package/lib/typescript/core/src/Timer.d.ts +20 -0
  16. package/lib/typescript/core/src/index.d.ts +3 -1
  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 +12 -11
  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 +4 -4
  25. package/src/__tests__/rum/instrumentation/DdRumReactNativeNavigationTracking.test.tsx +24 -1
  26. package/src/index.tsx +2 -2
  27. package/src/rum/instrumentation/DdRumReactNativeNavigationTracking.tsx +11 -3
  28. package/lib/typescript/core/src/NativeSdkVerbosity.d.ts +0 -9
package/README.md CHANGED
@@ -20,13 +20,19 @@ yarn add @datadog/mobile-react-native-navigation
20
20
 
21
21
  ### Track view navigation
22
22
 
23
- In order to start tracking your navigation events, simply call the add the following lines before setting up your navigation:
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
24
 
25
25
  ```js
26
- import { DdRumReactNativeNavigationTracking } from '@datadog/mobile-react-native-navigation';
26
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from '@datadog/mobile-react-native-navigation';
27
+ import { ComponentDidAppearEvent } from 'react-native-navigation';
27
28
 
28
- DdRumReactNativeNavigationTracking.startTracking();
29
+ const viewNamePredicate: ViewNamePredicate = function customViewNamePredicate(event: ComponentDidAppearEvent, trackedName: string) {
30
+ return "My custom View Name"
31
+ }
32
+
33
+ DdRumReactNativeNavigationTracking.startTracking(viewNamePredicate);
29
34
  ```
30
35
 
31
36
  [1]: https://github.com/wix/react-native-navigation
32
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
 
@@ -23,6 +23,10 @@ class DdRumReactNativeNavigationTracking {
23
23
  * Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
24
24
  */
25
25
  static startTracking() {
26
+ let viewNamePredicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (_event, trackedName) {
27
+ return trackedName;
28
+ };
29
+
26
30
  // extra safety to avoid wrapping more than 1 time this function
27
31
  if (DdRumReactNativeNavigationTracking.isTracking) {
28
32
  return;
@@ -31,13 +35,18 @@ class DdRumReactNativeNavigationTracking {
31
35
  const original = _react.default.createElement;
32
36
  DdRumReactNativeNavigationTracking.originalCreateElement = original;
33
37
 
34
- _react.default.createElement = (element, props, ...children) => {
38
+ _react.default.createElement = function (element, props) {
35
39
  if (props && props.componentId != undefined && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)) {
36
40
  const componentId = props.componentId;
37
41
 
38
42
  _reactNativeNavigation.Navigation.events().registerComponentListener({
39
43
  componentDidAppear: event => {
40
- _mobileReactNative.DdRum.startView(componentId, event.componentName);
44
+ var _predicate;
45
+
46
+ const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;
47
+ const screenName = (_predicate = predicate(event, event.componentName)) !== null && _predicate !== void 0 ? _predicate : event.componentName;
48
+
49
+ _mobileReactNative.DdRum.startView(componentId, screenName);
41
50
  },
42
51
  componentDidDisappear: () => {
43
52
  _mobileReactNative.DdRum.stopView(componentId);
@@ -47,10 +56,15 @@ class DdRumReactNativeNavigationTracking {
47
56
  DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);
48
57
  }
49
58
 
59
+ for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
60
+ children[_key - 2] = arguments[_key];
61
+ }
62
+
50
63
  return original(element, props, ...children);
51
64
  };
52
65
 
53
66
  DdRumReactNativeNavigationTracking.isTracking = true;
67
+ DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;
54
68
  }
55
69
  /**
56
70
  * Stops tracking Navigation.
@@ -68,15 +82,21 @@ class DdRumReactNativeNavigationTracking {
68
82
 
69
83
  DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length);
70
84
  DdRumReactNativeNavigationTracking.isTracking = false;
85
+
86
+ DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event, trackedName) {
87
+ return trackedName;
88
+ };
71
89
  }
72
90
 
73
91
  }
74
92
 
75
- exports.default = DdRumReactNativeNavigationTracking;
93
+ exports.DdRumReactNativeNavigationTracking = DdRumReactNativeNavigationTracking;
76
94
 
77
95
  _defineProperty(DdRumReactNativeNavigationTracking, "isTracking", false);
78
96
 
79
97
  _defineProperty(DdRumReactNativeNavigationTracking, "trackedComponentIds", []);
80
98
 
81
99
  _defineProperty(DdRumReactNativeNavigationTracking, "originalCreateElement", undefined);
100
+
101
+ _defineProperty(DdRumReactNativeNavigationTracking, "viewNamePredicate", void 0);
82
102
  //# 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","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,UAAID,KAAK,IAAIA,KAAK,CAACE,WAAN,IAAqBC,SAA9B,IACG,CAACX,kCAAkC,CAACY,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;AACpDC,qCAAMC,SAAN,CAAgBV,WAAhB,EAA6BQ,KAAK,CAACG,aAAnC;AACH,WAHL;AAIIC,UAAAA,qBAAqB,EAAE,MAAM;AACzBH,qCAAMI,QAAN,CAAeb,WAAf;AACH;AANL,SADJ,EASIA,WATJ;;AAWAV,QAAAA,kCAAkC,CAACY,mBAAnC,CAAuDY,IAAvD,CAA4Dd,WAA5D;AACH;;AAED,aAAOP,QAAQ,CAACI,OAAD,EAAUC,KAAV,EAAiB,GAAGC,QAApB,CAAf;AACH,KApBD;;AAqBAT,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,IAAhD;AACH;AAED;AACJ;AACA;;;AACuB,SAAZuB,YAAY,GAAS;AACxB,QAAI,CAACzB,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,CAAuDc,MAAvD,CAA8D,CAA9D,EAAiE1B,kCAAkC,CAACY,mBAAnC,CAAuDe,MAAxH;AACA3B,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,KAAhD;AACH;;AApDmD;;;;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 (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 DdRum.startView(componentId, event.componentName);\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 }\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","componentId","undefined","trackedComponentIds","includes","Navigation","events","registerComponentListener","componentDidAppear","event","predicate","screenName","componentName","DdRum","startView","componentDidDisappear","stopView","push","children","stopTracking","splice","length"],"mappings":";;;;;;;AAMA;;AACA;;AACA;;;;;;AAIA;AACA;AACA;AACO,MAAMA,kCAAN,CAAyC;AAQ5C;AACJ;AACA;AACwB,SAAbC,aAAa,GAAuI;AAAA,QAAtIC,iBAAsI,uEAA/F,UAAUC,MAAV,EAA2CC,WAA3C,EAAgE;AAAE,aAAOA,WAAP;AAAqB,KAAQ;;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,UAACE,OAAD,EAAeC,KAAf,EAAqD;AACvE,UAAIA,KAAK,IAAIA,KAAK,CAACC,WAAN,IAAqBC,SAA9B,IACG,CAACb,kCAAkC,CAACc,mBAAnC,CAAuDC,QAAvD,CAAgEJ,KAAK,CAACC,WAAtE,CADR,EAEE;AACE,cAAMA,WAAW,GAAGD,KAAK,CAACC,WAA1B;;AACAI,0CAAWC,MAAX,GAAoBC,yBAApB,CACI;AACIC,UAAAA,kBAAkB,EAAGC,KAAD,IAAoC;AAAA;;AACpD,kBAAMC,SAAS,GAAGrB,kCAAkC,CAACE,iBAArD;AACA,kBAAMoB,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;;AAaAZ,QAAAA,kCAAkC,CAACc,mBAAnC,CAAuDc,IAAvD,CAA4DhB,WAA5D;AACH;;AAnBsE,wCAAvBiB,QAAuB;AAAvBA,QAAAA,QAAuB;AAAA;;AAqBvE,aAAOvB,QAAQ,CAACI,OAAD,EAAUC,KAAV,EAAiB,GAAGkB,QAApB,CAAf;AACH,KAtBD;;AAuBA7B,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,IAA4DI,SAAhE,EAA2E;AACvEN,qBAAMC,aAAN,GAAsBR,kCAAkC,CAACS,qBAAzD;AACH;;AACDT,IAAAA,kCAAkC,CAACc,mBAAnC,CAAuDiB,MAAvD,CAA8D,CAA9D,EAAiE/B,kCAAkC,CAACc,mBAAnC,CAAuDkB,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,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}"]}
@@ -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,19 @@ 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
19
  static startTracking() {
20
+ let viewNamePredicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function (_event, trackedName) {
21
+ return trackedName;
22
+ };
23
+
20
24
  // extra safety to avoid wrapping more than 1 time this function
21
25
  if (DdRumReactNativeNavigationTracking.isTracking) {
22
26
  return;
@@ -25,12 +29,16 @@ export default class DdRumReactNativeNavigationTracking {
25
29
  const original = React.createElement;
26
30
  DdRumReactNativeNavigationTracking.originalCreateElement = original;
27
31
 
28
- React.createElement = (element, props, ...children) => {
32
+ React.createElement = function (element, props) {
29
33
  if (props && props.componentId != undefined && !DdRumReactNativeNavigationTracking.trackedComponentIds.includes(props.componentId)) {
30
34
  const componentId = props.componentId;
31
35
  Navigation.events().registerComponentListener({
32
36
  componentDidAppear: event => {
33
- DdRum.startView(componentId, event.componentName);
37
+ var _predicate;
38
+
39
+ const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;
40
+ const screenName = (_predicate = predicate(event, event.componentName)) !== null && _predicate !== void 0 ? _predicate : event.componentName;
41
+ DdRum.startView(componentId, screenName);
34
42
  },
35
43
  componentDidDisappear: () => {
36
44
  DdRum.stopView(componentId);
@@ -39,10 +47,15 @@ export default class DdRumReactNativeNavigationTracking {
39
47
  DdRumReactNativeNavigationTracking.trackedComponentIds.push(componentId);
40
48
  }
41
49
 
50
+ for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
51
+ children[_key - 2] = arguments[_key];
52
+ }
53
+
42
54
  return original(element, props, ...children);
43
55
  };
44
56
 
45
57
  DdRumReactNativeNavigationTracking.isTracking = true;
58
+ DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;
46
59
  }
47
60
  /**
48
61
  * Stops tracking Navigation.
@@ -60,6 +73,10 @@ export default class DdRumReactNativeNavigationTracking {
60
73
 
61
74
  DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length);
62
75
  DdRumReactNativeNavigationTracking.isTracking = false;
76
+
77
+ DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event, trackedName) {
78
+ return trackedName;
79
+ };
63
80
  }
64
81
 
65
82
  }
@@ -69,4 +86,6 @@ _defineProperty(DdRumReactNativeNavigationTracking, "isTracking", false);
69
86
  _defineProperty(DdRumReactNativeNavigationTracking, "trackedComponentIds", []);
70
87
 
71
88
  _defineProperty(DdRumReactNativeNavigationTracking, "originalCreateElement", undefined);
89
+
90
+ _defineProperty(DdRumReactNativeNavigationTracking, "viewNamePredicate", void 0);
72
91
  //# 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","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,UAAID,KAAK,IAAIA,KAAK,CAACE,WAAN,IAAqBC,SAA9B,IACG,CAACV,kCAAkC,CAACW,mBAAnC,CAAuDC,QAAvD,CAAgEL,KAAK,CAACE,WAAtE,CADR,EAEE;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;AACH,WAHL;AAIIC,UAAAA,qBAAqB,EAAE,MAAM;AACzBpB,YAAAA,KAAK,CAACqB,QAAN,CAAeX,WAAf;AACH;AANL,SADJ,EASIA,WATJ;AAWAT,QAAAA,kCAAkC,CAACW,mBAAnC,CAAuDU,IAAvD,CAA4DZ,WAA5D;AACH;;AAED,aAAON,QAAQ,CAACG,OAAD,EAAUC,KAAV,EAAiB,GAAGC,QAApB,CAAf;AACH,KApBD;;AAqBAR,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,IAAhD;AACH;AAED;AACJ;AACA;;;AACuB,SAAZoB,YAAY,GAAS;AACxB,QAAI,CAACtB,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,CAAuDY,MAAvD,CAA8D,CAA9D,EAAiEvB,kCAAkC,CAACW,mBAAnC,CAAuDa,MAAxH;AACAxB,IAAAA,kCAAkC,CAACE,UAAnC,GAAgD,KAAhD;AACH;;AApDmD;;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 (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 DdRum.startView(componentId, event.componentName);\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 }\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","componentId","undefined","trackedComponentIds","includes","events","registerComponentListener","componentDidAppear","event","predicate","screenName","componentName","startView","componentDidDisappear","stopView","push","children","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,GAAuI;AAAA,QAAtIC,iBAAsI,uEAA/F,UAAUC,MAAV,EAA2CC,WAA3C,EAAgE;AAAE,aAAOA,WAAP;AAAqB,KAAQ;;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,UAACE,OAAD,EAAeC,KAAf,EAAqD;AACvE,UAAIA,KAAK,IAAIA,KAAK,CAACC,WAAN,IAAqBC,SAA9B,IACG,CAACZ,kCAAkC,CAACa,mBAAnC,CAAuDC,QAAvD,CAAgEJ,KAAK,CAACC,WAAtE,CADR,EAEE;AACE,cAAMA,WAAW,GAAGD,KAAK,CAACC,WAA1B;AACAb,QAAAA,UAAU,CAACiB,MAAX,GAAoBC,yBAApB,CACI;AACIC,UAAAA,kBAAkB,EAAGC,KAAD,IAAoC;AAAA;;AACpD,kBAAMC,SAAS,GAAGnB,kCAAkC,CAACE,iBAArD;AACA,kBAAMkB,UAAU,iBAAGD,SAAS,CAACD,KAAD,EAAQA,KAAK,CAACG,aAAd,CAAZ,mDAA4CH,KAAK,CAACG,aAAlE;AACAtB,YAAAA,KAAK,CAACuB,SAAN,CAAgBX,WAAhB,EAA6BS,UAA7B;AACH,WALL;AAMIG,UAAAA,qBAAqB,EAAE,MAAM;AACzBxB,YAAAA,KAAK,CAACyB,QAAN,CAAeb,WAAf;AACH;AARL,SADJ,EAWIA,WAXJ;AAaAX,QAAAA,kCAAkC,CAACa,mBAAnC,CAAuDY,IAAvD,CAA4Dd,WAA5D;AACH;;AAnBsE,wCAAvBe,QAAuB;AAAvBA,QAAAA,QAAuB;AAAA;;AAqBvE,aAAOpB,QAAQ,CAACG,OAAD,EAAUC,KAAV,EAAiB,GAAGgB,QAApB,CAAf;AACH,KAtBD;;AAuBA1B,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,IAA4DI,SAAhE,EAA2E;AACvEf,MAAAA,KAAK,CAACU,aAAN,GAAsBP,kCAAkC,CAACQ,qBAAzD;AACH;;AACDR,IAAAA,kCAAkC,CAACa,mBAAnC,CAAuDe,MAAvD,CAA8D,CAA9D,EAAiE5B,kCAAkC,CAACa,mBAAnC,CAAuDgB,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,2BAImCY,S;;gBAJnCZ,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,8 +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;
8
10
  private static readonly DD_SDK_VERBOSITY_KEY;
9
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;
10
19
  private static wasInitialized;
11
20
  /**
12
21
  * Initializes the Datadog SDK.
@@ -1,5 +1,6 @@
1
1
  import { TrackingConsent } from './TrackingConsent';
2
- import type { NativeSdkVerbosity } from './NativeSdkVerbosity';
2
+ import type { SdkVerbosity } from './SdkVerbosity';
3
+ import type { ProxyConfiguration } from './ProxyConfiguration';
3
4
  /**
4
5
  * The SDK configuration class.
5
6
  * It will be used to configure the SDK functionality at initialization.
@@ -15,8 +16,10 @@ export declare class DdSdkReactNativeConfiguration {
15
16
  nativeCrashReportEnabled: boolean;
16
17
  sampleRate: number;
17
18
  site: string;
18
- verbosity: NativeSdkVerbosity | undefined;
19
+ verbosity: SdkVerbosity | undefined;
19
20
  nativeViewTracking: boolean;
21
+ proxyConfig?: ProxyConfiguration;
22
+ serviceName?: string;
20
23
  additionalConfig: {
21
24
  [k: string]: any;
22
25
  };
@@ -0,0 +1,6 @@
1
+ import { SdkVerbosity } from './SdkVerbosity';
2
+ export declare class InternalLog {
3
+ private static levelMap;
4
+ static verbosity: SdkVerbosity | undefined;
5
+ static log(message: string, verbosity: SdkVerbosity): void;
6
+ }
@@ -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,9 @@
1
+ /**
2
+ * Enum specifying possible log levels for DD SDK.
3
+ */
4
+ export declare enum SdkVerbosity {
5
+ DEBUG = "debug",
6
+ INFO = "info",
7
+ WARN = "warn",
8
+ ERROR = "error"
9
+ }
@@ -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,7 @@
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
+ import { SdkVerbosity } from './SdkVerbosity';
7
+ export { DdLogs, DdTrace, DdRum, DdSdkReactNativeConfiguration, DdSdkReactNative, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
@@ -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
  }
@@ -74,14 +74,14 @@ export declare type DdTraceType = {
74
74
  * Start a span, and returns a unique identifier for the span.
75
75
  * @param operation: The operation name of the span.
76
76
  * @param context: The additional context to send.
77
- * @param timestampMs: The timestamp when the operation started (in milliseconds).
77
+ * @param timestampMs: The timestamp when the operation started (in milliseconds). If not provided, current timestamp will be used.
78
78
  */
79
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
83
  * @param context: The additional context to send.
84
- * @param timestampMs: The timestamp when the operation stopped (in milliseconds).
84
+ * @param timestampMs: The timestamp when the operation stopped (in milliseconds). If not provided, current timestamp will be used.
85
85
  */
86
86
  finishSpan(spanId: string, context?: object, timestampMs?: number): Promise<void>;
87
87
  };
@@ -94,14 +94,14 @@ export declare type DdRumType = {
94
94
  * @param key: The view unique key identifier.
95
95
  * @param name: The view name.
96
96
  * @param context: The additional context to send.
97
- * @param timestampMs: The timestamp when the view started (in milliseconds).
97
+ * @param timestampMs: The timestamp when the view started (in milliseconds). If not provided, current timestamp will be used.
98
98
  */
99
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
103
  * @param context: The additional context to send.
104
- * @param timestampMs: The timestamp when the view stopped (in milliseconds).
104
+ * @param timestampMs: The timestamp when the view stopped (in milliseconds). If not provided, current timestamp will be used.
105
105
  */
106
106
  stopView(key: string, context?: object, timestampMs?: number): Promise<void>;
107
107
  /**
@@ -109,13 +109,13 @@ export declare type DdRumType = {
109
109
  * @param type: The action type (tap, scroll, swipe, click, custom).
110
110
  * @param name: The action name.
111
111
  * @param context: The additional context to send.
112
- * @param timestampMs: The timestamp when the action started (in milliseconds).
112
+ * @param timestampMs: The timestamp when the action started (in milliseconds). If not provided, current timestamp will be used.
113
113
  */
114
114
  startAction(type: string, name: string, context?: object, timestampMs?: number): Promise<void>;
115
115
  /**
116
116
  * Stop tracking the ongoing RUM Action.
117
117
  * @param context: The additional context to send.
118
- * @param timestampMs: The timestamp when the action stopped (in milliseconds).
118
+ * @param timestampMs: The timestamp when the action stopped (in milliseconds). If not provided, current timestamp will be used.
119
119
  */
120
120
  stopAction(context?: object, timestampMs?: number): Promise<void>;
121
121
  /**
@@ -123,7 +123,7 @@ export declare type DdRumType = {
123
123
  * @param type: The action type (tap, scroll, swipe, click, custom).
124
124
  * @param name: The action name.
125
125
  * @param context: The additional context to send.
126
- * @param timestampMs: The timestamp when the action occurred (in milliseconds).
126
+ * @param timestampMs: The timestamp when the action occurred (in milliseconds). If not provided, current timestamp will be used.
127
127
  */
128
128
  addAction(type: string, name: string, context?: object, timestampMs?: number): Promise<void>;
129
129
  /**
@@ -132,7 +132,7 @@ export declare type DdRumType = {
132
132
  * @param method: The resource method (GET, POST, …).
133
133
  * @param url: The resource url.
134
134
  * @param context: The additional context to send.
135
- * @param timestampMs: The timestamp when the resource started (in milliseconds).
135
+ * @param timestampMs: The timestamp when the resource started (in milliseconds). If not provided, current timestamp will be used.
136
136
  */
137
137
  startResource(key: string, method: string, url: string, context?: object, timestampMs?: number): Promise<void>;
138
138
  /**
@@ -140,17 +140,18 @@ export declare type DdRumType = {
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 size: The resource size in bytes. If size is unknown, use -1.
143
144
  * @param context: The additional context to send.
144
- * @param timestampMs: The timestamp when the resource stopped (in milliseconds).
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, context?: object, timestampMs?: number): 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
153
  * @param context: The additional context to send.
153
- * @param timestampMs: The timestamp when the error occurred (in milliseconds).
154
+ * @param timestampMs: The timestamp when the error occurred (in milliseconds). If not provided, current timestamp will be used.
154
155
  */
155
156
  addError(message: string, source: string, stacktrace: string, context?: object, timestampMs?: number): Promise<void>;
156
157
  /**
@@ -0,0 +1 @@
1
+ export declare const version = "1.0.0-rc5";
@@ -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-rc2",
3
+ "version": "1.0.0-rc5",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -36,14 +36,14 @@
36
36
  "prepare": "bob build"
37
37
  },
38
38
  "devDependencies": {
39
- "@datadog/mobile-react-native": "^1.0.0-rc2",
39
+ "@datadog/mobile-react-native": "^1.0.0-rc5",
40
40
  "react-native-gesture-handler": "1.10.3",
41
41
  "react-native-navigation": "7.13.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@datadog/mobile-react-native": "^1.0.0-beta4",
45
45
  "react": ">=16.13.1",
46
- "react-native": "^0.63.4",
46
+ "react-native": ">=0.63.4 <1.0",
47
47
  "react-native-navigation": "^7.5.0"
48
48
  },
49
49
  "jest": {
@@ -70,5 +70,5 @@
70
70
  ]
71
71
  ]
72
72
  },
73
- "gitHead": "ed6e0566e2096406ba393ecd03ba8ac964ba8b9b"
73
+ "gitHead": "6be800b36e37b072e43a36a32fd058a1ba6fd889"
74
74
  }
@@ -6,7 +6,8 @@
6
6
 
7
7
  import React from 'react';
8
8
  import { DdRum } from '@datadog/mobile-react-native';
9
- import DdRumReactNativeNavigationTracking from '../../../rum/instrumentation/DdRumReactNativeNavigationTracking';
9
+ import { ComponentDidAppearEvent } from 'react-native-navigation';
10
+ import { DdRumReactNativeNavigationTracking, ViewNamePredicate } from '../../../rum/instrumentation/DdRumReactNativeNavigationTracking';
10
11
 
11
12
  jest.mock('@datadog/mobile-react-native', () => {
12
13
  return {
@@ -120,6 +121,28 @@ it('M send a RUM ViewEvent W startTracking() componentDidAppear', async () => {
120
121
 
121
122
 
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
+
123
146
  it('M send a RUM ViewEvent W startTracking() componentDidDisappear', async () => {
124
147
 
125
148
  // GIVEN
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
@@ -35,7 +39,9 @@ export default class DdRumReactNativeNavigationTracking {
35
39
  Navigation.events().registerComponentListener(
36
40
  {
37
41
  componentDidAppear: (event: ComponentDidAppearEvent) => {
38
- DdRum.startView(componentId, event.componentName);
42
+ const predicate = DdRumReactNativeNavigationTracking.viewNamePredicate;
43
+ const screenName = predicate(event, event.componentName) ?? event.componentName;
44
+ DdRum.startView(componentId, screenName);
39
45
  },
40
46
  componentDidDisappear: () => {
41
47
  DdRum.stopView(componentId);
@@ -49,6 +55,7 @@ export default class DdRumReactNativeNavigationTracking {
49
55
  return original(element, props, ...children)
50
56
  }
51
57
  DdRumReactNativeNavigationTracking.isTracking = true
58
+ DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate
52
59
  }
53
60
 
54
61
  /**
@@ -63,5 +70,6 @@ export default class DdRumReactNativeNavigationTracking {
63
70
  }
64
71
  DdRumReactNativeNavigationTracking.trackedComponentIds.splice(0, DdRumReactNativeNavigationTracking.trackedComponentIds.length)
65
72
  DdRumReactNativeNavigationTracking.isTracking = false
73
+ DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event: ComponentDidAppearEvent, trackedName: string) { return trackedName; }
66
74
  }
67
75
  }
@@ -1,9 +0,0 @@
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
- }