@datadog/mobile-react-native-navigation 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/lib/commonjs/rum/instrumentation/DdRumReactNativeNavigationTracking.js +2 -0
  2. package/lib/commonjs/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
  3. package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js +2 -0
  4. package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
  5. package/lib/typescript/core/src/DdSdkReactNativeConfiguration.d.ts +11 -3
  6. package/lib/typescript/core/src/index.d.ts +3 -3
  7. package/lib/typescript/core/src/rum/eventMappers/resourceEventMapper.d.ts +0 -1
  8. package/lib/typescript/core/src/rum/instrumentation/interactionTracking/DdRumUserInteractionTracking.d.ts +1 -0
  9. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/DdRumResourceTracking.d.ts +2 -1
  10. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/distributedTracing.d.ts +32 -6
  11. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/distributedTracingHeaders.d.ts +21 -0
  12. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/firstPartyHosts.d.ts +4 -2
  13. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/interfaces/RequestProxy.d.ts +6 -1
  14. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/domain/interfaces/RumResource.d.ts +0 -1
  15. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/XHRProxy.d.ts +0 -6
  16. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/implementation/responseSize.d.ts +0 -1
  17. package/lib/typescript/core/src/rum/types.d.ts +17 -0
  18. package/lib/typescript/core/src/version.d.ts +1 -1
  19. package/package.json +3 -3
  20. package/src/rum/instrumentation/DdRumReactNativeNavigationTracking.tsx +2 -0
@@ -64,6 +64,8 @@ class DdRumReactNativeNavigationTracking {
64
64
  if (this.appStateSubscription) {
65
65
  this.appStateSubscription.remove();
66
66
  } else {
67
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
68
+ // @ts-ignore
67
69
  _reactNative.AppState.removeEventListener('change', DdRumReactNativeNavigationTracking.appStateListener);
68
70
  }
69
71
 
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["DdRumReactNativeNavigationTracking","startTracking","viewNamePredicate","_event","trackedName","isTracking","eventSubscription","Navigation","events","registerComponentDidAppearListener","event","predicate","screenName","componentName","DdRum","startView","componentId","lastView","key","name","appStateSubscription","AppState","addEventListener","appStateListener","stopTracking","remove","removeEventListener","undefined","appStateStatus","InternalLog","log","SdkVerbosity","ERROR","stopView"],"mappings":";;;;;;;AAMA;;AAEA;;AAMA;;;;AAeA;AACA;AACA;AACO,MAAMA,kCAAN,CAAyC;AAe5C;AACJ;AACA;AACwB,SAAbC,aAAa,CAChBC,iBAAoC,GAAG,UACnCC,MADmC,EAEnCC,WAFmC,EAGrC;AACE,WAAOA,WAAP;AACH,GANe,EAOZ;AACJ;AACA,QAAIJ,kCAAkC,CAACK,UAAvC,EAAmD;AAC/C;AACH;;AAEDL,IAAAA,kCAAkC,CAACM,iBAAnC,GAAuDC,kCAAWC,MAAX,GAAoBC,kCAApB,CAClDC,KAAD,IAAoC;AAChC,YAAMC,SAAS,GACXX,kCAAkC,CAACE,iBADvC;AAEA,YAAMU,UAAU,GAAGD,SAAS,CAACD,KAAD,EAAQA,KAAK,CAACG,aAAd,CAA5B;;AACA,UAAID,UAAU,KAAK,IAAnB,EAAyB;AACrBE,iCAAMC,SAAN,CAAgBL,KAAK,CAACM,WAAtB,EAAmCJ,UAAnC;;AACAZ,QAAAA,kCAAkC,CAACiB,QAAnC,GAA8C;AAC1CC,UAAAA,GAAG,EAAER,KAAK,CAACM,WAD+B;AAE1CG,UAAAA,IAAI,EAAEP;AAFoC,SAA9C;AAIH;A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KAAK,YAAvB,EAAqC;AACjCd,6BAAMmB,QAAN,CAAehB,QAAQ,CAACC,GAAxB;AACH,GAFD,MAEO,IACHU,cAAc,KAAK,QAAnB,IACAA,cAAc,KAAKD,SAFhB,EAGL;AACE;AACA;AACAb,6BAAMC,SAAN,CAAgBE,QAAQ,CAACC,GAAzB,EAA8BD,QAAQ,CAACE,IAAvC;AACH;AACJ,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum, InternalLog, SdkVerbosity } from '@datadog/mobile-react-native';\nimport type { ComponentDidAppearEvent } from 'react-native-navigation';\nimport { Navigation } from 'react-native-navigation';\nimport type {\n AppStateStatus,\n EmitterSubscription,\n NativeEventSubscription\n} from 'react-native';\nimport { AppState } from 'react-native';\n\nexport type ViewNamePredicate = (\n event: ComponentDidAppearEvent,\n trackedName: string\n) => string | null;\n\n// AppStateStatus can have values:\n// 'active' - The app is running in the foreground\n// 'background' - The app is running in the background. The user is either in another app or on the home screen\n// 'inactive' [iOS] - This is a transition state that currently never happens for typical React Native apps.\n// 'unknown' [iOS] - Initial value until the current app state is determined\n// 'extension' [iOS] - The app is running as an app extension\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null;\n\n/**\n * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n */\nexport class DdRumReactNativeNavigationTracking {\n private static isTracking = false;\n private static eventSubscription:\n | EmitterSubscription\n | undefined = undefined;\n private static appStateSubscription?: NativeEventSubscription;\n\n private static viewNamePredicate: ViewNamePredicate;\n private static lastView?:\n | {\n key: string;\n name: string;\n }\n | 'tracking_not_started' = 'tracking_not_started';\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(\n viewNamePredicate: ViewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n }\n ): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n\n DdRumReactNativeNavigationTracking.eventSubscription = Navigation.events().registerComponentDidAppearListener(\n (event: ComponentDidAppearEvent) => {\n const predicate =\n DdRumReactNativeNavigationTracking.viewNamePredicate;\n const screenName = predicate(event, event.componentName);\n if (screenName !== null) {\n DdRum.startView(event.componentId, screenName);\n DdRumReactNativeNavigationTracking.lastView = {\n key: event.componentId,\n name: screenName\n };\n }\n }\n );\n\n DdRumReactNativeNavigationTracking.isTracking = true;\n DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;\n this.appStateSubscription = AppState.addEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n if (DdRumReactNativeNavigationTracking.eventSubscription) {\n DdRumReactNativeNavigationTracking.eventSubscription.remove();\n }\n // For versions of React Native below 0.65, addEventListener does not return a subscription.\n // We have to call AppState.removeEventListener instead.\n if (this.appStateSubscription) {\n this.appStateSubscription.remove();\n } else {\n AppState.removeEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n DdRumReactNativeNavigationTracking.lastView = undefined;\n DdRumReactNativeNavigationTracking.isTracking = false;\n DdRumReactNativeNavigationTracking.viewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n };\n }\n\n private static appStateListener: AppStateListener = (\n appStateStatus: AppStateStatus\n ) => {\n const lastView = DdRumReactNativeNavigationTracking.lastView;\n if (lastView === undefined) {\n InternalLog.log(\n `We could not determine the route when changing the application state to: ${appStateStatus}. No RUM View event will be sent in this case.`,\n SdkVerbosity.ERROR\n );\n return;\n }\n\n if (lastView === 'tracking_not_started') {\n // Do nothing as no view has been tracked already\n return;\n }\n\n if (appStateStatus === 'background') {\n DdRum.stopView(lastView.key);\n } else if (\n appStateStatus === 'active' ||\n appStateStatus === undefined\n ) {\n // case when app goes into foreground,\n // in that case navigation listener won't be called\n DdRum.startView(lastView.key, lastView.name);\n }\n };\n}\n"]}
1
+ {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["DdRumReactNativeNavigationTracking","startTracking","viewNamePredicate","_event","trackedName","isTracking","eventSubscription","Navigation","events","registerComponentDidAppearListener","event","predicate","screenName","componentName","DdRum","startView","componentId","lastView","key","name","appStateSubscription","AppState","addEventListener","appStateListener","stopTracking","remove","removeEventListener","undefined","appStateStatus","InternalLog","log","SdkVerbosity","ERROR","stopView"],"mappings":";;;;;;;AAMA;;AAEA;;AAMA;;;;AAeA;AACA;AACA;AACO,MAAMA,kCAAN,CAAyC;AAe5C;AACJ;AACA;AACwB,SAAbC,aAAa,CAChBC,iBAAoC,GAAG,UACnCC,MADmC,EAEnCC,WAFmC,EAGrC;AACE,WAAOA,WAAP;AACH,GANe,EAOZ;AACJ;AACA,QAAIJ,kCAAkC,CAACK,UAAvC,EAAmD;AAC/C;AACH;;AAEDL,IAAAA,kCAAkC,CAACM,iBAAnC,GAAuDC,kCAAWC,MAAX,GAAoBC,kCAApB,CAClDC,KAAD,IAAoC;AAChC,YAAMC,SAAS,GACXX,kCAAkC,CAACE,iBADvC;AAEA,YAAMU,UAAU,GAAGD,SAAS,CAACD,KAAD,EAAQA,KAAK,CAACG,aAAd,CAA5B;;AACA,UAAID,UAAU,KAAK,IAAnB,EAAyB;AACrBE,iCAAMC,SAAN,CAAgBL,KAAK,CAACM,WAAtB,EAAmCJ,UAAnC;;AACAZ,QAAAA,kCAAkC,CAACiB,QAAnC,GAA8C;AAC1CC,UAAAA,GAAG,EAAER,KAAK,CAACM,WAD+B;AAE1CG,UAAAA,IAAI,EAAEP;AAFoC,SAA9C;AAIH;AACJ,KAZkD,CAAvD;AAeAZ,IAAAA,kCAAkC,CAACK,UAAnC,GAAgD,IAAhD;AACAL,IAAA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H,GAFD,MAEO,IACHU,cAAc,KAAK,QAAnB,IACAA,cAAc,KAAKD,SAFhB,EAGL;AACE;AACA;AACAb,6BAAMC,SAAN,CAAgBE,QAAQ,CAACC,GAAzB,EAA8BD,QAAQ,CAACE,IAAvC;AACH;AACJ,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum, InternalLog, SdkVerbosity } from '@datadog/mobile-react-native';\nimport type { ComponentDidAppearEvent } from 'react-native-navigation';\nimport { Navigation } from 'react-native-navigation';\nimport type {\n AppStateStatus,\n EmitterSubscription,\n NativeEventSubscription\n} from 'react-native';\nimport { AppState } from 'react-native';\n\nexport type ViewNamePredicate = (\n event: ComponentDidAppearEvent,\n trackedName: string\n) => string | null;\n\n// AppStateStatus can have values:\n// 'active' - The app is running in the foreground\n// 'background' - The app is running in the background. The user is either in another app or on the home screen\n// 'inactive' [iOS] - This is a transition state that currently never happens for typical React Native apps.\n// 'unknown' [iOS] - Initial value until the current app state is determined\n// 'extension' [iOS] - The app is running as an app extension\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null;\n\n/**\n * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n */\nexport class DdRumReactNativeNavigationTracking {\n private static isTracking = false;\n private static eventSubscription:\n | EmitterSubscription\n | undefined = undefined;\n private static appStateSubscription?: NativeEventSubscription;\n\n private static viewNamePredicate: ViewNamePredicate;\n private static lastView?:\n | {\n key: string;\n name: string;\n }\n | 'tracking_not_started' = 'tracking_not_started';\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(\n viewNamePredicate: ViewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n }\n ): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n\n DdRumReactNativeNavigationTracking.eventSubscription = Navigation.events().registerComponentDidAppearListener(\n (event: ComponentDidAppearEvent) => {\n const predicate =\n DdRumReactNativeNavigationTracking.viewNamePredicate;\n const screenName = predicate(event, event.componentName);\n if (screenName !== null) {\n DdRum.startView(event.componentId, screenName);\n DdRumReactNativeNavigationTracking.lastView = {\n key: event.componentId,\n name: screenName\n };\n }\n }\n );\n\n DdRumReactNativeNavigationTracking.isTracking = true;\n DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;\n this.appStateSubscription = AppState.addEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n if (DdRumReactNativeNavigationTracking.eventSubscription) {\n DdRumReactNativeNavigationTracking.eventSubscription.remove();\n }\n // For versions of React Native below 0.65, addEventListener does not return a subscription.\n // We have to call AppState.removeEventListener instead.\n if (this.appStateSubscription) {\n this.appStateSubscription.remove();\n } else {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n AppState.removeEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n DdRumReactNativeNavigationTracking.lastView = undefined;\n DdRumReactNativeNavigationTracking.isTracking = false;\n DdRumReactNativeNavigationTracking.viewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n };\n }\n\n private static appStateListener: AppStateListener = (\n appStateStatus: AppStateStatus\n ) => {\n const lastView = DdRumReactNativeNavigationTracking.lastView;\n if (lastView === undefined) {\n InternalLog.log(\n `We could not determine the route when changing the application state to: ${appStateStatus}. No RUM View event will be sent in this case.`,\n SdkVerbosity.ERROR\n );\n return;\n }\n\n if (lastView === 'tracking_not_started') {\n // Do nothing as no view has been tracked already\n return;\n }\n\n if (appStateStatus === 'background') {\n DdRum.stopView(lastView.key);\n } else if (\n appStateStatus === 'active' ||\n appStateStatus === undefined\n ) {\n // case when app goes into foreground,\n // in that case navigation listener won't be called\n DdRum.startView(lastView.key, lastView.name);\n }\n };\n}\n"]}
@@ -59,6 +59,8 @@ export class DdRumReactNativeNavigationTracking {
59
59
  if (this.appStateSubscription) {
60
60
  this.appStateSubscription.remove();
61
61
  } else {
62
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
63
+ // @ts-ignore
62
64
  AppState.removeEventListener('change', DdRumReactNativeNavigationTracking.appStateListener);
63
65
  }
64
66
 
@@ -1 +1 @@
1
- {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["DdRum","InternalLog","SdkVerbosity","Navigation","AppState","DdRumReactNativeNavigationTracking","startTracking","viewNamePredicate","_event","trackedName","isTracking","eventSubscription","events","registerComponentDidAppearListener","event","predicate","screenName","componentName","startView","componentId","lastView","key","name","appStateSubscription","addEventListener","appStateListener","stopTracking","remove","removeEventListener","undefined","appStateStatus","log","ERROR","stopView"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,EAAgBC,WAAhB,EAA6BC,YAA7B,QAAiD,8BAAjD;AAEA,SAASC,UAAT,QAA2B,yBAA3B;AAMA,SAASC,QAAT,QAAyB,cAAzB;;AAeA;AACA;AACA;AACA,OAAO,MAAMC,kCAAN,CAAyC;AAe5C;AACJ;AACA;AACwB,SAAbC,aAAa,CAChBC,iBAAoC,GAAG,UACnCC,MADmC,EAEnCC,WAFmC,EAGrC;AACE,WAAOA,WAAP;AACH,GANe,EAOZ;AACJ;AACA,QAAIJ,kCAAkC,CAACK,UAAvC,EAAmD;AAC/C;AACH;;AAEDL,IAAAA,kCAAkC,CAACM,iBAAnC,GAAuDR,UAAU,CAACS,MAAX,GAAoBC,kCAApB,CAClDC,KAAD,IAAoC;AAChC,YAAMC,SAAS,GACXV,kCAAkC,CAACE,iBADvC;AAEA,YAAMS,UAAU,GAAGD,SAAS,CAACD,KAAD,EAAQA,KAAK,CA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;gBAbtBA,kC,sBAsFLyB,cADgD,IAE/C;AACD,QAAMV,QAAQ,GAAGf,kCAAkC,CAACe,QAApD;;AACA,MAAIA,QAAQ,KAAKS,SAAjB,EAA4B;AACxB5B,IAAAA,WAAW,CAAC8B,GAAZ,CACK,4EAA2ED,cAAe,gDAD/F,EAEI5B,YAAY,CAAC8B,KAFjB;AAIA;AACH;;AAED,MAAIZ,QAAQ,KAAK,sBAAjB,EAAyC;AACrC;AACA;AACH;;AAED,MAAIU,cAAc,KAAK,YAAvB,EAAqC;AACjC9B,IAAAA,KAAK,CAACiC,QAAN,CAAeb,QAAQ,CAACC,GAAxB;AACH,GAFD,MAEO,IACHS,cAAc,KAAK,QAAnB,IACAA,cAAc,KAAKD,SAFhB,EAGL;AACE;AACA;AACA7B,IAAAA,KAAK,CAACkB,SAAN,CAAgBE,QAAQ,CAACC,GAAzB,EAA8BD,QAAQ,CAACE,IAAvC;AACH;AACJ,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum, InternalLog, SdkVerbosity } from '@datadog/mobile-react-native';\nimport type { ComponentDidAppearEvent } from 'react-native-navigation';\nimport { Navigation } from 'react-native-navigation';\nimport type {\n AppStateStatus,\n EmitterSubscription,\n NativeEventSubscription\n} from 'react-native';\nimport { AppState } from 'react-native';\n\nexport type ViewNamePredicate = (\n event: ComponentDidAppearEvent,\n trackedName: string\n) => string | null;\n\n// AppStateStatus can have values:\n// 'active' - The app is running in the foreground\n// 'background' - The app is running in the background. The user is either in another app or on the home screen\n// 'inactive' [iOS] - This is a transition state that currently never happens for typical React Native apps.\n// 'unknown' [iOS] - Initial value until the current app state is determined\n// 'extension' [iOS] - The app is running as an app extension\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null;\n\n/**\n * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n */\nexport class DdRumReactNativeNavigationTracking {\n private static isTracking = false;\n private static eventSubscription:\n | EmitterSubscription\n | undefined = undefined;\n private static appStateSubscription?: NativeEventSubscription;\n\n private static viewNamePredicate: ViewNamePredicate;\n private static lastView?:\n | {\n key: string;\n name: string;\n }\n | 'tracking_not_started' = 'tracking_not_started';\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(\n viewNamePredicate: ViewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n }\n ): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n\n DdRumReactNativeNavigationTracking.eventSubscription = Navigation.events().registerComponentDidAppearListener(\n (event: ComponentDidAppearEvent) => {\n const predicate =\n DdRumReactNativeNavigationTracking.viewNamePredicate;\n const screenName = predicate(event, event.componentName);\n if (screenName !== null) {\n DdRum.startView(event.componentId, screenName);\n DdRumReactNativeNavigationTracking.lastView = {\n key: event.componentId,\n name: screenName\n };\n }\n }\n );\n\n DdRumReactNativeNavigationTracking.isTracking = true;\n DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;\n this.appStateSubscription = AppState.addEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n if (DdRumReactNativeNavigationTracking.eventSubscription) {\n DdRumReactNativeNavigationTracking.eventSubscription.remove();\n }\n // For versions of React Native below 0.65, addEventListener does not return a subscription.\n // We have to call AppState.removeEventListener instead.\n if (this.appStateSubscription) {\n this.appStateSubscription.remove();\n } else {\n AppState.removeEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n DdRumReactNativeNavigationTracking.lastView = undefined;\n DdRumReactNativeNavigationTracking.isTracking = false;\n DdRumReactNativeNavigationTracking.viewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n };\n }\n\n private static appStateListener: AppStateListener = (\n appStateStatus: AppStateStatus\n ) => {\n const lastView = DdRumReactNativeNavigationTracking.lastView;\n if (lastView === undefined) {\n InternalLog.log(\n `We could not determine the route when changing the application state to: ${appStateStatus}. No RUM View event will be sent in this case.`,\n SdkVerbosity.ERROR\n );\n return;\n }\n\n if (lastView === 'tracking_not_started') {\n // Do nothing as no view has been tracked already\n return;\n }\n\n if (appStateStatus === 'background') {\n DdRum.stopView(lastView.key);\n } else if (\n appStateStatus === 'active' ||\n appStateStatus === undefined\n ) {\n // case when app goes into foreground,\n // in that case navigation listener won't be called\n DdRum.startView(lastView.key, lastView.name);\n }\n };\n}\n"]}
1
+ {"version":3,"sources":["DdRumReactNativeNavigationTracking.tsx"],"names":["DdRum","InternalLog","SdkVerbosity","Navigation","AppState","DdRumReactNativeNavigationTracking","startTracking","viewNamePredicate","_event","trackedName","isTracking","eventSubscription","events","registerComponentDidAppearListener","event","predicate","screenName","componentName","startView","componentId","lastView","key","name","appStateSubscription","addEventListener","appStateListener","stopTracking","remove","removeEventListener","undefined","appStateStatus","log","ERROR","stopView"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,KAAT,EAAgBC,WAAhB,EAA6BC,YAA7B,QAAiD,8BAAjD;AAEA,SAASC,UAAT,QAA2B,yBAA3B;AAMA,SAASC,QAAT,QAAyB,cAAzB;;AAeA;AACA;AACA;AACA,OAAO,MAAMC,kCAAN,CAAyC;AAe5C;AACJ;AACA;AACwB,SAAbC,aAAa,CAChBC,iBAAoC,GAAG,UACnCC,MADmC,EAEnCC,WAFmC,EAGrC;AACE,WAAOA,WAAP;AACH,GANe,EAOZ;AACJ;AACA,QAAIJ,kCAAkC,CAACK,UAAvC,EAAmD;AAC/C;AACH;;AAEDL,IAAAA,kCAAkC,CAACM,iBAAnC,GAAuDR,UAAU,CAACS,MAAX,GAAoBC,kCAApB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aAAOA,WAAP;AACH,KALD;AAMH;;AArF2C;;gBAAnCJ,kC,gBACmB,K;;gBADnBA,kC,uBAISwB,S;;gBAJTxB,kC;;gBAAAA,kC;;gBAAAA,kC,cAasB,sB;;gBAbtBA,kC,sBAwFLyB,cADgD,IAE/C;AACD,QAAMV,QAAQ,GAAGf,kCAAkC,CAACe,QAApD;;AACA,MAAIA,QAAQ,KAAKS,SAAjB,EAA4B;AACxB5B,IAAAA,WAAW,CAAC8B,GAAZ,CACK,4EAA2ED,cAAe,gDAD/F,EAEI5B,YAAY,CAAC8B,KAFjB;AAIA;AACH;;AAED,MAAIZ,QAAQ,KAAK,sBAAjB,EAAyC;AACrC;AACA;AACH;;AAED,MAAIU,cAAc,KAAK,YAAvB,EAAqC;AACjC9B,IAAAA,KAAK,CAACiC,QAAN,CAAeb,QAAQ,CAACC,GAAxB;AACH,GAFD,MAEO,IACHS,cAAc,KAAK,QAAnB,IACAA,cAAc,KAAKD,SAFhB,EAGL;AACE;AACA;AACA7B,IAAAA,KAAK,CAACkB,SAAN,CAAgBE,QAAQ,CAACC,GAAzB,EAA8BD,QAAQ,CAACE,IAAvC;AACH;AACJ,C","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { DdRum, InternalLog, SdkVerbosity } from '@datadog/mobile-react-native';\nimport type { ComponentDidAppearEvent } from 'react-native-navigation';\nimport { Navigation } from 'react-native-navigation';\nimport type {\n AppStateStatus,\n EmitterSubscription,\n NativeEventSubscription\n} from 'react-native';\nimport { AppState } from 'react-native';\n\nexport type ViewNamePredicate = (\n event: ComponentDidAppearEvent,\n trackedName: string\n) => string | null;\n\n// AppStateStatus can have values:\n// 'active' - The app is running in the foreground\n// 'background' - The app is running in the background. The user is either in another app or on the home screen\n// 'inactive' [iOS] - This is a transition state that currently never happens for typical React Native apps.\n// 'unknown' [iOS] - Initial value until the current app state is determined\n// 'extension' [iOS] - The app is running as an app extension\ndeclare type AppStateListener = (appStateStatus: AppStateStatus) => void | null;\n\n/**\n * Provides RUM integration for the [React Native Navigation](https://wix.github.io/react-native-navigation) API.\n */\nexport class DdRumReactNativeNavigationTracking {\n private static isTracking = false;\n private static eventSubscription:\n | EmitterSubscription\n | undefined = undefined;\n private static appStateSubscription?: NativeEventSubscription;\n\n private static viewNamePredicate: ViewNamePredicate;\n private static lastView?:\n | {\n key: string;\n name: string;\n }\n | 'tracking_not_started' = 'tracking_not_started';\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(\n viewNamePredicate: ViewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n }\n ): void {\n // extra safety to avoid wrapping more than 1 time this function\n if (DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n\n DdRumReactNativeNavigationTracking.eventSubscription = Navigation.events().registerComponentDidAppearListener(\n (event: ComponentDidAppearEvent) => {\n const predicate =\n DdRumReactNativeNavigationTracking.viewNamePredicate;\n const screenName = predicate(event, event.componentName);\n if (screenName !== null) {\n DdRum.startView(event.componentId, screenName);\n DdRumReactNativeNavigationTracking.lastView = {\n key: event.componentId,\n name: screenName\n };\n }\n }\n );\n\n DdRumReactNativeNavigationTracking.isTracking = true;\n DdRumReactNativeNavigationTracking.viewNamePredicate = viewNamePredicate;\n this.appStateSubscription = AppState.addEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n /**\n * Stops tracking Navigation.\n */\n static stopTracking(): void {\n if (!DdRumReactNativeNavigationTracking.isTracking) {\n return;\n }\n if (DdRumReactNativeNavigationTracking.eventSubscription) {\n DdRumReactNativeNavigationTracking.eventSubscription.remove();\n }\n // For versions of React Native below 0.65, addEventListener does not return a subscription.\n // We have to call AppState.removeEventListener instead.\n if (this.appStateSubscription) {\n this.appStateSubscription.remove();\n } else {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n AppState.removeEventListener(\n 'change',\n DdRumReactNativeNavigationTracking.appStateListener\n );\n }\n\n DdRumReactNativeNavigationTracking.lastView = undefined;\n DdRumReactNativeNavigationTracking.isTracking = false;\n DdRumReactNativeNavigationTracking.viewNamePredicate = function (\n _event: ComponentDidAppearEvent,\n trackedName: string\n ) {\n return trackedName;\n };\n }\n\n private static appStateListener: AppStateListener = (\n appStateStatus: AppStateStatus\n ) => {\n const lastView = DdRumReactNativeNavigationTracking.lastView;\n if (lastView === undefined) {\n InternalLog.log(\n `We could not determine the route when changing the application state to: ${appStateStatus}. No RUM View event will be sent in this case.`,\n SdkVerbosity.ERROR\n );\n return;\n }\n\n if (lastView === 'tracking_not_started') {\n // Do nothing as no view has been tracked already\n return;\n }\n\n if (appStateStatus === 'background') {\n DdRum.stopView(lastView.key);\n } else if (\n appStateStatus === 'active' ||\n appStateStatus === undefined\n ) {\n // case when app goes into foreground,\n // in that case navigation listener won't be called\n DdRum.startView(lastView.key, lastView.name);\n }\n };\n}\n"]}
@@ -5,12 +5,20 @@ import type { LogEventMapper } from './logs/types';
5
5
  import type { ActionEventMapper } from './rum/eventMappers/actionEventMapper';
6
6
  import type { ErrorEventMapper } from './rum/eventMappers/errorEventMapper';
7
7
  import type { ResourceEventMapper } from './rum/eventMappers/resourceEventMapper';
8
+ import type { FirstPartyHost } from './rum/types';
8
9
  export declare enum VitalsUpdateFrequency {
9
10
  FREQUENT = "FREQUENT",
10
11
  AVERAGE = "AVERAGE",
11
12
  RARE = "RARE",
12
13
  NEVER = "NEVER"
13
14
  }
15
+ export declare type FirstPartyHostsConfiguration = (FirstPartyHost | LegacyFirstPartyHost)[];
16
+ export declare type LegacyFirstPartyHost = string;
17
+ /**
18
+ * Defaults legacy first party hosts format to Datadog first party hosts to keep
19
+ * retro-compatibility before OTel support was introduced.
20
+ */
21
+ export declare const formatFirstPartyHosts: (firstPartyHosts: FirstPartyHostsConfiguration) => FirstPartyHost[];
14
22
  /**
15
23
  * The SDK configuration class.
16
24
  * It will be used to configure the SDK functionality at initialization.
@@ -63,7 +71,7 @@ export declare class DdSdkReactNativeConfiguration {
63
71
  *
64
72
  * Matches domains and subdomains, e.g. `['example.com']` matches `example.com` and `api.example.com`.
65
73
  */
66
- firstPartyHosts: string[];
74
+ firstPartyHosts: FirstPartyHostsConfiguration;
67
75
  /**
68
76
  * Overrides the reported version of the app.
69
77
  * Accepted characters are alphanumerics and `_`, `-`, `:`, `.`, `/`.
@@ -134,7 +142,7 @@ export declare class DdSdkReactNativeConfiguration {
134
142
  export declare type AutoInstrumentationConfiguration = {
135
143
  readonly trackInteractions: boolean;
136
144
  readonly trackResources: boolean;
137
- readonly firstPartyHosts?: string[];
145
+ readonly firstPartyHosts?: FirstPartyHostsConfiguration;
138
146
  readonly resourceTracingSamplingRate?: number;
139
147
  readonly trackErrors: boolean;
140
148
  readonly logEventMapper?: LogEventMapper | null;
@@ -148,7 +156,7 @@ export declare type AutoInstrumentationConfiguration = {
148
156
  export declare type AutoInstrumentationParameters = {
149
157
  readonly trackInteractions: boolean;
150
158
  readonly trackResources: boolean;
151
- readonly firstPartyHosts: string[];
159
+ readonly firstPartyHosts: FirstPartyHostsConfiguration;
152
160
  readonly resourceTracingSamplingRate: number;
153
161
  readonly trackErrors: boolean;
154
162
  readonly logEventMapper: LogEventMapper | null;
@@ -1,4 +1,4 @@
1
- import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode } from './DdSdkReactNativeConfiguration';
1
+ import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency } from './DdSdkReactNativeConfiguration';
2
2
  import { DdSdkReactNative } from './DdSdkReactNative';
3
3
  import { InternalLog } from './InternalLog';
4
4
  import { ProxyConfiguration, ProxyType } from './ProxyConfiguration';
@@ -7,6 +7,6 @@ import { TrackingConsent } from './TrackingConsent';
7
7
  import { DdTrace } from './foundation';
8
8
  import { DdLogs } from './logs/DdLogs';
9
9
  import { DdRum } from './rum/DdRum';
10
- import { RumActionType, ErrorSource } from './rum/types';
10
+ import { RumActionType, ErrorSource, PropagatorType } from './rum/types';
11
11
  import { DatadogProvider } from './sdk/DatadogProvider/DatadogProvider';
12
- export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity };
12
+ export { DatadogProvider, DatadogProviderConfiguration, InitializationMode, DdLogs, DdTrace, DdRum, RumActionType, ErrorSource, DdSdkReactNativeConfiguration, DdSdkReactNative, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType };
@@ -1,4 +1,3 @@
1
- /// <reference types="react-native" />
2
1
  import type { AdditionalEventDataForMapper } from '../../sdk/EventMappers/EventMapper';
3
2
  import { EventMapper } from '../../sdk/EventMappers/EventMapper';
4
3
  import type { ResourceKind } from '../types';
@@ -7,6 +7,7 @@ export declare class DdRumUserInteractionTracking {
7
7
  private static eventsInterceptor;
8
8
  private static originalCreateElement;
9
9
  private static originalMemo;
10
+ private static originalJsx;
10
11
  private static patchCreateElementFunction;
11
12
  /**
12
13
  * Starts tracking user interactions and sends a RUM Action event every time a new interaction was detected.
@@ -1,3 +1,4 @@
1
+ import type { FirstPartyHost } from '../../types';
1
2
  /**
2
3
  * Provides RUM auto-instrumentation feature to track resources (fetch, XHR, axios) as RUM events.
3
4
  */
@@ -9,7 +10,7 @@ export declare class DdRumResourceTracking {
9
10
  */
10
11
  static startTracking({ tracingSamplingRate, firstPartyHosts }: {
11
12
  tracingSamplingRate: number;
12
- firstPartyHosts: string[];
13
+ firstPartyHosts: FirstPartyHost[];
13
14
  }): void;
14
15
  static stopTracking(): void;
15
16
  }
@@ -1,19 +1,45 @@
1
+ import type { PropagatorType } from '../../../types';
1
2
  import type { Hostname } from './firstPartyHosts';
3
+ import type { RegexMap } from './interfaces/RequestProxy';
2
4
  export declare type DdRumResourceTracingAttributes = {
3
5
  tracingStrategy: 'KEEP';
4
- traceId: string;
5
- spanId: string;
6
- samplingPriorityHeader: '1';
6
+ traceId: TraceId;
7
+ spanId: SpanId;
8
+ samplingPriorityHeader: '1' | '0';
7
9
  rulePsr: number;
10
+ propagatorTypes: PropagatorType[];
8
11
  } | {
9
12
  tracingStrategy: 'DISCARD';
10
13
  traceId?: void;
11
14
  spanId?: void;
12
15
  samplingPriorityHeader: '0';
13
16
  };
14
- export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegex, tracingSamplingRate }: {
17
+ export declare const getTracingAttributes: ({ hostname, firstPartyHostsRegexMap, tracingSamplingRate }: {
15
18
  hostname: Hostname | null;
16
- firstPartyHostsRegex: RegExp;
19
+ firstPartyHostsRegexMap: RegexMap;
17
20
  tracingSamplingRate: number;
18
21
  }) => DdRumResourceTracingAttributes;
19
- export declare function generateTraceId(): string;
22
+ /**
23
+ * Using branded types will ensure we don't accidentally use
24
+ * traceId for spanId when generating headers.
25
+ */
26
+ export declare type TraceId = TraceIdentifier & {
27
+ _brand: 'traceId';
28
+ };
29
+ export declare type SpanId = TraceIdentifier & {
30
+ _brand: 'spanId';
31
+ };
32
+ export declare class TraceIdentifier {
33
+ private low;
34
+ private high;
35
+ constructor();
36
+ toString: (radix: number) => string;
37
+ /**
38
+ * This function pads the trace with `0`.
39
+ * It should not be used with a `length` lower than the trace, as we return the full trace in this case.
40
+ * @param radix radix for the trace
41
+ * @param length minimum length
42
+ * @returns padded string
43
+ */
44
+ toPaddedString: (radix: number, length: number) => string;
45
+ }
@@ -0,0 +1,21 @@
1
+ import type { DdRumResourceTracingAttributes } from './distributedTracing';
2
+ export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
3
+ /**
4
+ * Datadog headers
5
+ */
6
+ export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
7
+ export declare const ORIGIN_RUM = "rum";
8
+ export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
9
+ export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
10
+ /**
11
+ * OTel headers
12
+ */
13
+ export declare const TRACECONTEXT_HEADER_KEY = "traceparent";
14
+ export declare const B3_HEADER_KEY = "b3";
15
+ export declare const B3_MULTI_TRACE_ID_HEADER_KEY = "X-B3-TraceId";
16
+ export declare const B3_MULTI_SPAN_ID_HEADER_KEY = "X-B3-SpanId";
17
+ export declare const B3_MULTI_SAMPLED_HEADER_KEY = "X-B3-Sampled";
18
+ export declare const getTracingHeaders: (tracingAttributes: DdRumResourceTracingAttributes) => {
19
+ header: string;
20
+ value: string;
21
+ }[];
@@ -1,6 +1,8 @@
1
+ import type { FirstPartyHost, PropagatorType } from '../../../types';
2
+ import type { RegexMap } from './interfaces/RequestProxy';
1
3
  export declare type Hostname = {
2
4
  _type: 'Hostname';
3
5
  } & string;
4
6
  export declare const NO_MATCH_REGEX: RegExp;
5
- export declare const firstPartyHostsRegexBuilder: (firstPartyHosts: string[]) => RegExp;
6
- export declare const isHostFirstParty: (hostname: Hostname, firstPartyHostsRegex: RegExp) => boolean;
7
+ export declare const firstPartyHostsRegexMapBuilder: (firstPartyHosts: FirstPartyHost[]) => RegexMap;
8
+ export declare const getPropagatorsForHost: (hostname: Hostname, firstPartyHostsRegexMap: RegexMap) => PropagatorType[] | null;
@@ -1,7 +1,12 @@
1
+ import type { PropagatorType } from '../../../../types';
1
2
  export interface RequestProxyOptions {
2
3
  tracingSamplingRate: number;
3
- firstPartyHostsRegex: RegExp;
4
+ firstPartyHostsRegexMap: RegexMap;
4
5
  }
6
+ export declare type RegexMap = {
7
+ regex: RegExp;
8
+ propagatorType: PropagatorType;
9
+ }[];
5
10
  export declare abstract class RequestProxy {
6
11
  abstract onTrackingStart: (context: RequestProxyOptions) => void;
7
12
  abstract onTrackingStop: () => void;
@@ -1,4 +1,3 @@
1
- /// <reference types="react-native" />
2
1
  import type { ResourceKind } from '../../../../types';
3
2
  import type { DdRumResourceTracingAttributes } from '../distributedTracing';
4
3
  export interface RUMResource {
@@ -1,12 +1,6 @@
1
- /// <reference types="react-native" />
2
1
  import type { RequestProxyOptions } from '../domain/interfaces/RequestProxy';
3
2
  import { RequestProxy } from '../domain/interfaces/RequestProxy';
4
3
  import type { ResourceReporter } from './DatadogRumResource/ResourceReporter';
5
- export declare const TRACE_ID_HEADER_KEY = "x-datadog-trace-id";
6
- export declare const PARENT_ID_HEADER_KEY = "x-datadog-parent-id";
7
- export declare const ORIGIN_HEADER_KEY = "x-datadog-origin";
8
- export declare const SAMPLING_PRIORITY_HEADER_KEY = "x-datadog-sampling-priority";
9
- export declare const ORIGIN_RUM = "rum";
10
4
  interface XHRProxyProviders {
11
5
  xhrType: typeof XMLHttpRequest;
12
6
  resourceReporter: ResourceReporter;
@@ -1,3 +1,2 @@
1
- /// <reference types="react-native" />
2
1
  export declare const RESOURCE_SIZE_ERROR_MESSAGE = "Couldn't get resource size, because an error occured: ";
3
2
  export declare function calculateResponseSize(xhr: XMLHttpRequest): number;
@@ -108,3 +108,20 @@ export declare enum ErrorSource {
108
108
  WEBVIEW = "WEBVIEW",
109
109
  CUSTOM = "CUSTOM"
110
110
  }
111
+ /**
112
+ * Type of instrumentation on the host.
113
+ * - DATADOG: Datadog’s propagator (`x-datadog-*`)
114
+ * - TRACECONTEXT: W3C Trace Context (`traceparent`)
115
+ * - B3: B3 single header (`b3`)
116
+ * - B3MULTI: B3 multiple headers (`X-B3-*`)
117
+ */
118
+ export declare enum PropagatorType {
119
+ DATADOG = "datadog",
120
+ TRACECONTEXT = "tracecontext",
121
+ B3 = "b3",
122
+ B3MULTI = "b3multi"
123
+ }
124
+ export declare type FirstPartyHost = {
125
+ match: string;
126
+ propagatorTypes: PropagatorType[];
127
+ };
@@ -1 +1 @@
1
- export declare const version = "1.3.0";
1
+ export declare const version = "1.4.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-navigation",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -36,7 +36,7 @@
36
36
  "prepare": "rm -rf lib && yarn bob build"
37
37
  },
38
38
  "devDependencies": {
39
- "@datadog/mobile-react-native": "^1.3.0",
39
+ "@datadog/mobile-react-native": "^1.4.0",
40
40
  "@testing-library/react-native": "7.0.2",
41
41
  "react-native-gesture-handler": "1.10.3",
42
42
  "react-native-navigation": "7.31.1",
@@ -72,5 +72,5 @@
72
72
  ]
73
73
  ]
74
74
  },
75
- "gitHead": "16a9d318f9882dc85339b9b59045157d1bc62e7b"
75
+ "gitHead": "cc9c7937cecfd48720ec46852c24965f4a00bab4"
76
76
  }
@@ -99,6 +99,8 @@ export class DdRumReactNativeNavigationTracking {
99
99
  if (this.appStateSubscription) {
100
100
  this.appStateSubscription.remove();
101
101
  } else {
102
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
103
+ // @ts-ignore
102
104
  AppState.removeEventListener(
103
105
  'change',
104
106
  DdRumReactNativeNavigationTracking.appStateListener