Repository navigation
fix(playground): render stored tracking state only in the browser - #234
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After a reload with tracking disabled, the playground showed "DISABLED" styled green, as if tracking were on. The module's controls worked: enabling, disabling, capturing while disabled, and reloading all stored and skipped visits correctly. Only the playground's display was wrong.
The tracking preference and the history live in localStorage, which only the browser can read, so the server always renders the configured default: enabled, with no history. When the browser has a saved opt-out or stored entries, its first render disagrees with the server's HTML. Vue fixes mismatched text during hydration but keeps the server's
class, and it warns that the class mismatch "will not be rectified in production".The playground now wraps the status label and the collected data panel in
<ClientOnly>, as the README recommends for displays of browser history. I drove the playground in Chromium through enabling, disabling, capturing while disabled, clearing, and reloading in each state. Before the change, the label kept theenabledclass in five of eleven steps, and the console showed class and text hydration mismatches. After it, the class matched the text at every step and no hydration warnings appeared.Validation:
pnpm format:check,pnpm lint --max-warnings 0,pnpm test, and the playground type check pass.