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