forked from djyde/cusdis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstat.service.ts
58 lines (55 loc) · 1.17 KB
/
stat.service.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { resolvedConfig, sentry } from '../utils.server'
import { MiniCapture } from 'mini-capture'
export class StatService {
private client = resolvedConfig.minicapture.apiKey
? new MiniCapture(resolvedConfig.minicapture.apiKey)
: null
async capture(
event: string,
options?: {
identity?: string
properties: any
},
) {
// if (this.client) {
// try {
// this.client.capture(event, {
// identity: options?.identity,
// properties: options?.properties || {},
// })
// } catch (e) {
// console.error(e)
// // TODO: log error
// }
// } else {
// return null
// }
}
start(
op: string,
name: string,
options?: {
description?: string
tags?: Record<string, string>
},
) {
if (sentry) {
const transaction = sentry.startTransaction({
op,
name,
tags: options?.tags,
description: options?.description,
})
return {
end() {
transaction.finish()
},
}
} else {
return {
end() {},
}
}
}
}
export const statService = new StatService()