@rensblitz/customer-instant-feedback-app 3.0.2 → 3.1.1

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 CHANGED
@@ -1,75 +1,39 @@
1
- # Customer Instant Feedback App
1
+ # Feedback Module Setup
2
2
 
3
- A React component library for collecting user feedback directly within your application. Uses a centralized Supabase backend with reviewer-based authentication.
3
+ This project integrates the `@rensblitz/customer-instant-feedback-app` npm package to collect in-app feedback from reviewers. Feedback is stored in a **dedicated, separate Supabase project** not in this project's own database.
4
4
 
5
- ## Repository layout (this monorepo)
5
+ ---
6
6
 
7
- - **`packages/customer-instant-feedback-app`** the publishable npm package (`npm run build`, `npm publish -w @rensblitz/customer-instant-feedback-app`).
8
- - **`apps/demo`** — local consumer app (workspace `file:` link).
9
- - **`apps/demo-npm`** — same idea, but depends on the **published** package from npm (see `apps/demo-npm/README.md`).
10
- - **`apps/feedback-admin-app`** — standalone admin UI (deploy from repo root; see [`render.yaml`](./render.yaml)).
7
+ ## 1. Environment variables
11
8
 
12
- ## Features
9
+ Add the following to `frontend/.env`:
13
10
 
14
- - Capture screenshots with feedback
15
- - Annotate specific elements
16
- - Categorize feedback (Bug, UX, Content, Other)
17
- - Reviewer-based authentication (no anonymous feedback)
18
- - Admin UI is a **standalone app** in [`apps/feedback-admin-app/`](./apps/feedback-admin-app/) (not exported from the npm package in v3+)
19
- - Feedback review page for reviewers to see all feedback (including from colleagues)
20
- - Client-side rate limiting
21
- - Input validation
11
+ ```env
12
+ # Feedback module — dedicated Supabase project
13
+ VITE_FEEDBACK_SUPABASE_URL=https://<your-supabase-project>.supabase.co
14
+ VITE_FEEDBACK_SUPABASE_ANON_KEY=<your-anon-key>
22
15
 
23
- ## Installation
16
+ # The project ID assigned by projectinablitz (format: short-code_uuid)
17
+ VITE_FEEDBACK_PROJECT_ID=<your-project-id>
24
18
 
25
- In your React project:
26
-
27
- ```bash
28
- npm install @rensblitz/customer-instant-feedback-app @supabase/supabase-js react react-dom react-router-dom
19
+ # Set to "true" to enable the feedback widget, "false" to disable it
20
+ VITE_FEEDBACK_ENABLED=true
29
21
  ```
30
22
 
31
- Or with yarn:
23
+ These are distinct from the app's own Supabase credentials (`VITE_SUPABASE_URL` / `VITE_SUPABASE_ANON_KEY`), which are used for the app's own auth and data and must remain in `.env` alongside these.
32
24
 
33
- ```bash
34
- yarn add @rensblitz/customer-instant-feedback-app @supabase/supabase-js react react-dom react-router-dom
35
- ```
25
+ > **Note:** Because Vite does not substitute env vars inside pre-bundled npm packages, `configureFeedbackClient()` must be called from within the host project's own source (see section 3). This is what makes the env vars available to the package at runtime.
36
26
 
37
- Or with pnpm:
27
+ **Next.js users:** use `NEXT_PUBLIC_` instead of `VITE_`:
38
28
 
39
- ```bash
40
- pnpm add @rensblitz/customer-instant-feedback-app @supabase/supabase-js react react-dom react-router-dom
29
+ ```env
30
+ NEXT_PUBLIC_FEEDBACK_SUPABASE_URL=https://<your-supabase-project>.supabase.co
31
+ NEXT_PUBLIC_FEEDBACK_SUPABASE_ANON_KEY=<your-anon-key>
32
+ NEXT_PUBLIC_FEEDBACK_PROJECT_ID=<your-project-id>
33
+ NEXT_PUBLIC_FEEDBACK_ENABLED=true
41
34
  ```
42
35
 
43
- > **Note:** React, React DOM, React Router, and Supabase are peer dependencies. If your project already has them, you only need to install the feedback package.
44
-
45
- ### Upgrading from 2.x to 3.x
46
-
47
- - **`FeedbackAdminPage` was removed** from the package. Remove any import and route; use the standalone [`apps/feedback-admin-app`](./apps/feedback-admin-app/) (or deploy it separately).
48
- - **`getSupabaseClient`** is now exported if you need direct Supabase access in advanced integrations.
49
-
50
- ## Quick Start
51
-
52
- **Host app integration (typical):** install the package, add Supabase URL + anon key to `.env`, wrap the app with `FeedbackAuthProvider` / `FeedbackProvider`, and pass the `project_id` string from your operator. You do **not** need to run database migrations in your repo—that happens on the Supabase project (see below if you operate that backend). The in-app setup page at `/readme` (`FeedbackReadmePage`) describes only this flow; full operator steps stay in this README.
53
-
54
- ### 1. Environment variables (host project)
55
-
56
- Add these to your **host project's** `.env` file (not this package):
57
-
58
- **Vite / Create React App:**
59
- ```
60
- VITE_FEEDBACK_SUPABASE_URL=https://your-project.supabase.co
61
- VITE_FEEDBACK_SUPABASE_ANON_KEY=your-anon-key
62
- ```
63
-
64
- **Next.js:**
65
- ```
66
- NEXT_PUBLIC_FEEDBACK_SUPABASE_URL=https://your-project.supabase.co
67
- NEXT_PUBLIC_FEEDBACK_SUPABASE_ANON_KEY=your-anon-key
68
- ```
69
-
70
- Get these from Supabase: Project Settings → API. Use the `anon` (public) key.
71
-
72
- **TypeScript users:** Add type definitions for these environment variables. For Vite projects, create `src/vite-env.d.ts`:
36
+ **TypeScript users:** add type declarations for these env vars. For Vite, in `src/vite-env.d.ts`:
73
37
 
74
38
  ```typescript
75
39
  /// <reference types="vite/client" />
@@ -77,37 +41,37 @@ Get these from Supabase: Project Settings → API. Use the `anon` (public) key.
77
41
  interface ImportMetaEnv {
78
42
  readonly VITE_FEEDBACK_SUPABASE_URL: string
79
43
  readonly VITE_FEEDBACK_SUPABASE_ANON_KEY: string
44
+ readonly VITE_FEEDBACK_PROJECT_ID: string
45
+ readonly VITE_FEEDBACK_ENABLED: string
80
46
  }
81
47
  ```
82
48
 
83
- For Next.js, add to `next-env.d.ts` or create a similar declaration file.
49
+ ---
84
50
 
85
- Alternatively, call `configureFeedbackClient({ url, anonKey })` at app init.
51
+ ## 2. Installation
86
52
 
87
- ### 2. Database migrations
88
-
89
- Run these SQL files in your Supabase SQL editor, in order:
53
+ ```bash
54
+ npm install @rensblitz/customer-instant-feedback-app
55
+ ```
90
56
 
91
- 1. `migrations/schema_central.sql` Creates tables
92
- 2. `migrations/extend_feedback_items.sql` – **Skip for new installs.** Only run if you already have `feedback_items` from a previous setup; running on a fresh install will fail.
93
- 3. `migrations/rls_central.sql` – RLS policies
94
- 4. `migrations/create_admin.sql` – Creates your first admin (replace placeholder UUID)
57
+ The package requires these peer dependencies, which are already present in this project:
95
58
 
96
- ### 3. Edge Functions (required for admin)
59
+ - `react` ^18
60
+ - `react-dom` ^18
61
+ - `react-router-dom` ^6
62
+ - `@supabase/supabase-js` ^2
97
63
 
98
- The admin UI uses Edge Functions to create/delete reviewers. Deploy them:
64
+ Also import the stylesheet once in the app entry point:
99
65
 
100
- ```bash
101
- # From the package root (e.g. node_modules/@rensblitz/customer-instant-feedback-app)
102
- supabase functions deploy create-reviewer
103
- supabase functions deploy delete-reviewer
66
+ ```tsx
67
+ import '@rensblitz/customer-instant-feedback-app/style.css'
104
68
  ```
105
69
 
106
- Or copy `supabase/functions/` into your Supabase project and deploy.
70
+ ---
107
71
 
108
- ### 4. Wrap your app
72
+ ## 3. App.tsx setup
109
73
 
110
- In your root component (e.g. `App.tsx` or `main.tsx`):
74
+ ### Imports
111
75
 
112
76
  ```tsx
113
77
  import {
@@ -115,189 +79,90 @@ import {
115
79
  FeedbackProvider,
116
80
  FeedbackLoginPage,
117
81
  FeedbackReviewPage,
118
- } from '@rensblitz/customer-instant-feedback-app';
119
- import '@rensblitz/customer-instant-feedback-app/style.css';
120
- import { BrowserRouter, Routes, Route } from 'react-router-dom';
121
-
122
- const projectId = 'your-project-id';
123
-
124
- function App() {
125
- return (
126
- <FeedbackAuthProvider>
127
- <BrowserRouter>
128
- <Routes>
129
- <Route path="/feedback-login" element={<FeedbackLoginPage />} />
130
- <Route path="/feedback" element={<FeedbackReviewPage projectId={projectId} />} />
131
- <Route
132
- path="/*"
133
- element={
134
- <FeedbackProvider projectId={projectId} feedbackReviewPath="/feedback">
135
- <YourApp />
136
- </FeedbackProvider>
137
- }
138
- />
139
- </Routes>
140
- </BrowserRouter>
141
- </FeedbackAuthProvider>
142
- );
143
- }
82
+ configureFeedbackClient,
83
+ } from '@rensblitz/customer-instant-feedback-app'
84
+ import '@rensblitz/customer-instant-feedback-app/style.css'
144
85
  ```
145
86
 
146
- **Admin UI** (companies, projects, reviewers) is **not** part of the npm package. Run the standalone app in [`apps/feedback-admin-app/`](./apps/feedback-admin-app/) (see its README) or deploy it separately (e.g. Render).
147
-
148
- **Important:** Always import the CSS file. Without it, the feedback modal has no styles.
149
-
150
- ### 5. Get your project ID
87
+ ### Client configuration (module level, after all imports)
151
88
 
152
- Use the **Feedback Admin** standalone app (in `apps/feedback-admin-app/` in this repo) to create a company and project, then copy the `project_id` (format: `short-code_uuid`) and pass it to `FeedbackProvider` and `FeedbackReviewPage`.
153
-
154
- ### 6. Create the first admin
155
-
156
- 1. Create a user in Supabase: Authentication → Users → Add user (email + password)
157
- 2. Copy the user's UUID
158
- 3. Run the SQL from `migrations/create_admin.sql` (replace the placeholder UUID)
159
-
160
- ## How it works
161
-
162
- - **Reviewers** visit `/feedback-login` to sign in with credentials provided by an admin. Only logged-in reviewers can see and use the feedback widget. They can visit `/feedback` to see all feedback for the project (including from colleagues).
163
- - **Admins** use the standalone **Feedback Admin** app (`apps/feedback-admin-app/` in this repository, or your deployed instance) to manage companies, projects, and reviewers. Only users in the `admins` table can access it.
164
- - **Feedback** is stored in the centralized Supabase project, scoped by project. Each host app passes its `projectId` to identify which project the feedback belongs to.
165
-
166
- ## Usage
167
-
168
- ### FeedbackProvider props
89
+ Call this once at module level outside any component or function so the package has its Supabase credentials before it initialises:
169
90
 
170
91
  ```tsx
171
- <FeedbackProvider
172
- projectId="acme-dash_abc123-uuid" // Required for full functionality
173
- enabled={true}
174
- rateLimitSeconds={30}
175
- validation={{
176
- maxCommentLength: 2000,
177
- maxNameLength: 100,
178
- maxScreenshotSize: 500000,
179
- }}
180
- >
181
- <YourApp />
182
- </FeedbackProvider>
92
+ configureFeedbackClient({
93
+ url: import.meta.env.VITE_FEEDBACK_SUPABASE_URL,
94
+ anonKey: import.meta.env.VITE_FEEDBACK_SUPABASE_ANON_KEY,
95
+ })
183
96
  ```
184
97
 
185
- - **projectId**: The project identifier from the admin UI. If omitted, a warning banner is shown.
186
- - **enabled**: Toggle the feedback feature on/off.
187
- - **feedbackReviewPath**: Path to the feedback review page (default: `/feedback`). Used for the "View all" link in the feedback toolbar.
188
- - **rateLimitSeconds**: Minimum seconds between submissions.
189
- - **validation**: Input validation limits.
190
-
191
- ### Rate limiting
192
-
193
- ```tsx
194
- <FeedbackProvider projectId="..." rateLimitSeconds={60}>
195
- <YourApp />
196
- </FeedbackProvider>
197
- ```
98
+ ### Component tree structure
198
99
 
199
- ### Validation
100
+ The full provider/route structure in `App.tsx`:
200
101
 
201
102
  ```tsx
202
- <FeedbackProvider
203
- projectId="..."
204
- validation={{
205
- maxCommentLength: 500,
206
- maxNameLength: 50,
207
- allowScreenshots: true,
208
- maxScreenshotSize: 1024 * 1024,
209
- }}
210
- >
211
- <YourApp />
212
- </FeedbackProvider>
213
- ```
214
-
215
- ## Migrations (central Supabase project)
216
-
217
- Run these migrations in your Supabase SQL editor, in order:
218
-
219
- 1. `migrations/schema_central.sql` – Creates companies, projects, admins, reviewers, and feedback_items tables
220
- 2. `migrations/extend_feedback_items.sql` – **Skip for new installs.** Only run if you are upgrading an existing installation that already has a `feedback_items` table from a prior setup. Running on a fresh install will fail.
221
- 3. `migrations/rls_central.sql` – RLS policies
222
- 4. `migrations/create_admin.sql` – Template for creating first admin(s)
223
-
224
- ## TypeScript types
225
-
226
- ```typescript
227
- interface ValidationConfig {
228
- maxCommentLength?: number;
229
- maxNameLength?: number;
230
- allowScreenshots?: boolean;
231
- maxScreenshotSize?: number;
232
- }
103
+ function App() {
104
+ return (
105
+ <FeedbackAuthProvider> {/* outermost — manages reviewer auth state */}
106
+ <BrowserRouter>
107
+ <Routes>
233
108
 
234
- interface FeedbackProviderProps {
235
- children: React.ReactNode;
236
- projectId?: string;
237
- enabled?: boolean;
238
- rateLimitSeconds?: number;
239
- validation?: ValidationConfig;
240
- feedbackReviewPath?: string;
241
- }
109
+ {/* Feedback-specific routes — rendered outside FeedbackProvider intentionally */}
110
+ <Route path="/feedback-login" element={<FeedbackLoginPage />} />
111
+ <Route path="/feedback" element={<FeedbackReviewPage projectId={import.meta.env.VITE_FEEDBACK_PROJECT_ID} />} />
112
+
113
+ {/* All app routes — wrapped with FeedbackProvider so the widget appears on every page */}
114
+ <Route path="*" element={
115
+ <FeedbackProvider
116
+ projectId={import.meta.env.VITE_FEEDBACK_PROJECT_ID}
117
+ rateLimitSeconds={30}
118
+ enabled={import.meta.env.VITE_FEEDBACK_ENABLED === 'true'}
119
+ feedbackReviewPath="/feedback"
120
+ >
121
+ {/* rest of the app */}
122
+ </FeedbackProvider>
123
+ } />
242
124
 
243
- interface FeedbackReviewPageProps {
244
- projectId: string;
125
+ </Routes>
126
+ </BrowserRouter>
127
+ </FeedbackAuthProvider>
128
+ )
245
129
  }
246
130
  ```
247
131
 
248
- ## Development
249
-
250
- ### Testing the library locally
132
+ ### FeedbackProvider props
251
133
 
252
- The `apps/demo/` folder contains a separate app that imports the library like a real consumer would:
134
+ | Prop | Type | Description |
135
+ |---|---|---|
136
+ | `projectId` | `string` | Project ID from projectinablitz. Required for feedback to be stored correctly. |
137
+ | `enabled` | `boolean` | Toggle the widget on/off without redeployment. Driven by `VITE_FEEDBACK_ENABLED`. |
138
+ | `rateLimitSeconds` | `number` | Minimum seconds between submissions per reviewer. |
139
+ | `feedbackReviewPath` | `string` | Path to the review page. Used for the "View all" link in the widget. |
140
+ | `validation` | `object` | Optional. Limits: `maxCommentLength`, `maxNameLength`, `allowScreenshots`, `maxScreenshotSize`. |
253
141
 
254
- 1. **First time setup:**
255
- ```bash
256
- npm run demo:install
257
- npm link
258
- cd demo && npm link @rensblitz/customer-instant-feedback-app
259
- ```
260
- Add `VITE_FEEDBACK_SUPABASE_URL` and `VITE_FEEDBACK_SUPABASE_ANON_KEY` to `apps/demo/.env` (copy from `apps/demo/.env.example` if present).
142
+ ---
261
143
 
262
- 2. **Build the library:**
263
- ```bash
264
- npm run build
265
- ```
144
+ ## 4. Reviewer flow
266
145
 
267
- 3. **Run the demo app:**
268
- ```bash
269
- npm run demo
270
- ```
146
+ - Reviewers navigate to `/feedback-login` and sign in with credentials provisioned by an admin.
147
+ - Once logged in, the feedback widget becomes visible on all app pages (wherever `FeedbackProvider` wraps the UI).
148
+ - Reviewers can visit `/feedback` to see all submitted feedback for the project.
271
149
 
272
- The demo app imports from `node_modules` using `npm link`, so it works exactly like a real host app.
150
+ ---
273
151
 
274
- **After making changes to the library:**
275
- - Rebuild: `npm run build`
276
- - The demo will hot-reload automatically
152
+ ## 5. Managing companies, projects, and reviewers
277
153
 
278
- **Demo includes** (typical host routes; see `apps/demo/`):
279
- - `/feedback-login` - Login page for reviewers
280
- - `/feedback` - Feedback review page
281
- - `/readme` - Setup guide (also available as `FeedbackReadmePage` for host apps)
282
- - `/` - Demo page with the feedback widget
154
+ The operator UI (**projectinablitz**) is a separate application that lives in the package's monorepo (`apps/projectinablitz-frontend`). It is not part of this project. Use it to:
283
155
 
284
- **Admin** is a separate Vite app: run `npm run admin:dev` from the repo root (see [`apps/feedback-admin-app/README.md`](./apps/feedback-admin-app/README.md)).
156
+ - Create companies and projects (which gives you the `project_id` to use in the env)
157
+ - Provision and manage reviewer accounts
285
158
 
286
- ### Building for npm
159
+ ---
287
160
 
288
- ```bash
289
- npm run build
290
- ```
161
+ ## 6. Toggling feedback off
291
162
 
292
- Builds the library (ESM, CommonJS, TypeScript declarations, CSS).
293
-
294
- ### Publishing to npm
295
-
296
- ```bash
297
- npm publish --access public
298
- ```
163
+ Set `VITE_FEEDBACK_ENABLED=false` in `frontend/.env` and restart the Vite dev server. The widget will not render. All other feedback infrastructure (routes, providers) remains in place but is inert.
299
164
 
300
- The package is configured for npm distribution with proper exports.
165
+ ---
301
166
 
302
167
  ## License
303
168