Skip to content

Commit a33b8aa

Browse files
committed
Enable prettier formatting
- Uses default prettier settings
1 parent 583097d commit a33b8aa

50 files changed

Lines changed: 1508 additions & 1324 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,28 @@ jobs:
2121
# Steps represent a sequence of tasks that will be executed as part of the job
2222
steps:
2323
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v3
2525

26-
# Set up Node
27-
- name: Use Node 14
28-
uses: actions/setup-node@v1
29-
with:
30-
node-version: 14
31-
registry-url: 'https://registry.npmjs.org'
26+
# Set up Node
27+
- name: Use Node 14
28+
uses: actions/setup-node@v1
29+
with:
30+
node-version: 14
31+
registry-url: "https://registry.npmjs.org"
3232

33-
# Run install dependencies
34-
- name: Install dependencies
35-
run: npm i
33+
# Run install dependencies
34+
- name: Install dependencies
35+
run: npm i
3636

37-
# Build
38-
- name: Build
39-
run: npm run prepublish
37+
- name: Lint
38+
run: npm run lint
4039

41-
- name: Test
42-
run: npm test
40+
# Build
41+
- name: Build
42+
run: npm run prepublish
4343

44-
- name: Test packaging
45-
run: npm run package
44+
- name: Test
45+
run: npm test
46+
47+
- name: Test packaging
48+
run: npm run package

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
ci:
3+
autoupdate_commit_msg: "chore: pre-commit autoupdate"
4+
autoupdate_schedule: monthly
5+
autofix_commit_msg: |
6+
chore: auto fixes from pre-commit.com hooks
7+
8+
for more information, see https://pre-commit.ci
9+
minimum_pre_commit_version: 2.9.0 # types_or
10+
repos:
11+
- repo: https://github.com/pre-commit/mirrors-prettier
12+
# keep it before markdownlint and eslint
13+
rev: "v3.0.0-alpha.4"
14+
hooks:
15+
- id: prettier
16+
types_or: ["markdown", "json", "ts"]

.vscode/extensions.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["esbenp.prettier-vscode"]
3+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"[typescript]": {
4+
"editor.defaultFormatter": "esbenp.prettier-vscode"
5+
},
6+
"files.exclude": {
7+
".nyc_output": true,
8+
"coverage": true,
9+
"lib": true
10+
}
11+
}

README.md

Lines changed: 53 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ It's also possible to opt-in later, by setting the `redhat.telemetry.enabled` us
1414

1515
From File > Preferences > Settings (On macOS: Code > Preferences > Settings), search for telemetry, and check the `Redhat > Telemetry : Enabled` setting. This will enable sending all telemetry events from Red Hat extensions going forward.
1616

17-
1817
## How to disable telemetry reporting?
19-
If you want to stop sending usage data to Red Hat, you can set the `redhat.telemetry.enabled` user setting to `false`.
18+
19+
If you want to stop sending usage data to Red Hat, you can set the `redhat.telemetry.enabled` user setting to `false`.
2020

2121
From File > Preferences > Settings (On macOS: Code > Preferences > Settings), search for telemetry, and uncheck the `Redhat > Telemetry : Enabled` setting. This will silence all telemetry events from Red Hat extensions going forward.
2222

2323
Additionally, and starting from version 0.5.0, this module abides by Visual Studio Code's telemetry level: if `telemetry.telemetryLevel` is set to `off`, then no telemetry events will be sent to Red Hat, even if `redhat.telemetry.enabled` is set to `true`. If `telemetry.telemetryLevel` is set to `error` or `crash`, only events containing an `error` or `errors` property will be sent to Red Hat.
2424

2525
# Remote configuration
26+
2627
Starting from version 0.5.0, Red Hat Telemetry can be remotely configured. Once every 12h (or whatever is remotely configured), [telemetry-config.json](src/config/telemetry-config.json) will be downloaded to, depending on your platform:
2728

2829
- **Windows** `%APPDATA%\Code\User\globalStorage\vscode-redhat-telemetry\cache\telemetry-config.json`
@@ -31,35 +32,35 @@ Starting from version 0.5.0, Red Hat Telemetry can be remotely configured. Once
3132

3233
This allows Red Hat extensions to limit the events to be sent, by including or excluding certain events, by name or containing properties, or by limiting the ratio of users sending data.
3334
eg.:
35+
3436
- 50% of `redhat.vscode-hypothetical` users only, to report error events, excluding stackoverflows:
3537

3638
```json
3739
{
38-
"*": {
39-
"enabled":"all", // supports "all", "error", "crash", "off"
40-
"refresh": "12h",
41-
"includes": [
42-
{
43-
"name" : "*"
44-
}
45-
]
46-
},
47-
"redhat.vscode-hypothetical": {
48-
"enabled": "error",
49-
"ratio": "0.5",
50-
"excludes": [
51-
{
52-
"property": "error",
53-
"value": "*stackoverflow*"
54-
}
55-
]
56-
}
40+
"*": {
41+
"enabled": "all", // supports "all", "error", "crash", "off"
42+
"refresh": "12h",
43+
"includes": [
44+
{
45+
"name": "*"
46+
}
47+
]
48+
},
49+
"redhat.vscode-hypothetical": {
50+
"enabled": "error",
51+
"ratio": "0.5",
52+
"excludes": [
53+
{
54+
"property": "error",
55+
"value": "*stackoverflow*"
56+
}
57+
]
58+
}
5759
}
5860
```
5961

6062
Extension configuration inherits and overrides the `*` configuration.
6163

62-
6364
# How to use this library
6465

6566
## Add the `@redhat-developer/vscode-redhat-telemetry` dependency
@@ -69,7 +70,9 @@ In order to install [`@redhat-developer/vscode-redhat-telemetry`](https://github
6970
```
7071
npm i @redhat-developer/vscode-redhat-telemetry
7172
```
73+
7274
## Contribute the `redhat.telemetry.enabled` preference
75+
7376
Unless your extension already depends on a telemetry-enabled Red Hat extension, it needs to declare the `redhat.telemetry.enabled` preference in its package.json, like:
7477

7578
```
@@ -89,7 +92,9 @@ Unless your extension already depends on a telemetry-enabled Red Hat extension,
8992
}
9093
}
9194
```
95+
9296
## [Optional] Add a custom segment key in package.json file
97+
9398
By default, extensions will send their data to https://app.segment.com/redhat-devtools/sources/vscode/. In development mode, the data is sent to https://app.segment.com/redhat-devtools/sources/vs_code_tests/.
9499

95100
- You can specify custom segment keys in your package.json, to connect and push usage data to https://segment.com/
@@ -102,13 +107,14 @@ By default, extensions will send their data to https://app.segment.com/redhat-de
102107
## Add the below code to your `extension.ts`
103108

104109
Get a reference to the RedHatService instance from your VS Code extension's `activate` method in `extension.ts`:
110+
105111
```typescript
106112
import { getRedHatService, TelemetryService } from "@redhat-developer/vscode-redhat-telemetry";
107113

108114
let telemetryService: TelemetryService = null;
109115

110116
export async function activate(context: ExtensionContext) {
111-
const redhatService = await getRedHatService(context);
117+
const redhatService = await getRedHatService(context);
112118
telemetryService = await redhatService.getTelemetryService();
113119
telemetryService.sendStartupEvent();
114120
...
@@ -126,36 +132,40 @@ if (telemetryService) {
126132
name: "Test Event",
127133
type: "track", // optional type (track is the default)
128134
properties: { // optional custom properties
129-
foo: "bar",
135+
foo: "bar",
130136
}
131137
};
132138
telemetryService.send(event);
133139
}
134140
```
135141

136142
To access the anonymous Red Hat UUID for the current user:
143+
137144
```typescript
138-
const redhatUuid = await (await redhatService.getIdManager()).getRedHatUUID();
145+
const redhatUuid = await(await redhatService.getIdManager()).getRedHatUUID();
139146
```
140147

141148
Once your extension is deactivated, a shutdown event, including the session duration, will automatically be sent on its behalf. However, shutdown event delivery is not guaranteed, in case VS Code is faster to exit than to send those last events.
142149

143150
All event properties are automatically sanitized to anonymize all paths (best effort) and references to the username.
144151

145-
146152
## Publicly document your data collection
147153

148154
Once telemetry is in place, you need to document the extent of the telemetry collection performed by your extension.
149-
* add a USAGE_DATA.md page to your extension's repository, listing the type of data being collected by your extension.
150-
* add a `Data and Telemetry` paragraph at the end of your extension's README file:
151-
> `The ***** extension collects anonymous [usage data](USAGE_DATA.md) and sends it to Red Hat servers to help improve our products and services. Read our [privacy statement](https://developers.redhat.com/article/tool-data-collection) to learn more. This extension respects the `redhat.telemetry.enabled` setting which you can learn more about at https://github.com/redhat-developer/vscode-redhat-telemetry#how-to-disable-telemetry-reporting`
152155

153-
* add a reference to your telemetry documentation page to this repository's own [USAGE_DATA.md](https://github.com/redhat-developer/vscode-redhat-telemetry/blob/HEAD/USAGE_DATA.md#other-extensions).
156+
- add a USAGE_DATA.md page to your extension's repository, listing the type of data being collected by your extension.
157+
- add a `Data and Telemetry` paragraph at the end of your extension's README file:
158+
159+
> `The ***** extension collects anonymous [usage data](USAGE_DATA.md) and sends it to Red Hat servers to help improve our products and services. Read our [privacy statement](https://developers.redhat.com/article/tool-data-collection) to learn more. This extension respects the `redhat.telemetry.enabled` setting which you can learn more about at https://github.com/redhat-developer/vscode-redhat-telemetry#how-to-disable-telemetry-reporting`
160+
161+
- add a reference to your telemetry documentation page to this repository's own [USAGE_DATA.md](https://github.com/redhat-developer/vscode-redhat-telemetry/blob/HEAD/USAGE_DATA.md#other-extensions).
154162

155163
### Checking telemetry during development
164+
156165
In your `.vscode/launch.json`:
166+
157167
- set the `VSCODE_REDHAT_TELEMETRY_DEBUG` environment variable to `true`, to log telemetry events in the console
158-
- set the `REDHAT_TELEMETRY_REMOTE_CONFIG_URL` environment variable to the URL of a remote configuration file, if you need to test remote configuration
168+
- set the `REDHAT_TELEMETRY_REMOTE_CONFIG_URL` environment variable to the URL of a remote configuration file, if you need to test remote configuration
159169

160170
```json
161171
{
@@ -176,21 +186,22 @@ In your `.vscode/launch.json`:
176186
},
177187
```
178188

179-
180189
# How to use from a VS Code webview
181-
From a VS Code webview, since you can not rely on accessing the filesystem, you need to instanciate the `TelemetryService` from a `TelemetryServiceBuilder`, providing browser-specific implementations of services for collecting data.
190+
191+
From a VS Code webview, since you can not rely on accessing the filesystem, you need to instanciate the `TelemetryService` from a `TelemetryServiceBuilder`, providing browser-specific implementations of services for collecting data.
182192

183193
To get a reference to the TelemetryService instance for your VS Code extension:
194+
184195
```typescript
185196
import { TelemetryServiceBuilder, TelemetryService, TelemetrySettings, Environment, IdManager } from "@redhat-developer/vscode-redhat-telemetry";
186197
...
187-
const packageJson: any = ...; // an object defining `{publisher:string, name:string, version:string, segmentWriteKey:string}`
198+
const packageJson: any = ...; // an object defining `{publisher:string, name:string, version:string, segmentWriteKey:string}`
188199
const idManager: IdManager = ...; // a service returning Red Hat anonymous UUID
189200
const environment: Environment = ...; // an object containing environment specific data (OS, locale...)
190201
const settings:TelemetrySettings = ...; // an object checking whether telemetry collection is enabled
191202
const telemetryService: TelemetryService = new TelemetryServiceBuilder(packageJson)
192-
.setIdManager(idManager)
193-
.setEnvironment(environment)
203+
.setIdManager(idManager)
204+
.setEnvironment(environment)
194205
.setSettings(settings)
195206
...
196207
let event = {
@@ -204,14 +215,19 @@ const REDHAT_UUID = idManager.getRedHatUUID();
204215
```
205216

206217
# Build
207-
In a terminal, execute:
218+
219+
In a terminal, execute:
220+
208221
```
209222
npm i
210223
```
224+
211225
to install the dependencies, then:
226+
212227
```
213228
npm run prepublish
214229
```
230+
215231
to build the library
216232

217233
# Information on data transmission during development

USAGE_DATA.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
## Usage data being collected by Red Hat Extensions
2+
23
Only anonymous data is being collected by Red Hat extensions using `vscode-redhat-telemetry` facilities. The IP address of telemetry requests is not even stored on Red Hat servers.
34
All telemetry events are automatically sanitized to anonymize all paths (best effort) and references to the username.
45

56
### Common data
7+
68
Telemetry requests may contain:
79

8-
* a random anonymous user id (UUID v4), that is stored locally on `~/.redhat/anonymousId`
9-
* the client name (VS Code, VSCodium, Eclipse Che...) and its version
10-
* the type of client (Desktop vs Web)
11-
* the name and version of the extension sending the event (eg. `fabric8-analytics.fabric8-analytics-vscode-extension`)
12-
* whether the extension runs remotely or not (eg. in WSL)
13-
* the OS name and version (and distribution name, in case of Linux)
14-
* the user locale (eg. en_US)
15-
* the user timezone
16-
* the country id ( as determined by the current timezone)
10+
- a random anonymous user id (UUID v4), that is stored locally on `~/.redhat/anonymousId`
11+
- the client name (VS Code, VSCodium, Eclipse Che...) and its version
12+
- the type of client (Desktop vs Web)
13+
- the name and version of the extension sending the event (eg. `fabric8-analytics.fabric8-analytics-vscode-extension`)
14+
- whether the extension runs remotely or not (eg. in WSL)
15+
- the OS name and version (and distribution name, in case of Linux)
16+
- the user locale (eg. en_US)
17+
- the user timezone
18+
- the country id ( as determined by the current timezone)
1719

1820
Common events are reported:
1921

20-
* when extension is started
21-
* when extension is shutdown
22-
- duration of the session
22+
- when extension is started
23+
- when extension is shutdown
24+
- duration of the session
2325

2426
### Other extensions
27+
2528
Red Hat extensions' specific telemetry collection details can be found there:
2629

27-
* [Dependency Analytics](https://github.com/fabric8-analytics/fabric8-analytics-vscode-extension/blob/master/Telemetry.md)
28-
* [OpenShift Connector](https://github.com/redhat-developer/vscode-openshift-tools/blob/master/USAGE_DATA.md)
29-
* [Project Initializer](https://github.com/redhat-developer/vscode-project-initializer/blob/master/USAGE_DATA.md)
30-
* [Quarkus](https://github.com/redhat-developer/vscode-quarkus/blob/master/USAGE_DATA.md)
31-
* [Red Hat Authentication](https://github.com/redhat-developer/vscode-redhat-account/blob/main/USAGE_DATA.md)
32-
* [Red Hat OpenShift Application Services](https://github.com/redhat-developer/vscode-rhoas/blob/main/USAGE_DATA.md)
33-
* [Remote Server Protocol](https://github.com/redhat-developer/vscode-rsp-ui/blob/master/USAGE_DATA.md)
34-
* [Tekton Pipelines](https://github.com/redhat-developer/vscode-tekton/blob/master/USAGE_DATA.md)
35-
* [Tooling for Apache Camel K](https://github.com/camel-tooling/vscode-camelk/blob/main/USAGE_DATA.md)
36-
* [Language Support for Apache Camel](https://github.com/camel-tooling/camel-lsp-client-vscode/blob/main/USAGE_DATA.md)
37-
* [Debug Adapter for Apache Camel](https://github.com/camel-tooling/camel-dap-client-vscode/blob/main/USAGE_DATA.md)
38-
* [Tools for MicroProfile](https://github.com/redhat-developer/vscode-microprofile/blob/master/USAGE_DATA.md)
39-
* [XML](https://github.com/redhat-developer/vscode-xml/blob/master/USAGE_DATA.md)
40-
* [YAML](https://github.com/redhat-developer/vscode-yaml/blob/main/USAGE_DATA.md)
41-
* [Ansible](https://github.com/ansible/vscode-ansible/blob/main/USAGE_DATA.md)
30+
- [Dependency Analytics](https://github.com/fabric8-analytics/fabric8-analytics-vscode-extension/blob/master/Telemetry.md)
31+
- [OpenShift Connector](https://github.com/redhat-developer/vscode-openshift-tools/blob/master/USAGE_DATA.md)
32+
- [Project Initializer](https://github.com/redhat-developer/vscode-project-initializer/blob/master/USAGE_DATA.md)
33+
- [Quarkus](https://github.com/redhat-developer/vscode-quarkus/blob/master/USAGE_DATA.md)
34+
- [Red Hat Authentication](https://github.com/redhat-developer/vscode-redhat-account/blob/main/USAGE_DATA.md)
35+
- [Red Hat OpenShift Application Services](https://github.com/redhat-developer/vscode-rhoas/blob/main/USAGE_DATA.md)
36+
- [Remote Server Protocol](https://github.com/redhat-developer/vscode-rsp-ui/blob/master/USAGE_DATA.md)
37+
- [Tekton Pipelines](https://github.com/redhat-developer/vscode-tekton/blob/master/USAGE_DATA.md)
38+
- [Tooling for Apache Camel K](https://github.com/camel-tooling/vscode-camelk/blob/main/USAGE_DATA.md)
39+
- [Language Support for Apache Camel](https://github.com/camel-tooling/camel-lsp-client-vscode/blob/main/USAGE_DATA.md)
40+
- [Debug Adapter for Apache Camel](https://github.com/camel-tooling/camel-dap-client-vscode/blob/main/USAGE_DATA.md)
41+
- [Tools for MicroProfile](https://github.com/redhat-developer/vscode-microprofile/blob/master/USAGE_DATA.md)
42+
- [XML](https://github.com/redhat-developer/vscode-xml/blob/master/USAGE_DATA.md)
43+
- [YAML](https://github.com/redhat-developer/vscode-yaml/blob/main/USAGE_DATA.md)
44+
- [Ansible](https://github.com/ansible/vscode-ansible/blob/main/USAGE_DATA.md)

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"copy-files": "copyfiles -u 1 src/config/* src/tests/config/* lib/",
1010
"compile": "tsc -p .",
1111
"build": "npm run clean && npm run copy-files && npm run compile",
12+
"lint": "python3 -m pre_commit run -a",
13+
"prepare": "python3 -m pip install --user pre-commit",
1214
"prepublish": "npm run build",
1315
"coverage": "nyc -r lcov -e .ts -x \"*.ts\" npm run test",
1416
"test": "mocha -r ts-node/register --ui tdd \"src/tests/**/*.test.ts\"",

0 commit comments

Comments
 (0)