@rensblitz/customer-instant-feedback-app 2.0.3 → 2.0.5
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 +112 -17
- package/dist/customer-instant-feedback.js +5213 -4625
- package/dist/customer-instant-feedback.umd.cjs +115 -28
- package/dist/feedback/FeedbackAuthContext.d.ts +1 -0
- package/dist/feedback/FeedbackReadmePage.d.ts +1 -0
- package/dist/feedback/supabaseClient.d.ts +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/style.css +1 -1
- package/migrations/create_admin.sql +5 -3
- package/migrations/extend_feedback_items.sql +6 -1
- package/migrations/rls_central.sql +20 -4
- package/package.json +12 -5
- package/supabase/functions/create-reviewer/index.ts +110 -0
- package/supabase/functions/delete-reviewer/index.ts +111 -0
- package/supabase_schema.sql +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,61 @@ pnpm add @rensblitz/customer-instant-feedback-app @supabase/supabase-js react re
|
|
|
37
37
|
|
|
38
38
|
## Quick Start
|
|
39
39
|
|
|
40
|
-
### 1.
|
|
40
|
+
### 1. Environment variables (host project)
|
|
41
|
+
|
|
42
|
+
Add these to your **host project's** `.env` file (not this package):
|
|
43
|
+
|
|
44
|
+
**Vite / Create React App:**
|
|
45
|
+
```
|
|
46
|
+
VITE_FEEDBACK_SUPABASE_URL=https://your-project.supabase.co
|
|
47
|
+
VITE_FEEDBACK_SUPABASE_ANON_KEY=your-anon-key
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Next.js:**
|
|
51
|
+
```
|
|
52
|
+
NEXT_PUBLIC_FEEDBACK_SUPABASE_URL=https://your-project.supabase.co
|
|
53
|
+
NEXT_PUBLIC_FEEDBACK_SUPABASE_ANON_KEY=your-anon-key
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Get these from Supabase: Project Settings → API. Use the `anon` (public) key.
|
|
57
|
+
|
|
58
|
+
**TypeScript users:** Add type definitions for these environment variables. For Vite projects, create `src/vite-env.d.ts`:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
/// <reference types="vite/client" />
|
|
62
|
+
|
|
63
|
+
interface ImportMetaEnv {
|
|
64
|
+
readonly VITE_FEEDBACK_SUPABASE_URL: string
|
|
65
|
+
readonly VITE_FEEDBACK_SUPABASE_ANON_KEY: string
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
For Next.js, add to `next-env.d.ts` or create a similar declaration file.
|
|
70
|
+
|
|
71
|
+
Alternatively, call `configureFeedbackClient({ url, anonKey })` at app init.
|
|
72
|
+
|
|
73
|
+
### 2. Database migrations
|
|
74
|
+
|
|
75
|
+
Run these SQL files in your Supabase SQL editor, in order:
|
|
76
|
+
|
|
77
|
+
1. `migrations/schema_central.sql` – Creates tables
|
|
78
|
+
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.
|
|
79
|
+
3. `migrations/rls_central.sql` – RLS policies
|
|
80
|
+
4. `migrations/create_admin.sql` – Creates your first admin (replace placeholder UUID)
|
|
81
|
+
|
|
82
|
+
### 3. Edge Functions (required for admin)
|
|
83
|
+
|
|
84
|
+
The admin UI uses Edge Functions to create/delete reviewers. Deploy them:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# From the package root (e.g. node_modules/@rensblitz/customer-instant-feedback-app)
|
|
88
|
+
supabase functions deploy create-reviewer
|
|
89
|
+
supabase functions deploy delete-reviewer
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Or copy `supabase/functions/` into your Supabase project and deploy.
|
|
93
|
+
|
|
94
|
+
### 4. Wrap your app
|
|
41
95
|
|
|
42
96
|
In your root component (e.g. `App.tsx` or `main.tsx`):
|
|
43
97
|
|
|
@@ -65,7 +119,7 @@ function App() {
|
|
|
65
119
|
<Route
|
|
66
120
|
path="/*"
|
|
67
121
|
element={
|
|
68
|
-
<FeedbackProvider projectId={projectId}>
|
|
122
|
+
<FeedbackProvider projectId={projectId} feedbackReviewPath="/feedback">
|
|
69
123
|
<YourApp />
|
|
70
124
|
</FeedbackProvider>
|
|
71
125
|
}
|
|
@@ -79,19 +133,15 @@ function App() {
|
|
|
79
133
|
|
|
80
134
|
**Important:** Always import the CSS file. Without it, the feedback modal has no styles.
|
|
81
135
|
|
|
82
|
-
###
|
|
83
|
-
|
|
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`.
|
|
136
|
+
### 5. Get your project ID
|
|
85
137
|
|
|
86
|
-
|
|
138
|
+
Go to `/feedback-admin`, create a company and project, then copy the `project_id` (format: `short-code_uuid`) and pass it to `FeedbackProvider` and `FeedbackReviewPage`.
|
|
87
139
|
|
|
88
|
-
|
|
140
|
+
### 6. Create the first admin
|
|
89
141
|
|
|
90
|
-
1. Create a user in Authentication → Users → Add user (email + password)
|
|
142
|
+
1. Create a user in Supabase: Authentication → Users → Add user (email + password)
|
|
91
143
|
2. Copy the user's UUID
|
|
92
|
-
3. Run
|
|
93
|
-
|
|
94
|
-
See `migrations/create_admin.sql` for the template.
|
|
144
|
+
3. Run the SQL from `migrations/create_admin.sql` (replace the placeholder UUID)
|
|
95
145
|
|
|
96
146
|
## How it works
|
|
97
147
|
|
|
@@ -127,7 +177,9 @@ See `migrations/create_admin.sql` for the template.
|
|
|
127
177
|
### Rate limiting
|
|
128
178
|
|
|
129
179
|
```tsx
|
|
130
|
-
<FeedbackProvider projectId="..." rateLimitSeconds={60}
|
|
180
|
+
<FeedbackProvider projectId="..." rateLimitSeconds={60}>
|
|
181
|
+
<YourApp />
|
|
182
|
+
</FeedbackProvider>
|
|
131
183
|
```
|
|
132
184
|
|
|
133
185
|
### Validation
|
|
@@ -141,15 +193,17 @@ See `migrations/create_admin.sql` for the template.
|
|
|
141
193
|
allowScreenshots: true,
|
|
142
194
|
maxScreenshotSize: 1024 * 1024,
|
|
143
195
|
}}
|
|
144
|
-
|
|
196
|
+
>
|
|
197
|
+
<YourApp />
|
|
198
|
+
</FeedbackProvider>
|
|
145
199
|
```
|
|
146
200
|
|
|
147
201
|
## Migrations (central Supabase project)
|
|
148
202
|
|
|
149
|
-
|
|
203
|
+
Run these migrations in your Supabase SQL editor, in order:
|
|
150
204
|
|
|
151
205
|
1. `migrations/schema_central.sql` – Creates companies, projects, admins, reviewers, and feedback_items tables
|
|
152
|
-
2. `migrations/extend_feedback_items.sql` –
|
|
206
|
+
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
207
|
3. `migrations/rls_central.sql` – RLS policies
|
|
154
208
|
4. `migrations/create_admin.sql` – Template for creating first admin(s)
|
|
155
209
|
|
|
@@ -179,15 +233,56 @@ interface FeedbackReviewPageProps {
|
|
|
179
233
|
|
|
180
234
|
## Development
|
|
181
235
|
|
|
182
|
-
###
|
|
236
|
+
### Testing the library locally
|
|
237
|
+
|
|
238
|
+
The `demo/` folder contains a separate app that imports the library like a real consumer would:
|
|
239
|
+
|
|
240
|
+
1. **First time setup:**
|
|
241
|
+
```bash
|
|
242
|
+
npm run demo:install
|
|
243
|
+
npm link
|
|
244
|
+
cd demo && npm link @rensblitz/customer-instant-feedback-app
|
|
245
|
+
```
|
|
246
|
+
Add `VITE_FEEDBACK_SUPABASE_URL` and `VITE_FEEDBACK_SUPABASE_ANON_KEY` to `demo/.env` (copy from `demo/.env.example` if present).
|
|
247
|
+
|
|
248
|
+
2. **Build the library:**
|
|
249
|
+
```bash
|
|
250
|
+
npm run build
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
3. **Run the demo app:**
|
|
254
|
+
```bash
|
|
255
|
+
npm run demo
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
The demo app imports from `node_modules` using `npm link`, so it works exactly like a real host app.
|
|
259
|
+
|
|
260
|
+
**After making changes to the library:**
|
|
261
|
+
- Rebuild: `npm run build`
|
|
262
|
+
- The demo will hot-reload automatically
|
|
263
|
+
|
|
264
|
+
**Demo includes:**
|
|
265
|
+
- `/feedback-admin` - Admin interface for managing companies, projects, and reviewers
|
|
266
|
+
- `/feedback-login` - Login page for reviewers
|
|
267
|
+
- `/feedback` - Feedback review page
|
|
268
|
+
- `/readme` - Setup guide (also available as `FeedbackReadmePage` for host apps)
|
|
269
|
+
- `/` - Demo page with the feedback widget
|
|
270
|
+
|
|
271
|
+
### Building for npm
|
|
183
272
|
|
|
184
273
|
```bash
|
|
185
274
|
npm run build
|
|
186
275
|
```
|
|
187
276
|
|
|
277
|
+
Builds the library (ESM, CommonJS, TypeScript declarations, CSS).
|
|
278
|
+
|
|
188
279
|
### Publishing to npm
|
|
189
280
|
|
|
190
|
-
|
|
281
|
+
```bash
|
|
282
|
+
npm publish --access public
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
The package is configured for npm distribution with proper exports.
|
|
191
286
|
|
|
192
287
|
## License
|
|
193
288
|
|