@bugdump/sdk 0.0.1 → 0.0.4
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 +165 -17
- package/dist/index.cjs +264 -135
- package/dist/index.d.cts +19 -4
- package/dist/index.d.ts +19 -4
- package/dist/index.global.js +325 -184
- package/dist/index.js +264 -135
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,10 +9,22 @@ Official TypeScript SDK for [Bugdump](https://bugdump.com) - embed a bug reporti
|
|
|
9
9
|
- **Screenshot annotations** - Users can draw, highlight, and blur parts of screenshots
|
|
10
10
|
- **TypeScript-first** - Full type definitions out of the box
|
|
11
11
|
- **Shadow DOM isolated** - Widget styles never leak into your app
|
|
12
|
-
- **
|
|
12
|
+
- **Auto-init** - Single script tag with `data-api-key`, no JS required
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
16
|
+
### Script Tag (Recommended)
|
|
17
|
+
|
|
18
|
+
Drop a single line into your HTML — the widget initializes automatically:
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<script src="https://bugdump.com/sdk/latest.js" data-api-key="your-api-key"></script>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
That's it. A floating bug report button will appear on your page.
|
|
25
|
+
|
|
26
|
+
### npm
|
|
27
|
+
|
|
16
28
|
```bash
|
|
17
29
|
npm install @bugdump/sdk
|
|
18
30
|
# or
|
|
@@ -21,40 +33,84 @@ pnpm add @bugdump/sdk
|
|
|
21
33
|
yarn add @bugdump/sdk
|
|
22
34
|
```
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
```typescript
|
|
37
|
+
import { Bugdump } from '@bugdump/sdk';
|
|
38
|
+
|
|
39
|
+
const bugdump = Bugdump.init({
|
|
40
|
+
projectKey: 'your-project-key',
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Manual IIFE (without auto-init)
|
|
25
45
|
|
|
26
46
|
```html
|
|
27
|
-
<script src="https://
|
|
47
|
+
<script src="https://bugdump.com/sdk/latest.js"></script>
|
|
28
48
|
<script>
|
|
29
|
-
Bugdump.
|
|
49
|
+
Bugdump.init({ projectKey: 'your-project-key' });
|
|
30
50
|
</script>
|
|
31
51
|
```
|
|
32
52
|
|
|
33
|
-
##
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
55
|
+
| Option | Type | Required | Description |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| `projectKey` | `string` | Yes | Your Bugdump project key |
|
|
58
|
+
| `hideButton` | `boolean` | No | Hide the floating button and trigger the widget programmatically |
|
|
59
|
+
|
|
60
|
+
## Headless Mode (No Floating Button)
|
|
61
|
+
|
|
62
|
+
Hide the default floating button and trigger the report form from your own UI:
|
|
63
|
+
|
|
64
|
+
### npm
|
|
34
65
|
|
|
35
66
|
```typescript
|
|
36
67
|
import { Bugdump } from '@bugdump/sdk';
|
|
37
68
|
|
|
38
69
|
const bugdump = Bugdump.init({
|
|
39
70
|
projectKey: 'your-project-key',
|
|
71
|
+
hideButton: true,
|
|
40
72
|
});
|
|
41
|
-
```
|
|
42
73
|
|
|
43
|
-
|
|
74
|
+
// Open from your own button, menu item, keyboard shortcut, etc.
|
|
75
|
+
document.getElementById('my-report-btn')?.addEventListener('click', () => {
|
|
76
|
+
bugdump.open();
|
|
77
|
+
});
|
|
78
|
+
```
|
|
44
79
|
|
|
45
|
-
|
|
80
|
+
### Script Tag
|
|
46
81
|
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
```html
|
|
83
|
+
<script src="https://bugdump.com/sdk/latest.js" data-api-key="your-api-key" data-hide-button="true"></script>
|
|
84
|
+
<script>
|
|
85
|
+
document.getElementById('my-report-btn').addEventListener('click', function () {
|
|
86
|
+
Bugdump.getInstance().open();
|
|
87
|
+
});
|
|
88
|
+
</script>
|
|
52
89
|
```
|
|
53
90
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
### React example
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
import { useEffect, useCallback } from 'react';
|
|
95
|
+
import { Bugdump } from '@bugdump/sdk';
|
|
96
|
+
|
|
97
|
+
function App() {
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
const bugdump = Bugdump.init({
|
|
100
|
+
projectKey: 'your-project-key',
|
|
101
|
+
hideButton: true,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return () => bugdump.destroy();
|
|
105
|
+
}, []);
|
|
106
|
+
|
|
107
|
+
const openReportForm = useCallback(() => {
|
|
108
|
+
Bugdump.getInstance()?.open();
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
return <button onClick={openReportForm}>Report a Bug</button>;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
58
114
|
|
|
59
115
|
## Identify Users
|
|
60
116
|
|
|
@@ -68,6 +124,98 @@ bugdump.identify({
|
|
|
68
124
|
});
|
|
69
125
|
```
|
|
70
126
|
|
|
127
|
+
## Restrict to Authenticated Users Only
|
|
128
|
+
|
|
129
|
+
By default, anyone visiting your site can submit bug reports. If you want to allow only your registered (logged-in) users to report bugs, initialize the SDK **after** authentication and call `identify()` with the user's info.
|
|
130
|
+
|
|
131
|
+
### npm
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import { Bugdump } from '@bugdump/sdk';
|
|
135
|
+
|
|
136
|
+
// Initialize only after the user has logged in
|
|
137
|
+
function onUserLogin(user: { id: string; name: string; email: string }) {
|
|
138
|
+
const bugdump = Bugdump.init({
|
|
139
|
+
projectKey: 'your-project-key',
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
bugdump.identify({
|
|
143
|
+
id: user.id,
|
|
144
|
+
name: user.name,
|
|
145
|
+
email: user.email,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// Clean up on logout
|
|
150
|
+
function onUserLogout() {
|
|
151
|
+
Bugdump.getInstance()?.destroy();
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### React example
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { useEffect } from 'react';
|
|
159
|
+
import { Bugdump } from '@bugdump/sdk';
|
|
160
|
+
|
|
161
|
+
function App() {
|
|
162
|
+
const user = useAuth(); // your auth hook
|
|
163
|
+
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
if (!user) return;
|
|
166
|
+
|
|
167
|
+
const bugdump = Bugdump.init({
|
|
168
|
+
projectKey: 'your-project-key',
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
bugdump.identify({
|
|
172
|
+
id: user.id,
|
|
173
|
+
name: user.name,
|
|
174
|
+
email: user.email,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
return () => {
|
|
178
|
+
bugdump.destroy();
|
|
179
|
+
};
|
|
180
|
+
}, [user]);
|
|
181
|
+
|
|
182
|
+
return <div>{/* your app */}</div>;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Script Tag
|
|
187
|
+
|
|
188
|
+
When using the `<script>` tag, **do not** use the `data-api-key` attribute (which auto-initializes the widget for everyone). Instead, load the script without auto-init and initialize manually after authentication:
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<!-- Load the SDK without auto-init (no data-api-key) -->
|
|
192
|
+
<script src="https://bugdump.com/sdk/latest.js"></script>
|
|
193
|
+
|
|
194
|
+
<script>
|
|
195
|
+
// Call this after your user has logged in
|
|
196
|
+
function initBugdump(user) {
|
|
197
|
+
var bugdump = Bugdump.init({ projectKey: 'your-project-key' });
|
|
198
|
+
|
|
199
|
+
bugdump.identify({
|
|
200
|
+
id: user.id,
|
|
201
|
+
name: user.name,
|
|
202
|
+
email: user.email,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Call this on logout
|
|
207
|
+
function destroyBugdump() {
|
|
208
|
+
var instance = Bugdump.getInstance();
|
|
209
|
+
if (instance) instance.destroy();
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Example: init after your app confirms the user is authenticated
|
|
213
|
+
if (window.currentUser) {
|
|
214
|
+
initBugdump(window.currentUser);
|
|
215
|
+
}
|
|
216
|
+
</script>
|
|
217
|
+
```
|
|
218
|
+
|
|
71
219
|
## Custom Context
|
|
72
220
|
|
|
73
221
|
Attach arbitrary data to every report:
|