@metricshift/react 1.2.0 → 1.4.0

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,47 +1,57 @@
1
- # @metricshift/react
1
+ @metricshift/react
2
2
 
3
- The intelligent feedback SDK for React applications. Collect, store, and analyze user feedback with built-in AI insights — in minutes, not weeks.
3
+ The intelligent feedback widget for React applications.
4
+ Collect, analyze, and act on user feedback with AI-powered insights — in minutes, not weeks.
4
5
 
5
- [![npm version](https://img.shields.io/npm/v/@metricshift/react.svg)](https://www.npmjs.com/package/@metricshift/react)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
6
+ MetricShift gives you a drop-in feedback experience that feels native to your product, while quietly powering a structured analytics pipeline behind the scenes.
7
7
 
8
- ## Features
8
+ You can fully customize the widget — including rich media like avatars and images — so it feels truly brand-specific, not like a generic feedback tool.
9
9
 
10
- - 🚀 **2-Minute Setup** - Add powerful feedback collection to your React app instantly
11
- - 🎨 **Fully Customizable** - Match your brand with custom colors, sizes, and styles
12
- - 🤖 **AI-Powered Insights** - Automatic sentiment analysis and theme detection with GPT-4
13
- - 📊 **Beautiful Dashboard** - View trends, export data, and discover insights
14
- - ♿ **Accessible** - WCAG compliant with keyboard navigation and ARIA labels
15
- - 📱 **Mobile-Ready** - Perfect experience on any device
16
- - 🔒 **Privacy-First** - GDPR compliant, you control your data
17
- - 🎯 **TypeScript** - Full type safety included
18
10
 
19
- ## 📦 Installation
20
- ```bash
11
+
12
+
13
+ ✨ Features
14
+
15
+ 🚀 2-Minute Setup — Drop-in widget with modal + backend wired automatically
16
+
17
+ 🎨 Deep Customization — Colors, variants, avatars, images, inline placement
18
+
19
+ 🖼️ Rich Media Support — Add personal avatars or branded visuals to the widget
20
+
21
+ 🤖 AI-Powered Analysis — Sentiment detection, themes, summaries
22
+
23
+ 📊 Analytics-Ready — Widget events can be streamed into your analytics stack
24
+
25
+ 🔒 Safe by Design — Domain restrictions + rate limiting built in
26
+
27
+ ♿ Accessible — WCAG-friendly, keyboard & screen-reader support
28
+
29
+ 📱 Mobile-First — Works beautifully on all screen sizes
30
+
31
+ 🧩 TypeScript Ready — Full types & IntelliSense
32
+
33
+ 📦 Installation
21
34
  npm install @metricshift/react
22
- ```
35
+
23
36
 
24
37
  or
25
- ```bash
26
- yarn add @metricshift/react
27
- ```
28
38
 
29
- ## 🚀 Quick Start
39
+ yarn add @metricshift/react
30
40
 
31
- ### 1. Sign up for MetricShift
41
+ 🚀 Quick Start
42
+ 1. Create a MetricShift project
32
43
 
33
- Create your free account at [metricshift.co](https://metricshift.co) to get your credentials.
44
+ Get your Project ID and API key from
45
+ 👉 https://metricshift.co
34
46
 
35
- ### 2. Add the Feedback Button
36
- ```tsx
47
+ 2. Add the feedback widget
37
48
  import { FeedbackButton } from '@metricshift/react';
38
49
 
39
50
  function App() {
40
51
  return (
41
52
  <div>
42
- <h1>My Awesome App</h1>
43
-
44
- {/* Feedback button in bottom-right corner */}
53
+ <h1>My App</h1>
54
+
45
55
  <FeedbackButton
46
56
  projectId="your-project-id"
47
57
  apiKey="your-api-key"
@@ -49,275 +59,249 @@ function App() {
49
59
  </div>
50
60
  );
51
61
  }
52
- ```
53
62
 
54
- ### 3. View Feedback & Insights
63
+ 3. View feedback & AI insights
55
64
 
56
- Log in to your [MetricShift dashboard] to:
57
- - View all feedback in real-time
58
- - See AI-generated sentiment analysis
59
- - Discover common themes automatically
60
- - Export data to CSV
61
- - Track trends over time
65
+ Open your MetricShift dashboard to explore:
62
66
 
63
- That's it! 🎉
67
+ Real-time feedback
64
68
 
65
- ## 📚 Usage Examples
69
+ AI sentiment & themes
66
70
 
67
- ### Default Floating Button
68
- ```tsx
69
- <FeedbackButton
70
- projectId="your-project-id"
71
- apiKey="your-api-key"
72
- />
73
- ```
71
+ Filters, exports, trends
72
+
73
+ Project-level analytics
74
+
75
+ That’s it 🎉
74
76
 
75
- Perfect for most apps - floats in the bottom-right corner.
77
+ 🧠 Security note (important)
76
78
 
77
- ### Custom Styled Button
78
- ```tsx
79
+ It is safe to use projectId and apiKey in the frontend.
80
+
81
+ MetricShift protects your widget with:
82
+
83
+ Domain allow-listing (fully configurable in the dashboard)
84
+
85
+ Rate limiting to prevent abuse or hijacking
86
+
87
+ Project-scoped keys (no cross-project access)
88
+
89
+ If you prefer, you can still proxy keys via your backend — but for most use cases, frontend usage is perfectly fine.
90
+
91
+ 📚 Usage Examples
92
+ ⭐ Default Floating Button
79
93
  <FeedbackButton
80
- projectId="your-project-id"
81
- apiKey="your-api-key"
82
- buttonText="Share Feedback"
83
- buttonColor="#10b981"
84
- buttonHoverColor="#059669"
85
- size="large"
86
- position="bottom-left"
94
+ projectId={projectId}
95
+ apiKey={apiKey}
87
96
  />
88
- ```
89
97
 
90
- Match your brand colors and position.
91
98
 
92
- ### Inline Button
93
- ```tsx
99
+ Clean, neutral pill — bottom-right by default.
100
+
101
+ 🖼️ Custom Styled Button with Image / Avatar
102
+
103
+ Use rich media to make the widget feel personal and brand-specific.
104
+
94
105
  <FeedbackButton
95
- projectId="your-project-id"
96
- apiKey="your-api-key"
106
+ projectId={projectId}
107
+ apiKey={apiKey}
108
+ apiUrl={apiUrl}
97
109
  position="inline"
98
- buttonText="Help us improve"
99
- showIcon={false}
110
+
111
+ buttonText="Image"
112
+ subtitleText="And subtitle"
113
+
114
+ buttonTextColor="#000000"
115
+
116
+ avatarSrc="/niklasAvatar.png"
117
+ avatarAlt="MetricShift Support"
118
+ avatarSize={44}
100
119
  />
101
- ```
102
120
 
103
- Perfect for embedding in your UI, forms, or settings pages.
104
121
 
105
- ### With Event Callbacks
106
- ```tsx
122
+ Perfect for:
123
+
124
+ Founder-led products
125
+
126
+ Customer success flows
127
+
128
+ Onboarding & support touchpoints
129
+
130
+ 🎨 Brand-Themed Button
107
131
  <FeedbackButton
108
- projectId="your-project-id"
109
- apiKey="your-api-key"
110
- onSuccess={(feedbackId) => {
111
- // Track in your analytics
112
- analytics.track('Feedback Submitted', { feedbackId });
113
- // Show thank you message
114
- toast.success('Thanks for your feedback!');
115
- }}
116
- onError={(error) => {
117
- // Handle errors gracefully
118
- console.error('Feedback error:', error);
119
- }}
132
+ projectId={projectId}
133
+ apiKey={apiKey}
134
+ variant="solid"
135
+ accentColor="#3b82f6"
136
+ buttonText="Share feedback"
137
+ size="large"
120
138
  />
121
- ```
122
139
 
123
- Integrate with your existing analytics and notification systems.
124
140
 
125
- ### Multiple Feedback Buttons
126
- ```tsx
127
- function App() {
128
- return (
129
- <div>
130
- {/* Bug report button in header */}
131
- <header>
132
- <FeedbackButton
133
- projectId="your-project-id"
134
- apiKey="your-api-key"
135
- position="inline"
136
- buttonText="Report Bug"
137
- buttonColor="#ef4444"
138
- size="small"
139
- />
140
- </header>
141
-
142
- {/* General feedback floating button */}
143
- <FeedbackButton
144
- projectId="your-project-id"
145
- apiKey="your-api-key"
146
- position="bottom-right"
147
- />
148
- </div>
149
- );
150
- }
151
- ```
141
+ Variants:
152
142
 
153
- ## 🎛️ Props Reference
143
+ solid strong CTA
154
144
 
155
- | Prop | Type | Default | Description |
156
- |------|------|---------|-------------|
157
- | `projectId` | `string` | **required** | Your MetricShift project ID |
158
- | `apiKey` | `string` | **required** | Your MetricShift API key |
159
- | `apiUrl` | `string` | `'https://api.metricshift.co'` | API endpoint (rarely needs changing) |
160
- | `buttonText` | `string` | `'Feedback'` | Text displayed on the button |
161
- | `showIcon` | `boolean` | `true` | Show/hide the 💬 icon |
162
- | `position` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' \| 'inline'` | `'bottom-right'` | Button position |
163
- | `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Button size |
164
- | `buttonColor` | `string` | `'#3b82f6'` | Button background color |
165
- | `buttonHoverColor` | `string` | `'#2563eb'` | Hover state color |
166
- | `buttonTextColor` | `string` | `'#ffffff'` | Text color |
167
- | `customStyles` | `CSSProperties` | `{}` | Additional CSS styles |
168
- | `customClassName` | `string` | `''` | Custom CSS class |
169
- | `disabled` | `boolean` | `false` | Disable the button |
170
- | `autoOpen` | `boolean` | `false` | Auto-open modal on mount |
171
- | `onOpen` | `() => void` | - | Callback when modal opens |
172
- | `onClose` | `() => void` | - | Callback when modal closes |
173
- | `onSuccess` | `(feedbackId: string) => void` | - | Callback on successful submission |
174
- | `onError` | `(error: Error) => void` | - | Callback on error |
145
+ outline default
175
146
 
176
- ## 🎨 Styling Examples
147
+ ghost minimal
177
148
 
178
- ### Match Your Brand
179
- ```tsx
149
+ 🧬 Inline Button (Embed Anywhere)
180
150
  <FeedbackButton
181
- projectId="your-project-id"
182
- apiKey="your-api-key"
183
- buttonColor="#FF6B6B" // Your primary color
184
- buttonHoverColor="#EE5A52" // Slightly darker
185
- buttonTextColor="#FFFFFF"
186
- customStyles={{
187
- fontFamily: 'YourCustomFont, sans-serif',
188
- borderRadius: '12px',
189
- boxShadow: '0 4px 12px rgba(255, 107, 107, 0.3)'
190
- }}
151
+ projectId={projectId}
152
+ apiKey={apiKey}
153
+ position="inline"
154
+ buttonText="Help us improve"
191
155
  />
192
- ```
193
156
 
194
- ### Minimal Style
195
- ```tsx
157
+
158
+ Ideal for settings pages, dashboards, forms.
159
+
160
+ 🔧 Event Callbacks & Analytics
161
+
162
+ Callbacks let you connect widget events to your own analytics or product logic.
163
+
164
+ Think:
165
+
166
+ Tracking feedback submissions in GA / Segment / PostHog
167
+
168
+ Triggering in-app messages
169
+
170
+ Logging events internally
171
+
196
172
  <FeedbackButton
197
- projectId="your-project-id"
198
- apiKey="your-api-key"
199
- showIcon={false}
200
- buttonColor="transparent"
201
- buttonHoverColor="#f3f4f6"
202
- buttonTextColor="#111827"
203
- customStyles={{
204
- border: '1px solid #e5e7eb',
205
- fontWeight: '400'
206
- }}
173
+ projectId={projectId}
174
+ apiKey={apiKey}
175
+ onOpen={() => analytics.track('feedback_opened')}
176
+ onSuccess={(id) => analytics.track('feedback_submitted', { id })}
177
+ onError={(err) => console.error(err)}
207
178
  />
208
- ```
209
179
 
210
- ### Pill Shape
211
- ```tsx
180
+
181
+ This turns the widget into a first-class analytics signal, not just a UI element.
182
+
183
+ 🔧 Why callbacks matter
184
+
185
+ MetricShift callbacks turn the feedback widget into a first-class analytics signal — not just a UI element.
186
+
187
+ Every meaningful interaction inside the widget can be connected to your existing tools and workflows.
188
+
189
+ Think of callbacks as hooks into user intent.
190
+
191
+ Common use cases
192
+
193
+ Track feedback opens & submissions in GA, Segment, PostHog, etc.
194
+
195
+ Correlate feedback with feature usage or experiments
196
+
197
+ Trigger UX responses (toasts, modals, follow-ups)
198
+
199
+ Log feedback IDs for later investigation or support workflows
200
+
201
+ Example
212
202
  <FeedbackButton
213
- projectId="your-project-id"
214
- apiKey="your-api-key"
215
- customStyles={{
216
- borderRadius: '999px',
217
- padding: '12px 24px'
218
- }}
203
+ projectId={projectId}
204
+ apiKey={apiKey}
205
+ onOpen={() => analytics.track('feedback_opened')}
206
+ onClose={() => analytics.track('feedback_closed')}
207
+ onSuccess={(id) =>
208
+ analytics.track('feedback_submitted', { feedbackId: id })
209
+ }
210
+ onError={(err) =>
211
+ analytics.track('feedback_error', { message: err.message })
212
+ }
219
213
  />
220
- ```
221
214
 
222
- ## 📊 Dashboard Features
223
215
 
224
- Your MetricShift dashboard includes:
216
+ Instead of treating feedback as something you “look at later”, callbacks let you:
225
217
 
226
- - **Real-time Feedback Stream** - See submissions as they happen
227
- - **AI Sentiment Analysis** - Automatic positive/neutral/negative classification
228
- - **Theme Detection** - GPT-4 identifies common topics and patterns
229
- - **Advanced Filters** - Filter by type, sentiment, date, rating
230
- - **Export to CSV** - Download your data anytime
231
- - **Analytics & Trends** - Visualize feedback over time
232
- - **Search** - Find specific feedback instantly
218
+ Act on feedback at the moment intent happens.
233
219
 
234
- [View Dashboard →](https://metricshift.co/dashboard)
220
+ ## 🧩 Props
235
221
 
236
- ## 💼 Pricing
222
+ | Prop | Type | Default | Description |
223
+ | --- | --- | --- | --- |
224
+ | `projectId` | `string` | **required** | MetricShift project ID |
225
+ | `apiKey` | `string` | **required** | Project API key |
226
+ | `apiUrl` | `string` | `https://metricshift-sdk-be-production.up.railway.app` | MetricShift API backend endpoint |
227
+ | `buttonText` | `string` | `Feedback` | Main label |
228
+ | `subtitleText` | `string` | `undefined` | Optional second line |
229
+ | `avatarSrc` | `string` | `undefined` | Avatar / image URL |
230
+ | `avatarAlt` | `string` | `''` | Accessible alt text |
231
+ | `avatarSize` | `number` | `40` | Avatar diameter (px) |
232
+ | `variant` | `'solid' \| 'outline' \| 'ghost'` | `'outline'` | Visual style |
233
+ | `accentColor` | `string` | `'#111827'` | Brand accent color |
234
+ | `position` | `'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' \| 'inline'` | `'bottom-right'` | Widget placement |
235
+ | `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Button size |
236
+ | `customStyles` | `CSSProperties` | `{}` | Inline style overrides |
237
+ | `customClassName` | `string` | `''` | Custom CSS class |
238
+ | `onOpen` | `() => void` | — | Fired when modal opens |
239
+ | `onClose` | `() => void` | — | Fired when modal closes |
240
+ | `onSuccess` | `(id: string) => void` | — | Fired on successful submission |
241
+ | `onError` | `(error: Error) => void` | — | Fired on submission error |
237
242
 
238
- - **Free** - 100 feedback submissions/month
239
- - **Pro** - Starting at €19/month for growing teams
240
- - **Enterprise** - Custom solutions, self-hosted options available
243
+ 📊 Dashboard
241
244
 
242
- [View pricing →](https://metricshift.co/pricing)
245
+ Your MetricShift dashboard includes:
243
246
 
244
- ## 🔧 TypeScript Support
247
+ Real-time feedback stream
245
248
 
246
- Full TypeScript definitions included! Get autocomplete and type safety:
247
- ```tsx
248
- import { FeedbackButton, FeedbackButtonProps } from '@metricshift/react';
249
+ AI sentiment & theme clustering
249
250
 
250
- const props: FeedbackButtonProps = {
251
- projectId: 'abc123',
252
- apiKey: 'xyz789',
253
- onSuccess: (id: string) => console.log(id)
254
- };
251
+ Search, filters & CSV export
255
252
 
256
- <FeedbackButton {...props} />
257
- ```
253
+ Project-level configuration
258
254
 
259
- ## 🌍 Framework Support
255
+ Domain restrictions & rate limits
260
256
 
261
- Works with any React framework:
257
+ 👉 https://metricshift.co
262
258
 
263
- - ✅ **Create React App**
264
- - ✅ **Next.js** (App Router & Pages Router)
265
- - ✅ **Vite**
266
- - ✅ **Remix**
267
- - ✅ **Gatsby**
259
+ 💼 Pricing
268
260
 
269
- ## ❓ FAQ
261
+ Free
270
262
 
271
- ### Can I customize the feedback form?
263
+ MetricShift starts free.
264
+ For full plan details, limits, and AI token allowances, see:
272
265
 
273
- The form fields are standardized to ensure quality data collection and AI analysis. However, you can customize:
274
- - Button appearance and position
275
- - Colors and styling
276
- - Form behavior via callbacks
266
+ 👉 https://metricshift.co
277
267
 
278
- ### Where is my data stored?
268
+ FAQ
269
+ Can I customize the feedback form?
279
270
 
280
- Data is securely stored on MetricShift's cloud infrastructure with regular backups. Enterprise customers can request self-hosted deployments.
271
+ Yes.
272
+ The free plan includes a powerful “jack-of-all-trades” feedback template that works across most product use cases.
281
273
 
282
- ### Is this GDPR compliant?
274
+ We also support fully tailor-made templates that can be integrated directly into the widget. More templates and use-case-specific flows will be added as the platform evolves.
283
275
 
284
- Yes! MetricShift is GDPR compliant. Email collection is optional, and users can request data deletion at any time.
276
+ Can I use this with multiple projects or websites?
285
277
 
286
- ### Can I use this with multiple projects?
278
+ Yes, absolutely.
287
279
 
288
- Yes! Each project gets its own `projectId` and `apiKey`. Install the SDK in each project and use different credentials.
280
+ You can self-manage which domains and websites the widget runs on directly from the dashboard.
289
281
 
290
- ### What's included in the free tier?
282
+ Whats included in the free tier?
291
283
 
292
- - 100 feedback submissions per month
293
- - AI sentiment analysis
294
- - Theme detection
295
- - Full dashboard access
296
- - CSV export
284
+ The free plan includes:
297
285
 
298
- ## 🤝 Support & Resources
286
+ Feedback collection
299
287
 
300
- - 📧 **Email**: niklas@iamfrontend.com
301
- - 📖 **Documentation**: [docs.metricshift.co](https://metricshift.co/docs)
302
- - 🐛 **Issues**: Report bugs via email
303
- - 🌐 **Website**: [metricshift.co](https://metricshift.co)
288
+ Dashboard access
304
289
 
305
- ## 🚀 What's Next?
290
+ AI-powered analysis
306
291
 
307
- After installing the SDK:
292
+ A generous monthly allowance of AI tokens to analyze your data
308
293
 
309
- 1. **Customize the button** to match your brand
310
- 2. **Test it out** by submitting feedback
311
- 3. **Explore your dashboard** to see AI insights
312
- 4. **Set up notifications** to get alerts for new feedback
313
- 5. **Export data** and integrate with your workflow
294
+ For up-to-date details, see:
295
+ 👉 https://metricshift.co
314
296
 
315
- ## 📝 License
297
+ 📖 Documentation
316
298
 
317
- MIT © [MetricShift](https://metricshift.co)
299
+ All documentation and updates live at:
300
+ 👉 https://metricshift.co
318
301
 
319
- ---
302
+ 📝 License
320
303
 
321
- **Built with ❤️ for product teams who care about their users**
304
+ MIT © MetricShift
322
305
 
323
- [Get Started Free](https://metricshift.co/signup)
306
+ Built with ❤️ for teams who care about their users.
307
+ Start free → https://metricshift.co/
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,eAAO,MAAM,WAAW;IACtB;;;OAGG;mBACY,iBAAiB;IAWhC;;OAEG;;CAEJ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,YAAY,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,eAAO,MAAM,WAAW;IACtB;;;OAGG;mBACY,iBAAiB;IAWhC;;OAEG;;CAEJ,CAAC"}