@@ -7,12 +7,15 @@ import {
77import { UtilitiesService } from './services/utilities.service'
88import { UIService , UIDimensions , UIShownChangedEventCallback } from './services/ui.service'
99import { FadeInOutAnimation , FromTopAnimation } from '@eqmac/components'
10- import { MatDialog } from '@angular/material/dialog'
10+ import { MatDialog , MatDialogRef } from '@angular/material/dialog'
1111import { TransitionService } from './services/transitions.service'
1212import { AnalyticsService } from './services/analytics.service'
1313import { ApplicationService } from './services/app.service'
1414import { SettingsService , IconMode } from './sections/settings/settings.service'
1515import { ConfirmDialogComponent } from './components/confirm-dialog/confirm-dialog.component'
16+ import { SemanticVersion } from './services/semantic-version.service'
17+ import { OptionsDialogComponent } from './components/options-dialog/options-dialog.component'
18+ import { Option , Options } from './components/options/options.component'
1619
1720@Component ( {
1821 selector : 'app-root' ,
@@ -47,29 +50,107 @@ export class AppComponent implements OnInit, AfterContentInit {
4750 async ngOnInit ( ) {
4851 await this . sync ( )
4952 await this . fixUIMode ( )
53+ await this . setupPrivacy ( )
54+ }
5055
51- const uiSettings = await this . ui . getSettings ( )
52-
53- if ( typeof uiSettings . doCollectTelemetry !== 'boolean' ) {
54- uiSettings . doCollectTelemetry = await this . dialog . open ( ConfirmDialogComponent , {
55- hasBackdrop : true ,
56- disableClose : true ,
57- data : {
58- text : `Is it okay with you if eqMac will collect anonymous Telemetry analytics data like:
56+ async setupPrivacy ( ) {
57+ const [ uiSettings , info ] = await Promise . all ( [
58+ this . ui . getSettings ( ) ,
59+ this . app . getInfo ( )
60+ ] )
5961
60- • macOS Version
61- • App and UI Version
62- • Country (IP Addresses are anonymized)
62+ // Starting from v1.1.0 we need to show the Crash Reports consent as well
63+ if ( new SemanticVersion ( info . version ) . isGreaterThanOrEqualTo ( '1.1.0' ) ) {
64+ let doCollectCrashReports = await this . settings . getDoCollectCrashReports ( )
65+ if ( typeof uiSettings . privacyFormSeen !== 'boolean' ) {
66+ const doCollectTelemetryOption : Option = {
67+ type : 'checkbox' ,
68+ label : 'Send Anonymous Analytics data' ,
69+ tooltip : `
70+ eqMac would collect anonymous Telemetry analytics data like:
71+
72+ • macOS Version
73+ • App and UI Version
74+ • Country (IP Addresses are anonymized)
75+
76+ This helps us understand distribution of our users.
77+ ` ,
78+ value : uiSettings . doCollectTelemetry ?? false ,
79+ toggled : doCollectTelemetry => {
80+ uiSettings . doCollectTelemetry = doCollectTelemetry
81+ this . ui . setSettings ( { doCollectTelemetry } )
82+ }
83+ }
6384
64- This helps us understand distribution of eqMac's users.
65- You can change this setting any time later in the Settings.` ,
66- cancelText : 'Don\'t collect' ,
67- confirmText : 'It\'s okay'
85+ const doCollectCrashReportsOption : Option = {
86+ type : 'checkbox' ,
87+ label : 'Send Anonymous Crash reports' ,
88+ tooltip : `
89+ eqMac would send anonymized crash reports
90+ back to the developer in case eqMac crashes.
91+ This helps us understand improve eqMac
92+ and make it a more stable product.
93+ ` ,
94+ value : doCollectCrashReports ,
95+ toggled : doCollect => {
96+ doCollectCrashReports = doCollect
97+ this . settings . setDoCollectCrashReports ( {
98+ doCollectCrashReports
99+ } )
100+ }
68101 }
69- } ) . afterClosed ( ) . toPromise ( )
70- await this . ui . setSettings ( {
71- doCollectTelemetry : uiSettings . doCollectTelemetry
72- } )
102+ const privacyDialog : MatDialogRef < OptionsDialogComponent > = this . dialog . open ( OptionsDialogComponent , {
103+ hasBackdrop : true ,
104+ disableClose : true ,
105+ data : {
106+ options : [
107+ [ { type : 'label' , label : 'Privacy' } ] ,
108+ [ {
109+ type : 'label' , label : `eqMac respects it's user's privacy
110+ and is giving you a choice what data you wish to share with the developer.
111+ This data would help us improve and grow the product.`
112+ } ] ,
113+ [ doCollectTelemetryOption ] ,
114+ [ doCollectCrashReportsOption ] ,
115+ [
116+ {
117+ type : 'button' ,
118+ label : 'Save' ,
119+ action : ( ) => privacyDialog . close ( )
120+ }
121+ ]
122+ ] as Options
123+ }
124+ } )
125+
126+ await privacyDialog . afterClosed ( ) . toPromise ( )
127+ await this . ui . setSettings ( {
128+ privacyFormSeen : true
129+ } )
130+ }
131+ } else {
132+ // Can only show Analytics consent form on < v1.1.0
133+ if ( typeof uiSettings . doCollectTelemetry !== 'boolean' ) {
134+ uiSettings . doCollectTelemetry = await this . dialog . open ( ConfirmDialogComponent , {
135+ hasBackdrop : true ,
136+ disableClose : true ,
137+ data : {
138+ text : `Is it okay with you if eqMac will collect anonymous Telemetry analytics data like:
139+
140+ • macOS Version
141+ • App and UI Version
142+ • Country (IP Addresses are anonymized)
143+
144+ This helps us understand distribution of eqMac's users.
145+ You can change this setting any time later in the Settings.` ,
146+ cancelText : 'Don\'t collect' ,
147+ confirmText : 'It\'s okay'
148+ }
149+ } ) . afterClosed ( ) . toPromise ( )
150+ await this . ui . setSettings ( {
151+ doCollectTelemetry : uiSettings . doCollectTelemetry
152+ } )
153+ }
73154 }
74155
75156 if ( uiSettings . doCollectTelemetry ) {
0 commit comments