@bugport.dev/widget 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/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/index.cjs +7295 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +576 -0
- package/dist/index.d.ts +576 -0
- package/dist/index.js +7211 -0
- package/dist/index.js.map +1 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BugPort
|
|
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,133 @@
|
|
|
1
|
+
# `@bugport.dev/widget`
|
|
2
|
+
|
|
3
|
+
Install the BugPort customer-facing bug reporting widget:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @bugport.dev/widget
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
React usage:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { BugPortWidget } from '@bugport.dev/widget'
|
|
13
|
+
|
|
14
|
+
export function App() {
|
|
15
|
+
return (
|
|
16
|
+
<BugPortWidget
|
|
17
|
+
projectKey='bp_pub_xxxxx'
|
|
18
|
+
environment='staging'
|
|
19
|
+
apiBaseUrl='http://localhost:8000/v1'
|
|
20
|
+
user={{
|
|
21
|
+
id: 'user_123',
|
|
22
|
+
email: 'qa@example.com',
|
|
23
|
+
name: 'QA Reviewer',
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`publicKey` is also accepted as an alias for `projectKey` when you want the prop name to match the dashboard/widget-key terminology.
|
|
31
|
+
|
|
32
|
+
Imperative mounting:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { initBugPortWidget } from '@bugport.dev/widget'
|
|
36
|
+
|
|
37
|
+
const widget = initBugPortWidget({
|
|
38
|
+
projectKey: 'bp_pub_xxxxx',
|
|
39
|
+
environment: 'staging',
|
|
40
|
+
apiBaseUrl: 'http://localhost:8000/v1',
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
// later
|
|
44
|
+
widget.destroy()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`window.BugPort.init(...)` is also registered automatically when the package runs in a browser bundle.
|
|
48
|
+
|
|
49
|
+
> A CDN/IIFE single-file build is not published yet — the package targets bundler (ESM/CJS) consumers.
|
|
50
|
+
|
|
51
|
+
## Project key setup
|
|
52
|
+
|
|
53
|
+
1. In the BugPort dashboard, open your project → **Widget keys**.
|
|
54
|
+
2. Create a key for the environment you are embedding in (e.g. `staging`,
|
|
55
|
+
`production`).
|
|
56
|
+
3. Copy the public key (`bp_pub_…`) and pass it as `projectKey`.
|
|
57
|
+
|
|
58
|
+
## Allowed origins
|
|
59
|
+
|
|
60
|
+
Widget keys are origin-restricted. Add every site origin that will load the
|
|
61
|
+
widget (e.g. `https://app.yourcompany.com`) to the key's **allowed origins** in
|
|
62
|
+
the dashboard, or submissions will be rejected.
|
|
63
|
+
|
|
64
|
+
## Configuration
|
|
65
|
+
|
|
66
|
+
| Prop | Type | Default | Notes |
|
|
67
|
+
|------|------|---------|-------|
|
|
68
|
+
| `projectKey` / `publicKey` | `string` | — | Public widget key (`bp_pub_…`). Required. |
|
|
69
|
+
| `environment` | `string` | key default | Matches the widget key environment. |
|
|
70
|
+
| `apiBaseUrl` | `string` | `https://api.bugport.dev/v1` | Override for local/self-hosted API. |
|
|
71
|
+
| `user` | `{ id?, email?, name? }` | — | Optional reporter identity. |
|
|
72
|
+
| `diagnostics` | `BugPortDiagnosticsConfig` | disabled | Optional in-page console/network capture (see below). |
|
|
73
|
+
|
|
74
|
+
## Events / callbacks
|
|
75
|
+
|
|
76
|
+
| Callback | Fires when |
|
|
77
|
+
|----------|-----------|
|
|
78
|
+
| `onSubmitted(result)` | A bug was successfully submitted (`result` includes the dashboard URL). |
|
|
79
|
+
| `onError(error)` | Submission or capture failed. |
|
|
80
|
+
| `onSubmitPayload(payload)` | Before submit — inspect/augment the outgoing payload. |
|
|
81
|
+
|
|
82
|
+
## Privacy / captured data
|
|
83
|
+
|
|
84
|
+
The widget captures only what the reporter triggers: feedback text,
|
|
85
|
+
annotations, an optional screenshot, and page context (URL, viewport, user
|
|
86
|
+
agent). Screenshots are optional. Provide a `user` only if you want to
|
|
87
|
+
attribute reports.
|
|
88
|
+
|
|
89
|
+
## Diagnostics (console & network capture)
|
|
90
|
+
|
|
91
|
+
Optionally attach in-page diagnostics — console logs, runtime errors, and
|
|
92
|
+
fetch/XHR network activity — so a bug report carries the context an engineer
|
|
93
|
+
needs. **Off by default**; nothing is instrumented until you opt in.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<BugPortWidget
|
|
97
|
+
projectKey="bp_pub_xxxxx"
|
|
98
|
+
diagnostics={{
|
|
99
|
+
enabled: true,
|
|
100
|
+
console: true,
|
|
101
|
+
runtimeErrors: true,
|
|
102
|
+
network: true, // fetch + XHR
|
|
103
|
+
requestBodies: false, // bodies are off by default (privacy)
|
|
104
|
+
responseBodies: false,
|
|
105
|
+
userControlled: true, // show end-user attach toggles in the report form
|
|
106
|
+
deniedUrls: [/\/auth\//, 'https://api.stripe.com'],
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Privacy safeguards: request/response bodies are **opt-in**; common secrets
|
|
112
|
+
(auth headers, tokens, password-like values) are **redacted** by default
|
|
113
|
+
(`redactHeaders` / `redactPatterns` extend this); `allowedUrls` / `deniedUrls`
|
|
114
|
+
scope what network traffic is captured; and `userControlled` lets the reporter
|
|
115
|
+
decide what to attach. Buffer sizes are bounded via the `max*Events` options.
|
|
116
|
+
|
|
117
|
+
The collector lifecycle is managed for you — instrumentation installs on mount
|
|
118
|
+
and is fully removed on unmount. Lower-level helpers (`DiagnosticsCollector`,
|
|
119
|
+
`buildDiagnosticsPayload`, the `redact*` utilities) are also exported for
|
|
120
|
+
advanced use.
|
|
121
|
+
|
|
122
|
+
## Troubleshooting
|
|
123
|
+
|
|
124
|
+
- **Submissions rejected (403/origin)** → add your site origin to the widget
|
|
125
|
+
key's allowed origins.
|
|
126
|
+
- **Requests 404** → check `apiBaseUrl`; it must resolve to a BugPort API base
|
|
127
|
+
ending in `/v1`.
|
|
128
|
+
- **Nothing renders** → ensure React 18+ is installed (peer dependency) and the
|
|
129
|
+
component is mounted client-side.
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT © BugPort. See [LICENSE](./LICENSE).
|