@salesforce/telemetry 6.5.1 → 6.6.0

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/lib/exported.d.ts CHANGED
@@ -2,4 +2,4 @@ import { TelemetryReporter } from './telemetryReporter';
2
2
  export * from './telemetryReporter';
3
3
  export { isEnabled } from './enabledCheck';
4
4
  export default TelemetryReporter;
5
- export type { Attributes, O11ySchema, O11yBatchingConfig } from './types';
5
+ export type { Attributes, O11ySchema, O11yBatchingConfig, PdpEvent } from './types';
@@ -1,5 +1,5 @@
1
1
  import { type BatchingOptions } from '@salesforce/o11y-reporter';
2
- import { Attributes, O11ySchema, Properties, TelemetryOptions } from './types';
2
+ import { Attributes, O11ySchema, PdpEvent, Properties, TelemetryOptions } from './types';
3
3
  import { BaseReporter } from './baseReporter';
4
4
  export declare class O11yReporter extends BaseReporter {
5
5
  private service;
@@ -46,6 +46,12 @@ export declare class O11yReporter extends BaseReporter {
46
46
  * @param schema - O11y schema object (e.g. from o11y_schema package)
47
47
  */
48
48
  sendTelemetryEventWithSchema(eventName: string, attributes: Attributes, schema: O11ySchema): Promise<void>;
49
+ /**
50
+ * Sends a PDP event via O11y service.
51
+ *
52
+ * @param event - PDP event to send.
53
+ */
54
+ sendPdpEvent(event: PdpEvent): Promise<void>;
49
55
  flush(): Promise<void>;
50
56
  /**
51
57
  * Publishes exception to O11y service
@@ -17,6 +17,9 @@ exports.O11yReporter = void 0;
17
17
  * limitations under the License.
18
18
  */
19
19
  const o11y_reporter_1 = require("@salesforce/o11y-reporter");
20
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21
+ // @ts-ignore o11y_schema/sf_pdp.d.ts is not a valid module
22
+ const sf_pdp_1 = require("o11y_schema/sf_pdp");
20
23
  const baseReporter_1 = require("./baseReporter");
21
24
  const utils_1 = require("./utils");
22
25
  class O11yReporter extends baseReporter_1.BaseReporter {
@@ -105,6 +108,18 @@ class O11yReporter extends baseReporter_1.BaseReporter {
105
108
  await this.service.forceFlush();
106
109
  }
107
110
  }
111
+ /**
112
+ * Sends a PDP event via O11y service.
113
+ *
114
+ * @param event - PDP event to send.
115
+ */
116
+ async sendPdpEvent(event) {
117
+ await this.initialized;
118
+ this.service.logEventWithSchema(event, sf_pdp_1.pdpEventSchema);
119
+ if (!this._batchingEnabled) {
120
+ await this.service.forceFlush();
121
+ }
122
+ }
108
123
  async flush() {
109
124
  // Wait for initialization to complete before using the service
110
125
  await this.initialized;
@@ -1,7 +1,7 @@
1
1
  import { AsyncCreatable } from '@salesforce/kit';
2
2
  import type { BatchingOptions } from '@salesforce/o11y-reporter';
3
3
  import { TelemetryClient } from './appInsights';
4
- import { Attributes, O11ySchema, Properties, TelemetryOptions } from './types';
4
+ import { Attributes, O11ySchema, PdpEvent, Properties, TelemetryOptions } from './types';
5
5
  /**
6
6
  * This is the main telemetry reporter that should be used by consumers.
7
7
  * It will check if telemetry is disabled and do GDPR checks.
@@ -44,6 +44,12 @@ export declare class TelemetryReporter extends AsyncCreatable<TelemetryOptions>
44
44
  * @param schema - O11y schema object (e.g. from o11y_schema package)
45
45
  */
46
46
  sendTelemetryEventWithSchema(eventName: string, attributes: Attributes, schema: O11ySchema): void;
47
+ /**
48
+ * Sends a PDP event via O11y.
49
+ *
50
+ * @param event - PDP event data to send.
51
+ */
52
+ sendPdpEvent(event: PdpEvent): void;
47
53
  /**
48
54
  * Sends message to both AppInsights and O11y (if enabled).
49
55
  *
@@ -203,6 +203,18 @@ class TelemetryReporter extends kit_1.AsyncCreatable {
203
203
  });
204
204
  }
205
205
  }
206
+ /**
207
+ * Sends a PDP event via O11y.
208
+ *
209
+ * @param event - PDP event data to send.
210
+ */
211
+ sendPdpEvent(event) {
212
+ if (this.isSfdxTelemetryEnabled() && this.enableO11y && this.o11yReporter) {
213
+ void this.o11yReporter.sendPdpEvent(event).catch((error) => {
214
+ this.logger.debug('Failed to send PDP event to O11y:', error);
215
+ });
216
+ }
217
+ }
206
218
  /**
207
219
  * Sends message to both AppInsights and O11y (if enabled).
208
220
  *
package/lib/types.d.ts CHANGED
@@ -15,6 +15,49 @@ export type Attributes = {
15
15
  * (not a primitive, null, or undefined).
16
16
  */
17
17
  export type O11ySchema = Record<string, unknown>;
18
+ /**
19
+ * PDP Product Feature Taxonomy (PFT) event sent via O11y.
20
+ */
21
+ export type PdpEvent = {
22
+ /**
23
+ * Unique identifier for the event. Follows this naming convention:
24
+ * <object>.<action>
25
+ *
26
+ * object = Specific object within the Product Feature that give us context around the action in lowerCamelCase format.
27
+ * Note: The object name can include context around the Product Feature (eg. slackforceMessage).
28
+ * Examples: calculatedInsightsRecord,checkoutPaymentmethod, slackforceMessage, promptBuilderTemplate
29
+ *
30
+ * action = Action the user takes in past tense. This should only be ONE word, in lower case
31
+ * Examples: processed, selected, sent, saved
32
+ */
33
+ eventName: `${string}.${string}`;
34
+ /**
35
+ * Product Feature ID from GUS.
36
+ *
37
+ * Examples:
38
+ * Salesforce CLI = aJCEE0000000mHP4AY
39
+ * Salesforce Extensions for VS Code = aJCEE0000000mLm4AI
40
+ */
41
+ productFeatureId: `aJC${string}`;
42
+ /**
43
+ * Populate this if there is a unique component with your Event for which a distinct count would be a relevant metric
44
+ * E.g., CLI plugin command name (<pluginName.commandName>) or ext command name.
45
+ */
46
+ componentId?: string;
47
+ /**
48
+ * Populate this if there is a unique quantity with your Event for which a sum would be a relevant metric for your
49
+ * Product Feature. E.g., rowsProcessed → total Rows processed for Data Streams.
50
+ */
51
+ eventVolume?: number;
52
+ /**
53
+ * Use this field to specify the name of your flexible attribute (eg. experimentId, buttonColor).
54
+ */
55
+ contextName?: string;
56
+ /**
57
+ * Use this field to specify the value of your flexible attribute (eg. exp_123, green).
58
+ */
59
+ contextValue?: string;
60
+ };
18
61
  /**
19
62
  * Batching configuration for O11y telemetry
20
63
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/telemetry",
3
- "version": "6.5.1",
3
+ "version": "6.6.0",
4
4
  "description": "Library for telemetry reporting to Application Insights and O11y",
5
5
  "main": "lib/exported",
6
6
  "exports": {
@@ -43,9 +43,10 @@
43
43
  "dependencies": {
44
44
  "@salesforce/core": "^8.25.1",
45
45
  "@salesforce/kit": "^3.2.4",
46
- "@salesforce/o11y-reporter": "1.7.0",
46
+ "@salesforce/o11y-reporter": "1.7.3",
47
47
  "applicationinsights": "^2.9.8",
48
48
  "got": "^11",
49
+ "o11y_schema": "^260.41.0",
49
50
  "proxy-agent": "^6.5.0"
50
51
  },
51
52
  "devDependencies": {