@salesforce/platform-sdk 10.9.1 → 10.10.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.
@@ -5,8 +5,9 @@ import { Analytics, AnalyticsOptions } from './types';
5
5
  * Handles all setup internally:
6
6
  * - Creates a ChatSDK instance via getChatSDK() (unless one is provided)
7
7
  * - Calls registerInstrumentedApp() with appPayloadProvider pre-wired
8
- * to attach appId, surface, axlPftId (always), and pftId (when set) to
9
- * every o11y log entry
8
+ * to attach appId and surface (always), plus axlPftId and pftId (when set)
9
+ * to every o11y log entry — PFT Ids are withheld when the internal gate is
10
+ * enforced and the session is not marked internal (see `enforceInternalGate`)
10
11
  * - Wraps the ChatSDK in a Proxy for auto-instrumentation
11
12
  * - Sets up global error listeners (window.onerror, unhandledrejection)
12
13
  * - Tracks session duration from init to dispose()
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/analytics/analytics.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CA2GnF"}
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/analytics/analytics.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CA0HnF"}
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export { createAnalytics } from './analytics';
7
7
  export type { Analytics, AnalyticsOptions } from './types';
8
- export { AXL_PFT_ID, PFT_META_KEY, validatePftId } from './pft';
8
+ export { AXL_PFT_ID, INTERNAL_SESSION_META_KEY, PFT_META_KEY, validatePftId } from './pft';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analytics/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analytics/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC"}
@@ -1,7 +1,8 @@
1
- import { A as t, P as e, c as A, v as P } from "../analytics-BIpcEJQq.js";
1
+ import { A as s, I as A, P as E, c as t, v as I } from "../analytics-CEBjImO5.js";
2
2
  export {
3
- t as AXL_PFT_ID,
4
- e as PFT_META_KEY,
5
- A as createAnalytics,
6
- P as validatePftId
3
+ s as AXL_PFT_ID,
4
+ A as INTERNAL_SESSION_META_KEY,
5
+ E as PFT_META_KEY,
6
+ t as createAnalytics,
7
+ I as validatePftId
7
8
  };
@@ -9,6 +9,14 @@
9
9
  * with other `_meta` consumers.
10
10
  */
11
11
  export declare const PFT_META_KEY = "sfdc.pftId";
12
+ /**
13
+ * Reserved key on `CallToolResult._meta` by which an MCP server marks the
14
+ * current session as Salesforce-internal, gating PFT Id tracking (W-22315204).
15
+ * Must be set by the server, not forwarded from client input; only a strict
16
+ * boolean `true` counts (see {@link Analytics.setInternalSession}). Namespaced
17
+ * alongside {@link PFT_META_KEY} to avoid `_meta` collisions.
18
+ */
19
+ export declare const INTERNAL_SESSION_META_KEY = "sfdc.internalSession";
12
20
  /**
13
21
  * The AXL team's own Product Feature Taxonomy (PFT) Id, emitted on every event
14
22
  * as `axlPftId` alongside the customer `pftId` (W-22315201). A fixed constant —
@@ -1 +1 @@
1
- {"version":3,"file":"pft.d.ts","sourceRoot":"","sources":["../../src/analytics/pft.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH;;;;GAIG;AACH,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC;;;;;GAKG;AACH,eAAO,MAAM,UAAU,uBAAuB,CAAC;AAiB/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,MAAM,CAqBvD"}
1
+ {"version":3,"file":"pft.d.ts","sourceRoot":"","sources":["../../src/analytics/pft.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwBH;;;;GAIG;AACH,eAAO,MAAM,YAAY,eAAe,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,yBAAyB,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,uBAAuB,CAAC;AAiB/C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,MAAM,CAqBvD"}
@@ -80,6 +80,18 @@ export interface AnalyticsOptions {
80
80
  * analytics dashboards only.
81
81
  */
82
82
  pftId?: string;
83
+ /**
84
+ * Restrict PFT Id tracking (customer `pftId` + AXL `axlPftId`) to
85
+ * Salesforce-internal sessions (W-22315204). "Internal" can't be inferred
86
+ * client-side, so the gate relies on a server-stamped marker
87
+ * ({@link INTERNAL_SESSION_META_KEY}) surfaced via
88
+ * {@link Analytics.setInternalSession} — the server is the source of truth.
89
+ *
90
+ * Default `false`: emission is unchanged, so this can ship before any server
91
+ * stamps the marker. When `true`, `pftId`/`axlPftId` are withheld until the
92
+ * session is marked internal; `appId`/`surface` always emit.
93
+ */
94
+ enforceInternalGate?: boolean;
83
95
  }
84
96
  /**
85
97
  * Analytics instance returned by createAnalytics().
@@ -111,6 +123,14 @@ export interface Analytics {
111
123
  * the Id set by earlier well-formed responses.
112
124
  */
113
125
  setPftId: (id: string) => void;
126
+ /**
127
+ * Mark whether the current session is Salesforce-internal, per the server
128
+ * (W-22315204). Only relevant when `enforceInternalGate` is set: `true` opens
129
+ * the gate so events carry `pftId`/`axlPftId`, `false` re-closes it (the
130
+ * server can revoke). Strict `true` only — any other value is treated as
131
+ * not-internal (forgery resistance). Late-bound; no-op after `dispose()`.
132
+ */
133
+ setInternalSession: (isInternal: boolean) => void;
114
134
  /** Cleanup — removes listeners, logs session duration, flushes events */
115
135
  dispose: () => void;
116
136
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/analytics/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD;;GAEG;AACH,MAAM,WAAW,MAAM;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,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AAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAClF,uCAAuC;IACvC,aAAa,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C;;;;;;;;;;;;OAYG;IACH,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,kBAAkB,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,yEAAyE;IACzE,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB"}
@@ -0,0 +1,174 @@
1
+ import { registerInstrumentedApp as S } from "o11y/client";
2
+ import { g as x } from "./surface-DX5JCZPQ.js";
3
+ import { getChatSDK as P } from "./chat/index.js";
4
+ import { r as h } from "./TelemetryUploader-DKkdppe9.js";
5
+ import { analyticsContextSchema as v, sessionSchema as _, pageViewSchema as k, errorContextSchema as C, interactionSchema as N, customEventSchema as F } from "o11y_schema/sf_mcpanalytics";
6
+ function L(e) {
7
+ const t = (s, d, m, a, c) => {
8
+ e.error(c ?? s);
9
+ }, n = (s) => {
10
+ e.error(s.reason);
11
+ };
12
+ return window.addEventListener("error", t), window.addEventListener("unhandledrejection", n), () => {
13
+ window.removeEventListener("error", t), window.removeEventListener("unhandledrejection", n);
14
+ };
15
+ }
16
+ const b = "aJC", q = "sfdc.pftId", V = "sfdc.internalSession", D = "aJCEE000000FgYP4A0", w = /* @__PURE__ */ new Set(), O = /^aJC[0-9A-Za-z]{12}(?:[0-9A-Za-z]{3})?$/;
17
+ function T(e) {
18
+ return typeof e != "string" || e.length === 0 ? !1 : e.length !== 15 && e.length !== 18 ? (E(e, "Expected a 15- or 18-character Salesforce ID"), !1) : O.test(e) ? !0 : (E(e, `Expected a Product Feature Id (prefix "${b}", base62).`), !1);
19
+ }
20
+ function E(e, t) {
21
+ w.has(e) || (w.add(e), console.debug(`[platform-sdk:analytics] Ignoring invalid PFT Id "${e}". ${t}`));
22
+ }
23
+ function u(e, t) {
24
+ return { surface: t };
25
+ }
26
+ const J = {
27
+ callTool: {
28
+ isAsync: !0,
29
+ extractTags: (e, t) => ({ toolName: e[0]?.toolName ?? "unknown", surface: t })
30
+ },
31
+ setWidgetState: {
32
+ isAsync: !1,
33
+ extractTags: u
34
+ },
35
+ getWidgetState: {
36
+ isAsync: !1,
37
+ extractTags: u
38
+ },
39
+ sendMessageToHost: {
40
+ isAsync: !0,
41
+ extractTags: u
42
+ },
43
+ openLink: {
44
+ isAsync: !0,
45
+ extractTags: u
46
+ },
47
+ subscribe: {
48
+ isAsync: !1,
49
+ extractTags: u,
50
+ wrapArgs: (e, t) => {
51
+ const n = e[0];
52
+ return [
53
+ () => {
54
+ t.activity("sdk.subscribe_callback", () => n());
55
+ }
56
+ ];
57
+ }
58
+ },
59
+ readResource: {
60
+ isAsync: !0,
61
+ extractTags: (e, t) => ({ uri: e[0]?.uri ?? "unknown", surface: t })
62
+ },
63
+ setDisplayMode: {
64
+ isAsync: !0,
65
+ extractTags: (e, t) => ({ mode: e[0] ?? "unknown", surface: t })
66
+ },
67
+ accessToolOutput: {
68
+ isAsync: !1,
69
+ extractTags: u
70
+ },
71
+ accessToolInput: {
72
+ isAsync: !1,
73
+ extractTags: u
74
+ },
75
+ accessToolMetadata: {
76
+ isAsync: !1,
77
+ extractTags: u
78
+ }
79
+ };
80
+ function M(e, t, n) {
81
+ return new Proxy(e, {
82
+ get(s, d, m) {
83
+ const a = Reflect.get(s, d, m), c = J[d];
84
+ return !c || typeof a != "function" ? a : (...g) => {
85
+ const f = c.extractTags(g, n), o = c.wrapArgs ? c.wrapArgs(g, t) : g, p = `sdk.${String(d)}`;
86
+ return c.isAsync ? t.activityAsync(p, async () => {
87
+ try {
88
+ const y = await a.apply(
89
+ s,
90
+ o
91
+ );
92
+ return t.incrementCounter(p, 1, !1, f), y;
93
+ } catch (y) {
94
+ throw t.incrementCounter(p, 1, !0, f), y;
95
+ }
96
+ }) : (t.incrementCounter(p, 1, !1, f), a.apply(s, o));
97
+ };
98
+ }
99
+ });
100
+ }
101
+ async function z(e) {
102
+ const { appId: t, clientSessionId: n } = e, s = x(), d = Date.now(), m = e.sdk ?? await P();
103
+ let a = null;
104
+ e.pftId !== void 0 && T(e.pftId) && (a = e.pftId);
105
+ const c = e.enforceInternalGate === !0;
106
+ let g = !1;
107
+ const f = S("mcp-widget", {
108
+ appPayloadProvider: {
109
+ getPayload: () => {
110
+ const r = !c || g;
111
+ return {
112
+ schema: v,
113
+ payload: {
114
+ appId: t,
115
+ surface: s,
116
+ ...r ? { axlPftId: D } : {},
117
+ ...r && a !== null ? { pftId: a } : {}
118
+ }
119
+ };
120
+ }
121
+ },
122
+ clientSessionId: n
123
+ }), o = f, p = M(m, o, s), y = L(o);
124
+ let A;
125
+ e.transport && (A = h(f, {
126
+ onEnvelope: (r) => {
127
+ e.transport.enqueue(r);
128
+ }
129
+ }));
130
+ let I, i = !1;
131
+ return {
132
+ instrumentedSDK: p,
133
+ app: f,
134
+ trackEvent(r, l) {
135
+ i || o.log(F, {
136
+ eventName: r,
137
+ properties: l ? JSON.stringify(l) : ""
138
+ });
139
+ },
140
+ trackInteraction(r, l) {
141
+ i || o.log(N, {
142
+ elementId: r,
143
+ properties: l ? JSON.stringify(l) : ""
144
+ });
145
+ },
146
+ trackError(r, l) {
147
+ i || o.error(r, C, {
148
+ properties: l ? JSON.stringify(l) : ""
149
+ });
150
+ },
151
+ trackPageView(r) {
152
+ i || r !== I && (I = r, o.log(k, { componentRef: r }));
153
+ },
154
+ setPftId(r) {
155
+ i || T(r) && (a = r);
156
+ },
157
+ setInternalSession(r) {
158
+ i || (g = r === !0);
159
+ },
160
+ dispose() {
161
+ if (i) return;
162
+ i = !0, y();
163
+ const r = Date.now() - d;
164
+ o.log(_, { durationMs: r }), A?.dispose();
165
+ }
166
+ };
167
+ }
168
+ export {
169
+ D as A,
170
+ V as I,
171
+ q as P,
172
+ z as c,
173
+ T as v
174
+ };
@@ -196,7 +196,7 @@ class ie {
196
196
  })).structuredContent;
197
197
  }
198
198
  }
199
- const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "10.9.1", de = (t) => {
199
+ const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "10.10.0", de = (t) => {
200
200
  let e = y(ce, he, t);
201
201
  return e = y(ue, le, e), u(e);
202
202
  }, pe = "X-CSRF-Token";
package/dist/index.d.ts CHANGED
@@ -9,5 +9,5 @@ export { createViewSDK, type ViewSDKOptions, MCPAppsViewSDK, getViewSDK, getView
9
9
  export { createDataSDK, type DataSDKOptions, type WebAppDataSDKOptions, type MosaicDataSDKOptions, type StatusCallback, type NodeOfConnection, gql, } from './data';
10
10
  export { createLightningSDK, type LightningSDKOptions } from './lightning';
11
11
  export { createTelemetryTransport, registerTelemetryUploader, TelemetryUploader, type TelemetryTransport, type TelemetryTransportOptions, type EnvelopeEntry, type EnvelopeMetadata, type TelemetryUploaderOptions, type OnEnvelopeCallback, type FlushReason, type TelemetryUploadContext, type TelemetryUploaderErrorContext, type InstrumentedAppLike, type DisposeOptions, } from './telemetry';
12
- export { AXL_PFT_ID, createAnalytics, PFT_META_KEY, validatePftId, type Analytics, type AnalyticsOptions, } from './analytics';
12
+ export { AXL_PFT_ID, createAnalytics, INTERNAL_SESSION_META_KEY, PFT_META_KEY, validatePftId, type Analytics, type AnalyticsOptions, } from './analytics';
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,QAAQ,CAAC;AAGvB,OAAO,EACN,aAAa,EACb,KAAK,cAAc,EACnB,cAAc,EACd,UAAU,EACV,cAAc,EACd,YAAY,GACZ,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,aAAa,EACb,KAAK,cAAc,EACnB,cAAc,EACd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mB,EAAE,MAAM,aAAa,CAAC;AAG3E,OAAO,EACN,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACN,UAAU,EACV,eAAe,EACf,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,KAAK,SAAS,EACd,KAAK,gBAAgB,GACrB,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,39 +1,40 @@
1
1
  import { S as t, g as a, i as o } from "./surface-DX5JCZPQ.js";
2
- import { M as p } from "./mcpapps-session-BThDrfRw.js";
2
+ import { M as S } from "./mcpapps-session-BThDrfRw.js";
3
3
  import { g as i } from "./capabilities-DtUMG0oZ.js";
4
4
  import { w as m } from "./sdk-promise-D0sy7OW1.js";
5
- import { MCPAppsChatSDK as D, createChatSDK as K, getChatSDK as g, getChatSDKSync as x, resetChatSDK as l } from "./chat/index.js";
6
- import { MCPAppsViewSDK as C, createViewSDK as T, getViewSDK as w, getViewSDKSync as A, resetViewSDK as P } from "./view/index.js";
7
- import { createDataSDK as h, gql as y } from "./data/index.js";
8
- import { createLightningSDK as V } from "./lightning/index.js";
9
- import { c as u } from "./transport-D8xgRy7y.js";
10
- import { T as I, r as b } from "./TelemetryUploader-DKkdppe9.js";
11
- import { A as F, P as L, c as U, v as q } from "./analytics-BIpcEJQq.js";
5
+ import { MCPAppsChatSDK as D, createChatSDK as K, getChatSDK as g, getChatSDKSync as x, resetChatSDK as T } from "./chat/index.js";
6
+ import { MCPAppsViewSDK as A, createViewSDK as n, getViewSDK as C, getViewSDKSync as w, resetViewSDK as E } from "./view/index.js";
7
+ import { createDataSDK as _, gql as d } from "./data/index.js";
8
+ import { createLightningSDK as y } from "./lightning/index.js";
9
+ import { c as M } from "./transport-D8xgRy7y.js";
10
+ import { T as u, r as L } from "./TelemetryUploader-DKkdppe9.js";
11
+ import { A as b, I as v, P as F, c as U, v as Y } from "./analytics-CEBjImO5.js";
12
12
  export {
13
- F as AXL_PFT_ID,
13
+ b as AXL_PFT_ID,
14
+ v as INTERNAL_SESSION_META_KEY,
14
15
  D as MCPAppsChatSDK,
15
- C as MCPAppsViewSDK,
16
- p as McpAppsSession,
17
- L as PFT_META_KEY,
16
+ A as MCPAppsViewSDK,
17
+ S as McpAppsSession,
18
+ F as PFT_META_KEY,
18
19
  t as Surface,
19
- I as TelemetryUploader,
20
+ u as TelemetryUploader,
20
21
  U as createAnalytics,
21
22
  K as createChatSDK,
22
- h as createDataSDK,
23
- V as createLightningSDK,
24
- u as createTelemetryTransport,
25
- T as createViewSDK,
23
+ _ as createDataSDK,
24
+ y as createLightningSDK,
25
+ M as createTelemetryTransport,
26
+ n as createViewSDK,
26
27
  g as getChatSDK,
27
28
  x as getChatSDKSync,
28
29
  a as getSurface,
29
30
  i as getSurfaceCapabilities,
30
- w as getViewSDK,
31
- A as getViewSDKSync,
32
- y as gql,
31
+ C as getViewSDK,
32
+ w as getViewSDKSync,
33
+ d as gql,
33
34
  o as isSfEmbeddingIframe,
34
- b as registerTelemetryUploader,
35
- l as resetChatSDK,
36
- P as resetViewSDK,
37
- q as validatePftId,
35
+ L as registerTelemetryUploader,
36
+ T as resetChatSDK,
37
+ E as resetViewSDK,
38
+ Y as validatePftId,
38
39
  m as wrapSDKPromise
39
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/platform-sdk",
3
- "version": "10.9.1",
3
+ "version": "10.10.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -107,7 +107,7 @@
107
107
  "@conduit-client/service-pubsub": "3.19.6",
108
108
  "@conduit-client/service-retry": "3.19.6",
109
109
  "@conduit-client/utils": "3.19.6",
110
- "@salesforce/jsonrpc": "^10.9.1",
110
+ "@salesforce/jsonrpc": "^10.10.0",
111
111
  "@sf-embedding/sf-embedding-bridge": "2.2.1-rc.4"
112
112
  },
113
113
  "peerDependencies": {
@@ -1,165 +0,0 @@
1
- import { registerInstrumentedApp as I } from "o11y/client";
2
- import { g as x } from "./surface-DX5JCZPQ.js";
3
- import { getChatSDK as P } from "./chat/index.js";
4
- import { r as E } from "./TelemetryUploader-DKkdppe9.js";
5
- import { analyticsContextSchema as h, sessionSchema as S, pageViewSchema as v, errorContextSchema as k, interactionSchema as _, customEventSchema as C } from "o11y_schema/sf_mcpanalytics";
6
- function F(e) {
7
- const t = (o, d, y, c, s) => {
8
- e.error(s ?? o);
9
- }, n = (o) => {
10
- e.error(o.reason);
11
- };
12
- return window.addEventListener("error", t), window.addEventListener("unhandledrejection", n), () => {
13
- window.removeEventListener("error", t), window.removeEventListener("unhandledrejection", n);
14
- };
15
- }
16
- const b = "aJC", j = "sfdc.pftId", D = "aJCEE000000FgYP4A0", w = /* @__PURE__ */ new Set(), L = /^aJC[0-9A-Za-z]{12}(?:[0-9A-Za-z]{3})?$/;
17
- function A(e) {
18
- return typeof e != "string" || e.length === 0 ? !1 : e.length !== 15 && e.length !== 18 ? (T(e, "Expected a 15- or 18-character Salesforce ID"), !1) : L.test(e) ? !0 : (T(e, `Expected a Product Feature Id (prefix "${b}", base62).`), !1);
19
- }
20
- function T(e, t) {
21
- w.has(e) || (w.add(e), console.debug(`[platform-sdk:analytics] Ignoring invalid PFT Id "${e}". ${t}`));
22
- }
23
- function l(e, t) {
24
- return { surface: t };
25
- }
26
- const N = {
27
- callTool: {
28
- isAsync: !0,
29
- extractTags: (e, t) => ({ toolName: e[0]?.toolName ?? "unknown", surface: t })
30
- },
31
- setWidgetState: {
32
- isAsync: !1,
33
- extractTags: l
34
- },
35
- getWidgetState: {
36
- isAsync: !1,
37
- extractTags: l
38
- },
39
- sendMessageToHost: {
40
- isAsync: !0,
41
- extractTags: l
42
- },
43
- openLink: {
44
- isAsync: !0,
45
- extractTags: l
46
- },
47
- subscribe: {
48
- isAsync: !1,
49
- extractTags: l,
50
- wrapArgs: (e, t) => {
51
- const n = e[0];
52
- return [
53
- () => {
54
- t.activity("sdk.subscribe_callback", () => n());
55
- }
56
- ];
57
- }
58
- },
59
- readResource: {
60
- isAsync: !0,
61
- extractTags: (e, t) => ({ uri: e[0]?.uri ?? "unknown", surface: t })
62
- },
63
- setDisplayMode: {
64
- isAsync: !0,
65
- extractTags: (e, t) => ({ mode: e[0] ?? "unknown", surface: t })
66
- },
67
- accessToolOutput: {
68
- isAsync: !1,
69
- extractTags: l
70
- },
71
- accessToolInput: {
72
- isAsync: !1,
73
- extractTags: l
74
- },
75
- accessToolMetadata: {
76
- isAsync: !1,
77
- extractTags: l
78
- }
79
- };
80
- function J(e, t, n) {
81
- return new Proxy(e, {
82
- get(o, d, y) {
83
- const c = Reflect.get(o, d, y), s = N[d];
84
- return !s || typeof c != "function" ? c : (...a) => {
85
- const p = s.extractTags(a, n), m = s.wrapArgs ? s.wrapArgs(a, t) : a, u = `sdk.${String(d)}`;
86
- return s.isAsync ? t.activityAsync(u, async () => {
87
- try {
88
- const g = await c.apply(
89
- o,
90
- m
91
- );
92
- return t.incrementCounter(u, 1, !1, p), g;
93
- } catch (g) {
94
- throw t.incrementCounter(u, 1, !0, p), g;
95
- }
96
- }) : (t.incrementCounter(u, 1, !1, p), c.apply(o, m));
97
- };
98
- }
99
- });
100
- }
101
- async function q(e) {
102
- const { appId: t, clientSessionId: n } = e, o = x(), d = Date.now(), y = e.sdk ?? await P();
103
- let c = null;
104
- e.pftId !== void 0 && A(e.pftId) && (c = e.pftId);
105
- const s = I("mcp-widget", {
106
- appPayloadProvider: {
107
- getPayload: () => ({
108
- schema: h,
109
- payload: {
110
- appId: t,
111
- surface: o,
112
- axlPftId: D,
113
- ...c !== null ? { pftId: c } : {}
114
- }
115
- })
116
- },
117
- clientSessionId: n
118
- }), a = s, p = J(y, a, o), m = F(a);
119
- let u;
120
- e.transport && (u = E(s, {
121
- onEnvelope: (r) => {
122
- e.transport.enqueue(r);
123
- }
124
- }));
125
- let g, f = !1;
126
- return {
127
- instrumentedSDK: p,
128
- app: s,
129
- trackEvent(r, i) {
130
- f || a.log(C, {
131
- eventName: r,
132
- properties: i ? JSON.stringify(i) : ""
133
- });
134
- },
135
- trackInteraction(r, i) {
136
- f || a.log(_, {
137
- elementId: r,
138
- properties: i ? JSON.stringify(i) : ""
139
- });
140
- },
141
- trackError(r, i) {
142
- f || a.error(r, k, {
143
- properties: i ? JSON.stringify(i) : ""
144
- });
145
- },
146
- trackPageView(r) {
147
- f || r !== g && (g = r, a.log(v, { componentRef: r }));
148
- },
149
- setPftId(r) {
150
- f || A(r) && (c = r);
151
- },
152
- dispose() {
153
- if (f) return;
154
- f = !0, m();
155
- const r = Date.now() - d;
156
- a.log(S, { durationMs: r }), u?.dispose();
157
- }
158
- };
159
- }
160
- export {
161
- D as A,
162
- j as P,
163
- q as c,
164
- A as v
165
- };