-
Notifications
You must be signed in to change notification settings - Fork 32
GDPR Changes #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
GDPR Changes #171
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,114 @@ | ||
import * as os from 'os'; | ||
import { Version } from '../common/version'; | ||
import { GUAService } from './guaService'; | ||
import { TelerikAnalyticsService } from './telerikAnalyticsService'; | ||
import { AnalyticsBaseInfo, OperatingSystem } from './analyticsBaseInfo'; | ||
import { Services } from '../services/extensionHostServices'; | ||
import * as utils from '../common/utilities'; | ||
import * as vscode from 'vscode'; | ||
import * as uuid from "uuid"; | ||
|
||
export class AnalyticsService { | ||
private static HAS_ANALYTICS_PROMPT_SHOWN_KEY = "nativescript.hasAnalyticsPromptShown"; | ||
private static CLIENT_ID_KEY = "nativescript.analyticsClientId"; | ||
private static ANALYTICS_PROMPT_MESSAGE = `Help us improve the NativeScript extension by allowing Progress to collect anonymous usage data. | ||
For more information about the gathered information and how it is used, read our [privacy statement](https://www.telerik.com/about/privacy-policy). | ||
You can [disable the analytics and data collection](https://github.com/NativeScript/nativescript-vscode-extension/blob/master/README.md#how-to-disable-the-analytics) at any given time. | ||
Do you want to enable analytics?`; | ||
private static ANALYTICS_PROMPT_ACCEPT_ACTION = "Yes"; | ||
private static ANALYTICS_PROMPT_DENY_ACTION = "No"; | ||
|
||
private _globalState: vscode.Memento; | ||
private _baseInfo: AnalyticsBaseInfo; | ||
private _gua: GUAService; | ||
private _ta: TelerikAnalyticsService; | ||
private _analyticsEnabled: boolean; | ||
|
||
public static generateMachineId(): string { | ||
let machineId = ''; | ||
try { | ||
let netInterfaces = os.networkInterfaces(); | ||
Object.keys(netInterfaces).forEach(interfName => { | ||
netInterfaces[interfName].forEach(interf => { | ||
if (!interf.internal) { | ||
machineId += `${interf.mac}-`; | ||
} | ||
}); | ||
}); | ||
} catch(e) {} | ||
return machineId; | ||
} | ||
constructor(globalState: vscode.Memento) { | ||
this._globalState = globalState; | ||
|
||
constructor() { | ||
this._analyticsEnabled = Services.workspaceConfigService().isAnalyticsEnabled; | ||
let operatingSystem = OperatingSystem.Other; | ||
switch(process.platform) { | ||
case 'win32': { operatingSystem = OperatingSystem.Windows; break; } | ||
case 'darwin': { operatingSystem = OperatingSystem.OSX; break; } | ||
case 'linux': | ||
case 'freebsd': { operatingSystem = OperatingSystem.Linux; break; } | ||
}; | ||
vscode.workspace.onDidChangeConfiguration(() => this.updateAnalyticsEnabled()); | ||
|
||
this._baseInfo = { | ||
cliVersion: Services.cli().version.toString(), | ||
extensionVersion: utils.getInstalledExtensionVersion().toString(), | ||
operatingSystem: operatingSystem, | ||
userId: AnalyticsService.generateMachineId() | ||
operatingSystem: AnalyticsService.getOperatingSystem(), | ||
clientId: this.getOrGenerateClientId() | ||
}; | ||
|
||
if(this._analyticsEnabled) { | ||
this._gua = new GUAService('UA-111455-29', this._baseInfo); | ||
this._ta = new TelerikAnalyticsService('b8b2e51f188f43e9b0dfb899f7b71cc6', this._baseInfo); | ||
} | ||
} | ||
|
||
public launchDebugger(request: string, platform: string): Promise<any> { | ||
if(this._analyticsEnabled) { | ||
try { | ||
return Promise.all([ | ||
this._gua.launchDebugger(request, platform), | ||
this._ta.launchDebugger(request, platform) | ||
]); | ||
return this._gua.launchDebugger(request, platform); | ||
} catch(e) {} | ||
} | ||
|
||
return Promise.resolve(); | ||
} | ||
|
||
public runRunCommand(platform: string): Promise<any> { | ||
if(this._analyticsEnabled) { | ||
try { | ||
return Promise.all([ | ||
this._gua.runRunCommand(platform), | ||
this._ta.runRunCommand(platform) | ||
]); | ||
return this._gua.runRunCommand(platform); | ||
} catch(e) { } | ||
} | ||
|
||
return Promise.resolve(); | ||
} | ||
|
||
private static getOperatingSystem() : OperatingSystem { | ||
switch(process.platform) { | ||
case 'win32': | ||
return OperatingSystem.Windows; | ||
case 'darwin': | ||
return OperatingSystem.OSX; | ||
case 'linux': | ||
case 'freebsd': | ||
return OperatingSystem.Linux; | ||
default: | ||
return OperatingSystem.Other; | ||
}; | ||
} | ||
|
||
public initialize() : void { | ||
const hasAnalyticsPromptShown = this._globalState.get<boolean>(AnalyticsService.HAS_ANALYTICS_PROMPT_SHOWN_KEY); | ||
if(!hasAnalyticsPromptShown) { | ||
vscode.window.showInformationMessage(AnalyticsService.ANALYTICS_PROMPT_MESSAGE, | ||
AnalyticsService.ANALYTICS_PROMPT_ACCEPT_ACTION, | ||
AnalyticsService.ANALYTICS_PROMPT_DENY_ACTION | ||
) | ||
.then(result => this.onAnalyticsMessageConfirmation(result)); | ||
|
||
return; | ||
} | ||
|
||
this.updateAnalyticsEnabled(); | ||
} | ||
|
||
private getOrGenerateClientId(): string { | ||
let clientId = this._globalState.get<string>(AnalyticsService.CLIENT_ID_KEY); | ||
|
||
if(!clientId) { | ||
clientId = uuid.v4(); | ||
this._globalState.update(AnalyticsService.CLIENT_ID_KEY, clientId); | ||
} | ||
|
||
return clientId; | ||
} | ||
|
||
private onAnalyticsMessageConfirmation(result: string) : void { | ||
const shouldEnableAnalytics = result === AnalyticsService.ANALYTICS_PROMPT_ACCEPT_ACTION ? true : false; | ||
|
||
this._globalState.update(AnalyticsService.HAS_ANALYTICS_PROMPT_SHOWN_KEY, true); | ||
|
||
Services.workspaceConfigService().isAnalyticsEnabled = shouldEnableAnalytics; | ||
this.updateAnalyticsEnabled(); | ||
} | ||
|
||
private updateAnalyticsEnabled() { | ||
this._analyticsEnabled = Services.workspaceConfigService().isAnalyticsEnabled; | ||
|
||
if(this._analyticsEnabled && !this._gua) { | ||
this._gua = new GUAService('UA-111455-29', this._baseInfo); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend using a list for the steps:
The anonymous usage data collected by Progress from the NativeScript extension for Visual Studio Code is used strictly to improve the product and its services, and enhance the overall user experience.
If you have previously enabled the analytics option, you can disable it by following the steps outlined below: