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: should attempt localstorage correctly before falling back to session storage #236

Merged
merged 2 commits into from
Jun 15, 2024

Conversation

haddowg
Copy link
Contributor

@haddowg haddowg commented Jun 13, 2024

Problem

Usage in the browser will always fallback to session storage rather than localstorage due to a simple logical conditional error.
When local storage is available it should be used when requested before falling back to sessionstorage.

Changes

Corrects faulty condition so availability of local storage is evaluated correctly

Release info Sub-libraries affected

Bump level

  • Major
  • Minor
  • Patch

Libraries affected

  • All of them
  • posthog-web
  • posthog-node
  • posthog-react-native

Changelog notes

  • use localstorage over sessionstorage where available

@marandaneto marandaneto requested a review from benjackwhite June 14, 2024 06:31
@marandaneto
Copy link
Member

@benjackwhite I think this is right but just double-checking since I don't know much about the so many storage options in the browser =D

Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

Oh wow yeah thats a mistake. Good find!

@marandaneto
Copy link
Member

@haddowg thanks for the PR
Mind adding an entry to the changelog https://github.com/PostHog/posthog-js-lite/blob/main/posthog-web/CHANGELOG.md so we can merge and release that?

@haddowg
Copy link
Contributor Author

haddowg commented Jun 14, 2024

@marandaneto hows that?

@haddowg haddowg force-pushed the fix/local-storage branch from 9fc9ee9 to f66d703 Compare June 14, 2024 16:05
@marandaneto marandaneto enabled auto-merge (squash) June 15, 2024 07:16
@marandaneto marandaneto merged commit 2da8050 into PostHog:main Jun 15, 2024
4 checks passed
@marandaneto marandaneto mentioned this pull request Jun 15, 2024
7 tasks
@haddowg haddowg deleted the fix/local-storage branch June 15, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants