-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
55 lines (41 loc) · 1.45 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const { app, BrowserWindow } = require('electron')
const Electrolytic = require('electrolytic')
const ELECTROLYTIC_APP_KEY = '<YOUR-APP-KEY>'
const electrolytic = Electrolytic({
appKey: ELECTROLYTIC_APP_KEY,
})
// Visit https://electrolytic.app/dashboard/analytics after you start app to see Analytics reporting there.
electrolytic
.analytics
.enable(true) // disabled by default.
.use(app) // to report current version of the app
.report() // need to explicitly call it.
electrolytic.on('token', token => { // will be called everytime on app start
console.log('user token', token);
mainWindow.webContents.send('token', token)
console.log('my configs', electrolytic.configs.get()); // get configs on first load
})
electrolytic.on('push', (payload) => { // when you use the API to send a push
console.log('got push notification in main', payload)
mainWindow.webContents.send('push', payload)
})
// when you update the config on our dashboard. It's pushed to all the apps in realtime 🙀
electrolytic.on('config', (config) => {
console.log('got new config', config)
})
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true // to be able to use ipcRenderer
}
})
mainWindow.loadFile('index.html')
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', app.quit)