| 52 | } |
| 53 | |
| 54 | async function getContext(): Promise<Context> { |
| 55 | if (contextCache) { |
| 56 | contextCache.date = new Date().toISOString().split("T")[0] |
| 57 | return contextCache |
| 58 | } |
| 59 | const deviceId = await Global.getDeviceId() |
| 60 | contextCache = { |
| 61 | deviceId, |
| 62 | os: os.platform(), |
| 63 | arch: os.arch(), |
| 64 | version: Installation.VERSION, |
| 65 | channel: Installation.CHANNEL, |
| 66 | date: new Date().toISOString().split("T")[0], |
| 67 | } |
| 68 | return contextCache |
| 69 | } |
| 70 | |
| 71 | export async function track(event: string, properties?: Record<string, string | number | boolean>): Promise<void> { |
| 72 | if (!(await isEnabled())) return |