generated from fingerprintjs/library-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
requestHandler.ts
29 lines (25 loc) · 895 Bytes
/
requestHandler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { handleIdentify } from './identifyHandler'
import { handlePage } from './pageHandler'
import { handleTrack } from './trackHandler'
import { handleGroup } from './groupHandler'
import { FPJSSegmentIntegrationBody } from '../types'
import { SegmentSourceRequest } from '../types/segment/request'
export function handleRequest(request: SegmentSourceRequest) {
const body = request.json()
const { tag } = body as FPJSSegmentIntegrationBody
const payload = tag?.integrations?.segment
if (!payload) {
return
}
if (payload.skipIntegration) {
return
}
const { identify, page, track, group } = payload
const userId = identify?.userId
handleIdentify(identify, userId, body)
handlePage(page, userId, body)
handleTrack(track, userId, body)
handleGroup(group, userId, body)
// uncomment below when mobile is supported
// handleScreen(screen, userId, body)
}