Skip to content
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

[DO NOT MERGE] Initial check-in for supporting telemetry in vscode #6123

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
some refine
  • Loading branch information
RodgeFu committed Feb 27, 2025
commit 77cb489d6213f93b7798e88bd8b6a346fa41fc04
68 changes: 5 additions & 63 deletions packages/typespec-vscode/ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
@@ -8,69 +8,11 @@ original copyright notices and the licenses under which Microsoft received such
components are set forth below. Microsoft reserves all rights not expressly
granted herein, whether by implication, estoppel or otherwise.

1. @nevware21/ts-async version 0.5.4 (https://github.com/nevware21/ts-async)
2. @nevware21/ts-utils version 0.11.6 (https://github.com/nevware21/ts-utils)
3. balanced-match version 1.0.2 (https://github.com/juliangruber/balanced-match)
4. brace-expansion version 2.0.1 (https://github.com/juliangruber/brace-expansion)
5. minimatch version 5.1.6 (https://github.com/isaacs/minimatch)
6. semver version 7.6.3 (https://github.com/npm/node-semver)
7. yaml version 2.7.0 (github:eemeli/yaml)


%% @nevware21/ts-async NOTICES AND INFORMATION BEGIN HERE
=====================================================
MIT License

Copyright (c) 2022 NevWare21 Solutions LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

=====================================================");
END OF @nevware21/ts-async NOTICES AND INFORMATION


%% @nevware21/ts-utils NOTICES AND INFORMATION BEGIN HERE
=====================================================
MIT License

Copyright (c) 2022 NevWare21 Solutions LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

=====================================================");
END OF @nevware21/ts-utils NOTICES AND INFORMATION
1. balanced-match version 1.0.2 (https://github.com/juliangruber/balanced-match)
2. brace-expansion version 2.0.1 (https://github.com/juliangruber/brace-expansion)
3. minimatch version 5.1.6 (https://github.com/isaacs/minimatch)
4. semver version 7.6.3 (https://github.com/npm/node-semver)
5. yaml version 2.7.0 (github:eemeli/yaml)


%% balanced-match NOTICES AND INFORMATION BEGIN HERE
2 changes: 1 addition & 1 deletion packages/typespec-vscode/package.json
Original file line number Diff line number Diff line change
@@ -253,7 +253,7 @@
"@typespec/internal-build-utils": "workspace:~",
"@vitest/coverage-v8": "^3.0.4",
"@vitest/ui": "^3.0.3",
"@vscode/extension-telemetry": "^0.9.8",
"@vscode/extension-telemetry": "^0.6.2",
"@vscode/test-web": "^0.0.65",
"@vscode/vsce": "~3.2.1",
"c8": "^10.1.3",
20 changes: 13 additions & 7 deletions packages/typespec-vscode/src/telemetry/telemetry-client.ts
Original file line number Diff line number Diff line change
@@ -24,32 +24,38 @@ class TelemetryClient {
}

private initClient() {
const cs = this.getConnectionString();
if (!cs) {
const key = this.getTelemetryKey();
if (!key) {
this.logErrorWhenLoggingTelemetry(
"Skip initializing telemetry client because no telemetry key is provided",
);
this._client = undefined;
} else {
this._client = new (TelemetryReporter as any)(cs);
this._client = new (TelemetryReporter as any)(
`${pkgJson.publisher}.${pkgJson.name}`,
pkgJson.version,
key,
true /*first party*/,
);
}
}

private getConnectionString(): string | undefined {
private getTelemetryKey(): string | undefined {
const isValidKey = (key: string | undefined) => key && key !== EmptyGuid;
let key: string | undefined = pkgJson.telemetryKey;
if (!key || key === EmptyGuid) {
if (!isValidKey(key)) {
logger.debug(
"Telemetry key is not provided in package.json, try to use environment variable VSCODE_TELEMETRY_KEY",
);
key = process.env.VSCODE_TELEMETRY_KEY;
}
if (!key || key === EmptyGuid) {
if (!isValidKey(key)) {
logger.debug(
"Telemetry key is not provided in package.json or environment variable VSCODE_TELEMETRY_KEY",
);
return undefined;
}
return `InstrumentationKey=${pkgJson.telemetryKey}`;
return key;
}

public async flush() {
131 changes: 32 additions & 99 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Oops, something went wrong.