@cohiva/support-widget 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/README.md +208 -0
- package/dist/index.cjs +1048 -0
- package/dist/index.d.cts +199 -0
- package/dist/index.d.ts +199 -0
- package/dist/index.js +1008 -0
- package/dist/styles.css +243 -0
- package/dist/widget-PDWZ5OMY.css +243 -0
- package/package.json +90 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type FeedbackType = 'bug' | 'feature' | 'feedback' | 'improvement';
|
|
4
|
+
type FeedbackPriority = 'low' | 'medium' | 'high' | 'critical';
|
|
5
|
+
type FeedbackFrequency = '' | 'once' | 'sometimes' | 'often' | 'every_time';
|
|
6
|
+
type FeedbackImpactLevel = '' | 'minor' | 'moderate' | 'major' | 'critical';
|
|
7
|
+
interface FeedbackFormData {
|
|
8
|
+
type: FeedbackType | '';
|
|
9
|
+
title: string;
|
|
10
|
+
priority: FeedbackPriority;
|
|
11
|
+
satisfaction_rating: number | null;
|
|
12
|
+
experience_summary: string;
|
|
13
|
+
what_were_you_doing: string;
|
|
14
|
+
what_happened: string;
|
|
15
|
+
expected_outcome: string;
|
|
16
|
+
steps_to_reproduce: string;
|
|
17
|
+
desired_solution: string;
|
|
18
|
+
impact_details: string;
|
|
19
|
+
additional_context: string;
|
|
20
|
+
frequency: FeedbackFrequency;
|
|
21
|
+
impact_level: FeedbackImpactLevel;
|
|
22
|
+
}
|
|
23
|
+
interface DiagnosticItem {
|
|
24
|
+
timestamp?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
message?: string;
|
|
27
|
+
}
|
|
28
|
+
interface DiagnosticsSnapshot {
|
|
29
|
+
page_title?: string;
|
|
30
|
+
page_url?: string;
|
|
31
|
+
current_route?: string;
|
|
32
|
+
referrer?: string;
|
|
33
|
+
language?: string;
|
|
34
|
+
languages?: string[];
|
|
35
|
+
timezone?: string;
|
|
36
|
+
submitted_at_client?: string;
|
|
37
|
+
browser_info?: string;
|
|
38
|
+
online?: boolean;
|
|
39
|
+
device_pixel_ratio?: number;
|
|
40
|
+
viewport?: {
|
|
41
|
+
width?: number;
|
|
42
|
+
height?: number;
|
|
43
|
+
};
|
|
44
|
+
screen?: {
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
};
|
|
48
|
+
network_info?: {
|
|
49
|
+
type?: string;
|
|
50
|
+
effective_type?: string;
|
|
51
|
+
downlink_mbps?: number;
|
|
52
|
+
rtt_ms?: number;
|
|
53
|
+
save_data?: boolean;
|
|
54
|
+
};
|
|
55
|
+
performance_timing?: {
|
|
56
|
+
page_load_ms?: number;
|
|
57
|
+
dom_interactive_ms?: number;
|
|
58
|
+
dom_content_loaded_ms?: number;
|
|
59
|
+
ttfb_ms?: number;
|
|
60
|
+
};
|
|
61
|
+
memory_info?: {
|
|
62
|
+
used_js_heap_mb?: number;
|
|
63
|
+
total_js_heap_mb?: number;
|
|
64
|
+
limit_mb?: number;
|
|
65
|
+
};
|
|
66
|
+
recent_actions?: DiagnosticItem[];
|
|
67
|
+
recent_console_errors?: DiagnosticItem[];
|
|
68
|
+
}
|
|
69
|
+
interface SubmitFeedbackRequest {
|
|
70
|
+
type: FeedbackType;
|
|
71
|
+
title: string;
|
|
72
|
+
description: string;
|
|
73
|
+
priority: FeedbackPriority;
|
|
74
|
+
satisfaction_rating?: number | null;
|
|
75
|
+
page_url?: string;
|
|
76
|
+
browser_info?: string;
|
|
77
|
+
experience_details?: Record<string, unknown>;
|
|
78
|
+
technical_context?: DiagnosticsSnapshot;
|
|
79
|
+
app_name?: string;
|
|
80
|
+
environment?: string;
|
|
81
|
+
repo_slug?: string;
|
|
82
|
+
route_path?: string;
|
|
83
|
+
context?: Record<string, unknown>;
|
|
84
|
+
custom_fields?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
interface ValidationResult {
|
|
87
|
+
valid: boolean;
|
|
88
|
+
title?: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
}
|
|
91
|
+
interface RouteMeta {
|
|
92
|
+
pathname?: string;
|
|
93
|
+
href?: string;
|
|
94
|
+
title?: string;
|
|
95
|
+
}
|
|
96
|
+
interface DiagnosticsEntry {
|
|
97
|
+
type: string;
|
|
98
|
+
message: string;
|
|
99
|
+
}
|
|
100
|
+
interface DiagnosticsConfig {
|
|
101
|
+
enabled?: boolean;
|
|
102
|
+
captureClicks?: boolean;
|
|
103
|
+
captureFormSubmits?: boolean;
|
|
104
|
+
captureConsoleWarnings?: boolean;
|
|
105
|
+
captureConsoleErrors?: boolean;
|
|
106
|
+
captureUnhandledRejections?: boolean;
|
|
107
|
+
captureWindowErrors?: boolean;
|
|
108
|
+
redact?: (entry: DiagnosticsEntry) => DiagnosticsEntry | null;
|
|
109
|
+
clearPolicy?: 'on_success' | 'on_close' | 'manual';
|
|
110
|
+
}
|
|
111
|
+
interface FeedbackTypeFieldConfig {
|
|
112
|
+
key: keyof FeedbackFormData;
|
|
113
|
+
label: string;
|
|
114
|
+
placeholder?: string;
|
|
115
|
+
helpText?: string;
|
|
116
|
+
required?: boolean;
|
|
117
|
+
inputType?: 'text' | 'textarea' | 'rating';
|
|
118
|
+
}
|
|
119
|
+
interface FeedbackTypeConfig {
|
|
120
|
+
value: FeedbackType;
|
|
121
|
+
label: string;
|
|
122
|
+
description: string;
|
|
123
|
+
icon?: string;
|
|
124
|
+
fields: FeedbackTypeFieldConfig[];
|
|
125
|
+
}
|
|
126
|
+
interface SupportWidgetTheme {
|
|
127
|
+
classNames?: Partial<Record<string, string>>;
|
|
128
|
+
launcherLabel?: string;
|
|
129
|
+
}
|
|
130
|
+
type SubmissionMode = 'central_api' | 'github_issue_proxy';
|
|
131
|
+
interface SubmissionConfig {
|
|
132
|
+
mode?: SubmissionMode;
|
|
133
|
+
endpointPath?: string;
|
|
134
|
+
}
|
|
135
|
+
interface SupportWidgetConfig {
|
|
136
|
+
appName: string;
|
|
137
|
+
environment: string;
|
|
138
|
+
repoSlug: string;
|
|
139
|
+
apiBaseUrl: string;
|
|
140
|
+
getCurrentRoute: () => RouteMeta;
|
|
141
|
+
getCurrentUserContext?: () => Record<string, unknown>;
|
|
142
|
+
getAuthToken?: () => string | null;
|
|
143
|
+
customFields?: Record<string, unknown>;
|
|
144
|
+
diagnostics?: DiagnosticsConfig;
|
|
145
|
+
theme?: SupportWidgetTheme;
|
|
146
|
+
submission?: SubmissionConfig;
|
|
147
|
+
}
|
|
148
|
+
interface SubmitResult {
|
|
149
|
+
message?: string;
|
|
150
|
+
feedback_id?: string;
|
|
151
|
+
type?: FeedbackType;
|
|
152
|
+
issue_number?: number;
|
|
153
|
+
issue_url?: string;
|
|
154
|
+
repo_slug?: string;
|
|
155
|
+
assigned_to?: string[];
|
|
156
|
+
warnings?: string[];
|
|
157
|
+
[key: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
interface SupportWidgetProps {
|
|
160
|
+
config: SupportWidgetConfig;
|
|
161
|
+
isVisible?: boolean;
|
|
162
|
+
onSuccess?: (result: SubmitResult) => void;
|
|
163
|
+
onError?: (error: unknown) => void;
|
|
164
|
+
onSubmit?: (payload: SubmitFeedbackRequest) => Promise<SubmitResult>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare function SupportWidget({ config, isVisible, onSuccess, onError, onSubmit }: SupportWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
168
|
+
|
|
169
|
+
declare const feedbackFieldLabels: Record<keyof FeedbackFormData, string>;
|
|
170
|
+
declare const feedbackTypes: FeedbackTypeConfig[];
|
|
171
|
+
declare function createEmptyFeedbackForm(): FeedbackFormData;
|
|
172
|
+
declare function getRequiredFeedbackFields(type: FeedbackType): Array<keyof FeedbackFormData>;
|
|
173
|
+
declare function validateFeedbackForm(formData: FeedbackFormData): ValidationResult;
|
|
174
|
+
declare function buildExperienceDetailsPayload(formData: FeedbackFormData): Record<string, unknown>;
|
|
175
|
+
|
|
176
|
+
declare function buildFeedbackDescription(formData: FeedbackFormData, diagnostics?: DiagnosticsSnapshot): string;
|
|
177
|
+
|
|
178
|
+
declare function installFeedbackDiagnostics(config?: DiagnosticsConfig): () => void;
|
|
179
|
+
declare function clearFeedbackDiagnostics(): void;
|
|
180
|
+
declare function recordFeedbackRouteVisit(route: RouteMeta): void;
|
|
181
|
+
declare function getFeedbackDiagnosticsSnapshot(route?: RouteMeta): DiagnosticsSnapshot;
|
|
182
|
+
|
|
183
|
+
interface CentralApiClientOptions {
|
|
184
|
+
apiBaseUrl: string;
|
|
185
|
+
getAuthToken?: () => string | null;
|
|
186
|
+
endpointPath?: string;
|
|
187
|
+
fetchImpl?: typeof fetch;
|
|
188
|
+
}
|
|
189
|
+
declare function createCentralFeedbackClient(options: CentralApiClientOptions): (payload: SubmitFeedbackRequest) => Promise<SubmitResult>;
|
|
190
|
+
|
|
191
|
+
interface GitHubIssueProxyClientOptions {
|
|
192
|
+
apiBaseUrl: string;
|
|
193
|
+
getAuthToken?: () => string | null;
|
|
194
|
+
endpointPath?: string;
|
|
195
|
+
fetchImpl?: typeof fetch;
|
|
196
|
+
}
|
|
197
|
+
declare function createGitHubIssueProxyClient(options: GitHubIssueProxyClientOptions): (payload: SubmitFeedbackRequest) => Promise<SubmitResult>;
|
|
198
|
+
|
|
199
|
+
export { type DiagnosticsConfig, type DiagnosticsSnapshot, type FeedbackFormData, type FeedbackType, type SubmissionConfig, type SubmissionMode, type SubmitFeedbackRequest, type SubmitResult, SupportWidget, type SupportWidgetConfig, type SupportWidgetProps, buildExperienceDetailsPayload, buildFeedbackDescription, clearFeedbackDiagnostics, createCentralFeedbackClient, createEmptyFeedbackForm, createGitHubIssueProxyClient, feedbackFieldLabels, feedbackTypes, getFeedbackDiagnosticsSnapshot, getRequiredFeedbackFields, installFeedbackDiagnostics, recordFeedbackRouteVisit, validateFeedbackForm };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
type FeedbackType = 'bug' | 'feature' | 'feedback' | 'improvement';
|
|
4
|
+
type FeedbackPriority = 'low' | 'medium' | 'high' | 'critical';
|
|
5
|
+
type FeedbackFrequency = '' | 'once' | 'sometimes' | 'often' | 'every_time';
|
|
6
|
+
type FeedbackImpactLevel = '' | 'minor' | 'moderate' | 'major' | 'critical';
|
|
7
|
+
interface FeedbackFormData {
|
|
8
|
+
type: FeedbackType | '';
|
|
9
|
+
title: string;
|
|
10
|
+
priority: FeedbackPriority;
|
|
11
|
+
satisfaction_rating: number | null;
|
|
12
|
+
experience_summary: string;
|
|
13
|
+
what_were_you_doing: string;
|
|
14
|
+
what_happened: string;
|
|
15
|
+
expected_outcome: string;
|
|
16
|
+
steps_to_reproduce: string;
|
|
17
|
+
desired_solution: string;
|
|
18
|
+
impact_details: string;
|
|
19
|
+
additional_context: string;
|
|
20
|
+
frequency: FeedbackFrequency;
|
|
21
|
+
impact_level: FeedbackImpactLevel;
|
|
22
|
+
}
|
|
23
|
+
interface DiagnosticItem {
|
|
24
|
+
timestamp?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
message?: string;
|
|
27
|
+
}
|
|
28
|
+
interface DiagnosticsSnapshot {
|
|
29
|
+
page_title?: string;
|
|
30
|
+
page_url?: string;
|
|
31
|
+
current_route?: string;
|
|
32
|
+
referrer?: string;
|
|
33
|
+
language?: string;
|
|
34
|
+
languages?: string[];
|
|
35
|
+
timezone?: string;
|
|
36
|
+
submitted_at_client?: string;
|
|
37
|
+
browser_info?: string;
|
|
38
|
+
online?: boolean;
|
|
39
|
+
device_pixel_ratio?: number;
|
|
40
|
+
viewport?: {
|
|
41
|
+
width?: number;
|
|
42
|
+
height?: number;
|
|
43
|
+
};
|
|
44
|
+
screen?: {
|
|
45
|
+
width?: number;
|
|
46
|
+
height?: number;
|
|
47
|
+
};
|
|
48
|
+
network_info?: {
|
|
49
|
+
type?: string;
|
|
50
|
+
effective_type?: string;
|
|
51
|
+
downlink_mbps?: number;
|
|
52
|
+
rtt_ms?: number;
|
|
53
|
+
save_data?: boolean;
|
|
54
|
+
};
|
|
55
|
+
performance_timing?: {
|
|
56
|
+
page_load_ms?: number;
|
|
57
|
+
dom_interactive_ms?: number;
|
|
58
|
+
dom_content_loaded_ms?: number;
|
|
59
|
+
ttfb_ms?: number;
|
|
60
|
+
};
|
|
61
|
+
memory_info?: {
|
|
62
|
+
used_js_heap_mb?: number;
|
|
63
|
+
total_js_heap_mb?: number;
|
|
64
|
+
limit_mb?: number;
|
|
65
|
+
};
|
|
66
|
+
recent_actions?: DiagnosticItem[];
|
|
67
|
+
recent_console_errors?: DiagnosticItem[];
|
|
68
|
+
}
|
|
69
|
+
interface SubmitFeedbackRequest {
|
|
70
|
+
type: FeedbackType;
|
|
71
|
+
title: string;
|
|
72
|
+
description: string;
|
|
73
|
+
priority: FeedbackPriority;
|
|
74
|
+
satisfaction_rating?: number | null;
|
|
75
|
+
page_url?: string;
|
|
76
|
+
browser_info?: string;
|
|
77
|
+
experience_details?: Record<string, unknown>;
|
|
78
|
+
technical_context?: DiagnosticsSnapshot;
|
|
79
|
+
app_name?: string;
|
|
80
|
+
environment?: string;
|
|
81
|
+
repo_slug?: string;
|
|
82
|
+
route_path?: string;
|
|
83
|
+
context?: Record<string, unknown>;
|
|
84
|
+
custom_fields?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
interface ValidationResult {
|
|
87
|
+
valid: boolean;
|
|
88
|
+
title?: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
}
|
|
91
|
+
interface RouteMeta {
|
|
92
|
+
pathname?: string;
|
|
93
|
+
href?: string;
|
|
94
|
+
title?: string;
|
|
95
|
+
}
|
|
96
|
+
interface DiagnosticsEntry {
|
|
97
|
+
type: string;
|
|
98
|
+
message: string;
|
|
99
|
+
}
|
|
100
|
+
interface DiagnosticsConfig {
|
|
101
|
+
enabled?: boolean;
|
|
102
|
+
captureClicks?: boolean;
|
|
103
|
+
captureFormSubmits?: boolean;
|
|
104
|
+
captureConsoleWarnings?: boolean;
|
|
105
|
+
captureConsoleErrors?: boolean;
|
|
106
|
+
captureUnhandledRejections?: boolean;
|
|
107
|
+
captureWindowErrors?: boolean;
|
|
108
|
+
redact?: (entry: DiagnosticsEntry) => DiagnosticsEntry | null;
|
|
109
|
+
clearPolicy?: 'on_success' | 'on_close' | 'manual';
|
|
110
|
+
}
|
|
111
|
+
interface FeedbackTypeFieldConfig {
|
|
112
|
+
key: keyof FeedbackFormData;
|
|
113
|
+
label: string;
|
|
114
|
+
placeholder?: string;
|
|
115
|
+
helpText?: string;
|
|
116
|
+
required?: boolean;
|
|
117
|
+
inputType?: 'text' | 'textarea' | 'rating';
|
|
118
|
+
}
|
|
119
|
+
interface FeedbackTypeConfig {
|
|
120
|
+
value: FeedbackType;
|
|
121
|
+
label: string;
|
|
122
|
+
description: string;
|
|
123
|
+
icon?: string;
|
|
124
|
+
fields: FeedbackTypeFieldConfig[];
|
|
125
|
+
}
|
|
126
|
+
interface SupportWidgetTheme {
|
|
127
|
+
classNames?: Partial<Record<string, string>>;
|
|
128
|
+
launcherLabel?: string;
|
|
129
|
+
}
|
|
130
|
+
type SubmissionMode = 'central_api' | 'github_issue_proxy';
|
|
131
|
+
interface SubmissionConfig {
|
|
132
|
+
mode?: SubmissionMode;
|
|
133
|
+
endpointPath?: string;
|
|
134
|
+
}
|
|
135
|
+
interface SupportWidgetConfig {
|
|
136
|
+
appName: string;
|
|
137
|
+
environment: string;
|
|
138
|
+
repoSlug: string;
|
|
139
|
+
apiBaseUrl: string;
|
|
140
|
+
getCurrentRoute: () => RouteMeta;
|
|
141
|
+
getCurrentUserContext?: () => Record<string, unknown>;
|
|
142
|
+
getAuthToken?: () => string | null;
|
|
143
|
+
customFields?: Record<string, unknown>;
|
|
144
|
+
diagnostics?: DiagnosticsConfig;
|
|
145
|
+
theme?: SupportWidgetTheme;
|
|
146
|
+
submission?: SubmissionConfig;
|
|
147
|
+
}
|
|
148
|
+
interface SubmitResult {
|
|
149
|
+
message?: string;
|
|
150
|
+
feedback_id?: string;
|
|
151
|
+
type?: FeedbackType;
|
|
152
|
+
issue_number?: number;
|
|
153
|
+
issue_url?: string;
|
|
154
|
+
repo_slug?: string;
|
|
155
|
+
assigned_to?: string[];
|
|
156
|
+
warnings?: string[];
|
|
157
|
+
[key: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
interface SupportWidgetProps {
|
|
160
|
+
config: SupportWidgetConfig;
|
|
161
|
+
isVisible?: boolean;
|
|
162
|
+
onSuccess?: (result: SubmitResult) => void;
|
|
163
|
+
onError?: (error: unknown) => void;
|
|
164
|
+
onSubmit?: (payload: SubmitFeedbackRequest) => Promise<SubmitResult>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
declare function SupportWidget({ config, isVisible, onSuccess, onError, onSubmit }: SupportWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
168
|
+
|
|
169
|
+
declare const feedbackFieldLabels: Record<keyof FeedbackFormData, string>;
|
|
170
|
+
declare const feedbackTypes: FeedbackTypeConfig[];
|
|
171
|
+
declare function createEmptyFeedbackForm(): FeedbackFormData;
|
|
172
|
+
declare function getRequiredFeedbackFields(type: FeedbackType): Array<keyof FeedbackFormData>;
|
|
173
|
+
declare function validateFeedbackForm(formData: FeedbackFormData): ValidationResult;
|
|
174
|
+
declare function buildExperienceDetailsPayload(formData: FeedbackFormData): Record<string, unknown>;
|
|
175
|
+
|
|
176
|
+
declare function buildFeedbackDescription(formData: FeedbackFormData, diagnostics?: DiagnosticsSnapshot): string;
|
|
177
|
+
|
|
178
|
+
declare function installFeedbackDiagnostics(config?: DiagnosticsConfig): () => void;
|
|
179
|
+
declare function clearFeedbackDiagnostics(): void;
|
|
180
|
+
declare function recordFeedbackRouteVisit(route: RouteMeta): void;
|
|
181
|
+
declare function getFeedbackDiagnosticsSnapshot(route?: RouteMeta): DiagnosticsSnapshot;
|
|
182
|
+
|
|
183
|
+
interface CentralApiClientOptions {
|
|
184
|
+
apiBaseUrl: string;
|
|
185
|
+
getAuthToken?: () => string | null;
|
|
186
|
+
endpointPath?: string;
|
|
187
|
+
fetchImpl?: typeof fetch;
|
|
188
|
+
}
|
|
189
|
+
declare function createCentralFeedbackClient(options: CentralApiClientOptions): (payload: SubmitFeedbackRequest) => Promise<SubmitResult>;
|
|
190
|
+
|
|
191
|
+
interface GitHubIssueProxyClientOptions {
|
|
192
|
+
apiBaseUrl: string;
|
|
193
|
+
getAuthToken?: () => string | null;
|
|
194
|
+
endpointPath?: string;
|
|
195
|
+
fetchImpl?: typeof fetch;
|
|
196
|
+
}
|
|
197
|
+
declare function createGitHubIssueProxyClient(options: GitHubIssueProxyClientOptions): (payload: SubmitFeedbackRequest) => Promise<SubmitResult>;
|
|
198
|
+
|
|
199
|
+
export { type DiagnosticsConfig, type DiagnosticsSnapshot, type FeedbackFormData, type FeedbackType, type SubmissionConfig, type SubmissionMode, type SubmitFeedbackRequest, type SubmitResult, SupportWidget, type SupportWidgetConfig, type SupportWidgetProps, buildExperienceDetailsPayload, buildFeedbackDescription, clearFeedbackDiagnostics, createCentralFeedbackClient, createEmptyFeedbackForm, createGitHubIssueProxyClient, feedbackFieldLabels, feedbackTypes, getFeedbackDiagnosticsSnapshot, getRequiredFeedbackFields, installFeedbackDiagnostics, recordFeedbackRouteVisit, validateFeedbackForm };
|