Documentation
¶
Overview ¶
Package analytics computes the dashboard's Overview: contacts, Engagement rates, automations and the daily time series (GLOSSARY "Engagement rates").
Days are Report days (ADR 0057): calendar days in the Workspace time zone, cut by internal/reportday, so the whole history is re-bucketed the moment the zone changes.
Engagement rates are a send cohort: the denominator is the Broadcast recipients sent in the window, and opens and clicks are counted among that same cohort, so opened never exceeds sent and every rate is within [0, 1]. They are not the Sending-domain Complaint and Bounce rates of internal/reputation.
Index ¶
- Constants
- type Automations
- type Contacts
- type Email
- type EventAction
- type HourCell
- type LinkClicks
- type Module
- func (m *Module) ClicksByLink(ctx context.Context, s *ent.Scoped, w Window) ([]LinkClicks, error)
- func (m *Module) Events(ctx context.Context, s *ent.Scoped, w Window) ([]EventAction, error)
- func (m *Module) NewPeople(ctx context.Context, s *ent.Scoped, w Window) (*NewPeople, error)
- func (m *Module) OpensByHour(ctx context.Context, s *ent.Scoped, w Window) (*OpensByHour, error)
- func (m *Module) Overview(ctx context.Context, s *ent.Scoped, w Window) (*Overview, error)
- func (m *Module) RetentionDays() int
- func (m *Module) SubscribedPeople(ctx context.Context, s *ent.Scoped, w Window) (*SubscribedPeople, error)
- func (m *Module) WithClock(now func() time.Time) *Module
- func (m *Module) WithRetention(d time.Duration) *Module
- type NewPeople
- type NewPeoplePoint
- type OpensByHour
- type Overview
- type OwnerClicks
- type OwnerKind
- type Point
- type SubscribedPeople
- type SubscribedPoint
- type Window
Constants ¶
const ( OwnerBroadcast = linkclicks.OwnerBroadcast OwnerAutomation = linkclicks.OwnerAutomation )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Automations ¶
type Automations struct {
Total, Active, RunsActive, RunsCompleted int
}
Automations is a point-in-time snapshot.
type Contacts ¶
type Contacts struct {
Total, Active, Unsubscribed, NewInWindow int
}
Contacts is the contact breakdown: Unsubscribed is "globally non-mailable" (ADR 0001), Active the remainder.
type EventAction ¶
EventAction is one action of the Events report: how often it happened in the window, for how many distinct Contacts (an anonymous Event counts as an occurrence, not as a Contact) and when it last happened.
type HourCell ¶
type HourCell struct {
Weekday, Hour, Opens int
}
HourCell is the human opens of one weekday and hour of day in the Workspace time zone. Weekday is ISO: 1 is Monday, 7 is Sunday.
type LinkClicks ¶
type LinkClicks struct {
URL string
Clicks int
Owners []OwnerClicks
}
LinkClicks is one link with its clicks over the window and the Broadcasts and Automations that carried it, most clicked first.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module computes Overviews. Its clock is time.Now.
func (*Module) ClicksByLink ¶
ClicksByLink counts the human clicks of the window over the whole Workspace by link, each link split by the Broadcast or Automation that carried it (ADR 0053 leaves machine clicks out). Every click is an Event, so the counts cover the Event retention window.
func (*Module) Events ¶
Events groups the Events of the window by action, most frequent first. Reserved `email.*` actions and customer-tracked ones are both listed; machine opens and clicks are left out (ADR 0053). An Event is placed at the moment it happened, `occurred_at` and when it has none its creation time (ADR 0044), so backfilled history lands on the day it happened.
func (*Module) NewPeople ¶
NewPeople reports the Contacts of the Workspace behind s created in the window.
func (*Module) OpensByHour ¶
OpensByHour counts the human opens of the window by hour of day and day of week, both read in the Workspace time zone (ADR 0057). Machine opens (ADR 0053) are in no cell. An open happened when `occurred_at` says, falling back to the creation time (ADR 0044).
func (*Module) Overview ¶
Overview computes the dashboard for the Workspace behind s over the window.
func (*Module) RetentionDays ¶
RetentionDays is the Event retention in whole days, which a report over history states next to its figures.
func (*Module) SubscribedPeople ¶
func (m *Module) SubscribedPeople(ctx context.Context, s *ent.Scoped, w Window) (*SubscribedPeople, error)
SubscribedPeople computes the report for the Workspace behind s over the window.
type NewPeople ¶
type NewPeople struct {
// Total is every Contact created in the window.
Total int
Series []NewPeoplePoint
}
NewPeople is the New people report: the Contacts created in the window, per Report day and by Contact source.
type NewPeoplePoint ¶
NewPeoplePoint is one Report day of the New people report, zero-filled across the window. Unknown counts the Contacts that predate the Contact source.
type OpensByHour ¶
OpensByHour is the Opens by hour report: a cell for every weekday and hour, empty ones zero, ordered Monday 00:00 first.
type Overview ¶
type Overview struct {
Contacts Contacts
Email Email
Automations Automations
Series []Point
}
Overview is everything the dashboard shows for one Workspace and window.
type OwnerClicks ¶
OwnerClicks is how often a link was clicked in the emails of one Broadcast or Automation.
type OwnerKind ¶
type OwnerKind = linkclicks.OwnerKind
OwnerKind is what carried a clicked link, so the page can link to that report.
type SubscribedPeople ¶
type SubscribedPeople struct {
// Current is the Contacts that are not globally opted out, read from current state.
Current int
Series []SubscribedPoint
}
SubscribedPeople is the Subscribed people report: the flow of subscriptions per Report day and the number of subscribed people now. There is no reconstructed running total, so the series never disagrees with Current after Contacts are deleted.
type SubscribedPoint ¶
SubscribedPoint is one Report day: people who subscribed (marketing.confirmed Events), people who unsubscribed (email.unsubscribed Events) and their difference.