@salesforce/telemetry 6.6.0 → 6.6.2

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/README.md CHANGED
@@ -107,8 +107,8 @@ const reporter = await TelemetryReporter.create({
107
107
  reporter.start();
108
108
  // Default events use the default schema
109
109
  reporter.sendTelemetryEvent('event-name', { foo: 'bar' });
110
- // PFT or other schema-specific events: pass schema per call
111
- reporter.sendTelemetryEventWithSchema('pftEventName', { userId: 'user-1', action: 'view' }, pdpEventSchema);
110
+ // Schema-specific events: pass only attributes (must include all fields required by the schema; no properties added by reporter)
111
+ reporter.sendTelemetryEventWithSchema({ userId: 'user-1', action: 'view', eventName: 'pftEventName' }, pdpEventSchema);
112
112
  ```
113
113
 
114
114
  **Note:** `sendTelemetryEventWithSchema` sends only to O11y (not AppInsights). Use it for events that must conform to a given schema; use `sendTelemetryEvent` for all other events.
@@ -40,12 +40,17 @@ export declare class O11yReporter extends BaseReporter {
40
40
  * Use this method when you need to send events that conform to a particular schema
41
41
  * (e.g. PFT/pdpEventSchema). Only the events you send via this method use the given schema;
42
42
  * all other events use the default schema via sendTelemetryEvent.
43
+ * Only the caller-provided attributes are sent; no properties (e.g. eventName, common.*)
44
+ * are added by the reporter.
43
45
  *
44
- * @param eventName - Name of the event
45
- * @param attributes - Properties and measurements to publish alongside the event
46
- * @param schema - O11y schema object (e.g. from o11y_schema package)
46
+ * The schema is the O11y encoding schema (e.g. from the o11y_schema package), not JSON Schema,
47
+ * so this library does not derive or run validation here. Callers should validate attributes
48
+ * (e.g. with zod) before calling, using the same schema context they use when importing the schema.
49
+ *
50
+ * @param attributes - Properties and measurements to publish (only these are sent; no properties added)
51
+ * @param schema - O11y encoding schema (e.g. from o11y_schema package)
47
52
  */
48
- sendTelemetryEventWithSchema(eventName: string, attributes: Attributes, schema: O11ySchema): Promise<void>;
53
+ sendTelemetryEventWithSchema(attributes: Attributes, schema: O11ySchema): Promise<void>;
49
54
  /**
50
55
  * Sends a PDP event via O11y service.
51
56
  *
@@ -91,18 +91,19 @@ class O11yReporter extends baseReporter_1.BaseReporter {
91
91
  * Use this method when you need to send events that conform to a particular schema
92
92
  * (e.g. PFT/pdpEventSchema). Only the events you send via this method use the given schema;
93
93
  * all other events use the default schema via sendTelemetryEvent.
94
+ * Only the caller-provided attributes are sent; no properties (e.g. eventName, common.*)
95
+ * are added by the reporter.
94
96
  *
95
- * @param eventName - Name of the event
96
- * @param attributes - Properties and measurements to publish alongside the event
97
- * @param schema - O11y schema object (e.g. from o11y_schema package)
97
+ * The schema is the O11y encoding schema (e.g. from the o11y_schema package), not JSON Schema,
98
+ * so this library does not derive or run validation here. Callers should validate attributes
99
+ * (e.g. with zod) before calling, using the same schema context they use when importing the schema.
100
+ *
101
+ * @param attributes - Properties and measurements to publish (only these are sent; no properties added)
102
+ * @param schema - O11y encoding schema (e.g. from o11y_schema package)
98
103
  */
99
- async sendTelemetryEventWithSchema(eventName, attributes, schema) {
104
+ async sendTelemetryEventWithSchema(attributes, schema) {
100
105
  await this.initialized;
101
- const merged = { ...this.commonProperties, ...attributes };
102
- const eventData = {
103
- eventName: `${this.extensionName}/${eventName}`,
104
- ...merged,
105
- };
106
+ const eventData = { ...attributes };
106
107
  this.service.logEventWithSchema(eventData, schema);
107
108
  if (!this._batchingEnabled) {
108
109
  await this.service.forceFlush();
@@ -38,12 +38,16 @@ export declare class TelemetryReporter extends AsyncCreatable<TelemetryOptions>
38
38
  * Sends a telemetry event to O11y only with a specific schema.
39
39
  * Use this for events that must conform to a given schema (e.g. PFT/pdpEventSchema).
40
40
  * Does not send to AppInsights. Only sends when O11y is enabled and reporter is initialized.
41
+ * Only the caller-provided attributes are sent; no properties are added by the reporter.
41
42
  *
42
- * @param eventName - Name of the event
43
- * @param attributes - Properties and measurements to publish alongside the event
44
- * @param schema - O11y schema object (e.g. from o11y_schema package)
43
+ * The schema is the O11y encoding schema (e.g. from the o11y_schema package), not JSON Schema,
44
+ * so this library does not derive or run validation here. Callers should validate attributes
45
+ * (e.g. with zod) before calling, using the same schema context they use when importing the schema.
46
+ *
47
+ * @param attributes - Properties and measurements to publish (only these are sent)
48
+ * @param schema - O11y encoding schema (e.g. from o11y_schema package)
45
49
  */
46
- sendTelemetryEventWithSchema(eventName: string, attributes: Attributes, schema: O11ySchema): void;
50
+ sendTelemetryEventWithSchema(attributes: Attributes, schema: O11ySchema): void;
47
51
  /**
48
52
  * Sends a PDP event via O11y.
49
53
  *
@@ -191,14 +191,18 @@ class TelemetryReporter extends kit_1.AsyncCreatable {
191
191
  * Sends a telemetry event to O11y only with a specific schema.
192
192
  * Use this for events that must conform to a given schema (e.g. PFT/pdpEventSchema).
193
193
  * Does not send to AppInsights. Only sends when O11y is enabled and reporter is initialized.
194
+ * Only the caller-provided attributes are sent; no properties are added by the reporter.
194
195
  *
195
- * @param eventName - Name of the event
196
- * @param attributes - Properties and measurements to publish alongside the event
197
- * @param schema - O11y schema object (e.g. from o11y_schema package)
196
+ * The schema is the O11y encoding schema (e.g. from the o11y_schema package), not JSON Schema,
197
+ * so this library does not derive or run validation here. Callers should validate attributes
198
+ * (e.g. with zod) before calling, using the same schema context they use when importing the schema.
199
+ *
200
+ * @param attributes - Properties and measurements to publish (only these are sent)
201
+ * @param schema - O11y encoding schema (e.g. from o11y_schema package)
198
202
  */
199
- sendTelemetryEventWithSchema(eventName, attributes, schema) {
203
+ sendTelemetryEventWithSchema(attributes, schema) {
200
204
  if (this.isSfdxTelemetryEnabled() && this.enableO11y && this.o11yReporter) {
201
- void this.o11yReporter.sendTelemetryEventWithSchema(eventName, attributes, schema).catch((error) => {
205
+ void this.o11yReporter.sendTelemetryEventWithSchema(attributes, schema).catch((error) => {
202
206
  this.logger.debug('Failed to send event with schema to O11y:', error);
203
207
  });
204
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/telemetry",
3
- "version": "6.6.0",
3
+ "version": "6.6.2",
4
4
  "description": "Library for telemetry reporting to Application Insights and O11y",
5
5
  "main": "lib/exported",
6
6
  "exports": {
@@ -41,7 +41,7 @@
41
41
  "!lib/**/*.map"
42
42
  ],
43
43
  "dependencies": {
44
- "@salesforce/core": "^8.25.1",
44
+ "@salesforce/core": "^8.26.0",
45
45
  "@salesforce/kit": "^3.2.4",
46
46
  "@salesforce/o11y-reporter": "1.7.3",
47
47
  "applicationinsights": "^2.9.8",