Sample: Tenant Inactivity
Opt-in deletion of abandoned free accounts. Mount createTenantInactivityFeature next to sessions, tenant-lifecycle and delivery; a daily job tracks the last activity per tenant, warns the tenant owners by mail and finally files the normal deletion request.
What you learn here
Section titled “What you learn here”- One rule for everybody, or one per tier:
{ rule }applies to every tenant;{ resolveTier, rulesByTier }returnsnullfor a tier to exempt it (paid plans). - Warning cycle: with
warnings: [{ days: 30 }, { days: 7 }]the owners get one mail 30 and one 7 days before the deadline. On the deadline the job calls the same core as the owner’srequest-destructionhandler, so the wait period comes from the compliance profile and the owner can still cancel. - Activity restarts the cycle: a new session counts, and so does the keep-account link in the mail (
keepAccountTokenSecretsigns it; without a secret the mail links tokeepAccountUrlonly). Other apps of the same account report throughactivitySources;fetchRemoteAppLastActivityreads the opt-inlastActivityProbeSecretroute of a remote sessions feature. - No write per request: the state is only written by the daily job; the state query (
tenant-inactivity:query:state) showsexempt,lastActivityAt,warningsSent,nextStepandnextStepAt.
Feature composition
Section titled “Feature composition”sessions, tenant, tenant-lifecycle, delivery (required)tenant-inactivity <- this samplesrc/__tests__/feature.integration.test.ts runs the job against a manual clock and reads the outlook through the state query. The full mail and deletion flow is covered in bundled-features/src/tenant-inactivity/__tests__.
Source
Section titled “Source”📄 On GitHub: samples/recipes/tenant-inactivity