Skip to content

Commit 74a2c86

Browse files
authored
Update instructions for builds (#262638)
* Add more validation instructions * Fix validation instructions numbering * Refined validation instructions
1 parent 8247902 commit 74a2c86

File tree

3 files changed

+133
-25
lines changed

3 files changed

+133
-25
lines changed

.github/copilot-instructions.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,25 @@ Each extension follows the standard VS Code extension structure with `package.js
4646
3. **Follow imports**: Check what files import the problematic module
4747
4. **Check test files**: Often reveal usage patterns and expected behavior
4848

49+
## Validating TypeScript changes
50+
51+
You MUST check compilation output before running ANY script or declaring work complete!
52+
53+
1. **ALWAYS** check the `VS Code - Build` watch task output for compilation errors
54+
2. **NEVER** run tests if there are compilation errors
55+
3. **NEVER** use `npm run compile` to compile TypeScript files, always check task output
56+
4. **FIX** all compilation errors before moving forward
57+
58+
### TypeScript compilation steps
59+
- Monitor the `VS Code - Build` task outputs for real-time compilation errors as you make changes
60+
- This task runs `Core - Build` and `Ext - Build` to incrementally compile VS Code TypeScript sources and built-in extensions
61+
- Start the task if it's not already running in the background
62+
63+
### TypeScript validation steps
64+
- Use run test tool or `scripts/test.sh` (`scripts\test.bat` on Windows) for unit tests (add `--grep <pattern>` to filter tests)
65+
- Use `scripts/test-integration.sh` (or `scripts\test-integration.bat` on Windows) for integration tests
66+
- Use `npm run valid-layers-check` to check for layering issues
67+
4968
## Coding Guidelines
5069

5170
### Indentation
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
applyTo: '**/*.ts'
3+
description: Telemetry Implementation Guide
4+
---
5+
6+
Patterns for GDPR-compliant telemetry in VS Code with proper type safety and privacy protection.
7+
8+
## Implementation Pattern
9+
10+
### 1. Define Types
11+
```typescript
12+
type MyFeatureEvent = {
13+
action: string;
14+
duration: number;
15+
success: boolean;
16+
errorCode?: string;
17+
};
18+
19+
type MyFeatureClassification = {
20+
action: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The action performed.' };
21+
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'Time in milliseconds.' };
22+
success: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; isMeasurement: true; comment: 'Whether action succeeded.' };
23+
errorCode: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'Error code if action failed.' };
24+
owner: 'yourGitHubUsername';
25+
comment: 'Tracks MyFeature usage and performance.';
26+
};
27+
```
28+
29+
### 2.1. Send Event
30+
```typescript
31+
this.telemetryService.publicLog2<MyFeatureEvent, MyFeatureClassification>('myFeatureAction', {
32+
action: 'buttonClick',
33+
duration: 150,
34+
success: true
35+
});
36+
```
37+
38+
### 2.2. Error Events
39+
For error-specific telemetry with stack traces or error messages:
40+
```typescript
41+
type MyErrorEvent = {
42+
operation: string;
43+
errorMessage: string;
44+
duration?: number;
45+
};
46+
47+
type MyErrorClassification = {
48+
operation: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; comment: 'The operation that failed.' };
49+
errorMessage: { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth'; comment: 'The error message.' };
50+
duration: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'Time until failure.' };
51+
owner: 'yourGitHubUsername';
52+
comment: 'Tracks MyFeature errors for reliability.';
53+
};
54+
55+
this.telemetryService.publicLogError2<MyErrorEvent, MyErrorClassification>('myFeatureError', {
56+
operation: 'fileRead',
57+
errorMessage: error.message,
58+
duration: 1200
59+
});
60+
```
61+
62+
### 3. Service Injection
63+
```typescript
64+
constructor(
65+
@ITelemetryService private readonly telemetryService: ITelemetryService,
66+
) { super(); }
67+
```
68+
69+
## GDPR Classifications & Purposes
70+
71+
**Classifications (choose the most restrictive):**
72+
- `SystemMetaData` - **Most common.** Non-personal system info, user preferences, feature usage, identifiers (extension IDs, language types, counts, durations, success flags)
73+
- `CallstackOrException` - Error messages, stack traces, exception details. **Only for actual error information.**
74+
- `PublicNonPersonalData` - Data already publicly available (rare)
75+
76+
**Purposes (combine with different classifications):**
77+
- `FeatureInsight` - **Default.** Understanding how features are used, user behavior patterns, feature adoption
78+
- `PerformanceAndHealth` - **For errors & performance.** Metrics, error rates, performance measurements, diagnostics
79+
80+
**Required Properties:**
81+
- `comment` - Clear explanation of what the field contains and why it's collected
82+
- `owner` - GitHub username (infer from branch or ask)
83+
- `isMeasurement: true` - **Required** for all numeric values flags used in calculations
84+
85+
## Error Events
86+
87+
Use `publicLogError2` for errors with `CallstackOrException` classification:
88+
89+
```typescript
90+
this.telemetryService.publicLogError2<ErrorEvent, ErrorClassification>('myFeatureError', {
91+
errorMessage: error.message,
92+
errorCode: 'MYFEATURE_001',
93+
context: 'initialization'
94+
});
95+
```
96+
97+
## Naming & Privacy Rules
98+
99+
**Naming Conventions:**
100+
- Event names: `camelCase` with context (`extensionActivationError`, `chatMessageSent`)
101+
- Property names: specific and descriptive (`agentId` not `id`, `durationMs` not `duration`)
102+
- Common patterns: `success/hasError/isEnabled`, `sessionId/extensionId`, `type/kind/source`
103+
104+
**Critical Don'ts:**
105+
- ❌ No PII (usernames, emails, file paths, content)
106+
- ❌ Missing `owner` field in classification (infer from branch name or ask user)
107+
- ❌ Vague comments ("user data" → "selected language identifier")
108+
- ❌ Wrong classification
109+
- ❌ Missing `isMeasurement` on numeric metrics
110+
111+
**Privacy Requirements:**
112+
- Minimize data collection to essential insights only
113+
- Use hashes/categories instead of raw values when possible
114+
- Document clear purpose for each data point

.github/instructions/typescript.instructions.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)