Documentation
¶
Overview ¶
Package campaigns implements campaigns: the list and summary, drafts and the composer's storage, versions, scheduling and sending state.
Index ¶
- Constants
- func ContentHash(subject, preheader, mjmlSrc, html string, ab json.RawMessage) string
- func PostDraftLabel(site string) string
- func PostDraftNote(site string) string
- func Register(h huma.API, s *Service)
- func RegisterComposer(h huma.API, s *Service)
- func ShortName(name, adapter string) string
- type CampaignDigestRef
- type CampaignList
- type CampaignListItem
- type CampaignPath
- type CampaignStatusCounts
- type CampaignSummary
- type ChangeHook
- type ChannelRows
- type ComposerABTest
- type ComposerABVariant
- type ComposerAccess
- type ComposerAudience
- type ComposerAudienceCount
- type ComposerAudienceInput
- type ComposerAudienceOption
- type ComposerCampaign
- type ComposerChecks
- type ComposerChecksRequest
- type ComposerCompileRequest
- type ComposerCompiled
- type ComposerContentSettings
- type ComposerContext
- type ComposerCreateCampaign
- type ComposerPreview
- type ComposerPreviewContact
- type ComposerPreviewContactList
- type ComposerPreviewRequest
- type ComposerRestoreVersion
- type ComposerRoute
- type ComposerSaveContent
- type ComposerSavedContent
- type ComposerSenderOption
- type ComposerSenderRef
- type ComposerTestRecipient
- type ComposerTestSend
- type ComposerTestSendResult
- type ComposerTokenValue
- type ComposerUpdateCampaign
- type ComposerVersion
- type ComposerVersionDetail
- type ComposerVersionList
- type Extras
- type ListParams
- type MoreChecks
- type ProviderCost
- type ReadinessSummary
- type RouteShare
- type Service
- func (s *Service) Checks(ctx context.Context, ws *store.Workspace, id uuid.UUID, ...) (ComposerChecks, error)
- func (s *Service) Context(ctx context.Context, ws *store.Workspace, p *authz.Principal) (ComposerContext, error)
- func (s *Service) CountAudience(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (ComposerAudienceCount, error)
- func (s *Service) Create(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (ComposerCampaign, error)
- func (s *Service) Detail(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (ComposerCampaign, error)
- func (s *Service) DetailIn(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerCampaign, error)
- func (s *Service) DraftFromPost(ctx context.Context, ws *store.Workspace, p *authz.Principal, ...) (uuid.UUID, error)
- func (s *Service) Duplicate(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (ComposerCampaign, error)
- func (s *Service) List(ctx context.Context, ws *store.Workspace, p ListParams) (CampaignList, error)
- func (s *Service) Preview(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerPreview, error)
- func (s *Service) PreviewContacts(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerPreviewContactList, error)
- func (s *Service) Restore(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerSavedContent, error)
- func (s *Service) Save(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerSavedContent, error)
- func (s *Service) SaveIn(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerSavedContent, error)
- func (s *Service) SendTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerTestSendResult, error)
- func (s *Service) Summary(ctx context.Context, ws *store.Workspace, days int) (CampaignSummary, error)
- func (s *Service) Update(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, ...) (ComposerCampaign, error)
- func (s *Service) Version(ctx context.Context, ws *store.Workspace, id uuid.UUID, version int) (ComposerVersionDetail, error)
- func (s *Service) Versions(ctx context.Context, ws *store.Workspace, id uuid.UUID, limit int) (ComposerVersionList, error)
- type TranslationContent
- type Translations
- type VersionPath
Constants ¶
const CodeVersionConflict = "version_conflict"
CodeVersionConflict is the problem code of an autosave based on an old version.
const KeepVersions = 300
KeepVersions is how many autosaved versions a campaign keeps; the first version and named saves (⌘S, restores, imports) are always kept.
Variables ¶
This section is empty.
Functions ¶
func ContentHash ¶
func ContentHash(subject, preheader, mjmlSrc, html string, ab json.RawMessage) string
ContentHash fingerprints what an approval covers in the content: subject, preheader, MJML, HTML and A/B variants.
func PostDraftLabel ¶
PostDraftLabel is the first version's label of a draft made from a WordPress post, in English as it's stored: "created from the post on blog.acme.io". The composer's history reads it in each reader's language.
func PostDraftNote ¶
PostDraftNote is the campaign list's note of a draft made from a WordPress post, in English as it's stored: "draft from blog.acme.io".
func RegisterComposer ¶
RegisterComposer adds the composer operations.
Types ¶
type CampaignDigestRef ¶
type CampaignDigestRef struct {
ID string `json:"id"`
Name string `json:"name"`
// IssueStatus is the issue's: prepared, waiting (for approval), held,
// draft, sending, sent…
IssueStatus string `json:"issueStatus" enum:"collecting,preparing,prepared,waiting,held,draft,sending,sent,skipped,not_sent"`
Posts int `json:"posts"`
PreparedAt *time.Time `json:"preparedAt,omitempty"`
SendAt *time.Time `json:"sendAt,omitempty"`
// ApprovalID is the issue's open approval request.
ApprovalID string `json:"approvalId,omitempty"`
}
CampaignDigestRef is the digest an issue belongs to (internal/digests).
type CampaignList ¶
type CampaignList struct {
Items []CampaignListItem `json:"items"`
Total int64 `json:"total" doc:"Campaigns matching the filter"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
Counts CampaignStatusCounts `json:"counts"`
}
CampaignList is one page of campaigns.
type CampaignListItem ¶
type CampaignListItem struct {
ID string `json:"id"`
Name string `json:"name"`
// Channel is email, sms, push or whatsapp (design expansion phase 8).
Channel string `json:"channel" enum:"email,sms,push,whatsapp"`
// Channel rows: opt-outs and cost of a text campaign; Local is true
// when it goes at a time in each recipient's time zone.
OptOuts *int64 `json:"optOuts,omitempty"`
Cost *float64 `json:"cost,omitempty"`
Local bool `json:"local,omitempty"`
// LocalTime is that time ("10:00").
LocalTime string `json:"localTime,omitempty"`
Status string `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
// Blocked is true for drafts whose latest Send Readiness run is Blocked.
Blocked bool `json:"blocked"`
// Audience is a readable label ("Weekly Digest", "All subscribers"); empty when not set.
Audience string `json:"audience"`
Recipients *int64 `json:"recipients,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
UpdatedBy string `json:"updatedBy"`
ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
Timezone string `json:"timezone,omitempty"`
StartedAt *time.Time `json:"startedAt,omitempty"`
// Rates in percent, set once the campaign has sent anything.
Delivered *float64 `json:"delivered,omitempty"`
HumanOpens *float64 `json:"humanOpens,omitempty"`
Clicks *float64 `json:"clicks,omitempty"`
// Routes lists the sending providers; empty for a draft without an
// audience (it will use the Broadcasts route).
Routes []RouteShare `json:"routes"`
// Origin is the importer source for history pulled in by migration ("brevo").
Origin string `json:"origin,omitempty"`
// Notes are short annotations: "A/B subject, winner B", "auto-paused once, Yahoo deferrals".
Notes []string `json:"notes"`
// Readiness of unsent campaigns: verdict and number of warnings or blocks.
Readiness *ReadinessSummary `json:"readiness,omitempty"`
// Digest is set for an issue of a recurring digest: the Digest badge
// links to it, and the issue's status reads in place of the campaign's.
Digest *CampaignDigestRef `json:"digest,omitempty"`
// PaidOnly is a campaign for paid members only (Earn): its "Paid only"
// badge.
PaidOnly bool `json:"paidOnly"`
}
CampaignListItem is one row of the campaigns list.
type CampaignPath ¶
type CampaignPath struct {
api.WorkspaceInput
CampaignID string `path:"campaignId" format:"uuid"`
}
CampaignPath is the {workspace}/{campaignId} part of composer operations.
type CampaignStatusCounts ¶
type CampaignStatusCounts struct {
All int64 `json:"all"`
Drafts int64 `json:"drafts"`
Scheduled int64 `json:"scheduled"`
Sending int64 `json:"sending"`
Sent int64 `json:"sent"`
// PaidOnly counts the campaigns for paid members only (Earn).
PaidOnly int64 `json:"paidOnly"`
}
CampaignStatusCounts feeds the All / Drafts / Scheduled / Sending / Sent tabs.
type CampaignSummary ¶
type CampaignSummary struct {
Days int `json:"days"`
Campaigns int64 `json:"campaigns"`
Sent int64 `json:"sent"`
Delivered *float64 `json:"delivered,omitempty"`
Bounces *float64 `json:"bounces,omitempty"`
Complaints *float64 `json:"complaints,omitempty"`
HumanOpens *float64 `json:"humanOpens,omitempty"`
Clicks *float64 `json:"clicks,omitempty"`
ClickToOpen *float64 `json:"clickToOpen,omitempty"`
Cost float64 `json:"cost" doc:"Dollars"`
CostBy []ProviderCost `json:"costBy"`
}
CampaignSummary is the KPI row above the list (last 30 days).
type ChangeHook ¶
ChangeHook is told which campaign changed. The save already committed, so a hook handles its own errors.
type ChannelRows ¶
type ChannelRows interface {
FillChannelRows(ctx context.Context, ws *store.Workspace, items []CampaignListItem)
}
ChannelRows fills in the list's rows of one channel's campaigns (internal/texting for SMS).
type ComposerABTest ¶
type ComposerABTest struct {
Kind string `json:"kind" enum:"subject,content,send_time"`
Variants []ComposerABVariant `json:"variants" minItems:"2" maxItems:"3"`
TestPercent int `json:"testPercent" minimum:"5" maximum:"50" doc:"Share of the audience in the test"`
Metric string `json:"metric" enum:"human_opens,clicks,manual"`
// DurationHours is how long the test runs before the winner is sent.
DurationHours int `json:"durationHours" minimum:"1" maximum:"72"`
// BestTime sends each recipient at their usual open time (send-time tests).
BestTime bool `json:"bestTime,omitempty"`
Winner string `json:"winner,omitempty"`
}
ComposerABTest compares variants on a sample, then sends the winner to the rest.
type ComposerABVariant ¶
type ComposerABVariant struct {
Key string `json:"key" enum:"A,B,C" doc:"Variant A is the campaign itself"`
Subject string `json:"subject,omitempty" maxLength:"998"`
Preheader string `json:"preheader,omitempty" maxLength:"500"`
// MJML and HTML are set for content tests (variants B and C).
MJML string `json:"mjml,omitempty" maxLength:"2000000"`
HTML string `json:"html,omitempty" maxLength:"2000000"`
// SendTime is the local send time for send-time tests ("14:00").
SendTime string `json:"sendTime,omitempty" pattern:"^([01]\\d|2[0-3]):[0-5]\\d$"`
}
ComposerABVariant is one variant of an A/B test.
type ComposerAccess ¶
type ComposerAccess struct {
// Editable is false once a campaign started sending.
Editable bool `json:"editable"`
ReadOnlyReason string `json:"readOnlyReason,omitempty"`
CanEdit bool `json:"canEdit"`
// CanSend is campaigns:send. Without it "Review & send" becomes "Request approval".
CanSend bool `json:"canSend"`
SendHelpers []string `json:"sendHelpers" doc:"Members who hold campaigns:send"`
// EditHelpers are members who hold campaigns:edit, named to people who
// can't edit (the Accessibility panel's read-only note).
EditHelpers []string `json:"editHelpers,omitempty" doc:"Members who hold campaigns:edit (when the caller can't edit)"`
// CanManageRouting is providers:manage; others see the route read-only.
CanManageRouting bool `json:"canManageRouting"`
// CanSendTestToOthers lets test emails go to other addresses (campaigns:send).
CanSendTestToOthers bool `json:"canSendTestToOthers"`
CanEditTemplates bool `json:"canEditTemplates"`
CanViewContacts bool `json:"canViewContacts"`
}
ComposerAccess tells the composer what the caller may do.
type ComposerAudience ¶
type ComposerAudience struct {
Lists []string `json:"lists"`
Segments []string `json:"segments"`
ExcludeLists []string `json:"excludeLists"`
ExcludeSegments []string `json:"excludeSegments"`
// Paid is "paid" for paid members only, "free" for free subscribers
// only; empty for everyone. PaidTier is the lowest tier of paid
// members ("Insider and above"); empty for any paid tier.
Paid string `json:"paid,omitempty" enum:"paid,free,"`
PaidTier string `json:"paidTier,omitempty"`
}
ComposerAudience says who receives a campaign: lists and segments, minus excluded lists and segments, and who on them (Earn: everyone, paid members only at a tier and above, or free subscribers only).
type ComposerAudienceCount ¶
type ComposerAudienceCount struct {
Count int64 `json:"count"`
// Approximate is true when segments are involved: their last cached
// count is used, so overlaps may be counted twice until Send Readiness
// computes the final number.
Approximate bool `json:"approximate"`
}
ComposerAudienceCount is the live count of an audience definition.
type ComposerAudienceInput ¶
type ComposerAudienceInput struct {
Lists []string `json:"lists,omitempty" maxItems:"100"`
Segments []string `json:"segments,omitempty" maxItems:"100"`
ExcludeLists []string `json:"excludeLists,omitempty" maxItems:"100"`
ExcludeSegments []string `json:"excludeSegments,omitempty" maxItems:"100"`
Paid string `` /* 128-byte string literal not displayed */
PaidTier string `json:"paidTier,omitempty" doc:"With paid: the lowest tier (the tier and above); empty for any paid tier"`
}
ComposerAudienceInput is an audience in requests (every part optional).
type ComposerAudienceOption ¶
type ComposerAudienceOption struct {
ID string `json:"id"`
Name string `json:"name"`
Count *int64 `json:"count,omitempty"`
}
ComposerAudienceOption is a list or segment with its size.
type ComposerCampaign ¶
type ComposerCampaign struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status" enum:"draft,approval,approved,scheduled,sending,paused,sent,cancelled,failed"`
Subject string `json:"subject"`
Preheader string `json:"preheader"`
Sender *ComposerSenderRef `json:"sender,omitempty"`
ReplyTo string `json:"replyTo"`
Audience ComposerAudience `json:"audience"`
AudienceLabel string `json:"audienceLabel"`
AudienceCount *int64 `json:"audienceCount,omitempty"`
EditorMode string `json:"editorMode" enum:"visual,mjml,html"`
MJML string `json:"mjml"`
HTML string `json:"html"`
PlainText string `json:"plainText"`
Version int `json:"version"`
VersionCount int `json:"versionCount"`
ContentHash string `json:"contentHash"`
ABTest *ComposerABTest `json:"abTest,omitempty"`
Settings ComposerContentSettings `json:"settings"`
ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
UpdatedBy string `json:"updatedBy"`
AutosavedAt *time.Time `json:"autosavedAt,omitempty"`
Route ComposerRoute `json:"route"`
Readiness *ReadinessSummary `json:"readiness,omitempty"`
Access ComposerAccess `json:"access"`
// Language is the language of the content returned: the source's, or
// the language version asked for with ?language=. SourceLanguage is the
// language the campaign is written in. Both are empty without content
// languages.
Language string `json:"language"`
SourceLanguage string `json:"sourceLanguage"`
// DigestID is set for a recurring digest's template (DigestRole
// "template"), its next issue ("next") and its issues ("issue"): the
// composer opens in digest mode (internal/digests).
DigestID string `json:"digestId,omitempty"`
DigestRole string `json:"digestRole,omitempty" enum:"template,next,issue,"`
}
ComposerCampaign is everything the composer loads.
type ComposerChecks ¶
type ComposerChecks struct {
contentcheck.ContentCheckReport
// footer existed in an earlier version.
FooterRemovedAt *time.Time `json:"footerRemovedAt,omitempty"`
// Lint lists MJML layout warnings (image wider than its column…).
Lint []mjml.MJMLProblem `json:"lint"`
}
ComposerChecks is a content report plus what the composer shows around it.
type ComposerChecksRequest ¶
type ComposerChecksRequest struct {
Subject string `json:"subject,omitempty" maxLength:"998"`
Preheader string `json:"preheader,omitempty" maxLength:"500"`
MJML string `json:"mjml,omitempty" maxLength:"2000000"`
HTML string `json:"html,omitempty" maxLength:"2500000"`
ProbeLinks bool `json:"probeLinks,omitempty" doc:"Also request every link (slower; Send Readiness does it)"`
// Language is the language version checked: subject heuristics look for
// English phrases only in English.
Language string `json:"language,omitempty" maxLength:"16"`
}
ComposerChecksRequest is content to check (unsaved edits included).
type ComposerCompileRequest ¶
type ComposerCompileRequest struct {
MJML string `json:"mjml" minLength:"1" maxLength:"2000000"`
}
ComposerCompileRequest is MJML to compile on the server.
type ComposerCompiled ¶
type ComposerCompiled struct {
HTML string `json:"html"`
Errors []mjml.MJMLProblem `json:"errors"`
Warnings []mjml.MJMLProblem `json:"warnings"`
SizeBytes int `json:"sizeBytes"`
DurationMs int64 `json:"durationMs"`
}
ComposerCompiled is the server-side compile result (gomjml, MJML 4.15).
type ComposerContentSettings ¶
type ComposerContentSettings struct {
// Minify shrinks the HTML (whitespace, inline CSS) to stay under Gmail's clipping limit.
Minify bool `json:"minify"`
}
ComposerContentSettings are composer options applied to the stored HTML.
type ComposerContext ¶
type ComposerContext struct {
Senders []ComposerSenderOption `json:"senders"`
DefaultSenderID string `json:"defaultSenderId,omitempty"`
Lists []ComposerAudienceOption `json:"lists"`
Segments []ComposerAudienceOption `json:"segments"`
Tokens []liquid.PersonalizationToken `json:"tokens"`
Members []ComposerTestRecipient `json:"members"`
BroadcastRoute ComposerRoute `json:"broadcastRoute"`
// PostalAddress is the workspace's address for footers, if set.
PostalAddress string `json:"postalAddress"`
// PublicURL is where images and links point once an email leaves ReputeCast.
PublicURL string `json:"publicUrl"`
SenderDomains []string `json:"senderDomains"`
}
ComposerContext is the workspace data the composer needs once.
type ComposerCreateCampaign ¶
type ComposerCreateCampaign struct {
Name string `json:"name,omitempty" maxLength:"200"`
TemplateID string `json:"templateId,omitempty" maxLength:"64" doc:"Start from a template (starter:<key> or a saved template id)"`
FromCampaignID string `json:"fromCampaignId,omitempty" format:"uuid" doc:"Start from a copy of another campaign's content"`
}
ComposerCreateCampaign starts a draft, blank or from a template or another campaign.
type ComposerPreview ¶
type ComposerPreview struct {
Subject string `json:"subject"`
Preheader string `json:"preheader"`
HTML string `json:"html"`
Text string `json:"text"`
FromName string `json:"fromName"`
FromEmail string `json:"fromEmail"`
Contact *ComposerPreviewContact `json:"contact,omitempty"`
Tokens []ComposerTokenValue `json:"tokens"`
// MissingFirstName counts audience contacts with no first name (they see the fallback).
MissingFirstName *int64 `json:"missingFirstName,omitempty"`
Problems []liquid.LiquidProblem `json:"problems"`
RenderedAt time.Time `json:"renderedAt"`
// Language is the language version shown, and LanguageReason why when
// it was picked for the contact (match, no_language, not_offered,
// missing, draft, held). Empty without content languages.
Language string `json:"language"`
LanguageReason string `json:"languageReason"`
}
ComposerPreview is the rendered email for one recipient.
type ComposerPreviewContact ¶
type ComposerPreviewContact struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Email string `json:"email"`
// Label describes the choice ("first_name set", "fallback "there"").
Label string `json:"label"`
// Language is the contact's language code ("es-MX"), empty when unset.
Language string `json:"language"`
}
ComposerPreviewContact is who the preview is personalized for.
type ComposerPreviewContactList ¶
type ComposerPreviewContactList struct {
Items []ComposerPreviewContact `json:"items"`
}
ComposerPreviewContactList is who the preview can be personalized for.
type ComposerPreviewRequest ¶
type ComposerPreviewRequest struct {
ContactID string `json:"contactId,omitempty" format:"uuid"`
Sample string `json:"sample,omitempty" enum:"contact,no_first_name,random" default:"contact"`
Variant string `json:"variant,omitempty" enum:"A,B,C"`
Subject *string `json:"subject,omitempty" maxLength:"998"`
Preheader *string `json:"preheader,omitempty" maxLength:"500"`
HTML *string `json:"html,omitempty" maxLength:"2500000"`
// Language previews a language version. Empty: the source, or, when
// previewing as a contact, the version that contact gets.
Language string `json:"language,omitempty" maxLength:"16"`
// Editing is the version the subject, preheader and HTML above belong
// to (the one the composer has open; empty is the source). Previewing as
// a contact who gets another version shows that version as saved.
Editing string `json:"editing,omitempty" maxLength:"16"`
}
ComposerPreviewRequest asks for the email as one recipient sees it. Subject, preheader and HTML may carry unsaved edits.
type ComposerRestoreVersion ¶
type ComposerRestoreVersion struct {
BaseVersion int `json:"baseVersion" minimum:"1"`
}
ComposerRestoreVersion makes an old version current again, as a new version.
type ComposerRoute ¶
type ComposerRoute struct {
Source string `json:"source" enum:"campaign,rule,none"`
}
ComposerRoute is the sending route of a campaign: its planned split, or the Broadcasts rule when it has none yet.
type ComposerSaveContent ¶
type ComposerSaveContent struct {
// BaseVersion is the version the editor started from. Saving on top of
// someone else's newer version fails with 409 unless Force is set.
BaseVersion int `json:"baseVersion" minimum:"1"`
Subject string `json:"subject,omitempty" maxLength:"998"`
Preheader string `json:"preheader,omitempty" maxLength:"500"`
MJML string `json:"mjml,omitempty" maxLength:"2000000"`
// HTML compiled by the composer (mjml-browser). Empty: the server
// compiles the MJML with gomjml.
HTML string `json:"html,omitempty" maxLength:"2500000"`
ABTest *ComposerABTest `json:"abTest,omitempty"`
// Label says what changed ("2-column section padding").
Label string `json:"label,omitempty" maxLength:"200"`
Source string `json:"source,omitempty" enum:"autosave,manual,import,template" default:"autosave"`
// Force saves on top of a newer version ("Keep mine").
Force bool `json:"force,omitempty"`
}
ComposerSaveContent is one save of the composer: subject, preheader, MJML and the HTML the browser compiled from it, and the A/B variants.
type ComposerSavedContent ¶
type ComposerSavedContent struct {
Version int `json:"version"`
SavedAt time.Time `json:"savedAt"`
ContentHash string `json:"contentHash"`
SizeBytes int `json:"sizeBytes"`
PlainText string `json:"plainText"`
// HTML is what was stored (minified when the campaign asks for it).
HTML string `json:"html"`
}
ComposerSavedContent is the result of a save.
type ComposerSenderOption ¶
type ComposerSenderOption struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Domain string `json:"domain"`
Verified bool `json:"verified"`
}
ComposerSenderOption is a sender the campaign can come from.
type ComposerSenderRef ¶
type ComposerSenderRef struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
}
ComposerSenderRef is the "From" identity.
type ComposerTestRecipient ¶
ComposerTestRecipient is a workspace member offered for test emails.
type ComposerTestSend ¶
type ComposerTestSend struct {
To []string `json:"to" minItems:"1" maxItems:"10"`
Variant string `json:"variant,omitempty" enum:"A,B,C"`
ContactID string `json:"contactId,omitempty" format:"uuid" doc:"Personalize as this contact"`
// Language sends one language version (the source when empty);
// EachLanguage sends one email per language that would be sent.
Language string `json:"language,omitempty" maxLength:"16"`
EachLanguage bool `json:"eachLanguage,omitempty"`
}
ComposerTestSend sends the saved content to a few addresses.
type ComposerTestSendResult ¶
type ComposerTestSendResult struct {
Sent []string `json:"sent"`
Provider string `json:"provider"`
// Languages are the versions sent to each address.
Languages []string `json:"languages"`
}
ComposerTestSendResult says where the test went.
type ComposerTokenValue ¶
type ComposerTokenValue struct {
Token string `json:"token" example:"{{ first_name | default: \"there\" }}"`
Key string `json:"key"`
Value string `json:"value"`
FallbackUsed bool `json:"fallbackUsed"`
PerRecipient bool `json:"perRecipient" doc:"A link filled in per recipient at send time"`
}
ComposerTokenValue is what one token printed.
type ComposerUpdateCampaign ¶
type ComposerUpdateCampaign struct {
Name *string `json:"name,omitempty" minLength:"1" maxLength:"200"`
SenderID *string `json:"senderId,omitempty" doc:"A sender id, or empty to clear"`
ReplyTo *string `json:"replyTo,omitempty" maxLength:"254"`
Audience *ComposerAudienceInput `json:"audience,omitempty"`
Settings *ComposerContentSettings `json:"settings,omitempty"`
}
ComposerUpdateCampaign changes what isn't versioned content: name, sender, reply-to, audience and content settings. Omitted fields stay.
type ComposerVersion ¶
type ComposerVersion struct {
Version int `json:"version"`
SavedAt time.Time `json:"savedAt"`
SavedBy string `json:"savedBy"`
Label string `json:"label"`
Source string `json:"source" enum:"create,autosave,manual,restore,template,import,duplicate,api"`
SizeBytes int `json:"sizeBytes"`
Current bool `json:"current"`
}
ComposerVersion is one entry of the version history.
type ComposerVersionDetail ¶
type ComposerVersionDetail struct {
ComposerVersion
Subject string `json:"subject"`
Preheader string `json:"preheader"`
MJML string `json:"mjml"`
HTML string `json:"html"`
ABTest *ComposerABTest `json:"abTest,omitempty"`
// Sections are the labels of the sections that differ from the version before.
Sections []string `json:"sections"`
}
ComposerVersionDetail is a version with its content (compare, restore).
type ComposerVersionList ¶
type ComposerVersionList struct {
Items []ComposerVersion `json:"items"`
Total int `json:"total"`
}
ComposerVersionList is the version history, newest first.
type Extras ¶
type Extras interface {
// TestLinks are the poll and survey links of a test email to one
// address: its answers are that address's test answers, never counted.
TestLinks(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, email string) (map[string]string, error)
// TestVersion is the email a contact gets ("" contact: every block).
TestVersion(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, contactID, html string) string
}
Extras fill in a test email's poll links and cut it to one contact's version of conditional content.
type ListParams ¶
type ListParams struct {
Status string
Query string
// Channel filters by channel; empty is every channel.
Channel string
PaidOnly bool
Page int
PageSize int
}
ListParams filters the list.
type MoreChecks ¶
type MoreChecks func(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, mjml string) []contentcheck.ContentCheckIssue
MoreChecks are other domains' findings about an email's content, for the composer's checks.
type ProviderCost ¶
type ProviderCost struct {
Provider string `json:"provider"`
Short string `json:"short"`
Cost float64 `json:"cost"`
}
ProviderCost is one provider's cost in the period.
type ReadinessSummary ¶
type ReadinessSummary struct {
Verdict string `json:"verdict" enum:"ready,warnings,blocked"`
// Issues are the blocking issues of a blocked campaign, otherwise its
// warnings.
Issues int64 `json:"issues"`
}
ReadinessSummary is the latest Send Readiness verdict.
type RouteShare ¶
type RouteShare struct {
// Short is the label used in badges ("SES", "Postal").
Percent float64 `json:"percent"`
// Planned recipients and, once sending started, how many were sent.
}
RouteShare is one sending provider's part of a campaign.
type Service ¶
type Service struct {
Pool *pgxpool.Pool
Q *store.Queries
Audit *audit.Logger
Now func() time.Time
// Templates resolves templates when a draft starts from one.
Templates *templates.Service
// Mail sends test emails through the System route (App.Mail, read at call time).
Mail func() mailer.Sender
// URLs builds public links (unsubscribe, preferences, view online).
URLs publicurl.Builder
// Checker runs the content checks (blocklist and link probing plug in here).
Checker *contentcheck.Checker
// AfterChange runs once a save of the content, audience, sender or
// settings committed (the approvals domain re-checks open approvals).
AfterChange ChangeHook
// Translations handles language versions (?language= on the content
// endpoints); nil without content languages.
Translations Translations
// Extras fill in test emails' poll links and cut them to a contact's
// version of conditional content (conditional.go); nil leaves them.
Extras Extras
// More adds other domains' findings to the composer's checks (the
// Sponsor block's creative, internal/sponsors); nil leaves them out.
More MoreChecks
// Channels fill in the rows of campaigns on other channels (SMS, and
// later push and WhatsApp): their routes, results and readiness. Nil
// leaves those rows as stored.
Channels ChannelRows
// Recipients add the per-reader variables of blocks (Grow's Referral
// and Recommendations blocks) to previews and test sends; nil adds none.
Recipients func() []liquid.RecipientData
}
Service holds the campaigns domain dependencies.
func (*Service) Checks ¶
func (s *Service) Checks(ctx context.Context, ws *store.Workspace, id uuid.UUID, in ComposerChecksRequest) (ComposerChecks, error)
Checks runs the content checks on the composer's current content.
func (*Service) Context ¶
func (s *Service) Context(ctx context.Context, ws *store.Workspace, p *authz.Principal) (ComposerContext, error)
Context returns senders, lists, segments, tokens, team and the route.
func (*Service) CountAudience ¶
func (s *Service) CountAudience(ctx context.Context, ws *store.Workspace, p *authz.Principal, def ComposerAudience) (ComposerAudienceCount, error)
CountAudience counts the recipients of a definition.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, ws *store.Workspace, p *authz.Principal, in ComposerCreateCampaign) (ComposerCampaign, error)
Create makes a draft and returns it.
func (*Service) Detail ¶
func (s *Service) Detail(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (ComposerCampaign, error)
Detail loads a campaign for the composer.
func (*Service) DetailIn ¶
func (s *Service) DetailIn(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, lang string) (ComposerCampaign, error)
DetailIn loads a campaign for the composer with the content of one language version ("" or the source language: the source).
func (*Service) DraftFromPost ¶
func (s *Service) DraftFromPost(ctx context.Context, ws *store.Workspace, p *authz.Principal, name, subject, preheader, src string) (uuid.UUID, error)
DraftFromPost makes a campaign draft from a web-only post of the publication website ("Send as a campaign", design expansion phase 7): the post's title as the subject, its excerpt as the preheader, its blocks as the email. The audience is left for the person to pick.
func (*Service) Duplicate ¶
func (s *Service) Duplicate(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID) (ComposerCampaign, error)
Duplicate copies a campaign (any status) into a new draft.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, ws *store.Workspace, p ListParams) (CampaignList, error)
List returns one page of campaigns with their route and readiness.
func (*Service) Preview ¶
func (s *Service) Preview(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in ComposerPreviewRequest) (ComposerPreview, error)
Preview renders the campaign for a contact (or a sample).
func (*Service) PreviewContacts ¶
func (s *Service) PreviewContacts(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, query string) (ComposerPreviewContactList, error)
PreviewContacts searches contacts of the audience.
func (*Service) Restore ¶
func (s *Service) Restore(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, version int, in ComposerRestoreVersion) (ComposerSavedContent, error)
Restore copies a version on top of the history.
func (*Service) Save ¶
func (s *Service) Save(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in ComposerSaveContent) (ComposerSavedContent, error)
Save stores a new version of the content.
func (*Service) SaveIn ¶
func (s *Service) SaveIn(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, lang string, in ComposerSaveContent) (ComposerSavedContent, error)
SaveIn stores a new version of one language version's content ("" or the source language: the source).
func (*Service) SendTest ¶
func (s *Service) SendTest(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in ComposerTestSend) (ComposerTestSendResult, error)
SendTest delivers test emails through the System route. Content Writers and other members without campaigns:send can only send to themselves.
func (*Service) Summary ¶
func (s *Service) Summary(ctx context.Context, ws *store.Workspace, days int) (CampaignSummary, error)
Summary returns the last-N-days totals across campaigns.
func (*Service) Update ¶
func (s *Service) Update(ctx context.Context, ws *store.Workspace, p *authz.Principal, id uuid.UUID, in ComposerUpdateCampaign) (ComposerCampaign, error)
Update applies an UpdateCampaign.
type TranslationContent ¶
type TranslationContent struct {
Language string
Subject string
Preheader string
MJML string
HTML string
PlainText string
ABTest json.RawMessage
Version int
VersionCount int
ContentHash string
UpdatedAt time.Time
UpdatedBy string
AutosavedAt *time.Time
}
TranslationContent is a language version's content.
type Translations ¶
type Translations interface {
// SourceLanguage is the language the campaign is written in.
SourceLanguage(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) (string, error)
// Content returns a language version's content (404 when it has none).
Content(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, lang string) (TranslationContent, error)
// Save stores a new version of a language version.
Save(ctx context.Context, ws *store.Workspace, p *authz.Principal, campaignID uuid.UUID, lang string, in ComposerSaveContent, minify bool) (ComposerSavedContent, error)
// Choose picks the version a reader with this contact language gets.
Choose(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID, contactLanguage string) (lang, reason string, err error)
// Ready lists the languages whose version is sent, the source first.
Ready(ctx context.Context, ws *store.Workspace, campaignID uuid.UUID) ([]string, error)
}
Translations are a campaign's language versions (internal/languages): the content endpoints take `language` and hand language versions to it.
type VersionPath ¶
type VersionPath struct {
CampaignPath
Version int `path:"version" minimum:"1"`
}
VersionPath adds a {version}.