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: Change default storage type, migrate existing users #875

Closed
wants to merge 7 commits into from

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Nov 3, 2023

See #876

Follow up to #869

Changes

Move the session-scoped props to smaller keys in storage. Not really the right fix (which would be moving them to a separate cookie) but at least a quick fix.

Also limit the keys stored to only the ones actually used. This is quite a dramatic change, so might be enough on its own to avoid reworking the storage for now

Checklist

return {
initialPathName: window.location.pathname,
referringDomain: _info.referringDomain(),
..._info.campaignParams(),
Copy link
Member Author

@robbie-c robbie-c Nov 3, 2023

Choose a reason for hiding this comment

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

this also means we're not storing extra stuff beyond the keys I actually use - actually the biggest space saving comapred to reducing the key lengths

@robbie-c robbie-c changed the title Reduce storage size fix: Reduce storage size Nov 3, 2023
Copy link

github-actions bot commented Nov 3, 2023

Size Change: +3.59 kB (0%)

Total Size: 749 kB

Filename Size Change
dist/array.full.js 178 kB +900 B (+1%)
dist/array.js 119 kB +898 B (+1%)
dist/es.js 119 kB +898 B (+1%)
dist/module.js 119 kB +898 B (+1%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 12 kB
dist/recorder-v2.js 104 kB
dist/recorder.js 58.4 kB
dist/surveys.js 39.9 kB

compressed-size-action

@robbie-c robbie-c marked this pull request as ready for review November 3, 2023 11:11
@robbie-c robbie-c added the bump minor Bump minor version when this PR gets merged label Nov 3, 2023
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.

The minification part I'm not so sure about tbh. I don't know if it helps all that much, given the main issue is in the generic "cookie" store.

Comment on lines 33 to 41
const campaignParams = _info.campaignParams()
return _strip_empty_properties({
p: window.location.pathname,
r: _info.referringDomain(),
m: campaignParams.utm_medium,
s: campaignParams.utm_source,
c: campaignParams.utm_campaign,
n: campaignParams.utm_content,
t: campaignParams.utm_term,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This won't actually help that much... 4Kb is not a lot especially as urls and things will be pretty long.
The main reason we see this issue on posthog.com is that we are not using localstorage+cookie persistence so I think this error can happen a lot anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

Every little helps 🤷 - but yeah the main thing is using the right storage engine, and the other main thing is not storing values I don't need

Copy link
Member

Choose a reason for hiding this comment

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

fly-by without having read or thought about the change much...

It would be nice to have the saving in the cookie without needing to read the tiny identifiers when being a human looking at the code. Feels easy to break something because there's not much for your brain to hold on to when reading it.

@robbie-c robbie-c marked this pull request as draft November 3, 2023 15:13
@robbie-c
Copy link
Member Author

robbie-c commented Nov 3, 2023

Converted to draft while I add the store migration

@robbie-c robbie-c changed the title fix: Reduce storage size fix: Change default storage type, migrate existing users Nov 8, 2023
@posthog-bot
Copy link
Collaborator

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor Bump minor version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants