Feedback Provider: Google Sheets
Google Sheets is the current provider implementation for Feedback Manager.
This provider is one implementation of the shared FeedbackProvider interface. Additional providers can be introduced independently under providers/ and in code under provider/ without changing upstream submission flow.
Provider Files
| File | Responsibility |
|---|---|
config.ts |
Env-backed provider configuration and sheet label map |
provider.ts |
Config validation, JWT auth client creation, append write logic |
Environment Variables
Provider selection:
FEEDBACK_PROVIDER=google-sheets
Provider-owned env vars:
| Env var | Required | Default | Purpose |
|---|---|---|---|
| FEEDBACK_SHEET_ID | Yes | None | Target spreadsheet ID |
| GOOGLE_CLIENT_EMAIL | Yes | None | Service account email |
| GOOGLE_PRIVATE_KEY | Yes | None | Service account private key |
| FEEDBACK_SHEET_RANGE | No | Feedback!A:Z | Append range |
Notes:
GOOGLE_PRIVATE_KEYmust keep escaped newlines and is normalized at runtime viasanitizePrivateKey.- Missing required provider env vars throw
config.missingduring provider initialization.
GCP Setup
- Create or choose a Google Cloud project.
- Enable Google Sheets API.
- Create a service account and generate a JSON key.
- Set service account values in environment:
GOOGLE_CLIENT_EMAILGOOGLE_PRIVATE_KEY
- Share target spreadsheet with the service account email with editor access.
- Set
FEEDBACK_SHEET_IDand optionalFEEDBACK_SHEET_RANGE.
Sheet Mapping
The provider appends rows in the following order:
| Column key | Label |
|---|---|
| timestamp | Timestamp |
| user_id | User ID (Internal) |
| site_name | Site |
| site_id | Site ID |
| module | Module |
| category | Category |
| feedback | Feedback |
| email_contact_allowed | Email Contact Allowed |
| url | URL |
Runtime Behavior
Write path:
- Validate provider config
- Build JWT auth client using Sheets scope
- Map
FeedbackContextto row values - Append row with valueInputOption RAW
- Return
successresponse or error response
Success response:
success: truemessage: Feedback submitted successfully
Failure response:
success: falseerror: <error message or fallback>
Common Failure Modes
| Symptom | Likely cause | What to check |
|---|---|---|
| config.missing on startup | Missing env vars | Required provider env vars |
| Failed to write feedback | Invalid key format | Private key value and newline escaping |
| Permission denied from Sheets API | Service account has no sheet access | Spreadsheet sharing settings |
| Spreadsheet not found | Wrong sheet ID or range | FEEDBACK_SHEET_ID and FEEDBACK_SHEET_RANGE |
Isolation Rule for Future Providers
Each provider must keep configuration isolated to its own implementation:
- Define provider env vars in provider-local config
- Validate only provider-specific requirements in provider initialization
- Keep provider docs in one dedicated file under
providers/