Skip to content

feat(email): preview provider tokens with labeled sample values (Issue #70 Slice 3) - #92

Merged
TheAggressive merged 1 commit into
masterfrom
issue-70-slice-3-preview-sample-values
Sep 19, 2026
Merged

TheAggressive merged 1 commit into
masterfrom
issue-70-slice-3-preview-sample-values

Conversation

@TheAggressive

Copy link
Copy Markdown
Owner

Slice 3 of #70. Builds on Slice 2 (#91: canonical token resolution and snapshot provenance). This does not close #70.

What this slice does

The compiled preview showed provider-resolved tokens as raw {{cb:...}} text. The preview can now show a clearly labeled sample view with synthetic values, while the canonical artifact stays exactly as it is.

  • Domain/Email/Token/Token_Preview (pure) derives the sample view from a successful artifact, using each token's registered preview behavior:
    Behavior Tokens Sample view
    sample subscriber.first_name, subscriber.last_name, campaign.view_online_url, campaign.unsubscribe_url Alex, Sample, https://example.com/campaignbridge-preview/...
    omit subscriber.email removed
    literal none yet left canonical
  • Sample values are constants. Nothing reads subscriber data, options, or providers. URLs use the reserved example.com domain.
  • Replacement is exact-match. It is safe because feat(email): resolve and preserve canonical tokens (Issue #70 Slice 2) #91's provenance invariant guarantees that every token left in a successful artifact is registered and was authored.
  • A sample-previewed provider token without a sample value fails at construction. A parity test keeps SAMPLE_VALUES in step with the registry.

Artifact stays canonical

POST /campaignbridge/v1/preview adds one field, sample: { html, text }, or null when the compile failed or no token needs a sample. html, text, and fingerprint are unchanged. So:

  • preview and download stay byte-identical;
  • matches_review() fingerprints are unaffected;
  • COMPILER_VERSION is unchanged (output is identical).

Editor preview

The preview modal shows a Personalization toggle, Sample values / Tokens, only when a sample view exists. It defaults to samples and shows a note: "Sample values stand in for each subscriber's data. Source and download keep the tokens." The iframe title names the sample view for assistive tech. The Source pane always shows the canonical HTML.

Tests

  • Unit Token_Preview_Test: sample/registry parity, reserved domain, the compiled artifact's sample view (HTML escaping, VML + HTML button hrefs, plain text), the artifact left unchanged, literal/omit behavior, construction failure, and CampaignBridge-resolved tokens left alone.
  • Integration Preview_Route_Test: sample is null without tokens and on failure, and it personalizes while html and text keep the tokens.
  • Jest: the hook keeps canonical and sample HTML separate; the modal toggle, labeling, and the Source pane stay canonical.
  • E2E preview-personalization.spec.ts: a real editor → preview → sample → tokens round trip.

Not in this slice

🤖 Generated with Claude Code

…#70 Slice 3)

The compiled preview showed provider-resolved tokens as raw {{cb:...}} text.
Token_Preview now derives a separate, display-only sample view from a
successful artifact using each token's preview behavior: sample tokens show
fixed synthetic values (Alex, Sample, reserved example.com links), omit
tokens such as subscriber.email are removed, and literal tokens stay
canonical. Nothing reads subscriber data, options, or providers.

The preview endpoint returns the view as `sample` next to the unchanged
canonical html, text, and fingerprint, so preview and download stay
byte-identical and review fingerprints are unaffected. The preview modal
labels the sample view and offers a toggle back to the tokens; source and
download always use the canonical artifact.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:email Email compiler or campaign workflow area:frontend Frontend source or Node tooling area:php PHP or Composer code area:tests Automated tests or test configuration risk:high Security or release sensitive; never auto-merged type:feature New capability needs-attention Automation stopped; maintainer action required labels Sep 19, 2026
@TheAggressive
TheAggressive merged commit f3d39f0 into master Sep 19, 2026
21 checks passed
@TheAggressive
TheAggressive deleted the issue-70-slice-3-preview-sample-values branch September 19, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:email Email compiler or campaign workflow area:frontend Frontend source or Node tooling area:php PHP or Composer code area:tests Automated tests or test configuration needs-attention Automation stopped; maintainer action required risk:high Security or release sensitive; never auto-merged type:feature New capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(M1): add provider-neutral personalization and system-token contracts

1 participant