@metricshift/react 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 MetricShift
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,323 @@
1
+ # @metricshift/react
2
+
3
+ The intelligent feedback SDK for React applications. Collect, store, and analyze user feedback with built-in AI insights — in minutes, not weeks.
4
+
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)
7
+
8
+ ## ✨ Features
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
+
19
+ ## 📦 Installation
20
+ ```bash
21
+ npm install @metricshift/react
22
+ ```
23
+
24
+ or
25
+ ```bash
26
+ yarn add @metricshift/react
27
+ ```
28
+
29
+ ## 🚀 Quick Start
30
+
31
+ ### 1. Sign up for MetricShift
32
+
33
+ Create your free account at [metricshift.co](https://metricshift.co) to get your credentials.
34
+
35
+ ### 2. Add the Feedback Button
36
+ ```tsx
37
+ import { FeedbackButton } from '@metricshift/react';
38
+
39
+ function App() {
40
+ return (
41
+ <div>
42
+ <h1>My Awesome App</h1>
43
+
44
+ {/* Feedback button in bottom-right corner */}
45
+ <FeedbackButton
46
+ projectId="your-project-id"
47
+ apiKey="your-api-key"
48
+ />
49
+ </div>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ### 3. View Feedback & Insights
55
+
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
62
+
63
+ That's it! 🎉
64
+
65
+ ## 📚 Usage Examples
66
+
67
+ ### Default Floating Button
68
+ ```tsx
69
+ <FeedbackButton
70
+ projectId="your-project-id"
71
+ apiKey="your-api-key"
72
+ />
73
+ ```
74
+
75
+ Perfect for most apps - floats in the bottom-right corner.
76
+
77
+ ### Custom Styled Button
78
+ ```tsx
79
+ <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"
87
+ />
88
+ ```
89
+
90
+ Match your brand colors and position.
91
+
92
+ ### Inline Button
93
+ ```tsx
94
+ <FeedbackButton
95
+ projectId="your-project-id"
96
+ apiKey="your-api-key"
97
+ position="inline"
98
+ buttonText="Help us improve"
99
+ showIcon={false}
100
+ />
101
+ ```
102
+
103
+ Perfect for embedding in your UI, forms, or settings pages.
104
+
105
+ ### With Event Callbacks
106
+ ```tsx
107
+ <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
+ }}
120
+ />
121
+ ```
122
+
123
+ Integrate with your existing analytics and notification systems.
124
+
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
+ ```
152
+
153
+ ## 🎛️ Props Reference
154
+
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 |
175
+
176
+ ## 🎨 Styling Examples
177
+
178
+ ### Match Your Brand
179
+ ```tsx
180
+ <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
+ }}
191
+ />
192
+ ```
193
+
194
+ ### Minimal Style
195
+ ```tsx
196
+ <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
+ }}
207
+ />
208
+ ```
209
+
210
+ ### Pill Shape
211
+ ```tsx
212
+ <FeedbackButton
213
+ projectId="your-project-id"
214
+ apiKey="your-api-key"
215
+ customStyles={{
216
+ borderRadius: '999px',
217
+ padding: '12px 24px'
218
+ }}
219
+ />
220
+ ```
221
+
222
+ ## 📊 Dashboard Features
223
+
224
+ Your MetricShift dashboard includes:
225
+
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
233
+
234
+ [View Dashboard →](https://metricshift.co/dashboard)
235
+
236
+ ## 💼 Pricing
237
+
238
+ - **Free** - 100 feedback submissions/month
239
+ - **Pro** - Starting at €19/month for growing teams
240
+ - **Enterprise** - Custom solutions, self-hosted options available
241
+
242
+ [View pricing →](https://metricshift.co/pricing)
243
+
244
+ ## 🔧 TypeScript Support
245
+
246
+ Full TypeScript definitions included! Get autocomplete and type safety:
247
+ ```tsx
248
+ import { FeedbackButton, FeedbackButtonProps } from '@metricshift/react';
249
+
250
+ const props: FeedbackButtonProps = {
251
+ projectId: 'abc123',
252
+ apiKey: 'xyz789',
253
+ onSuccess: (id: string) => console.log(id)
254
+ };
255
+
256
+ <FeedbackButton {...props} />
257
+ ```
258
+
259
+ ## 🌍 Framework Support
260
+
261
+ Works with any React framework:
262
+
263
+ - ✅ **Create React App**
264
+ - ✅ **Next.js** (App Router & Pages Router)
265
+ - ✅ **Vite**
266
+ - ✅ **Remix**
267
+ - ✅ **Gatsby**
268
+
269
+ ## ❓ FAQ
270
+
271
+ ### Can I customize the feedback form?
272
+
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
277
+
278
+ ### Where is my data stored?
279
+
280
+ Data is securely stored on MetricShift's cloud infrastructure with regular backups. Enterprise customers can request self-hosted deployments.
281
+
282
+ ### Is this GDPR compliant?
283
+
284
+ Yes! MetricShift is GDPR compliant. Email collection is optional, and users can request data deletion at any time.
285
+
286
+ ### Can I use this with multiple projects?
287
+
288
+ Yes! Each project gets its own `projectId` and `apiKey`. Install the SDK in each project and use different credentials.
289
+
290
+ ### What's included in the free tier?
291
+
292
+ - 100 feedback submissions per month
293
+ - AI sentiment analysis
294
+ - Theme detection
295
+ - Full dashboard access
296
+ - CSV export
297
+
298
+ ## 🤝 Support & Resources
299
+
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)
304
+
305
+ ## 🚀 What's Next?
306
+
307
+ After installing the SDK:
308
+
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
314
+
315
+ ## 📝 License
316
+
317
+ MIT © [MetricShift](https://metricshift.co)
318
+
319
+ ---
320
+
321
+ **Built with ❤️ for product teams who care about their users**
322
+
323
+ [Get Started Free](https://metricshift.co/signup)
@@ -0,0 +1,41 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface FeedbackButtonProps {
4
+ projectId: string;
5
+ apiKey?: string;
6
+ apiUrl?: string;
7
+ buttonText?: string;
8
+ showIcon?: boolean;
9
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'inline';
10
+ size?: 'small' | 'medium' | 'large';
11
+ buttonColor?: string;
12
+ buttonHoverColor?: string;
13
+ buttonTextColor?: string;
14
+ customStyles?: React.CSSProperties;
15
+ customClassName?: string;
16
+ disabled?: boolean;
17
+ autoOpen?: boolean;
18
+ onOpen?: () => void;
19
+ onClose?: () => void;
20
+ onSuccess?: (feedbackId: string) => void;
21
+ onError?: (error: Error) => void;
22
+ }
23
+ /**
24
+ * FeedbackButton Component
25
+ *
26
+ * A customizable button that opens a feedback modal when clicked.
27
+ * Collects and submits user feedback to your MetricShift backend.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * <FeedbackButton
32
+ * projectId="your-project-id"
33
+ * apiKey="your-api-key"
34
+ * position="bottom-right"
35
+ * size="medium"
36
+ * buttonColor="#3b82f6"
37
+ * />
38
+ * ```
39
+ */
40
+ export declare const FeedbackButton: React.FC<FeedbackButtonProps>;
41
+ //# sourceMappingURL=FeedbackButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedbackButton.d.ts","sourceRoot":"","sources":["../../src/components/FeedbackButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAIxC,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,QAAQ,CAAC,EAAE,cAAc,GAAG,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;IAGhF,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAGpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAGnB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAoLxD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+
3
+ interface FeedbackModalProps {
4
+ isOpen: boolean;
5
+ onClose: () => void;
6
+ onSubmit: (data: FeedbackFormData) => Promise<void>;
7
+ }
8
+ export interface FeedbackFormData {
9
+ text: string;
10
+ rating?: number;
11
+ feedbackType: 'general' | 'bug' | 'feature_request' | 'question' | 'praise';
12
+ userEmail?: string;
13
+ userName?: string;
14
+ }
15
+ export declare const FeedbackModal: React.FC<FeedbackModalProps>;
16
+ export {};
17
+ //# sourceMappingURL=FeedbackModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeedbackModal.d.ts","sourceRoot":"","sources":["../../src/components/FeedbackModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,UAAU,kBAAkB;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,SAAS,GAAG,KAAK,GAAG,iBAAiB,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAgdtD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { default as React } from 'react';
2
+ import { MetricShiftConfig } from '../types';
3
+
4
+ export declare const useMetricShift: () => MetricShiftConfig;
5
+ interface MetricShiftProviderProps {
6
+ config: MetricShiftConfig;
7
+ children: React.ReactNode;
8
+ }
9
+ /**
10
+ * MetricShiftProvider Component
11
+ *
12
+ * Provides MetricShift configuration to child components via React Context.
13
+ * Will be fully implemented in Week 2.
14
+ */
15
+ export declare const MetricShiftProvider: React.FC<MetricShiftProviderProps>;
16
+ export {};
17
+ //# sourceMappingURL=MetricShiftProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetricShiftProvider.d.ts","sourceRoot":"","sources":["../../src/components/MetricShiftProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAIlD,eAAO,MAAM,cAAc,yBAM1B,CAAC;AAEF,UAAU,wBAAwB;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CASlE,CAAC"}
@@ -0,0 +1,23 @@
1
+ export { FeedbackButton } from './components/FeedbackButton';
2
+ export { FeedbackModal } from './components/FeedbackModal';
3
+ export { MetricShiftProvider, useMetricShift } from './components/MetricShiftProvider';
4
+ export type { FeedbackButtonProps } from './components/FeedbackButton';
5
+ export type { FeedbackFormData } from './components/FeedbackModal';
6
+ export { submitFeedback } from './utils/api';
7
+ export interface MetricShiftConfig {
8
+ projectId: string;
9
+ apiKey?: string;
10
+ apiUrl?: string;
11
+ }
12
+ export declare const MetricShift: {
13
+ /**
14
+ * Initialize the MetricShift SDK
15
+ * @param config - SDK configuration
16
+ */
17
+ init: (config: MetricShiftConfig) => void;
18
+ /**
19
+ * Get current SDK configuration
20
+ */
21
+ getConfig: () => MetricShiftConfig | null;
22
+ };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}