@upstep/js 0.7.1 → 0.8.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/README.md +4 -2
- package/dist/api-BdOCiCLM.js +1 -0
- package/dist/{api-DSXEYv9R.mjs → api-ZTIiZxlg.mjs} +42 -21
- package/dist/api.d.ts +17 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +23 -15
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +175 -60
- package/dist/react.cjs +1 -1
- package/dist/react.js +1 -1
- package/dist/support.cjs +1 -1
- package/dist/support.d.ts +31 -0
- package/dist/support.d.ts.map +1 -1
- package/dist/support.js +136 -48
- package/dist/upstep.global.js +12 -4
- package/dist/widget.d.ts +20 -0
- package/dist/widget.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/api-ZqVkOuh0.js +0 -1
package/dist/support.js
CHANGED
|
@@ -1,55 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
function d(a, t) {
|
|
2
|
+
if (t === null) return [];
|
|
3
|
+
const e = a.filter((n) => n.role !== "SYSTEM"), s = e.findIndex((n) => n.id === t);
|
|
4
|
+
return s < 0 ? [] : e.slice(s + 1).filter((n) => n.role !== "CUSTOMER");
|
|
5
|
+
}
|
|
6
|
+
function y(a, t = 120) {
|
|
7
|
+
const e = a.replace(/\s+/g, " ").trim();
|
|
8
|
+
return e.length > t ? `${e.slice(0, t - 1).trimEnd()}…` : e;
|
|
9
|
+
}
|
|
10
|
+
class c extends Error {
|
|
11
|
+
constructor(t, e) {
|
|
12
|
+
super(t), this.status = e;
|
|
4
13
|
}
|
|
5
14
|
}
|
|
6
|
-
function
|
|
15
|
+
function u() {
|
|
7
16
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a) => {
|
|
8
17
|
const t = Math.floor(Math.random() * 16);
|
|
9
18
|
return (a === "x" ? t : t & 3 | 8).toString(16);
|
|
10
19
|
});
|
|
11
20
|
}
|
|
12
|
-
class
|
|
13
|
-
constructor(t,
|
|
14
|
-
this.storage =
|
|
21
|
+
class p {
|
|
22
|
+
constructor(t, e, s = fetch) {
|
|
23
|
+
this.storage = e, this.transport = s, this.token = null, this.session = null, this.epoch = 0, this.baseUrl = (t.baseUrl || "https://upstep.dev").replace(/\/$/, ""), this.key = t.apiKey, this.identityToken = t.supportIdentityToken, this.storageKey = `upstep:support:${this.baseUrl}:${this.key}`, this.seenKey = `upstep:support-seen:${this.baseUrl}:${this.key}`, this.soundKey = `upstep:support-sound:${this.baseUrl}:${this.key}`;
|
|
15
24
|
}
|
|
16
25
|
async identify(t) {
|
|
17
|
-
var
|
|
18
|
-
t !== this.identityToken && (this.epoch++, this.identityToken = t, this.token = null, this.session = null, await ((
|
|
26
|
+
var e;
|
|
27
|
+
t !== this.identityToken && (this.epoch++, this.identityToken = t, this.token = null, this.session = null, await ((e = this.storage) == null ? void 0 : e.removeItem(this.storageKey).catch(() => {
|
|
19
28
|
})));
|
|
20
29
|
}
|
|
21
|
-
async request(t,
|
|
22
|
-
var
|
|
23
|
-
const
|
|
30
|
+
async request(t, e) {
|
|
31
|
+
var i;
|
|
32
|
+
const s = new AbortController(), n = setTimeout(() => s.abort(), 2e4);
|
|
24
33
|
try {
|
|
25
|
-
const
|
|
26
|
-
method:
|
|
34
|
+
const o = await this.transport(`${this.baseUrl}/api/sdk/support${t}`, {
|
|
35
|
+
method: e === void 0 ? "GET" : "POST",
|
|
27
36
|
headers: {
|
|
28
37
|
"Content-Type": "application/json",
|
|
29
38
|
"x-api-key": this.key,
|
|
30
39
|
...this.token ? { Authorization: `Bearer ${this.token}` } : {}
|
|
31
40
|
},
|
|
32
|
-
...
|
|
41
|
+
...e === void 0 ? {} : { body: JSON.stringify(e) },
|
|
33
42
|
credentials: "omit",
|
|
34
43
|
redirect: "error",
|
|
35
|
-
signal:
|
|
36
|
-
}),
|
|
37
|
-
if (!
|
|
38
|
-
throw
|
|
39
|
-
}))), new
|
|
40
|
-
typeof
|
|
41
|
-
|
|
44
|
+
signal: s.signal
|
|
45
|
+
}), r = await o.json();
|
|
46
|
+
if (!o.ok)
|
|
47
|
+
throw o.status === 401 && t && (this.token = null, await ((i = this.storage) == null ? void 0 : i.removeItem(this.storageKey).catch(() => {
|
|
48
|
+
}))), new c(
|
|
49
|
+
typeof r.error == "string" ? r.error : "Could not connect to support.",
|
|
50
|
+
o.status
|
|
42
51
|
);
|
|
43
|
-
return
|
|
52
|
+
return r;
|
|
44
53
|
} finally {
|
|
45
|
-
clearTimeout(
|
|
54
|
+
clearTimeout(n);
|
|
46
55
|
}
|
|
47
56
|
}
|
|
48
57
|
async configuration() {
|
|
49
58
|
try {
|
|
50
59
|
return await this.request("");
|
|
51
60
|
} catch (t) {
|
|
52
|
-
if (t instanceof
|
|
61
|
+
if (t instanceof c && [402, 404].includes(t.status))
|
|
53
62
|
return null;
|
|
54
63
|
throw t;
|
|
55
64
|
}
|
|
@@ -57,28 +66,28 @@ class u {
|
|
|
57
66
|
async ensureSession() {
|
|
58
67
|
if (!this.token) {
|
|
59
68
|
if (!this.session) {
|
|
60
|
-
const t = this.epoch,
|
|
61
|
-
var
|
|
62
|
-
if (!
|
|
69
|
+
const t = this.epoch, e = this.identityToken, s = (async () => {
|
|
70
|
+
var i, o;
|
|
71
|
+
if (!e)
|
|
63
72
|
try {
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
this.token =
|
|
73
|
+
const r = await ((i = this.storage) == null ? void 0 : i.getItem(this.storageKey));
|
|
74
|
+
if (r && t === this.epoch) {
|
|
75
|
+
this.token = r;
|
|
67
76
|
return;
|
|
68
77
|
}
|
|
69
78
|
} catch {
|
|
70
79
|
}
|
|
71
80
|
if (t !== this.epoch) throw new Error("Customer identity changed.");
|
|
72
|
-
const
|
|
81
|
+
const n = await this.request(
|
|
73
82
|
"",
|
|
74
|
-
|
|
83
|
+
e ? { identityToken: e } : {}
|
|
75
84
|
);
|
|
76
85
|
if (t !== this.epoch) throw new Error("Customer identity changed.");
|
|
77
|
-
this.token =
|
|
86
|
+
this.token = n.token, e || await ((o = this.storage) == null ? void 0 : o.setItem(this.storageKey, n.token).catch(() => {
|
|
78
87
|
}));
|
|
79
88
|
})();
|
|
80
|
-
this.session =
|
|
81
|
-
this.session ===
|
|
89
|
+
this.session = s, s.finally(() => {
|
|
90
|
+
this.session === s && (this.session = null);
|
|
82
91
|
}).catch(() => {
|
|
83
92
|
});
|
|
84
93
|
}
|
|
@@ -98,30 +107,109 @@ class u {
|
|
|
98
107
|
`/conversations/${encodeURIComponent(t)}`
|
|
99
108
|
);
|
|
100
109
|
}
|
|
101
|
-
async send(t,
|
|
110
|
+
async send(t, e, s = u()) {
|
|
102
111
|
await this.ensureSession(), await this.request(`/conversations/${encodeURIComponent(t)}`, {
|
|
103
112
|
action: "message",
|
|
104
|
-
content:
|
|
105
|
-
clientMessageId:
|
|
113
|
+
content: e,
|
|
114
|
+
clientMessageId: s
|
|
106
115
|
});
|
|
107
116
|
}
|
|
108
|
-
async details(t,
|
|
117
|
+
async details(t, e) {
|
|
109
118
|
await this.ensureSession(), await this.request(`/conversations/${encodeURIComponent(t)}`, {
|
|
110
119
|
action: "details",
|
|
111
|
-
...
|
|
112
|
-
clientMessageId:
|
|
120
|
+
...e,
|
|
121
|
+
clientMessageId: e.clientMessageId || u()
|
|
113
122
|
});
|
|
114
123
|
}
|
|
115
|
-
async handoff(t,
|
|
124
|
+
async handoff(t, e, s) {
|
|
116
125
|
await this.ensureSession(), await this.request(`/conversations/${encodeURIComponent(t)}`, {
|
|
117
126
|
action: "handoff",
|
|
118
|
-
name:
|
|
119
|
-
email:
|
|
127
|
+
name: e,
|
|
128
|
+
email: s
|
|
120
129
|
});
|
|
121
130
|
}
|
|
131
|
+
/** True when this customer already has a support session, so checking for replies creates nothing new. */
|
|
132
|
+
async hasSession() {
|
|
133
|
+
var t;
|
|
134
|
+
if (this.token || this.identityToken) return !0;
|
|
135
|
+
try {
|
|
136
|
+
return !!await ((t = this.storage) == null ? void 0 : t.getItem(this.storageKey));
|
|
137
|
+
} catch {
|
|
138
|
+
return !1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** The last message the customer has read in a conversation, if one was recorded. */
|
|
142
|
+
async seenId(t) {
|
|
143
|
+
var e;
|
|
144
|
+
try {
|
|
145
|
+
const s = JSON.parse(
|
|
146
|
+
await ((e = this.storage) == null ? void 0 : e.getItem(this.seenKey)) || "null"
|
|
147
|
+
);
|
|
148
|
+
return (s == null ? void 0 : s.chat) === t ? s.id : null;
|
|
149
|
+
} catch {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** Record that the customer has read everything in this conversation. */
|
|
154
|
+
async markSeen(t) {
|
|
155
|
+
var n;
|
|
156
|
+
const e = t.messages.filter((i) => i.role !== "SYSTEM").at(-1);
|
|
157
|
+
if (!e) return;
|
|
158
|
+
const s = { chat: t.id, id: e.id };
|
|
159
|
+
await ((n = this.storage) == null ? void 0 : n.setItem(this.seenKey, JSON.stringify(s)).catch(() => {
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Unread AI or team messages in the latest conversation. A conversation with
|
|
164
|
+
* no saved record counts as read, so returning customers never see a stale count.
|
|
165
|
+
*/
|
|
166
|
+
async unread() {
|
|
167
|
+
var h;
|
|
168
|
+
const t = { count: 0, chatId: null };
|
|
169
|
+
if (!await this.hasSession()) return t;
|
|
170
|
+
const e = (await this.conversations())[0];
|
|
171
|
+
if (!e) return t;
|
|
172
|
+
const s = await this.conversation(e.id);
|
|
173
|
+
if (!s.messages.filter((l) => l.role !== "SYSTEM").at(-1)) return { count: 0, chatId: s.id };
|
|
174
|
+
let i = null;
|
|
175
|
+
try {
|
|
176
|
+
i = JSON.parse(await ((h = this.storage) == null ? void 0 : h.getItem(this.seenKey)) || "null");
|
|
177
|
+
} catch {
|
|
178
|
+
i = null;
|
|
179
|
+
}
|
|
180
|
+
if ((i == null ? void 0 : i.chat) !== s.id)
|
|
181
|
+
return await this.markSeen(s), { count: 0, chatId: s.id };
|
|
182
|
+
const o = d(s.messages, i.id), r = o.at(-1);
|
|
183
|
+
return {
|
|
184
|
+
count: o.length,
|
|
185
|
+
chatId: s.id,
|
|
186
|
+
...r ? {
|
|
187
|
+
latest: {
|
|
188
|
+
author: r.role === "ASSISTANT" ? "AI" : r.authorName,
|
|
189
|
+
role: r.role,
|
|
190
|
+
preview: y(r.content)
|
|
191
|
+
}
|
|
192
|
+
} : {}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
async soundEnabled() {
|
|
196
|
+
var t;
|
|
197
|
+
try {
|
|
198
|
+
return await ((t = this.storage) == null ? void 0 : t.getItem(this.soundKey)) !== "off";
|
|
199
|
+
} catch {
|
|
200
|
+
return !0;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async setSoundEnabled(t) {
|
|
204
|
+
var e;
|
|
205
|
+
await ((e = this.storage) == null ? void 0 : e.setItem(this.soundKey, t ? "on" : "off").catch(() => {
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
122
208
|
}
|
|
123
209
|
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
210
|
+
c as SupportApiError,
|
|
211
|
+
p as SupportClient,
|
|
212
|
+
u as supportMessageId,
|
|
213
|
+
y as supportPreview,
|
|
214
|
+
d as unreadSupportMessages
|
|
127
215
|
};
|
package/dist/upstep.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){"use strict";const
|
|
1
|
+
(function(){"use strict";const u="upstep-anonymous-id";function x(){const s=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return s;try{const e=window.localStorage.getItem(u);return e||(window.localStorage.setItem(u,s),s)}catch{return s}}class g{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=e.apiKey,this.supportIdentityToken=e.supportIdentityToken,this.chat=e.chat!==!1,e.userId!==void 0&&(this.userId=e.userId),this.anonymousId=x()}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const e=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return e.ok&&(await e.json()).enabled===!0}catch{return!1}}supportFrameUrl(e,t="#D97757"){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}&accent=${encodeURIComponent(t)}`}connectSupportFrame(e,t={}){const o=new URL(this.baseUrl).origin,i=()=>{var a;return(a=e.contentWindow)==null?void 0:a.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken,accentColor:getComputedStyle(e).color,...t.isVisible?{visible:t.isVisible()}:{}},o)},n=a=>{if(a.origin!==o||a.source!==e.contentWindow)return;const r=a.data;if((r==null?void 0:r.type)==="upstep:support:ready")i();else if((r==null?void 0:r.type)==="upstep:support:unread"&&t.onUnread){const m=Number(r.count);t.onUnread({count:Number.isFinite(m)?Math.max(0,Math.floor(m)):0,newMessage:r.newMessage===!0,author:String(r.author??"").slice(0,80),preview:String(r.preview??"").slice(0,200),sound:r.sound!==!1})}};return e.addEventListener("load",i),window.addEventListener("message",n),()=>{e.removeEventListener("load",i),window.removeEventListener("message",n)}}notifySupportVisibility(e,t){var o;(o=e.contentWindow)==null||o.postMessage({type:"upstep:support:visible",visible:t},new URL(this.baseUrl).origin)}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId,anonymousId:e.anonymousId??this.anonymousId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId,anonymousId:this.anonymousId})});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`);return o.json()}async removeVote(e){if(!this.userId&&!this.anonymousId)return;const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const o=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,{method:"DELETE",headers:this.headers()});if(!o.ok)throw new Error(`Upstep: ${o.status}`)}}const y="#D97757",l={bg:"#ffffff",bgSoft:"#f5f5f5",bgHover:"#ededed",text:"#1a1915",textSoft:"#56544d",textFaint:"#9b9890",border:"#e8e6df",overlay:"rgba(26,25,21,.45)"},c={bg:"#000000",bgSoft:"#171717",bgHover:"#262626",text:"#f5f4f0",textSoft:"#b4b1a8",textFaint:"#7d7a72",border:"#33312c",overlay:"rgba(0,0,0,.6)"};function h(s){if(s==="light"||s==="dark")return s;if(typeof document<"u"){const e=document.documentElement;return e.classList.contains("dark")||e.getAttribute("data-theme")==="dark"?"dark":"light"}return typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function k(s,e,t){return`
|
|
2
2
|
#upstep-root *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}
|
|
3
3
|
#upstep-btn{position:fixed;bottom:24px;right:24px;left:auto;z-index:9998;display:inline-flex;align-items:center;gap:7px;background:${s};color:#fff;border:none;border-radius:9999px;padding:12px 18px;font-size:14px;font-weight:600;cursor:pointer;box-shadow:0 6px 20px rgba(26,25,21,.18);transition:transform .15s,box-shadow .15s}
|
|
4
4
|
#upstep-btn svg{width:16px;height:16px;flex-shrink:0}
|
|
@@ -46,16 +46,24 @@
|
|
|
46
46
|
.upstep-badge-feature{background:#e9f0fd;color:#3b76d6}
|
|
47
47
|
.upstep-badge-general{background:${t.bgSoft};color:${t.textSoft}}
|
|
48
48
|
.upstep-feedback-date{font-size:11px;color:${t.textFaint}}
|
|
49
|
+
#upstep-btn{position:fixed}
|
|
50
|
+
.upstep-unread{position:absolute;top:-7px;right:-5px;min-width:22px;height:22px;padding:0 6px;border-radius:11px;background:${t.text};color:${t.bg};border:2px solid ${t.bg};font-size:12px;font-weight:700;line-height:18px;text-align:center;font-variant-numeric:tabular-nums;animation:upstep-pop .45s cubic-bezier(.3,1.6,.5,1)}
|
|
51
|
+
@keyframes upstep-pop{from{transform:scale(.4)}to{transform:scale(1)}}
|
|
52
|
+
#upstep-toast{position:fixed;bottom:84px;right:24px;z-index:9998;max-width:min(300px,calc(100vw - 48px));display:grid;gap:2px;text-align:left;background:${t.bg};color:${t.text};border:1px solid ${t.border};border-radius:14px 14px 4px 14px;padding:10px 12px;box-shadow:0 10px 32px rgba(0,0,0,.2);cursor:pointer;animation:upstep-rise .26s cubic-bezier(.16,1,.3,1)}
|
|
53
|
+
#upstep-toast b{font-size:12px}
|
|
54
|
+
#upstep-toast span{font-size:14px;line-height:1.4;color:${t.textSoft};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
55
|
+
#upstep-toast em{font-style:normal;font-size:11px;font-weight:600;color:${s}}
|
|
56
|
+
@media(prefers-reduced-motion:reduce){.upstep-unread,#upstep-toast{animation:none}}
|
|
49
57
|
.upstep-empty{text-align:center;color:${t.textFaint};font-size:14px;padding:40px 0}
|
|
50
58
|
.upstep-empty strong{display:block;color:${t.textSoft};font-size:15px;margin-bottom:4px}
|
|
51
|
-
`}const
|
|
59
|
+
`}const v='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';class w{constructor(e,t={}){this.isOpen=!1,this.tab="submit",this.feedItems=[],this.selectedType="GENERAL",this.loading=!1,this.hasSupport=!1,this.disconnectSupport=null,this.unread=0,this.audio=null,this.frameTheme=null,this.unreadListeners=new Set,this.client=e,this.accent=t.accentColor??y,this.position="right",this.showLauncher=t.launcher!==!1,this.themeMode=t.theme??"auto",this.palette=h(this.themeMode)==="dark"?c:l}mount(){this.injectStyles(),this.showLauncher&&this.renderButton(),this.client.supportEnabled().then(e=>{if(this.hasSupport=e,e){const t=document.querySelector("#upstep-btn span");t&&(t.textContent="Help & feedback"),this.isOpen?this.renderModal():this.hasOpenedSupport()&&this.preloadSupport()}})}openWidget(){this.openModal()}closeWidget(){this.closeModal()}isChatVisible(){return this.isOpen}onUnread(e){return this.unreadListeners.add(e),e(this.unread),()=>{this.unreadListeners.delete(e)}}injectStyles(){var t;(t=document.getElementById("upstep-styles"))==null||t.remove();const e=document.createElement("style");e.id="upstep-styles",e.textContent=k(this.accent,this.position,this.palette),document.head.appendChild(e)}renderButton(){const e=document.createElement("button");e.id="upstep-btn",e.setAttribute("aria-label","Open help and feedback"),e.innerHTML=`${v}<span>Feedback</span>`,e.addEventListener("click",()=>{this.openModal()}),document.body.appendChild(e)}supportFrame(){return document.querySelector("#upstep-support-frame")}get usedKey(){return`upstep:support-opened:${this.client.baseUrl}`}hasOpenedSupport(){try{return localStorage.getItem(this.usedKey)==="1"}catch{return!1}}preloadSupport(){this.tab="support",this.renderModal(!0)}openModal(){if(this.unlockAudio(),!this.isOpen&&this.hasSupport){this.tab="support";try{localStorage.setItem(this.usedKey,"1")}catch{}}const e=h(this.themeMode),t=document.getElementById("upstep-backdrop"),o=this.supportFrame();if(!this.isOpen&&t&&o&&t.style.display==="none"&&this.frameTheme===e){this.isOpen=!0,t.style.display="",this.client.notifySupportVisibility(o,!0),this.setUnread(0),this.fetchFeed();return}this.isOpen=!0,this.palette=e==="dark"?c:l,this.injectStyles(),this.fetchFeed(),this.renderModal(),this.setUnread(0)}closeModal(){var e,t;if(this.isOpen=!1,this.hasSupport){const o=this.supportFrame(),i=document.getElementById("upstep-backdrop");o&&i?(i.style.display="none",this.client.notifySupportVisibility(o,!1)):this.preloadSupport();return}(e=this.disconnectSupport)==null||e.call(this),this.disconnectSupport=null,(t=document.getElementById("upstep-backdrop"))==null||t.remove()}setUnread(e){this.unread=e;const t=document.getElementById("upstep-btn"),o=t==null?void 0:t.querySelector(".upstep-unread");if(t){if(e>0){const n=o??document.createElement("span");n.className="upstep-unread",n.textContent=e>9?"9+":String(e),o||t.appendChild(n)}else o==null||o.remove();t.setAttribute("aria-label",e>0?`Open help and feedback, ${e} unread ${e===1?"message":"messages"}`:"Open help and feedback")}const i=document.title.replace(/^\(\d+\)\s/,"");document.title=e>0?`(${e}) ${i}`:i,e===0&&this.hideToast(),this.unreadListeners.forEach(n=>n(e))}onSupportUnread(e){if(this.isOpen)return this.setUnread(0);this.setUnread(e.count),e.newMessage&&e.count>0&&(this.showToast(e),e.sound&&this.chime())}showToast(e){this.hideToast();const t=document.createElement("button");t.id="upstep-toast",t.type="button",t.setAttribute("role","status");const o=document.createElement("b");o.textContent=e.author||"New message";const i=document.createElement("span");i.textContent=e.preview;const n=document.createElement("em");n.textContent=e.count>1?`${e.count} new messages`:"Tap to reply",t.append(o,i,n),t.addEventListener("click",()=>this.openModal()),document.body.appendChild(t),this.toastTimer=setTimeout(()=>this.hideToast(),9e3)}hideToast(){var e;clearTimeout(this.toastTimer),(e=document.getElementById("upstep-toast"))==null||e.remove()}unlockAudio(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;this.audio=this.audio??new e,this.audio.state==="suspended"&&this.audio.resume()}catch{}}chime(){const e=this.audio;if(!e||e.state!=="running")return;const t=e.currentTime;for(const[o,i]of[[880,0],[1318,.12]]){const n=e.createOscillator(),a=e.createGain();n.type="sine",n.frequency.value=o,a.gain.setValueAtTime(1e-4,t+i),a.gain.exponentialRampToValueAtTime(.14,t+i+.02),a.gain.exponentialRampToValueAtTime(1e-4,t+i+.5),n.connect(a),a.connect(e.destination),n.start(t+i),n.stop(t+i+.55)}}async fetchFeed(){try{const e=await this.client.listFeedback({sort:"votes",limit:20});this.feedItems=e.items,this.renderFeedList()}catch{}}renderModal(e=!1){var i,n,a;(i=this.disconnectSupport)==null||i.call(this),this.disconnectSupport=null;const t=document.createElement("div");t.id="upstep-backdrop",t.addEventListener("click",r=>{r.target===t&&this.closeModal()}),t.innerHTML=`
|
|
52
60
|
<div id="upstep-modal" style="max-width:${this.hasSupport?"460px":"440px"}">
|
|
53
61
|
${this.hasSupport?`<div class="upstep-mode" style="display:flex;align-items:center;gap:14px;padding:10px 14px;border-bottom:1px solid ${this.palette.border}"><div id="upstep-tabs" style="margin:0;padding:0;background:transparent;flex:1"><button class="upstep-tab ${this.tab==="support"?"active":""}" data-tab="support">Support</button><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Ideas</button></div><button id="upstep-close" aria-label="Close" style="flex-shrink:0;background:transparent">✕</button></div>`:`<div id="upstep-header"><div><h2>Share your feedback</h2><p>Tell us what to build next, or vote on ideas.</p></div><button id="upstep-close" aria-label="Close">✕</button></div><div id="upstep-tabs"><button class="upstep-tab ${this.tab==="submit"?"active":""}" data-tab="submit">Give feedback</button><button class="upstep-tab ${this.tab==="feed"?"active":""}" data-tab="feed">Vote on ideas</button></div>`}
|
|
54
62
|
<div id="upstep-body" style="${this.tab==="support"?"padding:0;overflow:hidden":""}">
|
|
55
63
|
${this.tab==="support"?`<iframe id="upstep-support-frame" title="Customer support" src="${this.client.supportFrameUrl(this.palette.bg==="#000000"?"dark":"light",this.accent)}" style="width:100%;height:min(560px,calc(100dvh - 168px));min-height:300px;border:0;display:block"></iframe>`:this.tab==="submit"?this.renderSubmitForm():this.renderFeed()}
|
|
56
64
|
</div>
|
|
57
65
|
</div>
|
|
58
|
-
`,(
|
|
66
|
+
`,(n=document.getElementById("upstep-backdrop"))==null||n.remove(),e&&(t.style.display="none"),document.body.appendChild(t),(a=t.querySelector("#upstep-close"))==null||a.addEventListener("click",()=>this.closeModal()),t.querySelectorAll(".upstep-tab").forEach(r=>{r.addEventListener("click",()=>{this.tab=r.dataset.tab,this.renderModal()})});const o=t.querySelector("#upstep-support-frame");o&&(o.style.color=this.accent,this.frameTheme=this.palette.bg==="#000000"?"dark":"light",this.disconnectSupport=this.client.connectSupportFrame(o,{isVisible:()=>this.isOpen,onUnread:r=>this.onSupportUnread(r)})),this.bindSubmitForm(),this.bindVoteButtons()}renderSubmitForm(){const e=["BUG","FEATURE","GENERAL"],t={BUG:"Bug",FEATURE:"Feature",GENERAL:"General"},o={BUG:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><ellipse cx="8" cy="10" rx="3.5" ry="4.5"/><path d="M8 5.5V4M5.5 6.5 3.5 5M10.5 6.5 12.5 5M4.5 10.5 2.5 10M11.5 10.5 13.5 10"/></svg>',FEATURE:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.1 4.1l1 1M10.9 10.9l1 1M11.9 4.1l-1 1M5.1 10.9l-1 1"/><circle cx="8" cy="8" r="2.5"/></svg>',GENERAL:'<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14 9a2 2 0 0 1-2 2H5L2 14V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v5z"/></svg>'};return`
|
|
59
67
|
<div class="upstep-form">
|
|
60
68
|
<textarea id="upstep-textarea" placeholder="What's on your mind?" maxlength="2000"></textarea>
|
|
61
69
|
<div class="upstep-type-row">
|
|
@@ -78,4 +86,4 @@
|
|
|
78
86
|
<span class="upstep-feedback-date">${new Date(e.createdAt).toLocaleDateString()}</span>
|
|
79
87
|
</div>
|
|
80
88
|
</div>
|
|
81
|
-
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const n=t.value.trim();if(n){this.loading=!0,i&&(i.disabled=!0,i.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),t.value="",o&&(o.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,i&&(i.disabled=!1,i.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function b(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let
|
|
89
|
+
</div>`}).join(""):'<div class="upstep-empty"><strong>No ideas yet</strong>Be the first to share one.</div>'}renderFeedList(){const e=document.getElementById("upstep-body");!e||this.tab!=="feed"||(e.innerHTML=this.renderFeed(),this.bindVoteButtons())}bindSubmitForm(){var e;document.querySelectorAll(".upstep-type-btn").forEach(t=>{t.addEventListener("click",()=>{this.selectedType=t.dataset.type,document.querySelectorAll(".upstep-type-btn").forEach(o=>o.classList.remove("selected")),t.classList.add("selected")})}),(e=document.getElementById("upstep-submit-btn"))==null||e.addEventListener("click",async()=>{const t=document.getElementById("upstep-textarea"),o=document.getElementById("upstep-form-msg"),i=document.getElementById("upstep-submit-btn");if(!t||this.loading)return;const n=t.value.trim();if(n){this.loading=!0,i&&(i.disabled=!0,i.textContent="Sending…");try{await this.client.submitFeedback({content:n,type:this.selectedType}),t.value="",o&&(o.textContent="Feedback received. Thank you."),await this.fetchFeed()}catch{o&&(o.textContent="Something went wrong. Please try again.")}finally{this.loading=!1,i&&(i.disabled=!1,i.textContent="Send feedback")}}})}bindVoteButtons(){document.querySelectorAll(".upstep-vote").forEach(e=>{e.addEventListener("click",async()=>{const t=e.dataset.feedback;try{await this.client.vote(t,"UP"),await this.fetchFeed()}catch{}})})}}function b(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}let p=null,d=null;const f={init(s){if(p=new g(s),typeof window<"u"){const e={};s.accentColor!==void 0&&(e.accentColor=s.accentColor),s.position!==void 0&&(e.position=s.position),s.theme!==void 0&&(e.theme=s.theme),s.launcher!==void 0&&(e.launcher=s.launcher);const t=()=>{d=new w(p,e),d.mount()};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):t()}return p},open(){d==null||d.openWidget()},close(){d==null||d.closeWidget()},identify(s){p==null||p.setUserId(s)},identifySupport(s){var t;p&&(p.supportIdentityToken=s);const e=document.querySelector("#upstep-support-frame");e&&p&&((t=e.contentWindow)==null||t.postMessage({type:"upstep:support:identity",token:s,visible:(d==null?void 0:d.isChatVisible())??!0},new URL(p.baseUrl).origin))},onUnread(s){return(d==null?void 0:d.onUnread(s))??(()=>{})},get client(){if(!p)throw new Error("Upstep.init() must be called first");return p}};if(typeof document<"u"){const s=document.currentScript,e=s==null?void 0:s.dataset.apiKey,t=s==null?void 0:s.dataset.userId,o=s==null?void 0:s.dataset.baseUrl,i=s==null?void 0:s.dataset.accentColor,n=s==null?void 0:s.dataset.position,a=s==null?void 0:s.dataset.theme;if(e){const r={apiKey:e};t&&(r.userId=t),(s==null?void 0:s.dataset.chat)!==void 0&&(r.chat=s.dataset.chat!=="false"),o&&(r.baseUrl=o),i&&(r.accentColor=i),(n==="left"||n==="right")&&(r.position=n),(a==="light"||a==="dark"||a==="auto")&&(r.theme=a),f.init(r)}}window.Upstep=f})();
|
package/dist/widget.d.ts
CHANGED
|
@@ -22,16 +22,36 @@ export declare class UpstepWidget {
|
|
|
22
22
|
private palette;
|
|
23
23
|
private hasSupport;
|
|
24
24
|
private disconnectSupport;
|
|
25
|
+
private unread;
|
|
26
|
+
private toastTimer;
|
|
27
|
+
private audio;
|
|
28
|
+
private frameTheme;
|
|
29
|
+
private unreadListeners;
|
|
25
30
|
constructor(client: UpstepApiClient, options?: WidgetOptions);
|
|
26
31
|
mount(): void;
|
|
27
32
|
/** Open the feedback modal programmatically (e.g. from your own button). */
|
|
28
33
|
openWidget(): void;
|
|
29
34
|
/** Close the feedback modal programmatically. */
|
|
30
35
|
closeWidget(): void;
|
|
36
|
+
/** Whether the chat window is currently on screen. */
|
|
37
|
+
isChatVisible(): boolean;
|
|
38
|
+
/** Number of unread support messages. Subscribe to drive your own launcher or badge. */
|
|
39
|
+
onUnread(listener: (count: number) => void): () => void;
|
|
31
40
|
private injectStyles;
|
|
32
41
|
private renderButton;
|
|
42
|
+
private supportFrame;
|
|
43
|
+
private get usedKey();
|
|
44
|
+
private hasOpenedSupport;
|
|
45
|
+
private preloadSupport;
|
|
33
46
|
private openModal;
|
|
34
47
|
private closeModal;
|
|
48
|
+
private setUnread;
|
|
49
|
+
private onSupportUnread;
|
|
50
|
+
private showToast;
|
|
51
|
+
private hideToast;
|
|
52
|
+
/** Browsers only allow sound after a click, so prepare audio when the chat is first opened. */
|
|
53
|
+
private unlockAudio;
|
|
54
|
+
private chime;
|
|
35
55
|
private fetchFeed;
|
|
36
56
|
private renderModal;
|
|
37
57
|
private renderSubmitForm;
|
package/dist/widget.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAsB,MAAM,OAAO,CAAC;AAI5D,KAAK,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAoI3C,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAmB;IACnC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAA6B;IACtD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,KAAK,CAA6B;IAC1C,OAAO,CAAC,UAAU,CAAiC;IACnD,OAAO,CAAC,eAAe,CAAsC;gBAEjD,MAAM,EAAE,eAAe,EAAE,OAAO,GAAE,aAAkB;IAShE,KAAK;IAgBL,4EAA4E;IAC5E,UAAU;IAIV,iDAAiD;IACjD,WAAW;IAIX,sDAAsD;IACtD,aAAa;IAIb,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;IAQ1C,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,YAAY;IAIpB,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,SAAS;IAsCjB,OAAO,CAAC,UAAU;IAkBlB,OAAO,CAAC,SAAS;IAwBjB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,SAAS;IAKjB,+FAA+F;IAC/F,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,KAAK;YAsBC,SAAS;IAUvB,OAAO,CAAC,WAAW;IA+CnB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,cAAc;IAsDtB,OAAO,CAAC,eAAe;CAaxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upstep/js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "UpStep feedback, voting and AI support widgets for web apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://upstep.dev",
|
|
@@ -41,8 +41,13 @@
|
|
|
41
41
|
"files": [
|
|
42
42
|
"dist"
|
|
43
43
|
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "vite build && vite build --config vite.embed.config.ts",
|
|
46
|
+
"dev": "vite build --watch",
|
|
47
|
+
"type-check": "tsc --noEmit"
|
|
48
|
+
},
|
|
44
49
|
"dependencies": {
|
|
45
|
-
"@upstep/types": "
|
|
50
|
+
"@upstep/types": "workspace:*"
|
|
46
51
|
},
|
|
47
52
|
"peerDependencies": {
|
|
48
53
|
"react": ">=18",
|
|
@@ -64,10 +69,5 @@
|
|
|
64
69
|
"vite-plugin-dts": "^4.4.0"
|
|
65
70
|
},
|
|
66
71
|
"unpkg": "./dist/upstep.global.js",
|
|
67
|
-
"jsdelivr": "./dist/upstep.global.js"
|
|
68
|
-
|
|
69
|
-
"build": "vite build && vite build --config vite.embed.config.ts",
|
|
70
|
-
"dev": "vite build --watch",
|
|
71
|
-
"type-check": "tsc --noEmit"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
72
|
+
"jsdelivr": "./dist/upstep.global.js"
|
|
73
|
+
}
|
package/dist/api-ZqVkOuh0.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const d="upstep-anonymous-id";function h(){const o=typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;if(typeof window>"u")return o;try{const e=window.localStorage.getItem(d);return e||(window.localStorage.setItem(d,o),o)}catch{return o}}class u{constructor(e){this.baseUrl=(e.baseUrl??"https://upstep.dev").replace(/\/$/,""),this.apiKey=e.apiKey,this.supportIdentityToken=e.supportIdentityToken,this.chat=e.chat!==!1,e.userId!==void 0&&(this.userId=e.userId),this.anonymousId=h()}setUserId(e){this.userId=e}headers(){return{"Content-Type":"application/json","x-api-key":this.apiKey}}async supportEnabled(){if(!this.chat)return!1;try{const e=await fetch(`${this.baseUrl}/api/sdk/support`,{headers:this.headers()});return e.ok&&(await e.json()).enabled===!0}catch{return!1}}supportFrameUrl(e,t="#D97757"){return`${this.baseUrl}/support/${encodeURIComponent(this.apiKey)}?theme=${encodeURIComponent(e)}&accent=${encodeURIComponent(t)}`}connectSupportFrame(e){const t=new URL(this.baseUrl).origin,s=()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage({type:"upstep:support:identity",token:this.supportIdentityToken,accentColor:getComputedStyle(e).color},t)},i=n=>{var r;n.origin===t&&n.source===e.contentWindow&&((r=n.data)==null?void 0:r.type)==="upstep:support:ready"&&s()};return e.addEventListener("load",s),window.addEventListener("message",i),()=>{e.removeEventListener("load",s),window.removeEventListener("message",i)}}async listFeedback(e){const t=new URLSearchParams;e!=null&&e.cursor&&t.set("cursor",e.cursor),e!=null&&e.limit&&t.set("limit",String(e.limit)),e!=null&&e.type&&t.set("type",e.type),e!=null&&e.status&&t.set("status",e.status),e!=null&&e.sort&&t.set("sort",e.sort),this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async submitFeedback(e){const t=await fetch(`${this.baseUrl}/api/sdk/feedback`,{method:"POST",headers:this.headers(),body:JSON.stringify({...e,endUserId:e.endUserId??this.userId,anonymousId:e.anonymousId??this.anonymousId})});if(!t.ok)throw new Error(`Upstep: ${t.status}`);return t.json()}async vote(e,t){const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote`,{method:"POST",headers:this.headers(),body:JSON.stringify({value:t,endUserId:this.userId,anonymousId:this.anonymousId})});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}async getItem(e){const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}?${t}`,{headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`);return s.json()}async removeVote(e){if(!this.userId&&!this.anonymousId)return;const t=new URLSearchParams;this.userId&&t.set("endUserId",this.userId),this.anonymousId&&t.set("anonymousId",this.anonymousId);const s=await fetch(`${this.baseUrl}/api/sdk/feedback/${e}/vote?${t}`,{method:"DELETE",headers:this.headers()});if(!s.ok)throw new Error(`Upstep: ${s.status}`)}}exports.UpstepApiClient=u;
|