-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Dont sent telemetry in forks #21377
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
Dont sent telemetry in forks #21377
Changes from all commits
c068f18
0e9d972
7875c80
eea8190
e828ccc
e560611
73d08ac
1b0e2bf
8d61c1c
011b6ca
47f5e13
7bcb216
8ba88d4
6f5bf8b
b785161
81e6c98
eafb10f
56e1d05
57d5f5b
e48c002
8735489
29dbb30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import json | ||
| import pathlib | ||
| import sys | ||
|
|
||
| EXT_ROOT = pathlib.Path(__file__).parent.parent | ||
| PACKAGE_JSON_PATH = EXT_ROOT / "package.json" | ||
|
|
||
| def main(package_json: pathlib.Path) -> None: | ||
| package = json.loads(package_json.read_text(encoding="utf-8")) | ||
| package['enableTelemetry'] = True | ||
|
|
||
| # Overwrite package.json with new data add a new-line at the end of the file. | ||
| package_json.write_text( | ||
| json.dumps(package, indent=4, ensure_ascii=False) + "\n", encoding="utf-8" | ||
| ) | ||
|
|
||
| if __name__ == "__main__": | ||
| main(PACKAGE_JSON_PATH, sys.argv[1:]) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,10 @@ | |
|
|
||
| import TelemetryReporter from '@vscode/extension-telemetry'; | ||
|
|
||
| import * as path from 'path'; | ||
| import * as fs from 'fs-extra'; | ||
| import { DiagnosticCodes } from '../application/diagnostics/constants'; | ||
| import { IWorkspaceService } from '../common/application/types'; | ||
| import { AppinsightsKey, isTestExecution, isUnitTestExecution } from '../common/constants'; | ||
| import { AppinsightsKey, EXTENSION_ROOT_DIR, isTestExecution, isUnitTestExecution } from '../common/constants'; | ||
| import type { TerminalShellType } from '../common/terminal/types'; | ||
| import { StopWatch } from '../common/utils/stopWatch'; | ||
| import { isPromise } from '../common/utils/async'; | ||
|
|
@@ -41,12 +42,13 @@ function isTelemetrySupported(): boolean { | |
| } | ||
|
|
||
| /** | ||
| * Checks if the telemetry is disabled in user settings | ||
| * Checks if the telemetry is disabled | ||
| * @returns {boolean} | ||
| */ | ||
| export function isTelemetryDisabled(workspaceService: IWorkspaceService): boolean { | ||
| const settings = workspaceService.getConfiguration('telemetry').inspect<boolean>('enableTelemetry')!; | ||
| return settings.globalValue === false; | ||
| export function isTelemetryDisabled(): boolean { | ||
| const packageJsonPath = path.join(EXTENSION_ROOT_DIR, 'package.json'); | ||
| const packageJson = fs.readJSONSync(packageJsonPath); | ||
| return !packageJson.enableTelemetry; | ||
|
Comment on lines
+48
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File I/O is expensive for this check, this is being done every time a telemetry is sent. See #22991. Can we do this using setting instead of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should have access to package json as a part of the extension API. |
||
| } | ||
|
|
||
| const sharedProperties: Record<string, unknown> = {}; | ||
|
|
@@ -101,7 +103,7 @@ export function sendTelemetryEvent<P extends IEventNamePropertyMapping, E extend | |
| properties?: P[E], | ||
| ex?: Error, | ||
| ): void { | ||
| if (isTestExecution() || !isTelemetrySupported()) { | ||
| if (isTestExecution() || !isTelemetrySupported() || isTelemetryDisabled()) { | ||
| return; | ||
| } | ||
| const reporter = getTelemetryReporter(); | ||
|
|
||
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.
Are we removing this setting?
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 checked the code and we don't use that function anywhere.