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

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.
@@ -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;;AACA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K,4EAA2EF,cAAe,gDAD/F,EAEIG,gCAAaC,KAFjB;;AAIA;AACH;;AAED,MAAIf,QAAQ,KAAK,sBAAjB,EAAyC;AACrC;AACA;AACH;;AAED,MAAIW,cAAc,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,W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,QAAQ,KAAK,sBAAjB,EAAyC;AACrC;AACA;AACH;;AAED,MAAIW,cAAc,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 // 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,GAAo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aAAOA,WAAP;AACH,KALD;AAMH;;AAnF2C;;gBAAnCJ,kC,gBACmB,K;;gBADnBA,kC,uBAISwB,S;;gBAJTxB,kC;;gBAAAA,kC;;gBAAAA,kC,cAasB,sB;;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;A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C;AACAxB,IAAAA,kCAAkC,CAACK,UAAnC,GAAgD,KAAhD;;AACAL,IAAAA,kCAAkC,CAACE,iBAAnC,GAAuD,UACnDC,MADmD,EAEnDC,WAFmD,EAGrD;AACE,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"]}
@@ -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,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,4 +1,3 @@
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';
@@ -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;
@@ -1 +1 @@
1
- export declare const version = "1.3.0";
1
+ export declare const version = "1.3.1";
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.3.1",
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.3.1",
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": "c70d62caff28da6111c8e526de4dfbb82bb9bf2d"
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