@datadog/mobile-react-native-navigation 2.4.0 → 2.4.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.
- package/lib/commonjs/rum/instrumentation/DdRumReactNativeNavigationTracking.js +3 -2
- package/lib/commonjs/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
- package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js +3 -2
- package/lib/module/rum/instrumentation/DdRumReactNativeNavigationTracking.js.map +1 -1
- package/lib/typescript/core/src/DdSdkReactNative.d.ts +0 -5
- package/lib/typescript/core/src/index.d.ts +1 -0
- package/lib/typescript/core/src/sdk/GlobalState/GlobalState.d.ts +12 -0
- package/lib/typescript/core/src/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/__tests__/rum/instrumentation/DdRumReactNativeNavigationTracking.test.tsx +4 -0
- package/src/rum/instrumentation/DdRumReactNativeNavigationTracking.tsx +3 -0
|
@@ -20,7 +20,8 @@ class DdRumReactNativeNavigationTracking {
|
|
|
20
20
|
/**
|
|
21
21
|
* Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
|
|
22
22
|
*/
|
|
23
|
-
static startTracking(
|
|
23
|
+
static startTracking( // eslint-disable-next-line func-names
|
|
24
|
+
viewNamePredicate = function (_event, trackedName) {
|
|
24
25
|
return trackedName;
|
|
25
26
|
}) {
|
|
26
27
|
// extra safety to avoid wrapping more than 1 time this function
|
|
@@ -70,7 +71,7 @@ class DdRumReactNativeNavigationTracking {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
DdRumReactNativeNavigationTracking.lastView = undefined;
|
|
73
|
-
DdRumReactNativeNavigationTracking.isTracking = false;
|
|
74
|
+
DdRumReactNativeNavigationTracking.isTracking = false; // eslint-disable-next-line func-names
|
|
74
75
|
|
|
75
76
|
DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event, trackedName) {
|
|
76
77
|
return trackedName;
|
|
@@ -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,
|
|
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,EAChB;AACAC,EAAAA,iBAAoC,GAAG,UACnCC,MADmC,EAEnCC,WAFmC,EAGrC;AACE,WAAOA,WAAP;AACH,GAPe,EAQZ;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,iCAA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kC,CAACiB,QAApD;;AACA,MAAIA,QAAQ,KAAKU,SAAjB,EAA4B;AACxBE,mCAAYC,GAAZ,CACK,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 // eslint-disable-next-line func-names\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\n // eslint-disable-next-line func-names\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"]}
|
|
@@ -16,7 +16,8 @@ export class DdRumReactNativeNavigationTracking {
|
|
|
16
16
|
/**
|
|
17
17
|
* Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
|
|
18
18
|
*/
|
|
19
|
-
static startTracking(
|
|
19
|
+
static startTracking( // eslint-disable-next-line func-names
|
|
20
|
+
viewNamePredicate = function (_event, trackedName) {
|
|
20
21
|
return trackedName;
|
|
21
22
|
}) {
|
|
22
23
|
// extra safety to avoid wrapping more than 1 time this function
|
|
@@ -65,7 +66,7 @@ export class DdRumReactNativeNavigationTracking {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
DdRumReactNativeNavigationTracking.lastView = undefined;
|
|
68
|
-
DdRumReactNativeNavigationTracking.isTracking = false;
|
|
69
|
+
DdRumReactNativeNavigationTracking.isTracking = false; // eslint-disable-next-line func-names
|
|
69
70
|
|
|
70
71
|
DdRumReactNativeNavigationTracking.viewNamePredicate = function (_event, trackedName) {
|
|
71
72
|
return trackedName;
|
|
@@ -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,
|
|
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,EAChB;AACAC,EAAAA,iBAAoC,GAAG,UACnCC,MADmC,EAEnCC,WAFmC,EAGrC;AACE,WAAOA,WAAP;AACH,GAPe,EAQZ;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;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,gBACmB,K;;gBADnBA,kC,uBAISwB,S;;gBAJTxB,kC;;gBAAAA,kC;;gBAAAA,kC,cAasB,sB;;gBAbtBA,kC,sBA2FLyB,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 // eslint-disable-next-line func-names\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\n // eslint-disable-next-line func-names\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"]}
|
|
@@ -13,7 +13,6 @@ export declare class DdSdkReactNative {
|
|
|
13
13
|
private static readonly DD_VERSION_SUFFIX;
|
|
14
14
|
private static wasAutoInstrumented;
|
|
15
15
|
private static features?;
|
|
16
|
-
private static _isInitialized;
|
|
17
16
|
/**
|
|
18
17
|
* Initializes the Datadog SDK.
|
|
19
18
|
* @param configuration the configuration for the SDK library
|
|
@@ -57,10 +56,6 @@ export declare class DdSdkReactNative {
|
|
|
57
56
|
* @returns a Promise
|
|
58
57
|
*/
|
|
59
58
|
static clearAllData: () => Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Returns `true` if the SDK was initialized, `false` otherwise.
|
|
62
|
-
*/
|
|
63
|
-
static isInitialized(): boolean;
|
|
64
59
|
private static buildConfiguration;
|
|
65
60
|
private static enableFeatures;
|
|
66
61
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import './polyfills';
|
|
1
2
|
import { DatadogProviderConfiguration, DdSdkReactNativeConfiguration, InitializationMode, VitalsUpdateFrequency, UploadFrequency, BatchSize } from './DdSdkReactNativeConfiguration';
|
|
2
3
|
import { DdSdkReactNative } from './DdSdkReactNative';
|
|
3
4
|
import { InternalLog } from './InternalLog';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A singleton container for attributes that are shared internally across all
|
|
3
|
+
* the SDK classes.
|
|
4
|
+
*/
|
|
5
|
+
export declare class GlobalState {
|
|
6
|
+
/**
|
|
7
|
+
* `true` if the SDK is initialized, `false` otherwise.
|
|
8
|
+
*/
|
|
9
|
+
isInitialized: boolean;
|
|
10
|
+
private static _instance;
|
|
11
|
+
static get instance(): GlobalState;
|
|
12
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.4.
|
|
1
|
+
export declare const version = "2.4.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/mobile-react-native-navigation",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.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": "^2.4.
|
|
39
|
+
"@datadog/mobile-react-native": "^2.4.1",
|
|
40
40
|
"@testing-library/react-native": "7.0.2",
|
|
41
41
|
"react-native-builder-bob": "0.17.1",
|
|
42
42
|
"react-native-gesture-handler": "1.10.3",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
]
|
|
82
82
|
]
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f527de2facb85c3e5bdfcc7e46e2931c1f9e8039"
|
|
85
85
|
}
|
|
@@ -106,6 +106,8 @@ it('M send a RUM ViewEvent W startTracking() for the first view', async () => {
|
|
|
106
106
|
|
|
107
107
|
it('M send a RUM ViewEvent W startTracking() componentDidAppear { custom viewPredicate }', async () => {
|
|
108
108
|
// GIVEN
|
|
109
|
+
|
|
110
|
+
// eslint-disable-next-line func-names
|
|
109
111
|
const predicate: ViewNamePredicate = function (
|
|
110
112
|
_event: ComponentDidAppearEvent,
|
|
111
113
|
_trackedName: string
|
|
@@ -136,6 +138,8 @@ it('M send a RUM ViewEvent W startTracking() componentDidAppear { custom viewPre
|
|
|
136
138
|
it('M not send a RUM ViewEvent W startTracking() componentDidAppear { viewPredicate returns null }', async () => {
|
|
137
139
|
// GIVEN
|
|
138
140
|
let viewDropped = false;
|
|
141
|
+
|
|
142
|
+
// eslint-disable-next-line func-names
|
|
139
143
|
const predicate: ViewNamePredicate = function (
|
|
140
144
|
_event: ComponentDidAppearEvent,
|
|
141
145
|
_trackedName: string
|
|
@@ -49,6 +49,7 @@ export class DdRumReactNativeNavigationTracking {
|
|
|
49
49
|
* Starts tracking the Navigation and sends a RUM View event every time a root View component appear/disappear.
|
|
50
50
|
*/
|
|
51
51
|
static startTracking(
|
|
52
|
+
// eslint-disable-next-line func-names
|
|
52
53
|
viewNamePredicate: ViewNamePredicate = function (
|
|
53
54
|
_event: ComponentDidAppearEvent,
|
|
54
55
|
trackedName: string
|
|
@@ -109,6 +110,8 @@ export class DdRumReactNativeNavigationTracking {
|
|
|
109
110
|
|
|
110
111
|
DdRumReactNativeNavigationTracking.lastView = undefined;
|
|
111
112
|
DdRumReactNativeNavigationTracking.isTracking = false;
|
|
113
|
+
|
|
114
|
+
// eslint-disable-next-line func-names
|
|
112
115
|
DdRumReactNativeNavigationTracking.viewNamePredicate = function (
|
|
113
116
|
_event: ComponentDidAppearEvent,
|
|
114
117
|
trackedName: string
|