Skip to content

Commit

Permalink
✨ Add Disable Analytics
Browse files Browse the repository at this point in the history
Adds an option to Disable Analytics within YouTube Music Desktop

 Adds: ytmdesktop#238
  • Loading branch information
Alipoodle committed Oct 18, 2021
1 parent 774efc7 commit 8f18d21
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 20 deletions.
2 changes: 1 addition & 1 deletion STORE_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
| `settings-continue-where-left-of` | Boolean | `true` or `false` | `false` | When you close and open the app, will return where you stopped |
| `settings-custom-css-page` | Boolean | `true` or `false` | `false` | Custom css for web page |
| `settings-decibel-volume` | Boolean | `true` or `false` | `true` | Replace the volume control with a decibel based system |
| `settings-disable-analytics` | Boolean | `true` or `false` | `false` | Disables the Analytics which the Application sends to Google Analytics |
| `settings-discord-rich-presence` | Boolean | `true` or `false` | `false` | Integration with Discord Rich Presence |
| `settings-enable-double-tapping-show-hide` | Boolean | `true` or `false` | `true` | Enable or disable double-tapping to show/hide main window |
| `settings-enable-player-bgcolor` | Boolean | `true` or `false` | `false` | Enable or disable setting the background of the player to the color of the cover art |
Expand All @@ -36,7 +37,6 @@
| `settings-volume` | String | `0` ~ `100` | `100` | Playback volume |
| `settings-volume-media-keys` | Boolean | `true` or `false` | `false` | Enable media volume keys for the playback volume |
| `settings-pause-on-suspend` | Boolean | `true` or `false` | `false` | Pause media playback on `suspend` event triggered |

## Window
| Key | Type | Values | Default | Description |
| ------------------------------------- | ------- | ---------------------------- | ---------------------------- | --------------------------------------------- |
Expand Down
17 changes: 12 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2182,16 +2182,23 @@ powerMonitor.on('suspend', () => {
}
})

if (!settingsProvider.get('settings-disable-analytics')) {
const analytics = require('./src/providers/analyticsProvider')
analytics.setEvent(
'main',
'start',
'v' + app.getVersion(),
app.getVersion()
)
analytics.setEvent('main', 'os', process.platform, process.platform)
analytics.setScreen('main')
}

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
const mediaControl = require('./src/providers/mediaProvider')
const tray = require('./src/providers/trayProvider')
const updater = require('./src/providers/updateProvider')
const analytics = require('./src/providers/analyticsProvider')
const { getTrackInfo } = require('./src/providers/infoPlayerProvider')
const { ipcRenderer } = require('electron/renderer')
//const {UpdaterSignal} = require('electron-updater');

analytics.setEvent('main', 'start', 'v' + app.getVersion(), app.getVersion())
analytics.setEvent('main', 'os', process.platform, process.platform)
analytics.setScreen('main')
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"LABEL_SETTINGS_RELAUNCH": "Apply and restart",
"LABEL_SETTINGS_SHOW_HIDE_WINDOW": "Show/Hide Main Window",
"LABEL_SETTINGS_TAB_ABOUT": "About",
"LABEL_SETTINGS_TAB_ABOUT_DISABLE_ANALYTICS": "Disable Application Analytics",
"LABEL_SETTINGS_TAB_APPEARANCE_TASKBAR_PROGRESSBAR": "Show track progress on taskbar",
"LABEL_SETTINGS_TAB_APPEARANCE_PLAYER_BACKGROUND_COLOR": "Paint background with album color",
"LABEL_SETTINGS_TAB_APPEARENCE": "Appearance",
Expand Down
1 change: 1 addition & 0 deletions src/locales/scaffold.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"LABEL_SETTINGS_RELAUNCH": "Apply and restart",
"LABEL_SETTINGS_SHOW_HIDE_WINDOW": "Show/Hide Main Window",
"LABEL_SETTINGS_TAB_ABOUT": "About",
"LABEL_SETTINGS_TAB_ABOUT_DISABLE_ANALYTICS": "Disable Application Analytics",
"LABEL_SETTINGS_TAB_APPEARANCE_TASKBAR_PROGRESSBAR": "Show track progress on taskbar",
"LABEL_SETTINGS_TAB_APPEARANCE_PLAYER_BACKGROUND_COLOR": "Paint background with album color",
"LABEL_SETTINGS_TAB_APPEARENCE": "Appearance",
Expand Down
21 changes: 21 additions & 0 deletions src/pages/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,27 @@
</a>
</p>
</div>
<div class="row">
<small>
<span
i18n="i18n_LABEL_SETTINGS_TAB_ABOUT_DISABLE_ANALYTICS"
></span>
<sub>
<i class="material-icons tiny grey-text"
>autorenew</i
>
</sub>
</small>
<div class="switch">
<label>
<input
type="checkbox"
id="settings-disable-analytics"
/>
<span class="lever"></span>
</label>
</div>
</div>
</div>
</div>
</div>
Expand Down
38 changes: 24 additions & 14 deletions src/pages/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ document.addEventListener('DOMContentLoaded', () => {
initElement('settings-clipboard-always-ask-read', 'click', null)
initElement('settings-tray-icon', 'click', showRelaunchButton)
initElement('settings-pause-on-suspend', 'click', null)

initElement('settings-disable-analytics', 'click', showRelaunchButton)
mInit()

document.getElementById('content').classList.remove('hide')
Expand Down Expand Up @@ -270,17 +272,19 @@ if (!isMac()) {
}

if (!isWindows()) {
const windowsSpecificNodes =
document.getElementsByClassName('windows-specific')
const windowsSpecificNodes = document.getElementsByClassName(
'windows-specific'
)
for (let i = 0; i < windowsSpecificNodes.length; i++)
windowsSpecificNodes.item(i).classList.add('hide')
}

if (isWindows()) {
const os = require('os')
if (!os.release().startsWith('10.')) {
const windows10SpecificNodes =
document.getElementsByClassName('windows10-specific')
const windows10SpecificNodes = document.getElementsByClassName(
'windows10-specific'
)
for (let i = 0; i < windows10SpecificNodes.length; i++)
windows10SpecificNodes.item(i).classList.add('hide')
}
Expand Down Expand Up @@ -364,8 +368,9 @@ function loadSettings() {
'settings-skip-track-shorter-than'
)
if (settingsSkipTrackShorterThan) {
document.getElementById('range-skip-track-shorter-than').value =
settingsSkipTrackShorterThan
document.getElementById(
'range-skip-track-shorter-than'
).value = settingsSkipTrackShorterThan
document.getElementById(
'range-skip-track-shorter-than-value'
).innerText =
Expand All @@ -376,8 +381,9 @@ function loadSettings() {

document.getElementById('app-version').innerText = remote.app.getVersion()

document.getElementById('label-settings-companion-server-token').innerText =
settingsProvider.get('settings-companion-server-token')
document.getElementById(
'label-settings-companion-server-token'
).innerText = settingsProvider.get('settings-companion-server-token')

// Disable unsupported platforms which may get an API later
if (!['darwin', 'win32'].includes(process.platform)) {
Expand Down Expand Up @@ -413,7 +419,7 @@ function replaceAcceleratorText(text) {
if (text.indexOf('CmdOrCtrl') !== -1)
if (isMac()) text = text.replace('CmdOrCtrl', 'Cmd')
else text = text.replace('CmdOrCtrl', 'Ctrl')

if (text.indexOf('Meta') !== -1 && isWindows())
text = text.replace('Meta', 'Windows')

Expand Down Expand Up @@ -480,16 +486,17 @@ document
keyBindings = ''

if (e.metaKey) keyBindings += 'Meta+'

if (e.ctrlKey) keyBindings += 'CmdOrCtrl+'

if (e.altKey) keyBindings += 'Alt+'

if (e.shiftKey) keyBindings += 'Shift+'

keyBindings += validateKey(e)
document.querySelector('#modalEditAcceleratorKeys').innerText =
replaceAcceleratorText(keyBindings)
document.querySelector(
'#modalEditAcceleratorKeys'
).innerText = replaceAcceleratorText(keyBindings)
}
})

Expand Down Expand Up @@ -520,8 +527,11 @@ function loadCustomKeys() {
settingsAccelerators['media-track-dislike']
)

document.querySelector('#settings-accelerators_media-volume-up').innerText =
replaceAcceleratorText(settingsAccelerators['media-volume-up'])
document.querySelector(
'#settings-accelerators_media-volume-up'
).innerText = replaceAcceleratorText(
settingsAccelerators['media-volume-up']
)
document.querySelector(
'#settings-accelerators_media-volume-down'
).innerText = replaceAcceleratorText(
Expand Down
2 changes: 2 additions & 0 deletions src/utils/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,5 @@ settingsProvider.setInitialValue(
)

settingsProvider.setInitialValue('settings-pause-on-suspend', false)

settingsProvider.setInitialValue('settings-disable-analytics', false)

0 comments on commit 8f18d21

Please sign in to comment.