diff --git a/src/main/ScratchDesktopTelemetry.js b/src/main/ScratchDesktopTelemetry.js index ec27205..1dbecf0 100644 --- a/src/main/ScratchDesktopTelemetry.js +++ b/src/main/ScratchDesktopTelemetry.js @@ -36,6 +36,9 @@ class ScratchDesktopTelemetry { set didOptIn (value) { this._telemetryClient.didOptIn = value; } + clearDidOptIn () { + this._telemetryClient.clearDidOptIn(); + } appWasOpened () { this._telemetryClient.addEvent('app::open', {...EVENT_TEMPLATE, ...APP_INFO}); @@ -95,6 +98,11 @@ ipcMain.on('getTelemetryDidOptIn', event => { }); ipcMain.on('setTelemetryDidOptIn', (event, arg) => { scratchDesktopTelemetrySingleton.didOptIn = arg; + event.returnValue = null; +}); +ipcMain.on('clearTelemetryDidOptIn', event => { + scratchDesktopTelemetrySingleton.clearDidOptIn(); + event.returnValue = null; }); ipcMain.on('projectDidLoad', (event, arg) => { scratchDesktopTelemetrySingleton.projectDidLoad(arg); diff --git a/src/main/telemetry/TelemetryClient.js b/src/main/telemetry/TelemetryClient.js index c38cb5b..fafda8b 100644 --- a/src/main/telemetry/TelemetryClient.js +++ b/src/main/telemetry/TelemetryClient.js @@ -185,6 +185,9 @@ class TelemetryClient { set didOptIn (value) { this._store.set('optIn', !!value); } + clearDidOptIn () { + this._store.delete('optIn'); + } /** * Semi-persistent unique ID for this client diff --git a/src/renderer/app.jsx b/src/renderer/app.jsx index 8fff8cf..9fa906e 100644 --- a/src/renderer/app.jsx +++ b/src/renderer/app.jsx @@ -116,7 +116,23 @@ const ScratchDesktopHOC = function (WrappedComponent) { canSave={false} isScratchDesktop showTelemetryModal={shouldShowTelemetryModal} - onClickAbout={this.handleClickAbout} + onClickAbout={[ + { + title: 'About', + onClick: () => this.handleClickAbout() + }, + { + title: 'Privacy Policy', + onClick: () => showPrivacyPolicy() + }, + { + title: 'Telemetry Settings', + onClick: () => { + // set to null (non-Boolean) to cause app to ask again + ipcRenderer.sendSync('clearTelemetryDidOptIn'); + } + } + ]} onProjectTelemetryEvent={this.handleProjectTelemetryEvent} onShowPrivacyPolicy={showPrivacyPolicy} onStorageInit={this.handleStorageInit}