Documentation
¶
Overview ¶
Package paidaccess says who has paid access (Earn, design expansion X16) to the domains that choose recipients and content: paid-only campaigns ("Who on this list"), paid-only blocks (Visibility · Paid access), paid tokens and the contacts table. It reads Earn's tables the way segments read scores; internal/earn writes them.
A contact has paid access while a live subscription, complimentary grant or gift hasn't ended and is trialing, active, complimentary or a gift, or past due while Stripe retries (unless the access rule paused it). A higher tier includes a lower tier's paid content: "Insider and above" means a tier ranked at least Insider's. Test paid members never count.
Index ¶
- Constants
- func Facts(ctx context.Context, q *store.Queries, wsID uuid.UUID, ids []uuid.UUID) (map[uuid.UUID]Fact, error)
- func IsReaderLink(key string) bool
- func MinRank(ctx context.Context, q *store.Queries, wsID uuid.UUID, tier string) (int, error)
- func ShortName(name string, lists []string) string
- type Audience
- type Fact
- type Keeper
- type ListCounts
- type Member
- type Tier
Constants ¶
const ( Everyone = "" Paid = "paid" // paid members only Free = "free" // free subscribers only (no paid access at all) )
Who on a campaign's lists receives it.
const ( UpgradeURL = "upgrade_url" ManageURL = "manage_subscription_url" )
The reader's personal Earn links: internal/earn fills them in per reader at send time, like the unsubscribe link, and never through click tracking; the composer's checks and preview treat them as such.
Variables ¶
This section is empty.
Functions ¶
func Facts ¶
func Facts(ctx context.Context, q *store.Queries, wsID uuid.UUID, ids []uuid.UUID) (map[uuid.UUID]Fact, error)
Facts reads some contacts' paid access; contacts without any are left out.
func IsReaderLink ¶
IsReaderLink reports whether a Liquid variable is one of the reader's personal Earn links.
Types ¶
type Audience ¶
Audience is the paid part of campaigns.audience: who on the lists gets the campaign and, for paid members, the lowest tier (empty: any).
func Parse ¶
func Parse(raw json.RawMessage) Audience
Parse reads the paid part of a stored audience (both key styles).
type Fact ¶
type Fact struct {
Status string // trialing, active, past_due, complimentary, gift
Kind string // stripe, complimentary, gift
TierID uuid.UUID
Tier string
Rank int
Period string // month, year, or empty for grants and gifts
AmountCents int64
Currency string
Discount json.RawMessage
StartedAt time.Time
// RenewsAt is the next renewal while it renews; EndsAt is when access
// ends (a scheduled cancellation, a trial without a card, a grant's or
// a gift's end).
RenewsAt *time.Time
EndsAt *time.Time
TrialEnd *time.Time
}
Fact is a contact's paid access, as personalization and conditions read it: the highest tier's subscription, grant or gift.
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper decides who a paid audience keeps, read once per count or send. A nil Keeper keeps everyone.
type ListCounts ¶
ListCounts are the recipients of lists split by paid access.
func CountLists ¶
func CountLists(ctx context.Context, q *store.Queries, wsID uuid.UUID, lists, exclude []uuid.UUID, tier string) (ListCounts, error)
CountLists counts the recipients of lists (minus excluded lists and suppressions) as the composer does: everyone, paid members at the tier and above, and free subscribers.
type Member ¶
type Member struct {
Status string // trialing, active, past_due, complimentary, gift
Kind string // stripe, complimentary, gift
Rank int
}
Member is a contact's paid access as an audience reads it.
type Tier ¶
type Tier struct {
ID uuid.UUID
Name string
// Short is how readers name it: the name without its list's
// ("Weekly Digest Insider" on Weekly Digest is "Insider").
Short string
Rank int
// Top is the highest tier: "Founding member" rather than "Founding
// member and above".
Top bool
}
Tier is a tier in access order, for the pickers.