Commit b9a186c8 authored by Jeffrey Morgan's avatar Jeffrey Morgan
Browse files

basic telemetry

parent 8681ba0e
This diff is collapsed.
......@@ -31,8 +31,10 @@
"@electron-forge/plugin-webpack": "^6.2.1",
"@electron-forge/publisher-github": "^6.2.1",
"@types/chmodr": "^1.0.0",
"@types/node": "^20.3.1",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
......@@ -62,9 +64,11 @@
},
"dependencies": {
"@electron/remote": "^2.0.10",
"@types/node": "^20.3.1",
"@segment/analytics-node": "^1.0.0",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^8.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"uuid": "^9.0.0"
}
}
......@@ -3,6 +3,8 @@ import { app, autoUpdater, dialog, Tray, Menu, nativeTheme } from 'electron'
import * as path from 'path'
import * as fs from 'fs'
import { analytics, id } from './telemetry'
require('@electron/remote/main').initialize()
let tray: Tray | null = null
......@@ -172,9 +174,20 @@ autoUpdater.setFeedURL({
url: `https://ollama.ai/api/update?os=${process.platform}&arch=${process.arch}&version=${app.getVersion()}`,
})
async function heartbeat() {
analytics.track({
anonymousId: id(),
event: 'heartbeat',
})
}
heartbeat()
if (app.isPackaged) {
heartbeat()
autoUpdater.checkForUpdates()
setInterval(() => {
heartbeat()
autoUpdater.checkForUpdates()
}, 60000)
}
......
import { Analytics } from '@segment/analytics-node'
import { v4 as uuidv4 } from 'uuid'
const Store = require('electron-store')
const store = new Store()
export const analytics = new Analytics({ writeKey: process.env.TELEMETRY_WRITE_KEY })
export function id(): string {
const id = store.get('id')
if (id) {
return id
}
const uuid = uuidv4()
store.set('id', uuid)
return uuid
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment