feat: add initContextual flag for automatic pageview tracking with page context#277
Merged
mosherBT merged 2 commits intoOptable:masterfrom May 8, 2026
Merged
Conversation
…ge context When initContextual: true, the SDK fires a 'pageview' witness event with full page context during initialization, after passport init. Implies pageContext: true when no pageContext is explicitly configured. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Match the Playwire solution bundle pattern — hostname + pathname as an explicit witness property alongside the page context payload. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
jplaroche
approved these changes
May 8, 2026
Contributor
jplaroche
left a comment
There was a problem hiding this comment.
I believe URL is optional but we can keep it.
LGTM
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.
Summary
initContextual?: booleantoInitConfig— whentrue, the SDK automatically fires apageviewwitness event with full page context during initialization (after passport init)pageContext: truewhen nopageContextis explicitly configured, so callers only need one flaginitTargetingwitness(..., { includeContext: true })approach in READMEMotivation
Publishers integrating Optable for contextual audience assembly need to send page context on load. Previously this required custom integration code in each SDK bundle (e.g. the Playwire solution bundle). This flag makes it a first-class SDK feature with a single line of config.
Usage
Changes
lib/config.ts—initContextualadded toInitConfig,ResolvedConfig, andgetConfiglib/sdk.ts— constructor defaultscontextConfigto{}wheninitContextualis set withoutpageContext;initialize()fires the witness callREADME.md— newinitContextualandpageContextentries in Optional Keys; new "Contextual Pageview Tracking" section under Witness API with automatic and manual usage examples🤖 Generated with Claude Code