Skip to content

Commit d7206b5

Browse files
author
Erika Perugachi
authored
Merge pull request #1146 from JulianAdams4/nucleus
Fix analytics
2 parents b395d6b + ffa5c90 commit d7206b5

File tree

13 files changed

+66
-36
lines changed

13 files changed

+66
-36
lines changed

electron_app/electron-starter.js

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const {
1717
isFromStore,
1818
getSystemLanguage
1919
} = require('./src/windows/windowUtils');
20-
require('dotenv').config();
2120
require('./src/ipc/composer.js');
2221
require('./src/ipc/loading.js');
2322
require('./src/ipc/login.js');
@@ -27,9 +26,6 @@ require('./src/ipc/manager.js');
2726
require('./src/ipc/dataTransfer.js');
2827
require('./src/ipc/backup.js');
2928
const ipcUtils = require('./src/ipc/utils.js');
30-
const { version } = require('./package.json');
31-
const nucleusId = process.env.NUCLEUS_ID;
32-
const versionApp = process.env.NODE_ENV === 'development' ? '0.0.0' : version;
3329

3430
globalManager.forcequit.set(false);
3531

@@ -50,7 +46,7 @@ async function initApp() {
5046
mySettings.initialize(settings);
5147
wsClient.start(myAccount);
5248
createAppMenu();
53-
mailboxWindow.show();
49+
mailboxWindow.show({ firstOpenApp: true });
5450
} else {
5551
await getUserLanguage();
5652
createAppMenu();
@@ -83,8 +79,6 @@ async function initApp() {
8379
loadingWindow.send('socket-message', data);
8480
}
8581
});
86-
87-
upNucleus();
8882
}
8983

9084
// App
@@ -105,17 +99,6 @@ const getUserLanguage = async () => {
10599
await dbManager.updateSettings({ language: osLanguage });
106100
};
107101

108-
const upNucleus = () => {
109-
const data = {
110-
onlyMainProcess: true,
111-
userId: myAccount.recipientId,
112-
version: versionApp,
113-
language: mySettings.language
114-
}
115-
const Nucleus = require('electron-nucleus')(nucleusId, data);
116-
Nucleus.track("PLAYED_TRACK");
117-
}
118-
119102
app.on('ready', () => {
120103
initApp();
121104
});

electron_app/installerResources/make_installer.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
has_error=0
44
isSupported=0
5-
installerTypeDefaultValue="DEVELOPMENT";
5+
installerTypeDefaultValue="DEVELOPMENT"
6+
nucleusIdDefaultValue="0.0.0"
67
entitlementsOriginalFileName="entitlements.mac.plist"
78
entitlementsBackupFileName="backup-entitlements.mac.plist"
89
# Folders
@@ -30,11 +31,15 @@ CURRENT_OS=$( uname )
3031
if [ "$CURRENT_OS" = "Linux" ]; then
3132
echo " OS: Linux";
3233
isSupported=1;
34+
# Load environment variables
35+
source ./.env
3336
# Update package.json
3437
linuxInstallerType=$( cat ./installerResources/installerTypes.json | json "linux.installer" )
3538
json -I -f ./package.json -e "this.criptextInstallerType=\"${linuxInstallerType}\"" -q
39+
json -I -f ./package.json -e "this.nucleusId=\"${PROD_NUCLEUS_ID}\"" -q
3640
printf " Updated package.json \n";
37-
printf " -> Installer-type: ${linuxInstallerType} \n";
41+
printf " -> Installer-type: ${linuxInstallerType}\n";
42+
printf " -> Nucleus Id : ${PROD_NUCLEUS_ID}\n";
3843
echo " Executing: yarn build";
3944
yarn build > /dev/null;
4045
# Move to subfolder
@@ -55,9 +60,11 @@ elif [ "$CURRENT_OS" = "Darwin" ]; then
5560
# Update package.json
5661
macStoreType=$( cat ./installerResources/installerTypes.json | json "mac.store" )
5762
json -I -f ./package.json -e "this.criptextInstallerType=\"${macStoreType}\"" -q
63+
json -I -f ./package.json -e "this.nucleusId=\"${PROD_NUCLEUS_ID}\"" -q
5864
json -I -f ./package.json -e 'this.build.mac.target=["mas"]' -q
5965
printf " Updated package.json \n";
6066
printf " -> Installer-type: ${macStoreType} \n";
67+
printf " -> Nucleus Id : ${PROD_NUCLEUS_ID}\n";
6168
printf " -> Current target: MAS \n";
6269
# Building
6370
printf " Executing: yarn build \n";
@@ -77,6 +84,7 @@ elif [ "$CURRENT_OS" = "Darwin" ]; then
7784
json -I -f ./package.json -e 'this.build.mac.target=["dmg", "zip"]' -q
7885
printf "\n Updated package.json \n";
7986
printf " -> Installer-type: ${macInstallerType} \n";
87+
printf " -> Nucleus Id : ${PROD_NUCLEUS_ID}\n";
8088
printf " -> Current target: DMG & ZIP \n";
8189
mv "build/${entitlementsOriginalFileName}" "build/${entitlementsBackupFileName}";
8290
printf " Renamed [${entitlementsOriginalFileName}] to [${entitlementsBackupFileName}] \n";
@@ -107,9 +115,11 @@ else
107115
# Update package.json
108116
windowsInstallerType=$( cat ./installerResources/installerTypes.json | json "windows.installer" )
109117
json -I -f ./package.json -e "this.criptextInstallerType=\"${windowsInstallerType}\"" -q
118+
json -I -f ./package.json -e "this.nucleusId=\"${PROD_NUCLEUS_ID}\"" -q
110119
json -I -f ./package.json -e 'this.build.win.target=["nsis"]' -q
111120
printf " Updated package.json \n";
112121
printf " -> Installer-type: ${windowsInstallerType} \n";
122+
printf " -> Nucleus Id : ${PROD_NUCLEUS_ID}\n";
113123
printf " -> Current target: Nsis \n";
114124
# Building
115125
printf " Executing: yarn build";
@@ -133,8 +143,9 @@ else
133143
json -I -f ./package.json -e "this.build.appx.publisher=\"${WIN_STORE_DEVELOPER_ID}\"" -q
134144
printf "\n Updated package.json \n";
135145
printf " -> Installer-type: ${windowsStoreType} \n";
146+
printf " -> Nucleus Id : ${PROD_NUCLEUS_ID}\n";
136147
printf " -> Current target: AppX \n";
137-
printf " -> Publisher: ${WIN_STORE_DEVELOPER_ID} \n";
148+
printf " -> Publisher : ${WIN_STORE_DEVELOPER_ID} \n";
138149
# Building
139150
printf " Executing: yarn build";
140151
yarn build > /dev/null;
@@ -152,8 +163,9 @@ else
152163
fi
153164

154165

155-
# Set default criptextInstallerType
166+
# Set default criptextInstallerType & Nucleus Id
156167
json -I -f ./package.json -e "this.criptextInstallerType=\"${installerTypeDefaultValue}\"" -q
168+
json -I -f ./package.json -e "this.nucleusId=\"${nucleusIdDefaultValue}\"" -q
157169
# Remove modified package.json
158170
rm -f ./package.json
159171
# Restore original package.json

electron_app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "criptext",
3-
"version": "0.23.2",
3+
"version": "0.23.3",
44
"author": {
55
"name": "Criptext Inc",
66
"email": "[email protected]",
@@ -24,9 +24,10 @@
2424
"lint": "criptext-js-tools lint",
2525
"clear-build": "sh ./installerResources/clearBuild.sh",
2626
"package": "sh ./installerResources/converge_builds.sh",
27-
"release": "sh ./installerResources/make_installer.sh"
27+
"release": "bash ./installerResources/make_installer.sh"
2828
},
2929
"criptextInstallerType": "DEVELOPMENT",
30+
"nucleusId": "0.0.0",
3031
"build": {
3132
"appId": "com.criptext.criptextmail",
3233
"buildVersion": "1",

electron_app/src/ipc/mailbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ ipc.answerRenderer('open-file-explorer', filename => {
4444
mailboxWindow.showFileExplorer(filename);
4545
});
4646

47-
ipc.answerRenderer('open-mailbox', () => {
47+
ipc.answerRenderer('open-mailbox', ({ firstOpenApp }) => {
4848
wsClient.start(myAccount);
49-
mailboxWindow.show();
49+
mailboxWindow.show({ firstOpenApp });
5050
});
5151

5252
ipc.answerRenderer('print-to-pdf', async ({ emailId, threadId }) => {

electron_app/src/utils/const.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* process */
22
require('dotenv').config();
3+
const { version, nucleusId } = require('./../../package.json');
34

45
const API_CLIENT_VERSION = '9.0.0';
56
const LINK_DEVICES_FILE_VERSION = '5';
@@ -27,5 +28,9 @@ module.exports = {
2728
: PROD_DATA_TRANSFER_URL,
2829
NEWS_SERVER_URL,
2930
API_CLIENT_VERSION,
30-
LINK_DEVICES_FILE_VERSION
31+
LINK_DEVICES_FILE_VERSION,
32+
APP_VERSION: isDevelopment ? '0.0.0' : version,
33+
NUCLEUS_ID: isDevelopment
34+
? process.env.DEV_NUCLEUS_ID
35+
: process.env.PROD_NUCLEUS_ID || nucleusId
3136
};

electron_app/src/windows/mailbox.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ const { appUpdater } = require('./../updater');
88
const globalManager = require('./../globalManager');
99
const { mailtoProtocolRegex } = require('./../utils/RegexUtils');
1010
const { removeProtocolFromUrl } = require('./../utils/stringUtils');
11-
const { isFromStore, isDev } = require('./windowUtils');
11+
const {
12+
isFromStore,
13+
isDev,
14+
nucleusTrack,
15+
NUCLEUS_EVENTS
16+
} = require('./windowUtils');
1217
const { createTrayIcon, destroyTrayIcon } = require('./tray');
1318
const { isWindows } = require('./../utils/osUtils');
1419

@@ -89,18 +94,20 @@ const showFileExplorer = filename => {
8994
mailboxWindow.send('display-message-success-download');
9095
};
9196

92-
const show = async () => {
97+
const show = async ({ firstOpenApp = false }) => {
9398
const existVisibleWindow = BrowserWindow.getAllWindows().filter(w =>
9499
w.isVisible()
95100
);
96101
if (mailboxWindow) {
97102
mailboxWindow.show();
98103
createTrayIcon();
104+
if (firstOpenApp) nucleusTrack(NUCLEUS_EVENTS.MAILBOX_TRACK);
99105
} else if (!existVisibleWindow.length || !mailboxWindow) {
100106
await create();
101107
mailboxWindow.on('ready-to-show', () => {
102108
mailboxWindow.show();
103109
createTrayIcon();
110+
if (firstOpenApp) nucleusTrack(NUCLEUS_EVENTS.MAILBOX_TRACK);
104111
});
105112
mailboxWindow.on('focus', () => {
106113
if (!globalManager.windowsEvents.checkDisabled()) {

electron_app/src/windows/tray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const createTrayIcon = () => {
5353
tray.setContextMenu(contextMenu);
5454
tray.on('click', () => {
5555
const mailboxWindow = require('./mailbox');
56-
mailboxWindow.show();
56+
mailboxWindow.show({});
5757
});
5858
}
5959
};

electron_app/src/windows/windowUtils.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const { app, BrowserWindow } = require('electron');
22
const osLocale = require('os-locale');
33
const globalManager = require('./../globalManager');
4+
const myAccount = require('./../Account');
5+
const mySettings = require('./../Settings');
6+
const { APP_VERSION, NUCLEUS_ID } = require('./../utils/const');
47

58
const showWindows = () => {
69
const visibleWindows = BrowserWindow.getAllWindows();
@@ -39,6 +42,23 @@ const sendEventToAllWindows = (eventName, params) => {
3942
});
4043
};
4144

45+
const getNucleusPayload = () => ({
46+
onlyMainProcess: true,
47+
userId: myAccount.recipientId,
48+
version: APP_VERSION,
49+
language: mySettings.language
50+
});
51+
52+
const nucleusTrack = eventName => {
53+
const data = getNucleusPayload();
54+
const Nucleus = require('electron-nucleus')(NUCLEUS_ID, data);
55+
Nucleus.track(eventName);
56+
};
57+
58+
const NUCLEUS_EVENTS = {
59+
MAILBOX_TRACK: 'MAILBOX_TRACK'
60+
};
61+
4262
module.exports = {
4363
quit,
4464
isDev,
@@ -48,5 +68,7 @@ module.exports = {
4868
isFromStore,
4969
showWindows,
5070
getSystemLanguage,
51-
sendEventToAllWindows
71+
sendEventToAllWindows,
72+
NUCLEUS_EVENTS,
73+
nucleusTrack
5274
};

email_composer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email_composer",
3-
"version": "0.1.0",
3+
"version": "0.23.3",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.1.2-rc5",

email_loading/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "email_loading",
3-
"version": "0.1.0",
3+
"version": "0.23.3",
44
"private": true,
55
"dependencies": {
66
"@criptext/electron-better-ipc": "^0.1.2-rc5",

0 commit comments

Comments
 (0)