Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for route params to be passed to the startView tracking for react-navigation #579

Open
angelo-hub opened this issue Jan 2, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@angelo-hub
Copy link

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.

@louiszawadzki louiszawadzki added the enhancement New feature or request label Jan 12, 2024
@louiszawadzki
Copy link
Contributor

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.

@compwron
Copy link

compwron commented Oct 1, 2024

My team would also like this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants