- Set FEEDBACK_ENDPOINT to same-origin /api/feedback (no CORS, hides trigger URL) - Add web.config with ARR/URL-Rewrite proxy rule (placeholder trigger URL), HTTPS/POST/static-content setup - DEPLOYMENT.md: concrete IIS + Power Automate steps and the HTTP-trigger Request Body JSON Schema matching the app payload Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
2.6 KiB
JavaScript
49 lines
2.6 KiB
JavaScript
/* ──────────────────────────────────────────────────────────────────────────
|
|
CENTRAL FEEDBACK CONFIGURATION
|
|
----------------------------------------------------------------------------
|
|
By default the suite stores all feedback in each user's own browser
|
|
(localStorage) and reviewers share it via Export / Import. That needs no
|
|
server and works behind any firewall.
|
|
|
|
To ALSO collect feedback automatically into one central place, set
|
|
FEEDBACK_ENDPOINT below to a URL that accepts an HTTP POST of JSON. This
|
|
works with either:
|
|
• a small backend on your host (Node/PHP/Python/ASP.NET) that appends the
|
|
body to a feedback.json / .csv you can download, or
|
|
• a Microsoft Power Automate "When an HTTP request is received" trigger
|
|
that writes to a SharePoint list / Excel table.
|
|
|
|
Leave it as an empty string to stay fully local (export/import only).
|
|
See DEPLOYMENT.md for setup details and sample receivers.
|
|
|
|
This is set to the same-origin path '/api/feedback', which the IIS reverse
|
|
proxy (see web.config) forwards to the Power Automate HTTP trigger. Keeping it
|
|
relative means no CORS and the secret trigger URL never appears in client
|
|
code. Locally (no proxy) the POST simply fails silently and feedback is still
|
|
saved/exported from the browser.
|
|
────────────────────────────────────────────────────────────────────────── */
|
|
window.FEEDBACK_ENDPOINT = '/api/feedback';
|
|
|
|
/* Best-effort send to the central endpoint. Never throws and never blocks the
|
|
UI: feedback is always saved locally first by the caller, so a failed or
|
|
disabled POST simply means "not centrally collected." Returns a Promise that
|
|
resolves true on success, false otherwise. */
|
|
window.postFeedback = function (payload) {
|
|
if (!window.FEEDBACK_ENDPOINT) return Promise.resolve(false);
|
|
try {
|
|
return fetch(window.FEEDBACK_ENDPOINT, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
app: 'Work Package Suite',
|
|
page: (typeof location !== 'undefined' && location.pathname) || '',
|
|
submittedAt: new Date().toISOString(),
|
|
...payload
|
|
}),
|
|
keepalive: true // allow the send to complete even if the page unloads
|
|
}).then(function (r) { return r.ok; }).catch(function () { return false; });
|
|
} catch (e) {
|
|
return Promise.resolve(false);
|
|
}
|
|
};
|