feat: add support for route params to be passed to the `startView` tracking for react-navigation
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch @datadog/[email protected] for the project I'm working on.
This adds more detailed tracking of Views by passing the data to the Datadog package
Here is the diff that solved my problem:
diff --git a/node_modules/@datadog/mobile-react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.tsx b/node_modules/@datadog/mobile-react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.tsx
index 0e4828a..1b2de2c 100644
--- a/node_modules/@datadog/mobile-react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.tsx
+++ b/node_modules/@datadog/mobile-react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.tsx
@@ -184,7 +184,7 @@ export class DdRumReactNavigationTracking {
// On iOS, the app can start in either "active", "background" or "unknown" state
if (appStateStatus !== 'background') {
DdRumReactNavigationTracking.trackingState = 'TRACKING';
- DdRum.startView(key, screenName);
+ DdRum.startView(key, screenName, { params: route.params });
}
}
}
@@ -210,7 +210,7 @@ export class DdRumReactNavigationTracking {
// case when app goes into foreground,
// in that case navigation listener won't be called
DdRumReactNavigationTracking.trackingState = 'TRACKING';
- DdRum.startView(key, screenName);
+ DdRum.startView(key, screenName, { params: route.params });
}
}
}
This issue body was partially generated by patch-package.
Hi @angelo-hub, thanks for reaching out!
I've added a task in our backlog to see if we can add this feature :)
There are a few things we need to be cautious about when implementing it. You first need to make sure that no personal user information leaks through the route parameters. Then you also need to be sure that there is no parameter that cannot be serialized into JSON. If this is the case, when calling the native SDK the serialization done by React Native will fail and the app could crash.
For all these reasons I believe we need to consider a way to edit the params that are passed so some of them can be removed.
My team would also like this :)