Setup & Installation
Collect user feedback and ratings with the Feedback SDK
Last updated:
Installation
npm install @sessionsight/feedbackInitialize
import SessionSightFeedback from '@sessionsight/feedback';
SessionSightFeedback.init({
secretApiKey: 'YOUR_SECRET_API_KEY',
propertyId: 'YOUR_PROPERTY_ID',
});The Feedback SDK uses a secret API key and should run on your server, not in the browser.
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
secretApiKey | string | required | Your secret API key from the dashboard |
propertyId | string | required | Your property ID |
apiUrl | string | https://api.sessionsight.com | Override for self-hosted or local dev |
Usage
// Bug report (sessionId required — thread it through from the originating request)
await SessionSightFeedback.submit('bug-report', {
sessionId: currentSessionId,
option: 'critical',
message: 'Payment fails with Amex cards',
metadata: { page: '/checkout', browser: 'Chrome 120' },
});
// Star rating (1-5)
await SessionSightFeedback.submit('star-rating', {
sessionId: currentSessionId,
option: '4',
});
// Sentiment feedback
await SessionSightFeedback.submit('page-feedback', {
sessionId: currentSessionId,
option: 'good',
message: 'This article was really helpful!',
});Pairing with the Insights SDK
When the Insights SDK runs on your frontend, it writes an ss_sid cookie for the current recording session. Pass your inbound request to forRequest(req) and feedback gets automatically linked to that session. Feedback is session-scoped; visitor and user identity are resolved from the session on the backend.
app.post('/feedback', async (req, res) => {
await SessionSightFeedback.forRequest(req).submit('bug-report', {
option: req.body.severity,
message: req.body.message,
});
res.json({ ok: true });
});Works with every major framework (Next.js, SvelteKit, Nuxt, Hono, Express, Fastify, Koa, Workers, Remix, and more). See Pairing with backend SDKs for framework-specific examples.
Cleanup
Call destroy() when you’re done:
SessionSightFeedback.destroy();Class-based usage
The package also exports FeedbackClient if you’d rather hold an instance directly than use the singleton:
import { FeedbackClient } from '@sessionsight/feedback';
const feedback = new FeedbackClient({
secretApiKey: 'YOUR_SECRET_API_KEY',
propertyId: 'YOUR_PROPERTY_ID',
});
await feedback.submit('star-rating', { sessionId, option: '5' });
feedback.destroy();The class throws at construction if loaded in a browser environment, since the secret key must never be exposed client-side.