The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.
TypeScript ai-receptionistanswering-serviceappointment-bookinglivekitlocal-firstmcpopen-sourceself-hostedsiptelephonytypescriptvoice-agentvoice-ai
// Where a sign-up came from (LIN-910): the first landing the browser kept (apps/web/src/attribution.ts) goes with
// account.signUp and is stored once on the user. Only the campaign's own words (utm_source, utm_medium, utm_campaign)
// and the referring site's host; the first one wins, a later sign-up (a second workspace) never replaces it.
import type { SignupAttribution } from '@linedesk/actions'
import { type Tx, user } from '@linedesk/db'
import { eq } from 'drizzle-orm'
type Held = Pick<
typeof user.$inferSelect,
'id' | 'signupUtmSource' | 'signupUtmMedium' | 'signupUtmCampaign' | 'signupReferrer'
>
/** Stores the attribution on the user unless they have one already; nothing usable in it: nothing stored. */
export async function storeSignupAttribution(tx: Tx, me: Held, attribution: SignupAttribution | undefined) {
if (!attribution) return
const { utmSource, utmMedium, utmCampaign, referrer } = attribution
if (!utmSource && !utmMedium && !utmCampaign && !referrer) return
if (me.signupUtmSource || me.signupUtmMedium || me.signupUtmCampaign || me.signupReferrer) return
await tx
.update(user)
.set({
signupUtmSource: utmSource ?? null,
signupUtmMedium: utmMedium ?? null,
signupUtmCampaign: utmCampaign ?? null,
signupReferrer: referrer ?? null,
})
.where(eq(user.id, me.id))
}