📈 Send onboarding replies to PostHog
This commit is contained in:
@@ -45,7 +45,12 @@ export const trackEvents = async (events: TelemetryEvent[]) => {
|
||||
client.capture({
|
||||
distinctId: event.userId,
|
||||
event: event.name,
|
||||
properties: 'data' in event ? event.data : undefined,
|
||||
properties:
|
||||
event.name === 'User updated'
|
||||
? { $set: event.data }
|
||||
: 'data' in event
|
||||
? event.data
|
||||
: undefined,
|
||||
groups,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -51,6 +51,7 @@ model User {
|
||||
image String? @db.VarChar(1000)
|
||||
company String?
|
||||
onboardingCategories Json
|
||||
referral String?
|
||||
graphNavigation GraphNavigation?
|
||||
preferredAppAppearance String?
|
||||
accounts Account[]
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "referral" TEXT;
|
||||
@@ -47,6 +47,7 @@ model User {
|
||||
image String?
|
||||
company String?
|
||||
onboardingCategories Json
|
||||
referral String?
|
||||
graphNavigation GraphNavigation?
|
||||
preferredAppAppearance String?
|
||||
accounts Account[]
|
||||
|
||||
@@ -37,6 +37,18 @@ const userCreatedEventSchema = userEvent.merge(
|
||||
})
|
||||
)
|
||||
|
||||
const userUpdatedEventSchema = userEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('User updated'),
|
||||
data: z.object({
|
||||
name: z.string().optional(),
|
||||
onboardingCategories: z.array(z.string()).optional(),
|
||||
referral: z.string().optional(),
|
||||
company: z.string().optional(),
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
const typebotCreatedEventSchema = typebotEvent.merge(
|
||||
z.object({
|
||||
name: z.literal('Typebot created'),
|
||||
@@ -129,6 +141,7 @@ export const eventSchema = z.discriminatedUnion('name', [
|
||||
subscriptionAutoUpdatedEventSchema,
|
||||
workspacePastDueEventSchema,
|
||||
workspaceNotPastDueEventSchema,
|
||||
userUpdatedEventSchema,
|
||||
])
|
||||
|
||||
export type TelemetryEvent = z.infer<typeof eventSchema>
|
||||
|
||||
@@ -14,6 +14,7 @@ export const userSchema = z.object({
|
||||
image: z.string().nullable(),
|
||||
company: z.string().nullable(),
|
||||
onboardingCategories: z.array(z.string()),
|
||||
referral: z.string().nullable(),
|
||||
graphNavigation: z.nativeEnum(GraphNavigation),
|
||||
preferredAppAppearance: z.string().nullable(),
|
||||
displayedInAppNotifications: displayedInAppNotificationsSchema.nullable(),
|
||||
|
||||
Reference in New Issue
Block a user