Documentation
¶
Overview ¶
Package rivianexpiry warns about a Rivian session before it expires.
Rivian ends a user session 180 days after sign-in and gives the app no way to extend it (see rivian.SessionLifetime), so a user who never signs in again loses recording on that day, silently. The sweep finds sessions with at most 14 days left, counts them for the metric, and emails each user once at 7 days and once at 1 day left. It is read-only on the sessions; the notices are claimed in engagement_sends so each goes out at most once across replicas and restarts, and a new sign-in (a new session time) starts over.
Index ¶
Constants ¶
const ( WarnDays = 7 FinalDays = 1 CountDays = 14 )
Horizons, in days left.
const Kind = "rivian_expiry"
Kind is the engagement_sends kind of the notices.
const UnsubPurpose = "rivian-expiry"
UnsubPurpose scopes a signed one-click link to these reminders: the statement email's unsubscribe accepts only YYYY-MM and the welcome and setup emails' only "onboarding".
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counts ¶
type Counts struct {
Within14, Within7, Within1, Expired int
}
Counts is what a sweep saw.
type Entry ¶
type Entry struct {
User uuid.UUID
NeedsReauth bool
// OptedOut: the user stopped these reminders (Settings, or the link in the email).
OptedOut bool
// SignedIn is when the stored Rivian session was made (users.rivian_signed_in_at); zero when
// unknown. The sweep never opens the session itself.
SignedIn time.Time
}
Entry is a user with a stored Rivian session.
type Job ¶
type Job struct {
Sessions Sessions
Claims engage.Store
Mail Mailer
// Email returns the address on file ("" when none).
Email func(ctx context.Context, uid uuid.UUID) (string, error)
BaseURL string
// Signer signs the one-click "stop these reminders" link. Nil, or a nil result: nothing is
// sent (no way to opt out, no mail).
Signer func() *statement.Signer
// Skip excludes a user (the demo account).
Skip func(uid uuid.UUID) bool
Lifetime time.Duration
Now func() time.Time
Log *slog.Logger
// OnCounts gets the counts of each sweep; OnNotice each notice outcome ("sent",
// "failed", "no_email", "already_sent") by days (WarnDays or FinalDays).
OnCounts func(Counts)
OnNotice func(days int, outcome string)
}
Job is the sweep. Set the fields; Lifetime defaults to rivian.SessionLifetime.