feat(email): add EmailClient for SDK email send preview#182
Draft
jcpsimmons wants to merge 1 commit into
Draft
Conversation
Preview-grade. New EmailClient class with one method, `send`, calling POST /v1/send/email. Identifies itself to the server via a "CioEmailSDK-Preview" suffix on User-Agent so the matching Edge gate can scope rollout per workspace. - lib/email.ts: EmailClient class, exports SDK_PREVIEW_USER_AGENT_MARKER - lib/email-input.ts: SendEmailInput type + runtime validator - lib/request.ts: CIORequest gains optional userAgentSuffix constructor arg; defaults preserve existing User-Agent string exactly - test/email.ts: ava suite covering constructor, region routing, all validator branches — 100% coverage maintained - test/request.ts: two new test cases for the userAgentSuffix path - examples/email-quickstart.ts: copy-paste demo - README.md: "Sending email (preview)" section Existing APIClient and TrackClient surfaces and HTTP behavior are unchanged when no userAgentSuffix is provided (the default).
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.
What this is
Preview-grade addition of a small
EmailClientsurface tocustomerio-node. One constructor, one method (send), one input type. CallsPOST /v1/send/email. Pairs with the gated path in the Edge PR below.Files
lib/email.ts—EmailClientclass. ExportsSDK_PREVIEW_USER_AGENT_MARKERso the marker stays in sync with the server.lib/email-input.ts—SendEmailInputtype + runtime validator.lib/request.ts—CIORequestgains an optional third constructor arg,userAgentSuffix. When omitted (the default forTrackClient/APIClient), the User-Agent header is byte-identical to before. When provided (byEmailClient), it's appended.test/email.ts— ava tests, 100% coverage on the new surface.test/request.ts— two new test cases for theuserAgentSuffixpath.examples/email-quickstart.ts— copy-paste demo.package.json— version 4.4.0 → 4.5.0 (additive bump).lib/version.ts— same version bump (kept in sync per existing test invariant).README.md— new "Sending email (preview)" section.How it's used
Server-side gate
The SDK sets
User-Agent: Customer.io Node Client/4.5.0 CioEmailSDK-Preview. The matching Edge gate (sister PR) treats this as the "I'm using the preview" signal and 403s unless the workspace has thesdk_email_send_previewflag enabled. Any existing key on an enrolled workspace will work — no new key minting required.What this is NOT
APIClient.sendEmail. That keeps working with the same User-Agent it always had.TrackClientchange.Sister PR
customerio/edge: feat(transactional): add gated User-Agent path for SDK email preview.Tests