@salesforce/platform-sdk 10.18.2 → 10.18.3

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.
@@ -1,4 +1,4 @@
1
- import { A as s, I as A, P as E, c as t, v as I } from "../analytics-BVtlA4LT.js";
1
+ import { A as s, I as A, P as E, c as t, v as I } from "../analytics-Cgt83u0I.js";
2
2
  export {
3
3
  s as AXL_PFT_ID,
4
4
  A as INTERNAL_SESSION_META_KEY,
@@ -1 +1 @@
1
- {"version":3,"file":"method-configs.d.ts","sourceRoot":"","sources":["../../src/analytics/method-configs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,yEAAyE;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,WAAW,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1E;AAMD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAkCtD,CAAC"}
1
+ {"version":3,"file":"method-configs.d.ts","sourceRoot":"","sources":["../../src/analytics/method-configs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,yEAAyE;IACzE,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,WAAW,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1E;AAMD,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAoCtD,CAAC"}
@@ -0,0 +1,146 @@
1
+ import { registerInstrumentedApp as h } from "o11y/client";
2
+ import { g as A } from "./surface-DX5JCZPQ.js";
3
+ import { getChatSDK as T } from "./chat/index.js";
4
+ import { r as x } from "./TelemetryUploader-DKkdppe9.js";
5
+ import { analyticsContextSchema as v, sessionSchema as _, pageViewSchema as C, errorContextSchema as k, interactionSchema as L, customEventSchema as N } from "o11y_schema/sf_mcpanalytics";
6
+ function F(e) {
7
+ const r = (n, c, m, o, l) => {
8
+ e.error(l ?? n);
9
+ }, a = (n) => {
10
+ e.error(n.reason);
11
+ };
12
+ return window.addEventListener("error", r), window.addEventListener("unhandledrejection", a), () => {
13
+ window.removeEventListener("error", r), window.removeEventListener("unhandledrejection", a);
14
+ };
15
+ }
16
+ const D = "aJC", V = "sfdc.pftId", b = "sfdc.internalSession", O = "aJCEE000000FgYP4A0", w = /* @__PURE__ */ new Set(), J = /^aJC[0-9A-Za-z]{12}(?:[0-9A-Za-z]{3})?$/;
17
+ function E(e) {
18
+ return typeof e != "string" || e.length === 0 ? !1 : e.length !== 15 && e.length !== 18 ? (S(e, "Expected a 15- or 18-character Salesforce ID"), !1) : J.test(e) ? !0 : (S(e, `Expected a Product Feature Id (prefix "${D}", base62).`), !1);
19
+ }
20
+ function S(e, r) {
21
+ w.has(e) || (w.add(e), console.debug(`[platform-sdk:analytics] Ignoring invalid PFT Id "${e}". ${r}`));
22
+ }
23
+ function p(e, r) {
24
+ return { surface: r };
25
+ }
26
+ const K = {
27
+ callTool: {
28
+ isAsync: !0,
29
+ extractTags: (e, r) => ({ toolName: e[0]?.toolName ?? "unknown", surface: r })
30
+ },
31
+ setWidgetState: {
32
+ isAsync: !1,
33
+ extractTags: p
34
+ },
35
+ sendMessageToHost: {
36
+ isAsync: !0,
37
+ extractTags: p
38
+ },
39
+ openLink: {
40
+ isAsync: !0,
41
+ extractTags: p
42
+ },
43
+ readResource: {
44
+ isAsync: !0,
45
+ extractTags: (e, r) => {
46
+ const n = e[0]?.uri ?? "", c = n.indexOf("://");
47
+ return { scheme: c > 0 ? n.slice(0, c).toLowerCase() : "unknown", surface: r };
48
+ }
49
+ },
50
+ setDisplayMode: {
51
+ isAsync: !0,
52
+ extractTags: (e, r) => ({ mode: e[0] ?? "unknown", surface: r })
53
+ }
54
+ };
55
+ function M(e, r, a) {
56
+ return new Proxy(e, {
57
+ get(n, c, m) {
58
+ const o = Reflect.get(n, c, m), l = K[c];
59
+ return !l || typeof o != "function" ? o : (...d) => {
60
+ const f = l.extractTags(d, a), s = `sdk.${String(c)}`;
61
+ return l.isAsync ? r.activityAsync(s, async () => {
62
+ try {
63
+ const g = await o.apply(n, d);
64
+ return r.incrementCounter(s, 1, !1, f), g;
65
+ } catch (g) {
66
+ throw r.incrementCounter(s, 1, !0, f), g;
67
+ }
68
+ }) : (r.incrementCounter(s, 1, !1, f), o.apply(n, d));
69
+ };
70
+ }
71
+ });
72
+ }
73
+ async function z(e) {
74
+ const { appId: r, clientSessionId: a } = e, n = A(), c = Date.now(), m = e.sdk ?? await T();
75
+ let o = null;
76
+ e.pftId !== void 0 && E(e.pftId) && (o = e.pftId);
77
+ const l = e.enforceInternalGate === !0;
78
+ let d = !1;
79
+ const f = h("mcp-widget", {
80
+ appPayloadProvider: {
81
+ getPayload: () => {
82
+ const t = !l || d;
83
+ return {
84
+ schema: v,
85
+ payload: {
86
+ appId: r,
87
+ surface: n,
88
+ ...t ? { axlPftId: O } : {},
89
+ ...t && o !== null ? { pftId: o } : {}
90
+ }
91
+ };
92
+ }
93
+ },
94
+ clientSessionId: a
95
+ }), s = f, g = M(m, s, n), P = F(s);
96
+ let y;
97
+ e.transport && (y = x(f, {
98
+ onEnvelope: (t) => {
99
+ e.transport.enqueue(t);
100
+ }
101
+ }));
102
+ let I, i = !1;
103
+ return {
104
+ instrumentedSDK: g,
105
+ app: f,
106
+ trackEvent(t, u) {
107
+ i || s.log(N, {
108
+ eventName: t,
109
+ properties: u ? JSON.stringify(u) : ""
110
+ });
111
+ },
112
+ trackInteraction(t, u) {
113
+ i || s.log(L, {
114
+ elementId: t,
115
+ properties: u ? JSON.stringify(u) : ""
116
+ });
117
+ },
118
+ trackError(t, u) {
119
+ i || s.error(t, k, {
120
+ properties: u ? JSON.stringify(u) : ""
121
+ });
122
+ },
123
+ trackPageView(t) {
124
+ i || t !== I && (I = t, s.log(C, { componentRef: t }));
125
+ },
126
+ setPftId(t) {
127
+ i || E(t) && (o = t);
128
+ },
129
+ setInternalSession(t) {
130
+ i || (d = t === !0);
131
+ },
132
+ dispose() {
133
+ if (i) return;
134
+ i = !0, P();
135
+ const t = Date.now() - c;
136
+ s.log(_, { durationMs: t }), y?.dispose();
137
+ }
138
+ };
139
+ }
140
+ export {
141
+ O as A,
142
+ b as I,
143
+ V as P,
144
+ z as c,
145
+ E as v
146
+ };
@@ -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.18.2", de = (t) => {
199
+ const ce = "X-SFDC-Client-Name", ue = "X-SFDC-Client-Version", he = "@salesforce/platform-sdk", le = "10.18.3", 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.js CHANGED
@@ -8,7 +8,7 @@ import { createDataSDK as _, gql as d } from "./data/index.js";
8
8
  import { createLightningSDK as y } from "./lightning/index.js";
9
9
  import { c as M } from "./transport-CdXFRgRc.js";
10
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-BVtlA4LT.js";
11
+ import { A as b, I as v, P as F, c as U, v as Y } from "./analytics-Cgt83u0I.js";
12
12
  export {
13
13
  b as AXL_PFT_ID,
14
14
  v as INTERNAL_SESSION_META_KEY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/platform-sdk",
3
- "version": "10.18.2",
3
+ "version": "10.18.3",
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.18.2",
110
+ "@salesforce/jsonrpc": "^10.18.3",
111
111
  "@sf-embedding/sf-embedding-bridge": "2.2.1-rc.4"
112
112
  },
113
113
  "peerDependencies": {
@@ -1,143 +0,0 @@
1
- import { registerInstrumentedApp as A } from "o11y/client";
2
- import { g as T } from "./surface-DX5JCZPQ.js";
3
- import { getChatSDK as h } from "./chat/index.js";
4
- import { r as v } from "./TelemetryUploader-DKkdppe9.js";
5
- import { analyticsContextSchema as x, sessionSchema as _, pageViewSchema as C, errorContextSchema as k, interactionSchema as N, customEventSchema as F } from "o11y_schema/sf_mcpanalytics";
6
- function L(e) {
7
- const r = (s, f, m, o, u) => {
8
- e.error(u ?? s);
9
- }, a = (s) => {
10
- e.error(s.reason);
11
- };
12
- return window.addEventListener("error", r), window.addEventListener("unhandledrejection", a), () => {
13
- window.removeEventListener("error", r), window.removeEventListener("unhandledrejection", a);
14
- };
15
- }
16
- const D = "aJC", V = "sfdc.pftId", b = "sfdc.internalSession", J = "aJCEE000000FgYP4A0", w = /* @__PURE__ */ new Set(), O = /^aJC[0-9A-Za-z]{12}(?:[0-9A-Za-z]{3})?$/;
17
- function E(e) {
18
- return typeof e != "string" || e.length === 0 ? !1 : e.length !== 15 && e.length !== 18 ? (S(e, "Expected a 15- or 18-character Salesforce ID"), !1) : O.test(e) ? !0 : (S(e, `Expected a Product Feature Id (prefix "${D}", base62).`), !1);
19
- }
20
- function S(e, r) {
21
- w.has(e) || (w.add(e), console.debug(`[platform-sdk:analytics] Ignoring invalid PFT Id "${e}". ${r}`));
22
- }
23
- function p(e, r) {
24
- return { surface: r };
25
- }
26
- const K = {
27
- callTool: {
28
- isAsync: !0,
29
- extractTags: (e, r) => ({ toolName: e[0]?.toolName ?? "unknown", surface: r })
30
- },
31
- setWidgetState: {
32
- isAsync: !1,
33
- extractTags: p
34
- },
35
- sendMessageToHost: {
36
- isAsync: !0,
37
- extractTags: p
38
- },
39
- openLink: {
40
- isAsync: !0,
41
- extractTags: p
42
- },
43
- readResource: {
44
- isAsync: !0,
45
- extractTags: (e, r) => ({ uri: e[0]?.uri ?? "unknown", surface: r })
46
- },
47
- setDisplayMode: {
48
- isAsync: !0,
49
- extractTags: (e, r) => ({ mode: e[0] ?? "unknown", surface: r })
50
- }
51
- };
52
- function M(e, r, a) {
53
- return new Proxy(e, {
54
- get(s, f, m) {
55
- const o = Reflect.get(s, f, m), u = K[f];
56
- return !u || typeof o != "function" ? o : (...d) => {
57
- const l = u.extractTags(d, a), n = `sdk.${String(f)}`;
58
- return u.isAsync ? r.activityAsync(n, async () => {
59
- try {
60
- const g = await o.apply(s, d);
61
- return r.incrementCounter(n, 1, !1, l), g;
62
- } catch (g) {
63
- throw r.incrementCounter(n, 1, !0, l), g;
64
- }
65
- }) : (r.incrementCounter(n, 1, !1, l), o.apply(s, d));
66
- };
67
- }
68
- });
69
- }
70
- async function z(e) {
71
- const { appId: r, clientSessionId: a } = e, s = T(), f = Date.now(), m = e.sdk ?? await h();
72
- let o = null;
73
- e.pftId !== void 0 && E(e.pftId) && (o = e.pftId);
74
- const u = e.enforceInternalGate === !0;
75
- let d = !1;
76
- const l = A("mcp-widget", {
77
- appPayloadProvider: {
78
- getPayload: () => {
79
- const t = !u || d;
80
- return {
81
- schema: x,
82
- payload: {
83
- appId: r,
84
- surface: s,
85
- ...t ? { axlPftId: J } : {},
86
- ...t && o !== null ? { pftId: o } : {}
87
- }
88
- };
89
- }
90
- },
91
- clientSessionId: a
92
- }), n = l, g = M(m, n, s), P = L(n);
93
- let y;
94
- e.transport && (y = v(l, {
95
- onEnvelope: (t) => {
96
- e.transport.enqueue(t);
97
- }
98
- }));
99
- let I, c = !1;
100
- return {
101
- instrumentedSDK: g,
102
- app: l,
103
- trackEvent(t, i) {
104
- c || n.log(F, {
105
- eventName: t,
106
- properties: i ? JSON.stringify(i) : ""
107
- });
108
- },
109
- trackInteraction(t, i) {
110
- c || n.log(N, {
111
- elementId: t,
112
- properties: i ? JSON.stringify(i) : ""
113
- });
114
- },
115
- trackError(t, i) {
116
- c || n.error(t, k, {
117
- properties: i ? JSON.stringify(i) : ""
118
- });
119
- },
120
- trackPageView(t) {
121
- c || t !== I && (I = t, n.log(C, { componentRef: t }));
122
- },
123
- setPftId(t) {
124
- c || E(t) && (o = t);
125
- },
126
- setInternalSession(t) {
127
- c || (d = t === !0);
128
- },
129
- dispose() {
130
- if (c) return;
131
- c = !0, P();
132
- const t = Date.now() - f;
133
- n.log(_, { durationMs: t }), y?.dispose();
134
- }
135
- };
136
- }
137
- export {
138
- J as A,
139
- b as I,
140
- V as P,
141
- z as c,
142
- E as v
143
- };