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

[LIBWEB-1353] Fix cookie write error #891

Merged
merged 3 commits into from
Jul 18, 2023
Merged

[LIBWEB-1353] Fix cookie write error #891

merged 3 commits into from
Jul 18, 2023

Conversation

zikaari
Copy link
Contributor

@zikaari zikaari commented Jul 13, 2023

Analytics would fail fatally if cookies are made inaccessible by overriding the cookie getter/setter by a piece of code. This patch adds resilience against such a case.

@changeset-bot
Copy link

changeset-bot bot commented Jul 13, 2023

🦋 Changeset detected

Latest commit: 807d896

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@zikaari zikaari force-pushed the cookie_error_fix branch 3 times, most recently from c9b2dcb to cdc8606 Compare July 13, 2023 20:35
Copy link
Contributor

@silesky silesky left a comment

Choose a reason for hiding this comment

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

LGTM

cookieEnabled = document.cookie.includes('ajs:cookies')
jar.remove('ajs:cookies')
try {
jar.set('ajs_cookies', 'test')
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: for quick reuse putting ajs_cookies as a const AJS_COOKIE_AVAILABILITY_KEY or similar.

I would also suggest renaming it to ajs_cookies_check or something to highight that it is only an availability check cookie.

Copy link
Contributor

@silesky silesky Jul 14, 2023

Choose a reason for hiding this comment

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

good point! Also, all of these strings get repeated in the bundle -- using a constant saves bytes!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Copy link
Contributor

@chrisradek chrisradek left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just minor comment on versioning.

.changeset/pink-dancers-exist.md Outdated Show resolved Hide resolved
@zikaari zikaari merged commit e0c7792 into master Jul 18, 2023
3 checks passed
@zikaari zikaari deleted the cookie_error_fix branch July 18, 2023 19:07
@github-actions github-actions bot mentioned this pull request Jul 18, 2023
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.

4 participants