@triagly/sdk 1.4.0-beta.5 → 1.4.0-beta.6
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/dist/api.d.ts.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +75 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +75 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/ui.d.ts +10 -1
- package/dist/ui.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/screenshot.d.ts +0 -42
- package/dist/screenshot.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1083,6 +1083,7 @@
|
|
|
1083
1083
|
type="text"
|
|
1084
1084
|
id="triagly-name"
|
|
1085
1085
|
placeholder="Your name"
|
|
1086
|
+
${this.config.user?.name ? `value="${this.escapeHtml(this.config.user.name)}"` : ''}
|
|
1086
1087
|
/>
|
|
1087
1088
|
</div>
|
|
1088
1089
|
|
|
@@ -1092,9 +1093,16 @@
|
|
|
1092
1093
|
type="email"
|
|
1093
1094
|
id="triagly-email"
|
|
1094
1095
|
placeholder="your@email.com"
|
|
1096
|
+
${this.config.user?.email ? `value="${this.escapeHtml(this.config.user.email)}"` : ''}
|
|
1095
1097
|
/>
|
|
1096
1098
|
</div>
|
|
1097
1099
|
|
|
1100
|
+
${this.config.user?.email || this.config.user?.name ? `
|
|
1101
|
+
<div class="triagly-identified-user" id="triagly-identified-user">
|
|
1102
|
+
Submitting as ${this.escapeHtml(this.config.user.name || this.config.user.email || '')}
|
|
1103
|
+
</div>
|
|
1104
|
+
` : ''}
|
|
1105
|
+
|
|
1098
1106
|
${this.config.enableScreenshot ? `
|
|
1099
1107
|
<div class="triagly-field triagly-screenshot-field">
|
|
1100
1108
|
<label>Screenshot (optional)</label>
|
|
@@ -1394,9 +1402,13 @@
|
|
|
1394
1402
|
document.dispatchEvent(event);
|
|
1395
1403
|
// Wait for actual submission result
|
|
1396
1404
|
await submissionPromise;
|
|
1397
|
-
// Show success
|
|
1405
|
+
// Show success — personalize if we know the user's name
|
|
1398
1406
|
statusDiv.className = 'triagly-status triagly-success';
|
|
1399
|
-
|
|
1407
|
+
const userName = this.config.user?.name;
|
|
1408
|
+
const firstName = userName ? userName.split(' ')[0] : null;
|
|
1409
|
+
statusDiv.textContent = firstName
|
|
1410
|
+
? `Thanks, ${firstName}! Your feedback was received.`
|
|
1411
|
+
: (this.config.successMessage || 'Feedback sent successfully!');
|
|
1400
1412
|
// Close after delay
|
|
1401
1413
|
setTimeout(() => {
|
|
1402
1414
|
this.close();
|
|
@@ -1894,6 +1906,15 @@
|
|
|
1894
1906
|
.triagly-spin {
|
|
1895
1907
|
animation: triagly-spin 1s linear infinite;
|
|
1896
1908
|
}
|
|
1909
|
+
|
|
1910
|
+
.triagly-identified-user {
|
|
1911
|
+
font-size: 12px;
|
|
1912
|
+
color: var(--triagly-label-text, #6b7280);
|
|
1913
|
+
margin-bottom: 16px;
|
|
1914
|
+
padding: 6px 10px;
|
|
1915
|
+
background: var(--triagly-btn-secondary-bg, #f3f4f6);
|
|
1916
|
+
border-radius: 4px;
|
|
1917
|
+
}
|
|
1897
1918
|
`;
|
|
1898
1919
|
document.head.appendChild(style);
|
|
1899
1920
|
}
|
|
@@ -1959,6 +1980,44 @@
|
|
|
1959
1980
|
document.addEventListener('keydown', handleTab, true);
|
|
1960
1981
|
this.container._tabHandler = handleTab;
|
|
1961
1982
|
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Update the identified user. If the widget is currently open, updates
|
|
1985
|
+
* the live form fields and indicator. Otherwise stores for next open.
|
|
1986
|
+
*/
|
|
1987
|
+
updateUser(user) {
|
|
1988
|
+
this.config.user = { ...this.config.user, ...user };
|
|
1989
|
+
if (!this.isOpen || !this.container)
|
|
1990
|
+
return;
|
|
1991
|
+
const nameInput = this.container.querySelector('#triagly-name');
|
|
1992
|
+
const emailInput = this.container.querySelector('#triagly-email');
|
|
1993
|
+
const indicator = this.container.querySelector('#triagly-identified-user');
|
|
1994
|
+
if (nameInput && user.name !== undefined) {
|
|
1995
|
+
nameInput.value = user.name;
|
|
1996
|
+
}
|
|
1997
|
+
if (emailInput && user.email !== undefined) {
|
|
1998
|
+
emailInput.value = user.email;
|
|
1999
|
+
}
|
|
2000
|
+
const displayName = this.config.user?.name || this.config.user?.email;
|
|
2001
|
+
if (indicator) {
|
|
2002
|
+
if (displayName) {
|
|
2003
|
+
indicator.textContent = `Submitting as ${displayName}`;
|
|
2004
|
+
indicator.style.display = '';
|
|
2005
|
+
}
|
|
2006
|
+
else {
|
|
2007
|
+
indicator.style.display = 'none';
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Escape HTML special characters to prevent XSS when injecting into innerHTML
|
|
2013
|
+
*/
|
|
2014
|
+
escapeHtml(str) {
|
|
2015
|
+
return str
|
|
2016
|
+
.replace(/&/g, '&')
|
|
2017
|
+
.replace(/"/g, '"')
|
|
2018
|
+
.replace(/</g, '<')
|
|
2019
|
+
.replace(/>/g, '>');
|
|
2020
|
+
}
|
|
1962
2021
|
/**
|
|
1963
2022
|
* Destroy the widget
|
|
1964
2023
|
*/
|
|
@@ -2075,6 +2134,7 @@
|
|
|
2075
2134
|
tags: data.tags,
|
|
2076
2135
|
reporterEmail: data.reporterEmail,
|
|
2077
2136
|
reporterName: data.reporterName,
|
|
2137
|
+
reporterUserId: data.reporterUserId,
|
|
2078
2138
|
screenshot: data.screenshot,
|
|
2079
2139
|
turnstileToken,
|
|
2080
2140
|
hardenedToken,
|
|
@@ -2431,11 +2491,13 @@
|
|
|
2431
2491
|
}
|
|
2432
2492
|
// Collect metadata
|
|
2433
2493
|
const metadata = collectMetadata(this.config.metadata);
|
|
2434
|
-
// Prepare feedback data
|
|
2494
|
+
// Prepare feedback data, merging config.user as defaults
|
|
2435
2495
|
const feedbackData = {
|
|
2436
2496
|
title: data.title,
|
|
2437
2497
|
description: data.description,
|
|
2438
|
-
reporterEmail: data.reporterEmail,
|
|
2498
|
+
reporterEmail: data.reporterEmail || this.config.user?.email,
|
|
2499
|
+
reporterName: data.reporterName || this.config.user?.name,
|
|
2500
|
+
reporterUserId: this.config.user?.id,
|
|
2439
2501
|
consoleLogs: this.consoleLogger?.getLogs(),
|
|
2440
2502
|
screenshot: data.screenshot,
|
|
2441
2503
|
};
|
|
@@ -2477,6 +2539,15 @@
|
|
|
2477
2539
|
close() {
|
|
2478
2540
|
this.widget.close();
|
|
2479
2541
|
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Identify the current user. Call this after authentication to attach
|
|
2544
|
+
* user context to future feedback submissions. If the widget is open,
|
|
2545
|
+
* the form fields will update immediately.
|
|
2546
|
+
*/
|
|
2547
|
+
identify(user) {
|
|
2548
|
+
this.config.user = { ...this.config.user, ...user };
|
|
2549
|
+
this.widget.updateUser(this.config.user);
|
|
2550
|
+
}
|
|
2480
2551
|
/**
|
|
2481
2552
|
* Submit feedback programmatically without UI
|
|
2482
2553
|
* Note: When Turnstile is enabled, you must use the widget UI or provide a token
|