@feedvalue/core 0.1.0 → 0.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 +82 -10
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -35,8 +35,30 @@ feedvalue.open();
|
|
|
35
35
|
feedvalue.close();
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
### Headless Mode
|
|
39
|
+
|
|
40
|
+
For complete UI control, initialize in headless mode. The SDK fetches config and provides all API methods but renders no DOM elements:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
const feedvalue = FeedValue.init({
|
|
44
|
+
widgetId: 'your-widget-id',
|
|
45
|
+
headless: true, // No trigger button or modal rendered
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Wait until ready
|
|
49
|
+
await feedvalue.waitUntilReady();
|
|
50
|
+
|
|
51
|
+
// Build your own UI, use SDK for submission
|
|
52
|
+
await feedvalue.submit({
|
|
53
|
+
message: 'User feedback here',
|
|
54
|
+
sentiment: 'satisfied',
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
38
58
|
### User Identification
|
|
39
59
|
|
|
60
|
+
User data is automatically included with feedback submissions:
|
|
61
|
+
|
|
40
62
|
```typescript
|
|
41
63
|
// Identify the current user
|
|
42
64
|
feedvalue.identify('user-123', {
|
|
@@ -61,14 +83,26 @@ feedvalue.reset();
|
|
|
61
83
|
// Submit feedback programmatically
|
|
62
84
|
await feedvalue.submit({
|
|
63
85
|
message: 'Great product!',
|
|
64
|
-
sentiment: '
|
|
86
|
+
sentiment: 'excited', // 'angry' | 'disappointed' | 'satisfied' | 'excited'
|
|
65
87
|
metadata: {
|
|
66
88
|
page_url: window.location.href,
|
|
67
|
-
custom_field: 'value',
|
|
68
89
|
},
|
|
69
90
|
});
|
|
70
91
|
```
|
|
71
92
|
|
|
93
|
+
### Waiting for Ready State
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// Wait until widget is fully initialized
|
|
97
|
+
await feedvalue.waitUntilReady();
|
|
98
|
+
console.log('Widget ready, config loaded');
|
|
99
|
+
|
|
100
|
+
// Or use the event
|
|
101
|
+
feedvalue.on('ready', () => {
|
|
102
|
+
console.log('Widget is ready');
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
72
106
|
### Event Handling
|
|
73
107
|
|
|
74
108
|
```typescript
|
|
@@ -93,6 +127,11 @@ feedvalue.on('error', (error) => {
|
|
|
93
127
|
console.error('Widget error:', error);
|
|
94
128
|
});
|
|
95
129
|
|
|
130
|
+
// Subscribe to a single event emission
|
|
131
|
+
feedvalue.once('ready', () => {
|
|
132
|
+
console.log('First ready event only');
|
|
133
|
+
});
|
|
134
|
+
|
|
96
135
|
// Unsubscribe from events
|
|
97
136
|
feedvalue.off('open', handleOpen);
|
|
98
137
|
```
|
|
@@ -111,17 +150,32 @@ const state = feedvalue.getSnapshot();
|
|
|
111
150
|
// { isReady, isOpen, isVisible, error, isSubmitting }
|
|
112
151
|
```
|
|
113
152
|
|
|
153
|
+
### Configuration Updates
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
// Update runtime configuration
|
|
157
|
+
feedvalue.setConfig({
|
|
158
|
+
theme: 'dark',
|
|
159
|
+
debug: true,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Get current configuration
|
|
163
|
+
const config = feedvalue.getConfig();
|
|
164
|
+
```
|
|
165
|
+
|
|
114
166
|
## API Reference
|
|
115
167
|
|
|
116
168
|
### `FeedValue.init(options)`
|
|
117
169
|
|
|
118
170
|
Initialize a FeedValue instance.
|
|
119
171
|
|
|
120
|
-
| Option | Type | Required | Description |
|
|
121
|
-
|
|
122
|
-
| `widgetId` | `string` | Yes | Widget ID from FeedValue dashboard |
|
|
123
|
-
| `apiBaseUrl` | `string` | No | Custom API URL (for self-hosted) |
|
|
124
|
-
| `config` | `Partial<FeedValueConfig>` | No | Configuration overrides |
|
|
172
|
+
| Option | Type | Required | Default | Description |
|
|
173
|
+
|--------|------|----------|---------|-------------|
|
|
174
|
+
| `widgetId` | `string` | Yes | - | Widget ID from FeedValue dashboard |
|
|
175
|
+
| `apiBaseUrl` | `string` | No | Production URL | Custom API URL (for self-hosted) |
|
|
176
|
+
| `config` | `Partial<FeedValueConfig>` | No | - | Configuration overrides |
|
|
177
|
+
| `headless` | `boolean` | No | `false` | Disable all DOM rendering |
|
|
178
|
+
| `debug` | `boolean` | No | `false` | Enable debug logging |
|
|
125
179
|
|
|
126
180
|
### Instance Methods
|
|
127
181
|
|
|
@@ -132,23 +186,41 @@ Initialize a FeedValue instance.
|
|
|
132
186
|
| `toggle()` | Toggle the modal open/closed |
|
|
133
187
|
| `show()` | Show the trigger button |
|
|
134
188
|
| `hide()` | Hide the trigger button |
|
|
189
|
+
| `isOpen()` | Check if modal is open |
|
|
190
|
+
| `isVisible()` | Check if trigger is visible |
|
|
191
|
+
| `isReady()` | Check if widget is ready |
|
|
192
|
+
| `isHeadless()` | Check if running in headless mode |
|
|
135
193
|
| `submit(feedback)` | Submit feedback programmatically |
|
|
136
194
|
| `identify(userId, traits?)` | Identify the current user |
|
|
137
195
|
| `setData(data)` | Set additional user data |
|
|
138
196
|
| `reset()` | Reset user data |
|
|
139
197
|
| `on(event, handler)` | Subscribe to events |
|
|
198
|
+
| `once(event, handler)` | Subscribe to single event |
|
|
140
199
|
| `off(event, handler?)` | Unsubscribe from events |
|
|
200
|
+
| `waitUntilReady()` | Promise that resolves when ready |
|
|
141
201
|
| `subscribe(callback)` | Subscribe to state changes |
|
|
142
202
|
| `getSnapshot()` | Get current state |
|
|
203
|
+
| `setConfig(config)` | Update runtime configuration |
|
|
143
204
|
| `getConfig()` | Get current configuration |
|
|
144
205
|
| `destroy()` | Destroy the widget instance |
|
|
145
206
|
|
|
207
|
+
### Events
|
|
208
|
+
|
|
209
|
+
| Event | Payload | Description |
|
|
210
|
+
|-------|---------|-------------|
|
|
211
|
+
| `ready` | - | Widget initialized, config loaded |
|
|
212
|
+
| `open` | - | Modal opened |
|
|
213
|
+
| `close` | - | Modal closed |
|
|
214
|
+
| `submit` | `FeedbackData` | Feedback submitted successfully |
|
|
215
|
+
| `error` | `Error` | An error occurred |
|
|
216
|
+
| `stateChange` | `FeedValueState` | Any state change |
|
|
217
|
+
|
|
146
218
|
## Framework Packages
|
|
147
219
|
|
|
148
|
-
For framework-specific integrations:
|
|
220
|
+
For framework-specific integrations with hooks and components:
|
|
149
221
|
|
|
150
|
-
- **React**: [@feedvalue/react](https://www.npmjs.com/package/@feedvalue/react)
|
|
151
|
-
- **Vue**: [@feedvalue/vue](https://www.npmjs.com/package/@feedvalue/vue)
|
|
222
|
+
- **React/Next.js**: [@feedvalue/react](https://www.npmjs.com/package/@feedvalue/react)
|
|
223
|
+
- **Vue/Nuxt**: [@feedvalue/vue](https://www.npmjs.com/package/@feedvalue/vue)
|
|
152
224
|
|
|
153
225
|
## License
|
|
154
226
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@feedvalue/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "FeedValue Core SDK - TypeScript types, initialization, and vanilla JavaScript API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -23,10 +23,19 @@
|
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"dev": "tsup --watch",
|
|
29
|
+
"lint": "eslint src",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest",
|
|
32
|
+
"test:coverage": "vitest run --coverage",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"clean": "rm -rf dist"
|
|
35
|
+
},
|
|
26
36
|
"devDependencies": {
|
|
27
37
|
"@types/node": "^22.10.0",
|
|
28
38
|
"@vitest/coverage-v8": "^2.1.0",
|
|
29
|
-
"eslint": "^9.17.0",
|
|
30
39
|
"happy-dom": "^15.11.0",
|
|
31
40
|
"tsup": "^8.3.0",
|
|
32
41
|
"typescript": "^5.7.0",
|
|
@@ -56,15 +65,5 @@
|
|
|
56
65
|
],
|
|
57
66
|
"engines": {
|
|
58
67
|
"node": ">=18"
|
|
59
|
-
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"build": "tsup",
|
|
62
|
-
"dev": "tsup --watch",
|
|
63
|
-
"lint": "eslint src --ext .ts",
|
|
64
|
-
"test": "vitest run",
|
|
65
|
-
"test:watch": "vitest",
|
|
66
|
-
"test:coverage": "vitest run --coverage",
|
|
67
|
-
"typecheck": "tsc --noEmit",
|
|
68
|
-
"clean": "rm -rf dist"
|
|
69
68
|
}
|
|
70
|
-
}
|
|
69
|
+
}
|