From 5b09e73040c9264b6ddcda324932b66a6ec41b6b Mon Sep 17 00:00:00 2001 From: Ganesh Rathinavel Medayil Date: Wed, 12 Jun 2024 03:15:35 +0530 Subject: [PATCH 1/2] Machine id fetching improvements. --- app/helpers/identifiers.js | 18 ++++++++++++++++++ app/services/analytics/mixpanelAnalytics.js | 4 ++-- app/services/sentry/index.js | 4 ++-- app/utils/log.js | 4 ++-- package.json | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 app/helpers/identifiers.js diff --git a/app/helpers/identifiers.js b/app/helpers/identifiers.js new file mode 100644 index 00000000..545d481d --- /dev/null +++ b/app/helpers/identifiers.js @@ -0,0 +1,18 @@ +import { machineId } from 'node-machine-id'; +import { settingsStorage } from './storageHelper'; + +export async function getMachineId() { + const settings = settingsStorage.getItems(['machineId']); + + if (!settings?.machineId) { + const _machineId = await machineId(); + + settingsStorage.setItems({ + machineId: _machineId, + }); + + return _machineId; + } + + return settings.machineId; +} diff --git a/app/services/analytics/mixpanelAnalytics.js b/app/services/analytics/mixpanelAnalytics.js index 93503b5c..17a8eb91 100644 --- a/app/services/analytics/mixpanelAnalytics.js +++ b/app/services/analytics/mixpanelAnalytics.js @@ -1,6 +1,5 @@ import { isObject } from 'nice-utils'; import mixpanel from 'mixpanel-browser'; -import { machineId } from 'node-machine-id'; import { release } from 'os'; import { log } from '../../utils/log'; import { isEmpty } from '../../utils/funcs'; @@ -15,6 +14,7 @@ import { unixTimestampNow } from '../../utils/date'; import { getCurrentWindowHash } from '../../helpers/windowHelper'; import { getPlatform } from '../../utils/getPlatform'; import { APP_VERSION } from '../../constants/meta'; +import { getMachineId } from '../../helpers/identifiers'; export class MixpanelAnalytics { constructor() { @@ -48,7 +48,7 @@ export class MixpanelAnalytics { } // this is a hashed value (sha-256) - this.machineId = await machineId(); + this.machineId = await getMachineId(); if (ENV_FLAVOR.enableMixpanelAnalytics) { mixpanel.init(SERVICE_KEYS.mixpanelAnalytics); diff --git a/app/services/sentry/index.js b/app/services/sentry/index.js index 73811ff1..082ec410 100644 --- a/app/services/sentry/index.js +++ b/app/services/sentry/index.js @@ -1,5 +1,4 @@ import * as Sentry from '@sentry/electron'; -import { machineId } from 'node-machine-id'; import { ENV_FLAVOR } from '../../constants/env'; import { SERVICE_KEYS } from '../../constants/serviceKeys'; import { getDeviceInfo } from '../../helpers/deviceInfo'; @@ -7,6 +6,7 @@ import { isEmpty } from '../../utils/funcs'; import { pkginfo } from '../../utils/pkginfo'; import { checkIf } from '../../utils/checkIf'; import { MTP_MODE } from '../../enums'; +import { getMachineId } from '../../helpers/identifiers'; class SentryService { constructor() { @@ -25,7 +25,7 @@ class SentryService { release: pkginfo.version, }); - this.machineId = await machineId(); + this.machineId = await getMachineId(); } async report({ error, title, mtpMode }) { diff --git a/app/utils/log.js b/app/utils/log.js index ce070161..c4d03423 100644 --- a/app/utils/log.js +++ b/app/utils/log.js @@ -1,6 +1,5 @@ import clp from 'console-log-plus'; import os, { EOL } from 'os'; -import { machineId } from 'node-machine-id'; import { IS_PROD } from '../constants/env'; import { APP_NAME, APP_VERSION } from '../constants/meta'; import { PATHS } from '../constants/paths'; @@ -12,6 +11,7 @@ import { isEmpty } from './funcs'; import { getMtpModeSetting } from '../helpers/settings'; import { redactHomeDirectory } from '../helpers/logs'; import { isConsoleError } from './errors'; +import { getMachineId } from '../helpers/identifiers'; const { logFile } = PATHS; @@ -121,7 +121,7 @@ export const log = { let _deviceInfoStrigified = ''; const deviceInfo = getDeviceInfo(); const mtpMode = getMtpModeSetting(); - const uuid = await machineId(); + const uuid = await getMachineId(); if (!isEmpty(deviceInfo)) { Object.keys(deviceInfo).forEach((a) => { diff --git a/package.json b/package.json index 42594dbd..5933190c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "openmtp", "productName": "OpenMTP", - "version": "3.2.20", + "version": "3.2.21", "description": "OpenMTP | Android File Transfer for macOS", "scripts": { "build": "yarn lint && concurrently \"yarn build-main\" \"yarn build-renderer\"", From 265b86d859134d1483d47bad7afcce96e2c1f8dc Mon Sep 17 00:00:00 2001 From: Ganesh Rathinavel Medayil Date: Wed, 12 Jun 2024 03:45:26 +0530 Subject: [PATCH 2/2] sample env file fixed --- sample.env | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sample.env b/sample.env index e69de29b..198fbd37 100644 --- a/sample.env +++ b/sample.env @@ -0,0 +1,3 @@ +APPLEID="" +APPLE_APP_SPECIFIC_PASSWORD="" +APPLE_TEAM_ID=""