route.ts 396 B

1234567891011121314151617
  1. import { Analytics } from '@segment/analytics-node'
  2. import { v4 as uuid } from 'uuid'
  3. const analytics = new Analytics({ writeKey: process.env.TELEMETRY_WRITE_KEY || '<empty>' })
  4. export async function POST(req: Request) {
  5. const { email } = await req.json()
  6. analytics.identify({
  7. anonymousId: uuid(),
  8. traits: {
  9. email,
  10. },
  11. })
  12. return new Response(null, { status: 200 })
  13. }