-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdeleteVisitor.mjs
More file actions
38 lines (32 loc) · 925 Bytes
/
deleteVisitor.mjs
File metadata and controls
38 lines (32 loc) · 925 Bytes
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
30
31
32
33
34
35
36
37
38
import { FingerprintServerApiClient, Region, RequestError } from '@fingerprint/node-sdk'
import { config } from 'dotenv'
config()
const apiKey = process.env.API_KEY
const visitorId = process.env.VISITOR_ID
const envRegion = process.env.REGION
if (!visitorId) {
console.error('Visitor ID not defined')
process.exit(1)
}
if (!apiKey) {
console.error('API key not defined')
process.exit(1)
}
let region = Region.Global
if (envRegion === 'eu') {
region = Region.EU
} else if (envRegion === 'ap') {
region = Region.AP
}
const client = new FingerprintServerApiClient({ region, apiKey })
try {
await client.deleteVisitorData(visitorId)
console.log(`All data associated with visitor ${visitorId} is scheduled to be deleted.`)
} catch (error) {
if (error instanceof RequestError) {
console.log(error.statusCode, error.message)
} else {
console.error('unknown error: ', error)
}
process.exit(1)
}