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

fix(lld): fix analytics useEffect in default #6871

Merged
merged 1 commit into from
May 16, 2024

Conversation

LucasWerey
Copy link
Contributor

@LucasWerey LucasWerey commented May 16, 2024

βœ… Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • ...

πŸ“ Description

Fix analytics useEffect previously introduced that was overriding app.json

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@LucasWerey LucasWerey requested a review from a team as a code owner May 16, 2024 11:48
Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

5 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 2:06pm
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 2:06pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 2:06pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 2:06pm
web-tools ⬜️ Ignored (Inspect) Visit Preview May 16, 2024 2:06pm

@live-github-bot live-github-bot bot added the desktop Has changes in LLD label May 16, 2024
@cgrellard-ledger cgrellard-ledger changed the base branch from main to hotfix May 16, 2024 11:57
const dispatch = useDispatch();

useEffect(() => {
if (isLocked) return;
Copy link
Contributor

@cksanders cksanders May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is safer to wrap this:

Suggested change
if (isLocked) return;
if (!isLocked) {

In previous use cases with useEffect, having a return like this does not necessarily exit the function.

Copy link
Contributor Author

@LucasWerey LucasWerey May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Comment on lines 206 to 207
if (!isLocked) {
if (!analyticsFF?.enabled || hasSeenAnalyticsOptInPrompt) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!isLocked) {
if (!analyticsFF?.enabled || hasSeenAnalyticsOptInPrompt) return;
if (!isLocked && (analyticsFF?.enabled || !hasSeenAnalyticsOptInPrompt)) {

dispatch(setShareAnalytics(false));
dispatch(setSharePersonalizedRecommendations(false));
});
if (!isLocked && analyticsFF?.enabled && !hasSeenAnalyticsOptInPrompt) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we changing the logic? previously it was an or case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does the same as before because now we execute the logic instead of returning when the if is true

Copy link
Contributor Author

@LucasWerey LucasWerey May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it was an or case but we want to trigger the dispatches only if those 3 conditions are met:

  • App unlocked
  • feature flag is enabled
  • the prompt has not been seen by the user

The OR case was a return if the user didn't see the prompt or if the FF is disabled
So we have the same thing here as before

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes

@LucasWerey LucasWerey merged commit 9d01039 into hotfix May 16, 2024
33 checks passed
@LucasWerey LucasWerey deleted the fix/lld_locked_analytics branch May 16, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop Has changes in LLD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants