2023-07-06 21:32:48 +00:00
|
|
|
import { Analytics } from '@segment/analytics-node'
|
|
|
|
import { v4 as uuidv4 } from 'uuid'
|
2023-07-07 14:27:16 +00:00
|
|
|
import Store from 'electron-store'
|
2023-07-06 21:32:48 +00:00
|
|
|
|
|
|
|
const store = new Store()
|
|
|
|
|
2023-07-06 22:02:37 +00:00
|
|
|
export const analytics = new Analytics({ writeKey: process.env.TELEMETRY_WRITE_KEY || '<empty>' })
|
2023-07-06 21:32:48 +00:00
|
|
|
|
|
|
|
export function id(): string {
|
2023-07-07 14:27:16 +00:00
|
|
|
const id = store.get('id') as string
|
2023-07-06 21:32:48 +00:00
|
|
|
|
|
|
|
if (id) {
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
|
|
|
const uuid = uuidv4()
|
|
|
|
store.set('id', uuid)
|
|
|
|
return uuid
|
|
|
|
}
|