← Public packages
@kentcdodds/kit
Kit.com helpers for subscribers, tags, forms, sequences, and broadcasts.
src/subscribe-and-tag.d.ts
36 lines · 938 B · TypeScriptexport type SubscriberSummary = {
id: number
email_address?: string
first_name?: string
state?: string
created_at?: string
fields?: Record<string, unknown>
}
export type SubscribeAndTagInput = {
email_address: string
first_name?: string
fields?: Record<string, string>
tagName?: string
tagId?: number | string
}
export type SubscribeAndTagResult = {
subscriber: SubscriberSummary
tag: { id: number; name?: string }
}
/**
* Subscribe (upsert) an email and apply a tag, creating the tag on first use.
* @example
* import subscribeAndTag from 'kody:@kentcdodds/kit/subscribe-and-tag'
* const result = await subscribeAndTag({
* email_address: 'person@example.com',
* first_name: 'Ada',
* tagName: 'waitlist::kody',
* })
* // => { subscriber: { id, email_address, state: 'active' }, tag: { id, name } }
*/
export default function subscribeAndTag(
input: SubscribeAndTagInput,
): Promise<SubscribeAndTagResult>