@intentai/react 2.1.2 → 2.3.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 +315 -160
- package/dist/index.d.mts +334 -85
- package/dist/index.d.ts +334 -85
- package/dist/index.js +2 -1764
- package/dist/index.mjs +2 -1746
- package/package.json +21 -18
- package/dist/styles.css +0 -1047
package/dist/index.d.mts
CHANGED
|
@@ -1,130 +1,379 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1 from 'react';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
categories?: Category[];
|
|
9
|
-
allowVoice?: boolean;
|
|
10
|
-
allowText?: boolean;
|
|
11
|
-
allowScreenshot?: boolean;
|
|
12
|
-
maxRecordingDuration?: number;
|
|
13
|
-
onSubmit?: (feedback: FeedbackData) => Promise<void>;
|
|
14
|
-
onOpen?: () => void;
|
|
15
|
-
onClose?: () => void;
|
|
16
|
-
}
|
|
17
|
-
interface Category {
|
|
4
|
+
/**
|
|
5
|
+
* User identity for feedback attribution
|
|
6
|
+
*/
|
|
7
|
+
interface UserIdentity {
|
|
8
|
+
/** Unique user identifier */
|
|
18
9
|
id: string;
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
/** User email address */
|
|
11
|
+
email?: string;
|
|
12
|
+
/** User display name */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** User avatar URL */
|
|
15
|
+
avatar?: string;
|
|
16
|
+
/** Subscription plan */
|
|
17
|
+
plan?: string;
|
|
18
|
+
/** Company name */
|
|
19
|
+
company?: string;
|
|
20
|
+
/** Custom properties */
|
|
21
|
+
[key: string]: string | number | boolean | undefined;
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Widget position on screen
|
|
25
|
+
*/
|
|
26
|
+
type WidgetPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
27
|
+
/**
|
|
28
|
+
* Widget color theme
|
|
29
|
+
*/
|
|
30
|
+
type WidgetTheme = 'light' | 'dark' | 'auto';
|
|
31
|
+
/**
|
|
32
|
+
* Feedback type categories
|
|
33
|
+
*/
|
|
34
|
+
type FeedbackType = 'bug' | 'feature' | 'question' | 'praise' | 'other';
|
|
35
|
+
/**
|
|
36
|
+
* Sentiment analysis result
|
|
37
|
+
*/
|
|
38
|
+
type Sentiment = 'positive' | 'neutral' | 'negative';
|
|
39
|
+
/**
|
|
40
|
+
* Data returned when feedback is submitted
|
|
41
|
+
*/
|
|
22
42
|
interface FeedbackData {
|
|
23
|
-
|
|
43
|
+
/** Feedback ID */
|
|
44
|
+
id: string;
|
|
45
|
+
/** Type of feedback */
|
|
46
|
+
type: FeedbackType;
|
|
47
|
+
/** Text content */
|
|
24
48
|
content: string;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
49
|
+
/** Voice recording URL */
|
|
50
|
+
voiceUrl?: string;
|
|
51
|
+
/** Screenshot data URL */
|
|
28
52
|
screenshot?: string;
|
|
29
|
-
sentiment
|
|
30
|
-
|
|
53
|
+
/** AI-analyzed sentiment */
|
|
54
|
+
sentiment?: Sentiment;
|
|
55
|
+
/** Submission timestamp */
|
|
56
|
+
createdAt: string;
|
|
31
57
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Options for opening the widget
|
|
60
|
+
*/
|
|
61
|
+
interface OpenOptions {
|
|
62
|
+
/** Pre-select feedback type */
|
|
63
|
+
type?: FeedbackType;
|
|
64
|
+
/** Prefill text content */
|
|
65
|
+
prefill?: {
|
|
66
|
+
text?: string;
|
|
67
|
+
};
|
|
68
|
+
/** Additional metadata for this feedback */
|
|
69
|
+
metadata?: Record<string, unknown>;
|
|
38
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Configuration options for the Intent AI widget
|
|
73
|
+
*/
|
|
39
74
|
interface IntentAIConfig {
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Your Intent AI public key (pk_live_* or pk_test_*)
|
|
77
|
+
* Can also be set via environment variables:
|
|
78
|
+
* - NEXT_PUBLIC_INTENT_AI_KEY
|
|
79
|
+
* - REACT_APP_INTENT_AI_KEY
|
|
80
|
+
* - VITE_INTENT_AI_KEY
|
|
81
|
+
*/
|
|
82
|
+
apiKey?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Widget position on screen
|
|
85
|
+
* @default "bottom-right"
|
|
86
|
+
*/
|
|
87
|
+
position?: WidgetPosition;
|
|
88
|
+
/**
|
|
89
|
+
* Color theme
|
|
90
|
+
* @default "auto"
|
|
91
|
+
*/
|
|
92
|
+
theme?: WidgetTheme;
|
|
93
|
+
/**
|
|
94
|
+
* Primary brand color (hex)
|
|
95
|
+
* @default "#6366f1"
|
|
96
|
+
*/
|
|
51
97
|
primaryColor?: string;
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Show widget button automatically
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
autoShow?: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Initial user identification
|
|
105
|
+
*/
|
|
106
|
+
user?: UserIdentity;
|
|
107
|
+
/**
|
|
108
|
+
* Custom metadata attached to all feedback
|
|
109
|
+
*/
|
|
110
|
+
metadata?: Record<string, unknown>;
|
|
111
|
+
/**
|
|
112
|
+
* Callback when widget is ready
|
|
113
|
+
*/
|
|
114
|
+
onReady?: () => void;
|
|
115
|
+
/**
|
|
116
|
+
* Callback when widget opens
|
|
117
|
+
*/
|
|
65
118
|
onOpen?: () => void;
|
|
66
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Callback when widget closes
|
|
121
|
+
*/
|
|
67
122
|
onClose?: () => void;
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Callback when feedback is submitted
|
|
125
|
+
*/
|
|
126
|
+
onSubmit?: (feedback: FeedbackData) => void;
|
|
127
|
+
/**
|
|
128
|
+
* Callback when an error occurs
|
|
129
|
+
*/
|
|
71
130
|
onError?: (error: Error) => void;
|
|
72
131
|
}
|
|
73
|
-
|
|
74
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Props for IntentAIProvider component
|
|
134
|
+
*/
|
|
135
|
+
interface IntentAIProviderProps extends IntentAIConfig {
|
|
136
|
+
children: React.ReactNode;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Context value for IntentAI provider
|
|
140
|
+
*/
|
|
141
|
+
interface IntentAIContextValue {
|
|
142
|
+
/** Whether the widget is loaded and ready */
|
|
143
|
+
isReady: boolean;
|
|
144
|
+
/** Error if widget failed to load */
|
|
145
|
+
error: Error | null;
|
|
146
|
+
/** Open the feedback widget */
|
|
147
|
+
open: (options?: OpenOptions) => void;
|
|
148
|
+
/** Close the feedback widget */
|
|
75
149
|
close: () => void;
|
|
76
|
-
|
|
77
|
-
|
|
150
|
+
/** Identify a user */
|
|
151
|
+
identify: (user: UserIdentity) => void;
|
|
152
|
+
/** Track a custom event */
|
|
153
|
+
track: (event: string, properties?: Record<string, unknown>) => void;
|
|
154
|
+
/** Set custom metadata */
|
|
155
|
+
setMetadata: (metadata: Record<string, unknown>) => void;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Intent AI widget instance methods
|
|
159
|
+
*/
|
|
160
|
+
interface IntentAIInstance {
|
|
161
|
+
open: (options?: OpenOptions) => void;
|
|
162
|
+
close: () => void;
|
|
163
|
+
identify: (user: UserIdentity) => void;
|
|
164
|
+
track: (event: string, properties?: Record<string, unknown>) => void;
|
|
165
|
+
setMetadata: (metadata: Record<string, unknown>) => void;
|
|
78
166
|
destroy: () => void;
|
|
79
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Window augmentation for Intent AI global
|
|
170
|
+
*/
|
|
80
171
|
declare global {
|
|
81
172
|
interface Window {
|
|
82
|
-
|
|
173
|
+
IntentAI?: IntentAIInstance;
|
|
174
|
+
IntentAIConfig?: IntentAIConfig;
|
|
175
|
+
}
|
|
176
|
+
interface WindowEventMap {
|
|
177
|
+
'intentai:ready': CustomEvent;
|
|
178
|
+
'intentai:open': CustomEvent;
|
|
179
|
+
'intentai:close': CustomEvent;
|
|
180
|
+
'intentai:submit': CustomEvent<FeedbackData>;
|
|
181
|
+
'intentai:error': CustomEvent<Error>;
|
|
83
182
|
}
|
|
84
183
|
}
|
|
184
|
+
|
|
85
185
|
/**
|
|
86
|
-
*
|
|
186
|
+
* Provider component for Intent AI widget
|
|
87
187
|
*
|
|
88
188
|
* @example
|
|
89
189
|
* ```tsx
|
|
90
|
-
* import {
|
|
190
|
+
* import { IntentAIProvider } from '@intentai/react';
|
|
91
191
|
*
|
|
92
192
|
* function App() {
|
|
93
193
|
* return (
|
|
94
|
-
* <
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
194
|
+
* <IntentAIProvider apiKey="pk_live_xxxxx">
|
|
195
|
+
* <YourApp />
|
|
196
|
+
* </IntentAIProvider>
|
|
197
|
+
* );
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
declare function IntentAIProvider({ children, apiKey, user, position, theme, primaryColor, autoShow, metadata, onReady, onOpen, onClose, onSubmit, onError, }: IntentAIProviderProps): react_jsx_runtime.JSX.Element;
|
|
202
|
+
/**
|
|
203
|
+
* Hook to access Intent AI widget controls
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```tsx
|
|
207
|
+
* import { useIntentAI } from '@intentai/react';
|
|
208
|
+
*
|
|
209
|
+
* function FeedbackButton() {
|
|
210
|
+
* const { open, isReady } = useIntentAI();
|
|
211
|
+
*
|
|
212
|
+
* return (
|
|
213
|
+
* <button onClick={() => open()} disabled={!isReady}>
|
|
214
|
+
* Give Feedback
|
|
215
|
+
* </button>
|
|
99
216
|
* );
|
|
100
217
|
* }
|
|
101
218
|
* ```
|
|
102
219
|
*/
|
|
103
|
-
declare function
|
|
220
|
+
declare function useIntentAI(): IntentAIContextValue;
|
|
104
221
|
/**
|
|
105
|
-
* Hook to
|
|
222
|
+
* Hook to automatically identify a user when they're available
|
|
106
223
|
*
|
|
107
224
|
* @example
|
|
108
225
|
* ```tsx
|
|
109
|
-
* import {
|
|
226
|
+
* import { useIdentify } from '@intentai/react';
|
|
227
|
+
*
|
|
228
|
+
* function Profile({ user }) {
|
|
229
|
+
* useIdentify(user ? { id: user.id, email: user.email } : null);
|
|
230
|
+
* return <div>...</div>;
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
declare function useIdentify(user: UserIdentity | null | undefined): void;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Props for FeedbackButton component
|
|
238
|
+
*/
|
|
239
|
+
interface FeedbackButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
240
|
+
/** Options to pass when opening the widget */
|
|
241
|
+
openOptions?: OpenOptions;
|
|
242
|
+
/** Custom children to render */
|
|
243
|
+
children?: React$1.ReactNode;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Pre-built button component to open the feedback widget
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```tsx
|
|
250
|
+
* import { FeedbackButton } from '@intentai/react';
|
|
110
251
|
*
|
|
111
252
|
* function App() {
|
|
112
|
-
*
|
|
253
|
+
* return (
|
|
254
|
+
* <FeedbackButton className="my-custom-class">
|
|
255
|
+
* Send Feedback
|
|
256
|
+
* </FeedbackButton>
|
|
257
|
+
* );
|
|
258
|
+
* }
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
declare const FeedbackButton: React$1.ForwardRefExoticComponent<FeedbackButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
|
|
262
|
+
/**
|
|
263
|
+
* Props for FeedbackTrigger component
|
|
264
|
+
*/
|
|
265
|
+
interface FeedbackTriggerProps {
|
|
266
|
+
/** Render function or element */
|
|
267
|
+
children: React$1.ReactElement | ((props: {
|
|
268
|
+
open: (options?: OpenOptions) => void;
|
|
269
|
+
isReady: boolean;
|
|
270
|
+
error: Error | null;
|
|
271
|
+
}) => React$1.ReactElement);
|
|
272
|
+
/** Options to pass when opening */
|
|
273
|
+
openOptions?: OpenOptions;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Headless component for custom feedback triggers
|
|
113
277
|
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```tsx
|
|
280
|
+
* import { FeedbackTrigger } from '@intentai/react';
|
|
281
|
+
*
|
|
282
|
+
* function App() {
|
|
114
283
|
* return (
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
284
|
+
* <FeedbackTrigger>
|
|
285
|
+
* {({ open, isReady }) => (
|
|
286
|
+
* <MyCustomButton onClick={() => open()} disabled={!isReady}>
|
|
287
|
+
* Feedback
|
|
288
|
+
* </MyCustomButton>
|
|
289
|
+
* )}
|
|
290
|
+
* </FeedbackTrigger>
|
|
119
291
|
* );
|
|
120
292
|
* }
|
|
121
293
|
* ```
|
|
122
294
|
*/
|
|
123
|
-
declare function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
295
|
+
declare function FeedbackTrigger({ children, openOptions }: FeedbackTriggerProps): React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>>;
|
|
296
|
+
/**
|
|
297
|
+
* Props for IdentifyUser component
|
|
298
|
+
*/
|
|
299
|
+
interface IdentifyUserProps {
|
|
300
|
+
/** User to identify */
|
|
301
|
+
user: UserIdentity | null | undefined;
|
|
302
|
+
/** Children to render */
|
|
303
|
+
children?: React$1.ReactNode;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Component to identify a user declaratively
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```tsx
|
|
310
|
+
* import { IdentifyUser } from '@intentai/react';
|
|
311
|
+
*
|
|
312
|
+
* function App({ user }) {
|
|
313
|
+
* return (
|
|
314
|
+
* <IdentifyUser user={user ? { id: user.id, email: user.email } : null}>
|
|
315
|
+
* <YourApp />
|
|
316
|
+
* </IdentifyUser>
|
|
317
|
+
* );
|
|
318
|
+
* }
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
declare function IdentifyUser({ user, children }: IdentifyUserProps): react_jsx_runtime.JSX.Element;
|
|
322
|
+
/**
|
|
323
|
+
* Props for SetMetadata component
|
|
324
|
+
*/
|
|
325
|
+
interface SetMetadataProps {
|
|
326
|
+
/** Metadata to set */
|
|
327
|
+
metadata: Record<string, unknown>;
|
|
328
|
+
/** Children to render */
|
|
329
|
+
children?: React$1.ReactNode;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Component to set metadata declaratively
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```tsx
|
|
336
|
+
* import { SetMetadata } from '@intentai/react';
|
|
337
|
+
*
|
|
338
|
+
* function PricingPage() {
|
|
339
|
+
* return (
|
|
340
|
+
* <SetMetadata metadata={{ page: 'pricing', plan: 'pro' }}>
|
|
341
|
+
* <PricingContent />
|
|
342
|
+
* </SetMetadata>
|
|
343
|
+
* );
|
|
344
|
+
* }
|
|
345
|
+
* ```
|
|
346
|
+
*/
|
|
347
|
+
declare function SetMetadata({ metadata, children }: SetMetadataProps): react_jsx_runtime.JSX.Element;
|
|
348
|
+
/**
|
|
349
|
+
* Props for TrackEvent component
|
|
350
|
+
*/
|
|
351
|
+
interface TrackEventProps {
|
|
352
|
+
/** Event name to track */
|
|
353
|
+
event: string;
|
|
354
|
+
/** Event properties */
|
|
355
|
+
properties?: Record<string, unknown>;
|
|
356
|
+
/** When to track: 'mount' (default) or 'render' */
|
|
357
|
+
trigger?: 'mount' | 'render';
|
|
358
|
+
/** Children to render */
|
|
359
|
+
children?: React$1.ReactNode;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Component to track events declaratively
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```tsx
|
|
366
|
+
* import { TrackEvent } from '@intentai/react';
|
|
367
|
+
*
|
|
368
|
+
* function CheckoutPage() {
|
|
369
|
+
* return (
|
|
370
|
+
* <TrackEvent event="checkout_viewed" properties={{ items: 3 }}>
|
|
371
|
+
* <CheckoutContent />
|
|
372
|
+
* </TrackEvent>
|
|
373
|
+
* );
|
|
374
|
+
* }
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
377
|
+
declare function TrackEvent({ event, properties, trigger, children, }: TrackEventProps): react_jsx_runtime.JSX.Element;
|
|
129
378
|
|
|
130
|
-
export { type IntentAIConfig, type
|
|
379
|
+
export { FeedbackButton, type FeedbackButtonProps, type FeedbackData, FeedbackTrigger, type FeedbackTriggerProps, type FeedbackType, IdentifyUser, type IdentifyUserProps, type IntentAIConfig, type IntentAIContextValue, type IntentAIInstance, IntentAIProvider, type IntentAIProviderProps, type OpenOptions, type Sentiment, SetMetadata, type SetMetadataProps, TrackEvent, type TrackEventProps, type UserIdentity, type WidgetPosition, type WidgetTheme, useIdentify, useIntentAI };
|