mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
add system properties to analytics
This commit is contained in:
parent
c231432338
commit
737ccee354
6 changed files with 66 additions and 8 deletions
|
@ -140,6 +140,8 @@ function createWindow () {
|
|||
MenuManager.initMenu();
|
||||
MenuManager.initTray();
|
||||
|
||||
Api.systemInfo(mainWindow);
|
||||
|
||||
installNativeMessagingHost();
|
||||
|
||||
ipcMain.removeHandler('Api');
|
||||
|
|
|
@ -4,6 +4,7 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const keytar = require('keytar');
|
||||
const { download } = require('electron-dl');
|
||||
const si = require('systeminformation');
|
||||
|
||||
const MenuManager = require('./menu.js');
|
||||
const ConfigManager = require('./config.js');
|
||||
|
@ -215,6 +216,12 @@ class Api {
|
|||
win.webContents.reload();
|
||||
};
|
||||
|
||||
systemInfo (win) {
|
||||
si.getStaticData().then(data => {
|
||||
Util.send(win, 'commandGlobal', 'systemInfo', data);
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
module.exports = new Api();
|
28
package-lock.json
generated
28
package-lock.json
generated
|
@ -70,7 +70,8 @@
|
|||
"selection-ranges": "^3.0.3",
|
||||
"sha1": "^1.1.1",
|
||||
"stream-slicer": "^0.0.6",
|
||||
"swiper": "^11.0.3"
|
||||
"swiper": "^11.0.3",
|
||||
"systeminformation": "^5.23.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@electron/notarize": "^2.1.0",
|
||||
|
@ -16172,6 +16173,31 @@
|
|||
"node": ">= 4.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/systeminformation": {
|
||||
"version": "5.23.5",
|
||||
"resolved": "https://registry.npmjs.org/systeminformation/-/systeminformation-5.23.5.tgz",
|
||||
"integrity": "sha512-PEpJwhRYxZgBCAlWZhWIgfMTjXLqfcaZ1pJsJn9snWNfBW/Z1YQg1mbIUSWrEV3ErAHF7l/OoVLQeaZDlPzkpA==",
|
||||
"os": [
|
||||
"darwin",
|
||||
"linux",
|
||||
"win32",
|
||||
"freebsd",
|
||||
"openbsd",
|
||||
"netbsd",
|
||||
"sunos",
|
||||
"android"
|
||||
],
|
||||
"bin": {
|
||||
"systeminformation": "lib/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "Buy me a coffee",
|
||||
"url": "https://www.buymeacoffee.com/systeminfo"
|
||||
}
|
||||
},
|
||||
"node_modules/tap-min": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/tap-min/-/tap-min-1.3.0.tgz",
|
||||
|
|
|
@ -148,7 +148,8 @@
|
|||
"selection-ranges": "^3.0.3",
|
||||
"sha1": "^1.1.1",
|
||||
"stream-slicer": "^0.0.6",
|
||||
"swiper": "^11.0.3"
|
||||
"swiper": "^11.0.3",
|
||||
"systeminformation": "^5.23.5"
|
||||
},
|
||||
"build": {
|
||||
"npmRebuild": true,
|
||||
|
|
|
@ -114,7 +114,7 @@ class Analytics {
|
|||
this.instance.setVersionName(electron.version.app);
|
||||
};
|
||||
|
||||
this.instance.setUserProperties(props);
|
||||
this.setProperty(props);
|
||||
this.removeContext();
|
||||
this.setVersion();
|
||||
|
||||
|
@ -152,11 +152,11 @@ class Analytics {
|
|||
};
|
||||
|
||||
this.instance.setUserId(id);
|
||||
this.log(`[Analytics].profile: ${id}`);
|
||||
|
||||
if (id) {
|
||||
this.instance.setUserProperties({ networkId });
|
||||
this.setProperty({ networkId });
|
||||
};
|
||||
this.log(`[Analytics].profile: ${id} networkId: ${networkId}`);
|
||||
};
|
||||
|
||||
setContext (context: string, id: string) {
|
||||
|
@ -172,10 +172,12 @@ class Analytics {
|
|||
};
|
||||
|
||||
setTier (tier: I.TierType) {
|
||||
const t = I.TierType[tier] || 'Custom';
|
||||
this.setProperty({ tier: I.TierType[tier] || 'Custom' });
|
||||
};
|
||||
|
||||
this.instance.setUserProperties({ tier: t });
|
||||
this.log(`[Analytics].setTier: ${t}`);
|
||||
setProperty (props: any) {
|
||||
this.instance.setUserProperties(props);
|
||||
this.log(`[Analytics].setProperty: ${JSON.stringify(props, null, 3)}`);
|
||||
};
|
||||
|
||||
event (code: string, data?: any) {
|
||||
|
|
|
@ -616,6 +616,26 @@ class Keyboard {
|
|||
break;
|
||||
};
|
||||
|
||||
case 'systemInfo': {
|
||||
const props: any = {};
|
||||
const { cpu, graphics, memLayout, diskLayout } = arg;
|
||||
const { manufacturer, brand, speed, cores } = cpu;
|
||||
const { controllers, displays } = graphics;
|
||||
|
||||
props.systemCpu = [ manufacturer, brand ].join(', ');
|
||||
props.systemCpuSpeed = [ `${speed}GHz`, `${cores} cores` ].join(', ');
|
||||
props.systemVideo = (controllers || []).map(it => it.model).join(', ');
|
||||
props.systemDisplay = (displays || []).map(it => it.model).join(', ');
|
||||
props.systemResolution = `${window.screen.width}x${window.screen.height}`;
|
||||
props.systemMemory = (memLayout || []).map(it => U.File.size(it.size)).join(', ');
|
||||
props.systemMemoryType = (memLayout || []).map(it => it.type).join(', ');
|
||||
props.systemDisk = (diskLayout || []).map(it => U.File.size(it.size)).join(', ');
|
||||
props.systemDiskName = (diskLayout || []).map(it => it.name).join(', ');
|
||||
|
||||
analytics.setProperty(props);
|
||||
break;
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue