Add a Waitlist, Invites, Referrals and Onboarding
Launch tooling in your own database: waitlist, one-shot invites, referral rewards, onboarding progress, a changelog and feedback.
Install
npm i @dapplelight/signet-db drizzle-ormCreate the tables and service
import { growthTables } from "@dapplelight/signet-db/columns/sqlite"
import { createGrowth } from "@dapplelight/signet-db/growth"
import { db } from "./db"
export const { waitlist, invites, referralCodes, referrals, marks, feedback } = growthTables()
export const growth = createGrowth(db, {
tables: { waitlist, invites, referralCodes, referrals, marks, feedback },
inviteTtlMs: 7 * 86_400_000,
})Run the waitlist and invites
import { growth } from "./growth"
export async function launch(email: string, userId: string, orgId: string, referralCode?: string) {
await growth.joinWaitlist(email, { source: "launch", referralCode })
await growth.markInvited([email])
const { invite, token } = await growth.createInvite({ invitedBy: userId, scope: orgId, role: "member", email })
const result = await growth.acceptInvite(token, { userId, email })
}The token is returned once; only its hash is stored.
Reward referrals once
import { growth } from "./growth"
export async function referNewUser(userId: string, newUserId: string) {
const code = await growth.referralCode(userId)
await growth.refer(code, newUserId)
const c = await growth.convertReferral(newUserId)
if (c?.first) await growth.markRewarded(newUserId)
}Track onboarding, changelog and feedback
import { growth } from "./growth"
export async function onboard(userId: string, entries: { date: Date }[], message: string) {
await growth.completeStep(userId, "profile")
const progress = await growth.onboarding(userId, ["profile", "invite", "first-project"])
const unseen = await growth.unseenChangelog(userId, entries)
await growth.sendFeedback({ subject: userId, kind: "bug", message, rating: 4, page: "/settings" })
}