Skip to content

Commit 7cb9f88

Browse files
authored
Switch to a static import. Add telemetry. (#11686)
* Switch to a static import. Add telemetry.
1 parent 203823a commit 7cb9f88

File tree

4 files changed

+142
-33
lines changed

4 files changed

+142
-33
lines changed

Extension/ThirdPartyNotices.txt

Lines changed: 126 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,29 @@ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
332332
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
333333

334334

335+
---------------------------------------------------------
336+
337+
---------------------------------------------------------
338+
339+
webidl-conversions 3.0.1 - BSD-2-Clause
340+
https://github.com/jsdom/webidl-conversions#readme
341+
342+
Copyright (c) 2014, Domenic Denicola
343+
344+
# The BSD 2-Clause License
345+
346+
Copyright (c) 2014, Domenic Denicola
347+
All rights reserved.
348+
349+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
350+
351+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
352+
353+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
354+
355+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
356+
357+
335358
---------------------------------------------------------
336359

337360
---------------------------------------------------------
@@ -1173,34 +1196,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
11731196
THE SOFTWARE.
11741197

11751198

1176-
---------------------------------------------------------
1177-
1178-
---------------------------------------------------------
1179-
1180-
axios 1.6.1 - MIT
1181-
https://axios-http.com/
1182-
1183-
Copyright (c) 2014-present Matt Zabriskie & Collaborators
1184-
1185-
Permission is hereby granted, free of charge, to any person obtaining a copy
1186-
of this software and associated documentation files (the "Software"), to deal
1187-
in the Software without restriction, including without limitation the rights
1188-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1189-
copies of the Software, and to permit persons to whom the Software is
1190-
furnished to do so, subject to the following conditions:
1191-
1192-
The above copyright notice and this permission notice shall be included in
1193-
all copies or substantial portions of the Software.
1194-
1195-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1196-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1197-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1198-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1199-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1200-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1201-
THE SOFTWARE.
1202-
1203-
12041199
---------------------------------------------------------
12051200

12061201
---------------------------------------------------------
@@ -1233,6 +1228,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
12331228
SOFTWARE.
12341229

12351230

1231+
---------------------------------------------------------
1232+
1233+
---------------------------------------------------------
1234+
1235+
axios 1.6.1 - MIT
1236+
https://axios-http.com/
1237+
1238+
Copyright (c) 2023 Matt Zabriskie and contributors
1239+
Copyright (c) 2014-present Matt Zabriskie & Collaborators
1240+
1241+
# Copyright (c) 2014-present Matt Zabriskie & Collaborators
1242+
1243+
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:
1244+
1245+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1246+
1247+
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.
1248+
1249+
12361250
---------------------------------------------------------
12371251

12381252
---------------------------------------------------------
@@ -2235,6 +2249,39 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22352249
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22362250

22372251

2252+
---------------------------------------------------------
2253+
2254+
---------------------------------------------------------
2255+
2256+
node-fetch 2.7.0 - MIT
2257+
https://github.com/bitinn/node-fetch
2258+
2259+
Copyright (c) 2016 David Frank
2260+
2261+
The MIT License (MIT)
2262+
2263+
Copyright (c) 2016 David Frank
2264+
2265+
Permission is hereby granted, free of charge, to any person obtaining a copy
2266+
of this software and associated documentation files (the "Software"), to deal
2267+
in the Software without restriction, including without limitation the rights
2268+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2269+
copies of the Software, and to permit persons to whom the Software is
2270+
furnished to do so, subject to the following conditions:
2271+
2272+
The above copyright notice and this permission notice shall be included in all
2273+
copies or substantial portions of the Software.
2274+
2275+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2276+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2277+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2278+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2279+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2280+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2281+
SOFTWARE.
2282+
2283+
2284+
22382285
---------------------------------------------------------
22392286

22402287
---------------------------------------------------------
@@ -2716,6 +2763,24 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27162763
THE SOFTWARE.
27172764

27182765

2766+
---------------------------------------------------------
2767+
2768+
---------------------------------------------------------
2769+
2770+
tr46 0.0.3 - MIT
2771+
https://github.com/Sebmaster/tr46.js#readme
2772+
2773+
2774+
MIT License
2775+
2776+
Copyright (c) <year> <copyright holders>
2777+
2778+
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:
2779+
2780+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2781+
2782+
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.
2783+
27192784
---------------------------------------------------------
27202785

27212786
---------------------------------------------------------
@@ -2856,6 +2921,39 @@ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CON
28562921
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28572922

28582923

2924+
---------------------------------------------------------
2925+
2926+
---------------------------------------------------------
2927+
2928+
whatwg-url 5.0.0 - MIT
2929+
https://github.com/jsdom/whatwg-url#readme
2930+
2931+
(c) extraPathPercentEncodeSet.has
2932+
Copyright (c) 2015-2016 Sebastian Mayr
2933+
2934+
The MIT License (MIT)
2935+
2936+
Copyright (c) 2015–2016 Sebastian Mayr
2937+
2938+
Permission is hereby granted, free of charge, to any person obtaining a copy
2939+
of this software and associated documentation files (the "Software"), to deal
2940+
in the Software without restriction, including without limitation the rights
2941+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2942+
copies of the Software, and to permit persons to whom the Software is
2943+
furnished to do so, subject to the following conditions:
2944+
2945+
The above copyright notice and this permission notice shall be included in
2946+
all copies or substantial portions of the Software.
2947+
2948+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2949+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2950+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2951+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2952+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2953+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2954+
THE SOFTWARE.
2955+
2956+
28592957
---------------------------------------------------------
28602958

28612959
---------------------------------------------------------

Extension/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6360,6 +6360,7 @@
63606360
"glob": "^7.1.6",
63616361
"minimatch": "^3.0.5",
63626362
"mkdirp": "^0.5.5",
6363+
"node-fetch": "^2.6.9",
63636364
"node-loader": "^2.0.0",
63646365
"node-stream-zip": "^1.15.0",
63656366
"plist": "^3.0.5",

Extension/src/LanguageServer/extension.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
'use strict';
66

77
import * as fs from 'fs';
8+
// Node.js 18 fetch isn't available until VS 1.82.
9+
import fetch from 'node-fetch';
810
import * as StreamZip from 'node-stream-zip';
911
import * as os from 'os';
1012
import * as path from 'path';
@@ -1181,18 +1183,19 @@ export async function preReleaseCheck(): Promise<void> {
11811183
// First we need to make sure the user isn't already on a pre-release version and hasn't dismissed this prompt before.
11821184
if (!isOnPreRelease.Value && !displayedPreReleasePrompt.Value && util.getCppToolsTargetPopulation() === TargetPopulation.Public) {
11831185
// Get the info on the latest version from the marketplace to check if there is a pre-release version available.
1184-
const nodeFetch = await import('node-fetch'); // dynamic import is required
1185-
const fetch = nodeFetch.default; // Node.js 18 fetch isn't available until VS 1.82.
11861186
const response = await fetch('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', {
11871187
method: 'POST',
11881188
headers: {
1189-
Accept : 'application/json; api-version=3.0-preview',
1190-
'Content-Type' : 'application/json'
1189+
Accept: 'application/json; api-version=3.0-preview',
1190+
'Content-Type': 'application/json',
1191+
'User-Agent': 'vscode-cpptools'
11911192
},
11921193
body: '{"filters": [{"criteria": [{"filterType": 7, "value": "ms-vscode.cpptools"}]}], "flags": 529}'
11931194
}).catch(logAndReturn.undefined);
11941195

1195-
const data = await response?.json().catch(logAndReturn.undefined);
1196+
telemetry.logLanguageServerEvent("marketplaceFetch", undefined, { status: response?.status ?? 0 });
1197+
1198+
const data: any = await response?.json().catch(logAndReturn.undefined);
11961199

11971200
const preReleaseAvailable = data?.results[0].extensions[0].versions[0].properties.some((e: object) => Object.values(e).includes("Microsoft.VisualStudio.Code.PreRelease"));
11981201

Extension/yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,6 +3656,13 @@ node-fetch@^2.6.7:
36563656
dependencies:
36573657
whatwg-url "^5.0.0"
36583658

3659+
node-fetch@^2.6.9:
3660+
version "2.7.0"
3661+
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
3662+
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
3663+
dependencies:
3664+
whatwg-url "^5.0.0"
3665+
36593666
node-loader@^2.0.0:
36603667
version "2.0.0"
36613668
resolved "https://registry.yarnpkg.com/node-loader/-/node-loader-2.0.0.tgz#9109a6d828703fd3e0aa03c1baec12a798071562"

0 commit comments

Comments
 (0)