mirror of
https://github.com/hellodigua/ChatLab.git
synced 2026-10-26 02:04:37 +08:00
refactor(analytics): drop legacy settings migration
This commit is contained in:
1 parent
da1432a1d3
commit
aaea90d2fc
1 file changed
-14
@@ -1,6 +1,4 @@
|
||||
import { app, ipcMain } from 'electron'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { AnalyticsService } from '@openchatlab/node-runtime'
|
||||
import { getSystemDataDir } from './paths'
|
||||
|
||||
@@ -8,22 +6,10 @@ const APTABASE_APP_KEY = process.env.APTABASE_APP_KEY
|
||||
|
||||
let _service: AnalyticsService | null = null
|
||||
|
||||
function migrateAnalyticsIfNeeded(systemDir: string): void {
|
||||
const newPath = path.join(systemDir, 'analytics.json')
|
||||
if (fs.existsSync(newPath)) return
|
||||
try {
|
||||
const oldPath = path.join(app.getPath('userData'), 'analytics.json')
|
||||
if (fs.existsSync(oldPath)) fs.copyFileSync(oldPath, newPath)
|
||||
} catch (_e) {
|
||||
// Non-critical migration, ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
function getService(): AnalyticsService | null {
|
||||
if (!APTABASE_APP_KEY) return null
|
||||
if (!_service) {
|
||||
const systemDir = getSystemDataDir()
|
||||
migrateAnalyticsIfNeeded(systemDir)
|
||||
_service = new AnalyticsService(systemDir, APTABASE_APP_KEY, app.getVersion())
|
||||
}
|
||||
return _service
|
||||
|
||||
Reference in new issue
Block a user