Skip to content

Commit

Permalink
Release build, added completely anonymous data collection.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchantweb committed Dec 3, 2023
1 parent 852e717 commit 2084bc0
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 8 deletions.
10 changes: 9 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const si = require('systeminformation');
const packageJSON = require('./package.json');
const { updateElectronApp } = require('update-electron-app');

const crypto = require('crypto');

const {initializeDatabase, captureDataPoint, getDataPoints, deleteDataPoint} = require('./src/system/database');
const {initializeAppData, storeAppData} = require('./src/system/configuration');

Expand Down Expand Up @@ -115,11 +117,17 @@ app.whenReady().then(async () => {
}

// Get system initialization information once the application is ready
// We hash the UUID to prevent tracking of individual users
ipcMain.handle('application-ready', async () => {
let uuid = null;
let platform = null;
await si.system().then(data => uuid = data.uuid);
await si.osInfo().then(data => platform = data.platform);
const hash = crypto.createHash('sha256');
hash.update(uuid);
return {
'uuid': uuid,
'uuid': hash.digest('hex'),
'platform': platform,
'version': packageJSON.version,
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "RCKT Software, LLC.",
"description": "An open-source progress tracker that predicts when you'll reach your goals",
"private": true,
"version": "1.3.139",
"version": "1.3.140",
"main": "main.js",
"repository": "github:RCKT-Software/telemetry",
"scripts": {
Expand Down
34 changes: 29 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,46 @@ import Welcome from "./components/layout/welcome.vue";
import {Database, History, Plus, Table2, X} from "lucide-vue-next";
const appDataStore = useAppDataStore();
const modalStore = useModalStore();
const interfaceStore = useInterfaceStore();
const systemInformation = ref({
version: null,
uuid: null
uuid: null,
platform: null,
});
;
/**
* Get system information when available
* Send anonymous usage data once per minute
*/
onMounted(async () => {
systemInformation.value = await window["electronAPI"].getSystemInformation();
await sendAnonymousUsageData();
setInterval(async () => {
await sendAnonymousUsageData();
}, 1000 * 60);
});
const appDataStore = useAppDataStore();
const modalStore = useModalStore();
const interfaceStore = useInterfaceStore();
/**
* Sends anonymous usage data to the server
* @returns {Promise<void>}
*/
const sendAnonymousUsageData = async () => {
await fetch('https://telemetry.software/api/usage', {
method: 'POST',
body: JSON.stringify({
deviceId: systemInformation.value.uuid,
platform: systemInformation.value.platform,
version: systemInformation.value.version,
numCollections: appDataStore.collections.length,
numTrackers: appDataStore.numTrackers,
numGoals: appDataStore.numGoals,
numDataPoints: appDataStore.numDataPoints,
})
});
}
const rootStyles = computed(() => {
if (appDataStore.darkMode) {
Expand Down
42 changes: 41 additions & 1 deletion src/stores/appData.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,43 @@ export const useAppDataStore = defineStore('appData', () => {
}
}

/**
* The total number of trackers across all collections
*/
const numTrackers = computed(() => {
let count = 0;
for (let collection of collections.value) {
count += collection.trackers.length;
}
return count;
});

/**
* The total number of goals across all trackers
*/
const numGoals = computed(() => {
let count = 0;
for (let collection of collections.value) {
for (let tracker of collection.trackers) {
count += tracker.goals.length;
}
}
return count;
});

/**
* The total number of data points across all trackers
*/
const numDataPoints = computed(() => {
let count = 0;
for (let collection of collections.value) {
for (let tracker of collection.trackers) {
count += tracker.recentDataPoints.length;
}
}
return count;
})

/**
* A flag indicating whether the welcome screen should be shown when the user visits an empty collection
*/
Expand All @@ -104,6 +141,9 @@ export const useAppDataStore = defineStore('appData', () => {
getTrackerById,
addCollection,
deleteCollection,
showWelcome
showWelcome,
numTrackers,
numGoals,
numDataPoints
};
})

0 comments on commit 2084bc0

Please sign in to comment.