react-navigation.github.io icon indicating copy to clipboard operation
react-navigation.github.io copied to clipboard

Code of screen tracking example

Open delphinebugner opened this issue 4 years ago • 2 comments

We used this code on my project, but we had a bug: on some screens, analytics were not sent.

We used the fix I propose in this PR:routeNameRef.current has to be updated before the analytic is sent. If we do it after, the user has the time to navigate to a new screen during the time the analytic is sent. But it will be undetected, because previousRouteName would not have been updated already.

We also can move this line in the "if" block because if they are identical, we don't need to update the reference.

An other solution to achieve the same result is to delete the "await" before Analytics.setCurrentScreen. But I find it more confusing: we "hide" the fact that sending analytics is asynchronous. Especially if some action has to be performed after.

OK read

No screen-tracking.md file exists. Only the versioned file has been modified.

delphinebugner avatar Sep 17 '21 16:09 delphinebugner

✔️ Deploy Preview for react-navigation-docs ready!

🔨 Explore the source changes: 81d2a687d939d3144367384fa1f10203bab62772

🔍 Inspect the deploy log: https://app.netlify.com/sites/react-navigation-docs/deploys/6144bcaf7b4dfd00086ecdea

😎 Browse the preview: https://deploy-preview-1062--react-navigation-docs.netlify.app

netlify[bot] avatar Sep 17 '21 16:09 netlify[bot]

I don't know why Semantic Pull Request is blocking the merge :/ I can rename my commit if needed!

delphinebugner avatar Sep 17 '21 16:09 delphinebugner