fix(optimizely-x): capture campaignId for Personalization campaigns#1468
Merged
Matus Tomlein (matus-tomlein) merged 4 commits intomasterfrom Apr 20, 2026
Merged
Conversation
Copilot started reviewing on behalf of
Matus Tomlein (matus-tomlein)
April 20, 2026 07:55
View session
There was a problem hiding this comment.
Pull request overview
Updates the Optimizely X browser plugin to correctly attribute Optimizely Personalization campaigns by capturing campaignId (layerId) via the Optimizely state campaign APIs, and bumps the emitted context schema version accordingly.
Changes:
- Switch Optimizely state extraction from active experiment IDs to active campaign states to include
campaignId. - Extend
OptimizelyxSummarycontext interface with optionalcampaignId. - Update the emitted context schema version to
1-1-0.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| plugins/browser-plugin-optimizely-x/src/index.ts | Uses getCampaignStates({ isActive: true }), adds campaignId to emitted context, and bumps schema version to 1-1-0. |
| plugins/browser-plugin-optimizely-x/src/contexts.ts | Adds campaignId?: number | null to the summary context type. |
| plugins/browser-plugin-optimizely-x/pnpm-lock.yaml | Introduces a per-package pnpm lockfile (not aligned with the repo’s Rush setup). |
Files not reviewed (1)
- plugins/browser-plugin-optimizely-x/pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove stray per-package pnpm-lock.yaml (conflicts with Rush-managed lockfile at common/config/rush/pnpm-lock.yaml and pinned stale versions) - Restore trailing newlines on contexts.ts and index.ts to match the rest of the codebase - Drop misleading inline comment on campaignId (field is populated for both Web Experimentation and Personalization, not just Personalization) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Older Optimizely SDK versions don't expose state.getCampaignStates. Without this guard the call throws at runtime and prevents every context the plugin would attach, not just the Optimizely one. Return an empty array instead so the tracker keeps working. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Open
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.
Reopens PR #1463 with some formal adjustments for release.
Blocked by schema release snowplow/iglu-central#1483