@salesforce/mcp-provider-lwc-experts 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.bundle.js +109 -117
- package/knowledge/graphql/generation-guide.md +212 -0
- package/knowledge/graphql/generation-mutation.md +265 -0
- package/knowledge/graphql/generation-query.md +235 -0
- package/knowledge/graphql/generation-schema.md +20 -0
- package/knowledge/graphql/schema/shared.graphqls +1140 -0
- package/knowledge/o11y/activityApi.md +64 -0
- package/knowledge/o11y/bestPractices.md +106 -0
- package/knowledge/o11y/counterMetrics.md +61 -0
- package/knowledge/o11y/errorTracking.md +70 -0
- package/knowledge/o11y/initialization.md +46 -0
- package/knowledge/o11y/lifecycleInstrumentation.md +91 -0
- package/knowledge/o11y/logApi.md +53 -0
- package/knowledge/o11y/schemaUsage.md +48 -0
- package/knowledge/slds/styling-hooks/README.md +408 -0
- package/knowledge/slds/styling-hooks/categories/color.md +963 -0
- package/knowledge/slds/styling-hooks/categories/radius.md +526 -0
- package/knowledge/slds/styling-hooks/categories/shadow.md +489 -0
- package/knowledge/slds/styling-hooks/categories/sizing.md +667 -0
- package/knowledge/slds/styling-hooks/categories/spacing.md +501 -0
- package/knowledge/slds/styling-hooks/categories/typography.md +708 -0
- package/knowledge/slds/styling-hooks/global-semantic/accent-hooks.md +207 -0
- package/knowledge/slds/styling-hooks/global-semantic/feedback-hooks.md +819 -0
- package/knowledge/slds/styling-hooks/global-semantic/surface-hooks.md +215 -0
- package/knowledge/slds/styling-hooks/guidance.md +906 -0
- package/knowledge/slds/styling-hooks/metadata/hooks-index.json +6576 -0
- package/knowledge/utam/generation-guide.md +499 -0
- package/knowledge/utam/generation-workflow.md +243 -0
- package/knowledge/utam/namespaces-mapping.md +26 -0
- package/knowledge/utam/utam-json-schema.md +720 -0
- package/knowledge/utils.ts +27 -0
- package/package.json +4 -3
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-create-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-create-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-delete-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-delete-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-info-by-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-infos-by-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-infos-by-object-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-object-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-preferences.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-get-list-records-by-name.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-update-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-update-list-preferences.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/reference-update-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/lds-wire-adapter-types.json +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-count.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-info-batch.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-records-batch.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-list-records.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-get-related-lists-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-object-info.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-object-infos.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-picklist-values-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-picklist-values.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-record.md +0 -0
- /package/{agents → experts}/lds/resources/lwc/guides/reference/wire-adapters/reference-wire-adapters-records.md +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## o11y Activity API Usage Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper usage of the o11y activity APIs (`startActivity()` and `activity.stop()`) for measuring operation duration. I focus on verifying correct API usage, error handling, and appropriate use cases.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Missing activity tracking for async operations**: Async operations (API calls, data fetching, complex workflows) should use activities
|
|
10
|
+
- **Incorrect activity.start() usage**: `startActivity()` should be called on the instrumentation instance
|
|
11
|
+
- **Missing activity.stop() calls**: Every `startActivity()` must have a corresponding `activity.stop()` call
|
|
12
|
+
- **Activity not stopped in finally block**: Activities should be stopped in a `finally` block to ensure they're always stopped, even on errors
|
|
13
|
+
- **Missing error handling in activities**: When errors occur during activities, use `activity.error()` before stopping
|
|
14
|
+
- **Missing schema in activity.stop()**: When stopping an activity, provide a schema and payload for structured data
|
|
15
|
+
- **Activities not used for duration measurements**: Operations that need duration tracking should use activities (creates percentile metrics)
|
|
16
|
+
|
|
17
|
+
### What I Ignore
|
|
18
|
+
|
|
19
|
+
- Synchronous operations that complete immediately
|
|
20
|
+
- Simple operations that don't need duration tracking
|
|
21
|
+
- Components that already properly use activity APIs
|
|
22
|
+
- Test files and mock implementations
|
|
23
|
+
|
|
24
|
+
### Analysis Framework
|
|
25
|
+
|
|
26
|
+
**Activity API Pattern**
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
const activity = instrumentation.startActivity('operationName');
|
|
30
|
+
try {
|
|
31
|
+
await someAsyncOperation();
|
|
32
|
+
} catch (err) {
|
|
33
|
+
activity.error(err, errorSchema, errorPayload);
|
|
34
|
+
} finally {
|
|
35
|
+
activity.stop(activitySchema, payload);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Use Cases for Activities**
|
|
40
|
+
|
|
41
|
+
- Async operations (API calls, data fetching)
|
|
42
|
+
- Complex workflows with multiple steps
|
|
43
|
+
- Operations that need duration/performance tracking
|
|
44
|
+
- Operations that should generate percentile metrics
|
|
45
|
+
|
|
46
|
+
**Activity Lifecycle**
|
|
47
|
+
|
|
48
|
+
- `startActivity(name)`: Starts an activity, returns Activity object
|
|
49
|
+
- `activity.error(err, schema, data)`: Logs error during activity
|
|
50
|
+
- `activity.stop(schema, data)`: Stops activity and logs completion
|
|
51
|
+
|
|
52
|
+
**Error Handling**
|
|
53
|
+
|
|
54
|
+
- Always wrap activity operations in try/catch
|
|
55
|
+
- Use `activity.error()` when errors occur
|
|
56
|
+
- Always stop activity in `finally` block
|
|
57
|
+
|
|
58
|
+
**Schema Usage**
|
|
59
|
+
|
|
60
|
+
- `activity.stop()` should receive a schema and payload
|
|
61
|
+
- Schema provides structure for the activity completion data
|
|
62
|
+
- Payload should match schema field definitions
|
|
63
|
+
|
|
64
|
+
**Important**: If activity APIs are used correctly for appropriate operations, I return an empty list.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Observability (o11y) Instrumentation Best Practices for LWC
|
|
2
|
+
|
|
3
|
+
This expert analyzes Lightning Web Components to ensure proper observability instrumentation using the o11y client, schemas, and APIs.
|
|
4
|
+
|
|
5
|
+
## Core Principles
|
|
6
|
+
|
|
7
|
+
1. **Use o11y Client, Not Lightning Logger**
|
|
8
|
+
|
|
9
|
+
- Always use `getInstrumentation` from 'o11y/client'
|
|
10
|
+
- Never use `createLogger` from 'lightning/logger'
|
|
11
|
+
- Initialize instrumentation once in the constructor
|
|
12
|
+
|
|
13
|
+
2. **Schema-Based Instrumentation**
|
|
14
|
+
|
|
15
|
+
- Always import schemas from 'o11y_schema' directories
|
|
16
|
+
- Use schemas for structured logging with `log()` API
|
|
17
|
+
- Schemas provide type safety and automatic metric generation
|
|
18
|
+
|
|
19
|
+
3. **Proper API Usage**
|
|
20
|
+
|
|
21
|
+
- `log()`: For significant events with structured data (creates counter metrics)
|
|
22
|
+
- `startActivity()` / `activity.stop()`: For measuring operation duration (creates percentile metrics)
|
|
23
|
+
- `error()`: For error tracking (use with activities when possible)
|
|
24
|
+
- `incrementCounter()`: For discrete events/actions
|
|
25
|
+
- `trackValue()`: For numeric measurements
|
|
26
|
+
|
|
27
|
+
4. **Lifecycle Instrumentation**
|
|
28
|
+
|
|
29
|
+
- Instrument component lifecycle hooks (connectedCallback, renderedCallback)
|
|
30
|
+
- Track page loads, user interactions, and async operations
|
|
31
|
+
- Measure performance-critical operations
|
|
32
|
+
|
|
33
|
+
5. **Error Handling**
|
|
34
|
+
- Always catch errors in async operations
|
|
35
|
+
- Use `activity.error()` when errors occur during activities
|
|
36
|
+
- Log errors with appropriate context
|
|
37
|
+
|
|
38
|
+
## Automatically Collected Fields
|
|
39
|
+
|
|
40
|
+
Do NOT duplicate these fields in schemas or instrumentation:
|
|
41
|
+
|
|
42
|
+
- Activity: id, name, duration, stopReason, isRoot, preRootId, errorCount
|
|
43
|
+
- Error: name, message, stack, activityId, logType
|
|
44
|
+
- Request: requestId, rootRequestId, parentRequestId
|
|
45
|
+
- Context: organizationId, userId, clientSessionId, schemaSequence
|
|
46
|
+
- Application: appName, appVersion, deviceId, browserName, osName
|
|
47
|
+
- Page: pageUrl, pageEntityType, pageContext, pageEntityId
|
|
48
|
+
|
|
49
|
+
## Common Patterns
|
|
50
|
+
|
|
51
|
+
### Initialization Pattern
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import { getInstrumentation } from 'o11y/client';
|
|
55
|
+
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
this.instrumentation = getInstrumentation('logger-name');
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Logging Pattern
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
import { eventSchema } from 'o11y_schema/sf/team-folder/schema-name';
|
|
66
|
+
|
|
67
|
+
instrumentation.log(eventSchema, {
|
|
68
|
+
taskName: 'userAction',
|
|
69
|
+
// ... other schema fields
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Activity Pattern
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
const activity = instrumentation.startActivity('operationName');
|
|
77
|
+
try {
|
|
78
|
+
await someAsyncOperation();
|
|
79
|
+
} catch (err) {
|
|
80
|
+
activity.error(err, errorSchema, errorPayload);
|
|
81
|
+
} finally {
|
|
82
|
+
activity.stop(activitySchema, payload);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Counter Pattern
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
instrumentation.incrementCounter('BUTTON_CLICKED', 1, false, { buttonId: 'submit-button' });
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## What to Instrument
|
|
93
|
+
|
|
94
|
+
- User interactions (clicks, form submissions)
|
|
95
|
+
- Page/component loads
|
|
96
|
+
- Async operations (API calls, data fetching)
|
|
97
|
+
- Error conditions
|
|
98
|
+
- Performance-critical operations
|
|
99
|
+
- Feature usage and toggles
|
|
100
|
+
|
|
101
|
+
## What NOT to Instrument
|
|
102
|
+
|
|
103
|
+
- Don't over-instrument (avoid logging every single event)
|
|
104
|
+
- Don't use lightning/logger
|
|
105
|
+
- Don't duplicate automatically collected fields
|
|
106
|
+
- Don't instrument trivial operations
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
## o11y Counter Metrics Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper usage of the o11y \`incrementCounter()\` API for tracking discrete events or actions. I focus on verifying correct API usage and appropriate use cases.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Missing counter tracking for user actions**: Button clicks, form submissions, and other discrete user actions should use \`incrementCounter()\`
|
|
10
|
+
- **Incorrect incrementCounter() usage**: API should be called with operation name, increment value, error flag, and optional tags
|
|
11
|
+
- **Missing counter for high-frequency events**: Events that occur frequently should use counters instead of \`log()\`
|
|
12
|
+
- **Incorrect counter names**: Counter names should be descriptive, UPPER_SNAKE_CASE, and clearly identify the event
|
|
13
|
+
- **Missing tags for filtering**: Counters should include relevant tags for filtering and analysis
|
|
14
|
+
- **Using log() instead of incrementCounter()**: High-frequency discrete events should use counters, not \`log()\`
|
|
15
|
+
|
|
16
|
+
### What I Ignore
|
|
17
|
+
|
|
18
|
+
- Components that don't have discrete events to track
|
|
19
|
+
- Components that already properly use \`incrementCounter()\`
|
|
20
|
+
- Test files and mock implementations
|
|
21
|
+
- Events that are better tracked with \`log()\` (significant events with context)
|
|
22
|
+
|
|
23
|
+
### Analysis Framework
|
|
24
|
+
|
|
25
|
+
**Counter API Signature**
|
|
26
|
+
\`\`\`javascript
|
|
27
|
+
incrementCounter(
|
|
28
|
+
operation: string, // Counter name (UPPER_SNAKE_CASE)
|
|
29
|
+
increment?: number, // Increment value (default: 1)
|
|
30
|
+
hasError?: boolean, // Error flag (default: false)
|
|
31
|
+
tags?: MetricsTags // Optional tags for filtering
|
|
32
|
+
): void
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
**Use Cases for incrementCounter()**
|
|
36
|
+
|
|
37
|
+
- Button clicks
|
|
38
|
+
- Form submissions
|
|
39
|
+
- Navigation events
|
|
40
|
+
- Feature usage
|
|
41
|
+
- High-frequency discrete events
|
|
42
|
+
- Events that need simple counting
|
|
43
|
+
|
|
44
|
+
**Counter Naming**
|
|
45
|
+
|
|
46
|
+
- Use UPPER_SNAKE_CASE: \`BUTTON_CLICKED\`, \`FORM_SUBMITTED\`
|
|
47
|
+
- Be descriptive: \`SUBMIT_BUTTON_CLICKED\` not \`CLICK\`
|
|
48
|
+
- Include context: \`THUMBS_UP_BUTTON_CLICKED\` not \`BUTTON\`
|
|
49
|
+
|
|
50
|
+
**Tags Usage**
|
|
51
|
+
|
|
52
|
+
- Include relevant tags for filtering: \`{ buttonId: 'submit-button', featureId: 'feature-123' }\`
|
|
53
|
+
- Only use bounded values for tags (low cardinality)
|
|
54
|
+
- Tags help with analysis and filtering
|
|
55
|
+
|
|
56
|
+
**When to Use incrementCounter() vs log()**
|
|
57
|
+
|
|
58
|
+
- \`incrementCounter()\`: Simple counting of discrete events, high-frequency events
|
|
59
|
+
- \`log()\`: Significant events with structured context data, events that need detailed information
|
|
60
|
+
|
|
61
|
+
**Important**: If counter metrics are used correctly for appropriate events, I return an empty list.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
## o11y Error Tracking Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper error tracking using the o11y \`error()\` API. I focus on verifying that errors are caught, logged with appropriate context, and integrated with activities when applicable.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Unhandled errors in async operations**: Async operations (API calls, promises) should have try/catch blocks with error logging
|
|
10
|
+
- **Missing error() calls**: Errors should be logged using \`instrumentation.error()\` or \`activity.error()\`
|
|
11
|
+
- **Errors not logged with activities**: When errors occur during activities, use \`activity.error()\` instead of standalone \`error()\`
|
|
12
|
+
- **Missing error context**: Errors should be logged with schemas and context data when available
|
|
13
|
+
- **Errors swallowed without logging**: Catch blocks that don't log errors or re-throw them appropriately
|
|
14
|
+
- **Missing error tracking in wire service**: Wire service error handlers should log errors
|
|
15
|
+
|
|
16
|
+
### What I Ignore
|
|
17
|
+
|
|
18
|
+
- Expected errors that are handled gracefully without logging
|
|
19
|
+
- Test files and mock implementations
|
|
20
|
+
- Components that already properly track errors
|
|
21
|
+
- Errors that are re-thrown for upstream handling (if appropriate)
|
|
22
|
+
|
|
23
|
+
### Analysis Framework
|
|
24
|
+
|
|
25
|
+
**Error API Patterns**
|
|
26
|
+
|
|
27
|
+
**Standalone Error Logging**
|
|
28
|
+
\`\`\`javascript
|
|
29
|
+
try {
|
|
30
|
+
await someOperation();
|
|
31
|
+
} catch (err) {
|
|
32
|
+
instrumentation.error(err, errorSchema, errorPayload);
|
|
33
|
+
}
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
**Error with Activity**
|
|
37
|
+
\`\`\`javascript
|
|
38
|
+
const activity = instrumentation.startActivity('operation');
|
|
39
|
+
try {
|
|
40
|
+
await someOperation();
|
|
41
|
+
} catch (err) {
|
|
42
|
+
activity.error(err, errorSchema, errorPayload);
|
|
43
|
+
} finally {
|
|
44
|
+
activity.stop(activitySchema, payload);
|
|
45
|
+
}
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
**Error API Signature**
|
|
49
|
+
|
|
50
|
+
- \`error(error: unknown, userSchemaOrText?: Schema | string, userData?: SchematizedData, options?: ApiOptions)\`
|
|
51
|
+
- First argument: the error object
|
|
52
|
+
- Second argument: schema (preferred) or error text string
|
|
53
|
+
- Third argument: error data matching schema fields
|
|
54
|
+
|
|
55
|
+
**Use Cases for Error Tracking**
|
|
56
|
+
|
|
57
|
+
- API call failures
|
|
58
|
+
- Data validation errors
|
|
59
|
+
- Async operation failures
|
|
60
|
+
- Wire service errors
|
|
61
|
+
- User action errors
|
|
62
|
+
|
|
63
|
+
**Best Practices**
|
|
64
|
+
|
|
65
|
+
- Use \`activity.error()\` when errors occur during activities
|
|
66
|
+
- Provide error schemas for structured error data
|
|
67
|
+
- Include context data (operation name, user action, etc.)
|
|
68
|
+
- Don't swallow errors without logging
|
|
69
|
+
|
|
70
|
+
**Important**: If errors are properly tracked with appropriate context, I return an empty list.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## o11y Initialization Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper initialization of the o11y instrumentation client. I focus on verifying that \`getInstrumentation\` is imported correctly, called exactly once in the constructor, and that the instrumentation instance is properly stored.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Missing getInstrumentation import**: Code that should use o11y but doesn't import \`getInstrumentation\` from 'o11y/client'
|
|
10
|
+
- **Multiple getInstrumentation calls**: \`getInstrumentation\` should be called ONCE AND ONLY ONCE, typically in the constructor
|
|
11
|
+
- **Incorrect initialization location**: \`getInstrumentation\` should be called in the constructor, not in lifecycle hooks or methods
|
|
12
|
+
- **Missing instrumentation property**: The result of \`getInstrumentation\` should be stored in a class property (e.g., \`this.instrumentation\`)
|
|
13
|
+
- **Using lightning/logger instead**: Code that imports or uses \`createLogger\` from 'lightning/logger' instead of o11y
|
|
14
|
+
- **Instrumentation not stored**: Result of \`getInstrumentation\` is not assigned to a property for later use
|
|
15
|
+
|
|
16
|
+
### What I Ignore
|
|
17
|
+
|
|
18
|
+
- Components that don't need instrumentation (very simple, static components)
|
|
19
|
+
- Standard Lightning base components (they handle their own instrumentation)
|
|
20
|
+
- Test files and mock implementations
|
|
21
|
+
- Components that already have proper o11y initialization
|
|
22
|
+
|
|
23
|
+
### Analysis Framework
|
|
24
|
+
|
|
25
|
+
**Import Check**
|
|
26
|
+
|
|
27
|
+
- Verify \`getInstrumentation\` is imported from 'o11y/client'
|
|
28
|
+
- Check that the import statement is correct and not using 'lightning/logger'
|
|
29
|
+
|
|
30
|
+
**Initialization Check**
|
|
31
|
+
|
|
32
|
+
- \`getInstrumentation\` must be called exactly once
|
|
33
|
+
- Should be called in the constructor, not in connectedCallback, renderedCallback, or other methods
|
|
34
|
+
- The call should pass a logger name string as the argument
|
|
35
|
+
|
|
36
|
+
**Storage Check**
|
|
37
|
+
|
|
38
|
+
- Result should be stored in a class property (typically \`this.instrumentation\`)
|
|
39
|
+
- Property should be accessible throughout the component lifecycle
|
|
40
|
+
|
|
41
|
+
**Lightning Logger Detection**
|
|
42
|
+
|
|
43
|
+
- Flag any imports from 'lightning/logger'
|
|
44
|
+
- Flag any usage of \`createLogger\` function
|
|
45
|
+
|
|
46
|
+
**Important**: If the component has proper o11y initialization (single call in constructor, stored in property), I return an empty list.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
## o11y Lifecycle Instrumentation Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper instrumentation of component lifecycle hooks. I focus on verifying that lifecycle events (connectedCallback, renderedCallback, disconnectedCallback) are appropriately instrumented.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Missing page load instrumentation**: \`renderedCallback\` should log page/component load events when appropriate
|
|
10
|
+
- **Missing lifecycle tracking**: Components with significant initialization or cleanup should instrument lifecycle hooks
|
|
11
|
+
- **Incorrect lifecycle instrumentation**: Lifecycle hooks should use appropriate o11y APIs (\`log()\` for events, activities for async operations)
|
|
12
|
+
- **Missing connectedCallback instrumentation**: Components that perform initialization should track connection events
|
|
13
|
+
- **Missing disconnectedCallback instrumentation**: Components with cleanup logic should track disconnection events
|
|
14
|
+
- **Lifecycle hooks without instrumentation**: Components with complex lifecycle behavior should be instrumented
|
|
15
|
+
|
|
16
|
+
### What I Ignore
|
|
17
|
+
|
|
18
|
+
- Simple components that don't need lifecycle instrumentation
|
|
19
|
+
- Components that already properly instrument lifecycle hooks
|
|
20
|
+
- Test files and mock implementations
|
|
21
|
+
- Static components with no lifecycle behavior
|
|
22
|
+
|
|
23
|
+
### Analysis Framework
|
|
24
|
+
|
|
25
|
+
**Lifecycle Hooks to Instrument**
|
|
26
|
+
|
|
27
|
+
**connectedCallback**
|
|
28
|
+
|
|
29
|
+
- Called when component is inserted into DOM
|
|
30
|
+
- Use \`log()\` to track component connection
|
|
31
|
+
- Use activities for async initialization operations
|
|
32
|
+
|
|
33
|
+
**renderedCallback**
|
|
34
|
+
|
|
35
|
+
- Called after component renders
|
|
36
|
+
- Use \`log()\` to track page/component load events
|
|
37
|
+
- Should only log once (use flags to prevent duplicate logging)
|
|
38
|
+
|
|
39
|
+
**disconnectedCallback**
|
|
40
|
+
|
|
41
|
+
- Called when component is removed from DOM
|
|
42
|
+
- Use \`log()\` to track component disconnection
|
|
43
|
+
- Use for cleanup tracking
|
|
44
|
+
|
|
45
|
+
**Instrumentation Patterns**
|
|
46
|
+
|
|
47
|
+
**Page Load Pattern**
|
|
48
|
+
\`\`\`javascript
|
|
49
|
+
renderedCallback() {
|
|
50
|
+
if (!this.hasLoaded) {
|
|
51
|
+
this.instrumentation.log(pageLoadSchema, {
|
|
52
|
+
taskName: 'pageLoad',
|
|
53
|
+
loadTime: performance.now()
|
|
54
|
+
});
|
|
55
|
+
this.hasLoaded = true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
**Component Connection Pattern**
|
|
61
|
+
\`\`\`javascript
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
this.instrumentation.log(componentConnectSchema, {
|
|
64
|
+
taskName: 'componentConnected',
|
|
65
|
+
componentName: this.constructor.name
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
**Async Initialization Pattern**
|
|
71
|
+
\`\`\`javascript
|
|
72
|
+
async connectedCallback() {
|
|
73
|
+
const activity = this.instrumentation.startActivity('componentInitialization');
|
|
74
|
+
try {
|
|
75
|
+
await this.initializeData();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
activity.error(err, errorSchema, errorPayload);
|
|
78
|
+
} finally {
|
|
79
|
+
activity.stop(activitySchema, payload);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
\`\`\`
|
|
83
|
+
|
|
84
|
+
**Best Practices**
|
|
85
|
+
|
|
86
|
+
- Use flags to prevent duplicate logging in \`renderedCallback\`
|
|
87
|
+
- Use activities for async lifecycle operations
|
|
88
|
+
- Include component context in lifecycle logs
|
|
89
|
+
- Track performance metrics for initialization
|
|
90
|
+
|
|
91
|
+
**Important**: If lifecycle hooks are properly instrumented, I return an empty list.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
## o11y Log API Usage Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper usage of the o11y \`log()\` API for tracking significant events with structured data. I focus on verifying correct API usage, schema integration, and appropriate use cases.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Missing log() calls for significant events**: User actions, page loads, feature toggles, or other important events that should be logged
|
|
10
|
+
- **Incorrect log() API usage**: \`log()\` called without a schema, or with incorrect arguments
|
|
11
|
+
- **Missing schema in log() calls**: \`log()\` should always receive a schema as the first argument
|
|
12
|
+
- **Incorrect data structure**: Data object passed to \`log()\` doesn't match the schema structure
|
|
13
|
+
- **Using log() for metrics**: \`log()\` is for events, not for counter metrics (use \`incrementCounter\` instead)
|
|
14
|
+
- **Missing log() for page loads**: \`renderedCallback\` should log page/component load events when appropriate
|
|
15
|
+
- **Missing log() for user interactions**: Significant user actions (form submissions, navigation, feature toggles) should be logged
|
|
16
|
+
|
|
17
|
+
### What I Ignore
|
|
18
|
+
|
|
19
|
+
- Simple components that don't have significant events to log
|
|
20
|
+
- Components that already properly use \`log()\` API
|
|
21
|
+
- Test files and mock implementations
|
|
22
|
+
- Trivial operations that don't warrant logging
|
|
23
|
+
|
|
24
|
+
### Analysis Framework
|
|
25
|
+
|
|
26
|
+
**Log API Signature**
|
|
27
|
+
|
|
28
|
+
- Correct: \`instrumentation.log(userSchema, userData, options)\`
|
|
29
|
+
- Schema must be the first argument
|
|
30
|
+
- Data object (optional) should match schema fields
|
|
31
|
+
- Options (optional) for additional configuration
|
|
32
|
+
|
|
33
|
+
**Use Cases for log()**
|
|
34
|
+
|
|
35
|
+
- Page/component load events
|
|
36
|
+
- User interactions (clicks, form submissions, navigation)
|
|
37
|
+
- Feature toggles and configuration changes
|
|
38
|
+
- Significant state changes
|
|
39
|
+
- Business events that need tracking
|
|
40
|
+
|
|
41
|
+
**When NOT to use log()**
|
|
42
|
+
|
|
43
|
+
- For simple counter metrics (use \`incrementCounter\` instead)
|
|
44
|
+
- For duration measurements (use \`startActivity\` / \`activity.stop\` instead)
|
|
45
|
+
- For numeric value tracking (use \`trackValue\` instead)
|
|
46
|
+
|
|
47
|
+
**Schema Integration**
|
|
48
|
+
|
|
49
|
+
- Every \`log()\` call must include a schema
|
|
50
|
+
- Data object must match schema field definitions
|
|
51
|
+
- Use descriptive event names in the data
|
|
52
|
+
|
|
53
|
+
**Important**: If \`log()\` API is used correctly for appropriate events, I return an empty list,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## o11y Schema Usage Analysis
|
|
2
|
+
|
|
3
|
+
### My Job
|
|
4
|
+
|
|
5
|
+
I analyze Lightning Web Component code to ensure proper usage of o11y schemas. I focus on verifying that schemas are imported from the correct location, used with the appropriate APIs, and that schema fields match the data being logged.
|
|
6
|
+
|
|
7
|
+
### What I Look For
|
|
8
|
+
|
|
9
|
+
- **Missing schema imports**: Code using \`log()\` or \`activity.stop()\` without importing the required schema
|
|
10
|
+
- **Incorrect schema import path**: Schemas should be imported from 'o11y_schema/sf/<team-folder>/<schema-name>', not from other locations
|
|
11
|
+
- **Schema not used with log()**: When using \`log()\` API, a schema must be provided as the first argument
|
|
12
|
+
- **Schema not used with activity.stop()**: When using \`activity.stop()\`, a schema should be provided for structured data
|
|
13
|
+
- **Schema field mismatch**: Data object passed to \`log()\` or \`activity.stop()\` doesn't match the schema field definitions
|
|
14
|
+
- **Missing schema for structured logging**: Using \`log()\` without a schema (schemas are required for structured logging)
|
|
15
|
+
|
|
16
|
+
### What I Ignore
|
|
17
|
+
|
|
18
|
+
- Counter and value tracking APIs (\`incrementCounter\`, \`trackValue\`) which don't require schemas
|
|
19
|
+
- Error logging with just error text (not structured error schemas)
|
|
20
|
+
- Components that don't use structured logging
|
|
21
|
+
- Test files and mock implementations
|
|
22
|
+
|
|
23
|
+
### Analysis Framework
|
|
24
|
+
|
|
25
|
+
**Schema Import Check**
|
|
26
|
+
|
|
27
|
+
- Verify schemas are imported from 'o11y_schema' directories
|
|
28
|
+
- Check import path follows pattern: 'o11y_schema/sf/<team-folder>/<schema-name>'
|
|
29
|
+
- Ensure schema names match their usage
|
|
30
|
+
|
|
31
|
+
**Schema Usage with log()**
|
|
32
|
+
|
|
33
|
+
- \`log()\` API signature: \`log(userSchema: Schema, userData?: SchematizedData, options?: ApiOptions)\`
|
|
34
|
+
- First argument must be a schema
|
|
35
|
+
- Data object (second argument) should match schema fields
|
|
36
|
+
|
|
37
|
+
**Schema Usage with activity.stop()**
|
|
38
|
+
|
|
39
|
+
- \`activity.stop()\` can accept a schema and data: \`activity.stop(activitySchema, payload)\`
|
|
40
|
+
- When used, schema should match the payload structure
|
|
41
|
+
|
|
42
|
+
**Field Validation**
|
|
43
|
+
|
|
44
|
+
- Data objects should only contain fields defined in the schema
|
|
45
|
+
- Field names should match schema field names exactly
|
|
46
|
+
- Field types should match schema field types
|
|
47
|
+
|
|
48
|
+
**Important**: If schemas are properly imported and used, I return an empty list.
|