fix(types): include triggerOnView on DOMChangeCreate#25
Conversation
Reverting my earlier wrong call. I removed triggerOnView from the 'create' branch of useDOMChangesEditor when CodeRabbit flagged it as inconsistent with the other change types, with the rationale that "the change itself inserts the element, so there's nothing to gate on viewport intersection." That rationale was wrong: triggerOnView is about exposure tracking (when the SDK fires the experiment-exposure event), not about applying the DOM change. The SDK plugin's ExposureTracker treats 'create' the same way as text / html / class / attribute / etc. — its else branch (ExposureTracker.ts:81) tracks change.selector for viewport intersection when type is not move/delete. Restore the field on DOMChangeCreate and serialise it in the 'create' case alongside every other change type. Without this, a user setting "trigger on view" on a 'create' change in the editor silently lost that flag at save time.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
Summary
Reverts my wrong call from PR #24. I had removed `triggerOnView` from the 'create' branch of `useDOMChangesEditor` (and from the `DOMChangeCreate` type) on the rationale that "the change itself inserts the element, so there's nothing to gate on viewport intersection". That conflated two concepts:
The SDK plugin's `ExposureTracker` (core/ExposureTracker.ts:67-87) handles `move` and `delete` specially (placeholder elements for cross-variant tracking), then has an `else` branch that catches every other change type — including `create` — and tracks `change.selector` for viewport intersection. So when the user ticks "trigger on view" on a 'create' change in the editor, the SDK is set up to honour it; the field was just silently being dropped at save time.
Changes
Test plan
Summary by CodeRabbit
Release Notes