Skip to content

Commit

Permalink
fix: store analytics in app.getPath(userData) (#1900)
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu committed Oct 1, 2021
1 parent 18c34e3 commit cb611d2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/analytics.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
const Countly = require('countly-sdk-nodejs')
const { ipcMain } = require('electron')
const { COUNTLY_KEY } = require('./common/consts')
const { join } = require('path')
const { app } = require('electron')
const { existsSync, mkdirSync } = require('fs')

module.exports = async function (ctx) {
// workaround: recursive mkdir https://github.com/Countly/countly-sdk-nodejs/pull/14
const countlyDataDir = join(app.getPath('userData'), 'countly-data')
if (!existsSync(countlyDataDir)) {
mkdirSync(countlyDataDir, { recursive: true })
}

Countly.init({
url: 'https://countly.ipfs.io',
app_key: COUNTLY_KEY,
debug: process.env.DEBUG_COUNTLY === 'true',
require_consent: true
require_consent: true,
// countlyDataDir for read-only node_modules
storage_path: countlyDataDir
})

ctx.countlyDeviceId = Countly.device_id
Expand Down

0 comments on commit cb611d2

Please sign in to comment.