diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index aae1e5a5..67936781 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -26,9 +26,9 @@ jobs: ERR_LOG_URL: ${{ secrets.ERR_LOG_URL }} ERR_LOG_SECRET: ${{ secrets.ERR_LOG_SECRET }} run: | - echo $ERR_LOG_KEY > err_log_creds.txt - echo $ERR_LOG_SECRET >> err_log_creds.txt - echo $ERR_LOG_URL >> err_log_creds.txt + echo $ERR_LOG_KEY > log_creds.txt + echo $ERR_LOG_SECRET >> log_creds.txt + echo $ERR_LOG_URL >> log_creds.txt - name: Run build env: @@ -71,9 +71,9 @@ jobs: ERR_LOG_URL: ${{ secrets.ERR_LOG_URL }} ERR_LOG_SECRET: ${{ secrets.ERR_LOG_SECRET }} run: | - echo $ERR_LOG_KEY > err_log_creds.txt - echo $ERR_LOG_SECRET >> err_log_creds.txt - echo $ERR_LOG_URL >> err_log_creds.txt + echo $ERR_LOG_KEY > log_creds.txt + echo $ERR_LOG_SECRET >> log_creds.txt + echo $ERR_LOG_URL >> log_creds.txt - name: Run build env: @@ -113,9 +113,9 @@ jobs: ERR_LOG_URL: ${{ secrets.ERR_LOG_URL }} ERR_LOG_SECRET: ${{ secrets.ERR_LOG_SECRET }} run: | - echo $ERR_LOG_KEY > err_log_creds.txt - echo $ERR_LOG_SECRET >> err_log_creds.txt - echo $ERR_LOG_URL >> err_log_creds.txt + echo $ERR_LOG_KEY > log_creds.txt + echo $ERR_LOG_SECRET >> log_creds.txt + echo $ERR_LOG_URL >> log_creds.txt - name: Run build env: diff --git a/.gitignore b/.gitignore index 27c39fea..a13fc135 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ yarn-error.log* #Electron-builder output /dist_electron -err_log_creds.txt \ No newline at end of file +log_creds.txt \ No newline at end of file diff --git a/electron-builder.yml b/electron-builder.yml index da8830d4..acb5245a 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -3,8 +3,8 @@ appId: io.frappe.books afterSign: build/notarize.js extraResources: [ { - from: 'err_log_creds.txt', - to: '../creds/err_log_creds.txt', + from: 'log_creds.txt', + to: '../creds/log_creds.txt', } ] mac: diff --git a/src/contactMothership.js b/src/contactMothership.js index cf5b8278..2ba4dcfd 100644 --- a/src/contactMothership.js +++ b/src/contactMothership.js @@ -4,24 +4,25 @@ import http from 'http'; import https from 'https'; import path from 'path'; -function getUrlAndTokenString() { +export function getUrlAndTokenString() { const inProduction = app.isPackaged; + const empty = { url: '', telemetryUrl: '', tokenString: '' }; let errLogCredsPath = path.join( process.resourcesPath, - '../creds/err_log_creds.txt' + '../creds/log_creds.txt' ); if (!fs.existsSync(errLogCredsPath)) { - errLogCredsPath = path.join(__dirname, '../err_log_creds.txt'); + errLogCredsPath = path.join(__dirname, '../log_creds.txt'); } if (!fs.existsSync(errLogCredsPath)) { !inProduction && console.log(`${errLogCredsPath} doesn't exist, can't log`); - return; + return empty; } - let apiKey, apiSecret, url; + let apiKey, apiSecret, url, telemetryUrl; try { - [apiKey, apiSecret, url] = fs + [apiKey, apiSecret, url, telemetryUrl] = fs .readFileSync(errLogCredsPath, 'utf-8') .split('\n') .filter((f) => f.length); @@ -30,10 +31,14 @@ function getUrlAndTokenString() { console.log(`logging error using creds at: ${errLogCredsPath} failed`); console.log(err); } - return; + return empty; } - return { url: encodeURI(url), tokenString: `token ${apiKey}:${apiSecret}` }; + return { + url: encodeURI(url), + telemetryUrl: encodeURI(telemetryUrl), + tokenString: `token ${apiKey}:${apiSecret}`, + }; } function post(bodyJson) {