@rensblitz/customer-instant-feedback-app 2.0.4 → 3.0.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
@@ -2,13 +2,20 @@
2
2
 
3
3
  A React component library for collecting user feedback directly within your application. Uses a centralized Supabase backend with reviewer-based authentication.
4
4
 
5
+ ## Repository layout (this monorepo)
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)).
11
+
5
12
  ## Features
6
13
 
7
14
  - Capture screenshots with feedback
8
15
  - Annotate specific elements
9
16
  - Categorize feedback (Bug, UX, Content, Other)
10
17
  - Reviewer-based authentication (no anonymous feedback)
11
- - Admin UI for managing companies, projects, and reviewers
18
+ - Admin UI is a **standalone app** in [`apps/feedback-admin-app/`](./apps/feedback-admin-app/) (not exported from the npm package in v3+)
12
19
  - Feedback review page for reviewers to see all feedback (including from colleagues)
13
20
  - Client-side rate limiting
14
21
  - Input validation
@@ -35,9 +42,70 @@ pnpm add @rensblitz/customer-instant-feedback-app @supabase/supabase-js react re
35
42
 
36
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.
37
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
+
38
50
  ## Quick Start
39
51
 
40
- ### 1. Wrap your app
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`:
73
+
74
+ ```typescript
75
+ /// <reference types="vite/client" />
76
+
77
+ interface ImportMetaEnv {
78
+ readonly VITE_FEEDBACK_SUPABASE_URL: string
79
+ readonly VITE_FEEDBACK_SUPABASE_ANON_KEY: string
80
+ }
81
+ ```
82
+
83
+ For Next.js, add to `next-env.d.ts` or create a similar declaration file.
84
+
85
+ Alternatively, call `configureFeedbackClient({ url, anonKey })` at app init.
86
+
87
+ ### 2. Database migrations
88
+
89
+ Run these SQL files in your Supabase SQL editor, in order:
90
+
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)
95
+
96
+ ### 3. Edge Functions (required for admin)
97
+
98
+ The admin UI uses Edge Functions to create/delete reviewers. Deploy them:
99
+
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
104
+ ```
105
+
106
+ Or copy `supabase/functions/` into your Supabase project and deploy.
107
+
108
+ ### 4. Wrap your app
41
109
 
42
110
  In your root component (e.g. `App.tsx` or `main.tsx`):
43
111
 
@@ -46,7 +114,6 @@ import {
46
114
  FeedbackAuthProvider,
47
115
  FeedbackProvider,
48
116
  FeedbackLoginPage,
49
- FeedbackAdminPage,
50
117
  FeedbackReviewPage,
51
118
  } from '@rensblitz/customer-instant-feedback-app';
52
119
  import '@rensblitz/customer-instant-feedback-app/style.css';
@@ -60,12 +127,11 @@ function App() {
60
127
  <BrowserRouter>
61
128
  <Routes>
62
129
  <Route path="/feedback-login" element={<FeedbackLoginPage />} />
63
- <Route path="/feedback-admin" element={<FeedbackAdminPage />} />
64
130
  <Route path="/feedback" element={<FeedbackReviewPage projectId={projectId} />} />
65
131
  <Route
66
132
  path="/*"
67
133
  element={
68
- <FeedbackProvider projectId={projectId}>
134
+ <FeedbackProvider projectId={projectId} feedbackReviewPath="/feedback">
69
135
  <YourApp />
70
136
  </FeedbackProvider>
71
137
  }
@@ -77,26 +143,24 @@ function App() {
77
143
  }
78
144
  ```
79
145
 
80
- **Important:** Always import the CSS file. Without it, the feedback modal has no styles.
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).
81
147
 
82
- ### 2. Get your project ID
148
+ **Important:** Always import the CSS file. Without it, the feedback modal has no styles.
83
149
 
84
- The `projectId` is created when you add a project in the admin UI (`/feedback-admin`). You must be an admin to access it. After creating a company and project, copy the generated `project_id` (format: `short-code_uuid`) and pass it to `FeedbackProvider`.
150
+ ### 5. Get your project ID
85
151
 
86
- ### 3. Create the first admin
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`.
87
153
 
88
- Admins are created manually via SQL. In the Supabase SQL editor for the central project:
154
+ ### 6. Create the first admin
89
155
 
90
- 1. Create a user in Authentication → Users → Add user (email + password)
156
+ 1. Create a user in Supabase: Authentication → Users → Add user (email + password)
91
157
  2. Copy the user's UUID
92
- 3. Run: `insert into public.admins (user_id) values ('your-user-uuid');`
93
-
94
- See `migrations/create_admin.sql` for the template.
158
+ 3. Run the SQL from `migrations/create_admin.sql` (replace the placeholder UUID)
95
159
 
96
160
  ## How it works
97
161
 
98
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).
99
- - **Admins** visit `/feedback-admin` to manage companies, projects, and reviewers. Only users in the `admins` table can access this page.
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.
100
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.
101
165
 
102
166
  ## Usage
@@ -127,7 +191,9 @@ See `migrations/create_admin.sql` for the template.
127
191
  ### Rate limiting
128
192
 
129
193
  ```tsx
130
- <FeedbackProvider projectId="..." rateLimitSeconds={60} />
194
+ <FeedbackProvider projectId="..." rateLimitSeconds={60}>
195
+ <YourApp />
196
+ </FeedbackProvider>
131
197
  ```
132
198
 
133
199
  ### Validation
@@ -141,15 +207,17 @@ See `migrations/create_admin.sql` for the template.
141
207
  allowScreenshots: true,
142
208
  maxScreenshotSize: 1024 * 1024,
143
209
  }}
144
- />
210
+ >
211
+ <YourApp />
212
+ </FeedbackProvider>
145
213
  ```
146
214
 
147
215
  ## Migrations (central Supabase project)
148
216
 
149
- The package uses a centralized Supabase project. Run these migrations in order:
217
+ Run these migrations in your Supabase SQL editor, in order:
150
218
 
151
219
  1. `migrations/schema_central.sql` – Creates companies, projects, admins, reviewers, and feedback_items tables
152
- 2. `migrations/extend_feedback_items.sql` – Run only if feedback_items already exists from a previous setup
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.
153
221
  3. `migrations/rls_central.sql` – RLS policies
154
222
  4. `migrations/create_admin.sql` – Template for creating first admin(s)
155
223
 
@@ -179,15 +247,57 @@ interface FeedbackReviewPageProps {
179
247
 
180
248
  ## Development
181
249
 
182
- ### Building the package
250
+ ### Testing the library locally
251
+
252
+ The `apps/demo/` folder contains a separate app that imports the library like a real consumer would:
253
+
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).
261
+
262
+ 2. **Build the library:**
263
+ ```bash
264
+ npm run build
265
+ ```
266
+
267
+ 3. **Run the demo app:**
268
+ ```bash
269
+ npm run demo
270
+ ```
271
+
272
+ The demo app imports from `node_modules` using `npm link`, so it works exactly like a real host app.
273
+
274
+ **After making changes to the library:**
275
+ - Rebuild: `npm run build`
276
+ - The demo will hot-reload automatically
277
+
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
283
+
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)).
285
+
286
+ ### Building for npm
183
287
 
184
288
  ```bash
185
289
  npm run build
186
290
  ```
187
291
 
292
+ Builds the library (ESM, CommonJS, TypeScript declarations, CSS).
293
+
188
294
  ### Publishing to npm
189
295
 
190
- The package is configured for publishing to npm with ESM and CommonJS builds, TypeScript declarations, and CSS styles exported separately.
296
+ ```bash
297
+ npm publish --access public
298
+ ```
299
+
300
+ The package is configured for npm distribution with proper exports.
191
301
 
192
302
  ## License
193
303