Skip to content

Commit c6888ee

Browse files
matus-tomleinclaude
andcommitted
Guard against older Optimizely SDK missing getCampaignStates
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>
1 parent 85134eb commit c6888ee

File tree

1 file changed

+1
-1
lines changed
  • plugins/browser-plugin-optimizely-x/src

1 file changed

+1
-1
lines changed

plugins/browser-plugin-optimizely-x/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function OptimizelyXPlugin(): BrowserPlugin {
7676
*/
7777
function getOptimizelyXSummary(): OptimizelyxSummary[] {
7878
const state = getOptimizelyXData('state');
79-
if (state == null) return [];
79+
if (state == null || typeof state.getCampaignStates !== 'function') return [];
8080

8181
const campaignStates = state.getCampaignStates({ isActive: true }) || {};
8282
const visitor = getOptimizelyXData('visitor');

0 commit comments

Comments
 (0)