@fogg/bug-reporter 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/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/chunk-6TCI6T2U.cjs +45 -0
- package/dist/chunk-6TCI6T2U.cjs.map +1 -0
- package/dist/chunk-S2YRP4GT.js +22 -0
- package/dist/chunk-S2YRP4GT.js.map +1 -0
- package/dist/index.cjs +1963 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +331 -0
- package/dist/index.d.ts +331 -0
- package/dist/index.js +1956 -0
- package/dist/index.js.map +1 -0
- package/dist/recording-ML63ZQ6A.cjs +120 -0
- package/dist/recording-ML63ZQ6A.cjs.map +1 -0
- package/dist/recording-YSR6IORT.js +118 -0
- package/dist/recording-YSR6IORT.js.map +1 -0
- package/dist/screenshot-F4W72WRK.js +176 -0
- package/dist/screenshot-F4W72WRK.js.map +1 -0
- package/dist/screenshot-FRAZAS6B.cjs +178 -0
- package/dist/screenshot-FRAZAS6B.cjs.map +1 -0
- package/dist/styles/index.css +495 -0
- package/dist/styles/index.css.map +1 -0
- package/dist/styles/index.d.cts +2 -0
- package/dist/styles/index.d.ts +2 -0
- package/docs/backend-local.md +16 -0
- package/docs/backend-s3.md +31 -0
- package/docs/browser-compatibility.md +8 -0
- package/docs/framework-cra.md +10 -0
- package/docs/framework-nextjs.md +16 -0
- package/docs/framework-remix.md +6 -0
- package/docs/framework-vite.md +21 -0
- package/docs/known-limitations.md +6 -0
- package/docs/quickstart.md +26 -0
- package/docs/security.md +9 -0
- package/examples/backend-local/README.md +11 -0
- package/examples/backend-local/package.json +13 -0
- package/examples/backend-local/src/server.mjs +31 -0
- package/examples/backend-s3-presign/README.md +14 -0
- package/examples/backend-s3-presign/package.json +13 -0
- package/examples/backend-s3-presign/src/server.mjs +53 -0
- package/examples/sandbox-vite/README.md +25 -0
- package/examples/sandbox-vite/index.html +12 -0
- package/examples/sandbox-vite/package-lock.json +1880 -0
- package/examples/sandbox-vite/package.json +24 -0
- package/examples/sandbox-vite/src/App.tsx +200 -0
- package/examples/sandbox-vite/src/main.tsx +10 -0
- package/examples/sandbox-vite/src/sandbox.css +74 -0
- package/examples/sandbox-vite/tsconfig.json +14 -0
- package/examples/sandbox-vite/vite.config.ts +9 -0
- package/package.json +93 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bug-reporter contributors
|
|
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,114 @@
|
|
|
1
|
+
# bug-reporter
|
|
2
|
+
|
|
3
|
+
`@fogg/bug-reporter` is a React 16.8+ SDK for collecting production bug reports with screenshot capture, short screen recording, diagnostics, and pluggable storage backends.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @fogg/bug-reporter
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quickstart
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { BugReporter } from "@fogg/bug-reporter";
|
|
15
|
+
import "@fogg/bug-reporter/styles.css";
|
|
16
|
+
|
|
17
|
+
export function App() {
|
|
18
|
+
return (
|
|
19
|
+
<BugReporter
|
|
20
|
+
config={{
|
|
21
|
+
apiEndpoint: "/api/bug-reports",
|
|
22
|
+
storage: {
|
|
23
|
+
mode: "local-public",
|
|
24
|
+
local: { uploadEndpoint: "/api/uploads" }
|
|
25
|
+
}
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Capture Console Errors and Requests
|
|
33
|
+
|
|
34
|
+
Enable these flags in config to attach logs and request traces to each report:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<BugReporter
|
|
38
|
+
config={{
|
|
39
|
+
apiEndpoint: "/api/bug-reports",
|
|
40
|
+
storage: { mode: "proxy", proxy: { uploadEndpoint: "/api/bug-assets" } },
|
|
41
|
+
features: {
|
|
42
|
+
consoleLogs: true,
|
|
43
|
+
networkInfo: true
|
|
44
|
+
},
|
|
45
|
+
diagnostics: {
|
|
46
|
+
consoleBufferSize: 200,
|
|
47
|
+
requestBufferSize: 300
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Docs
|
|
54
|
+
|
|
55
|
+
- `docs/quickstart.md`
|
|
56
|
+
- `docs/framework-nextjs.md`
|
|
57
|
+
- `docs/framework-vite.md`
|
|
58
|
+
- `docs/framework-cra.md`
|
|
59
|
+
- `docs/framework-remix.md`
|
|
60
|
+
- `docs/backend-s3.md`
|
|
61
|
+
- `docs/backend-local.md`
|
|
62
|
+
- `docs/security.md`
|
|
63
|
+
- `docs/browser-compatibility.md`
|
|
64
|
+
- `docs/known-limitations.md`
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install
|
|
70
|
+
npm run lint
|
|
71
|
+
npm run typecheck
|
|
72
|
+
npm test
|
|
73
|
+
npm run build
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Local Sandbox (Vite)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm run sandbox:vite
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Sandbox app path: `examples/sandbox-vite`.
|
|
83
|
+
|
|
84
|
+
## Publish To npm
|
|
85
|
+
|
|
86
|
+
1. Login to npm:
|
|
87
|
+
```bash
|
|
88
|
+
npm login
|
|
89
|
+
```
|
|
90
|
+
2. Verify quality/build locally:
|
|
91
|
+
```bash
|
|
92
|
+
npm run release:verify
|
|
93
|
+
```
|
|
94
|
+
3. Verify package contents before publishing:
|
|
95
|
+
```bash
|
|
96
|
+
npm run publish:dry-run
|
|
97
|
+
```
|
|
98
|
+
4. Publish `@fogg/bug-reporter`:
|
|
99
|
+
```bash
|
|
100
|
+
npm run publish:npm
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Changesets workflow
|
|
104
|
+
|
|
105
|
+
For versioned releases with Changesets:
|
|
106
|
+
```bash
|
|
107
|
+
npm run changeset
|
|
108
|
+
npm run version:packages
|
|
109
|
+
npm run release
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule) return e;
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var react__namespace = /*#__PURE__*/_interopNamespace(react);
|
|
24
|
+
|
|
25
|
+
var __defProp = Object.defineProperty;
|
|
26
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
27
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
28
|
+
|
|
29
|
+
// src/types/index.ts
|
|
30
|
+
var BugReporterError = class extends Error {
|
|
31
|
+
constructor(code, message, cause) {
|
|
32
|
+
super(message);
|
|
33
|
+
__publicField(this, "code");
|
|
34
|
+
__publicField(this, "cause");
|
|
35
|
+
this.name = "BugReporterError";
|
|
36
|
+
this.code = code;
|
|
37
|
+
this.cause = cause;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.React = react__namespace;
|
|
42
|
+
exports.BugReporterError = BugReporterError;
|
|
43
|
+
exports.__publicField = __publicField;
|
|
44
|
+
//# sourceMappingURL=chunk-6TCI6T2U.cjs.map
|
|
45
|
+
//# sourceMappingURL=chunk-6TCI6T2U.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+MO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EAI1C,WAAA,CAAY,IAAA,EAA4B,OAAA,EAAiB,KAAA,EAAiB;AACxE,IAAA,KAAA,CAAM,OAAO,CAAA;AAJf,IAAA,aAAA,CAAA,IAAA,EAAS,MAAA,CAAA;AACT,IAAA,aAAA,CAAA,IAAA,EAAS,OAAA,CAAA;AAIP,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF","file":"chunk-6TCI6T2U.cjs","sourcesContent":["import type { ComponentType } from \"react\";\n\nexport type StorageMode = \"s3-presigned\" | \"local-public\" | \"proxy\";\n\nexport type ReportEnvironment = \"development\" | \"staging\" | \"production\";\nexport type AssetType = \"screenshot\" | \"recording\" | \"attachment\";\nexport type FlowStep = \"describe\" | \"screenshot\" | \"recording\" | \"review\" | \"submitting\" | \"success\";\nexport type DockSide = \"left\" | \"right\" | \"top\" | \"bottom\";\nexport type LauncherPosition = \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\";\nexport type ThemeMode = \"dark\" | \"light\";\n\nexport type FeatureFlags = {\n screenshot?: boolean;\n recording?: boolean;\n annotations?: boolean;\n consoleLogs?: boolean;\n networkInfo?: boolean;\n};\n\nexport type ThemeConfig = {\n primaryColor?: string;\n position?: LauncherPosition;\n zIndex?: number;\n borderRadius?: string;\n};\n\nexport type StorageLimits = {\n maxVideoSeconds?: number;\n maxVideoBytes?: number;\n maxScreenshotBytes?: number;\n};\n\nexport type UploadFile = {\n id: string;\n name: string;\n type: AssetType;\n mimeType: string;\n size: number;\n};\n\nexport type UploadInstruction = {\n id: string;\n method: \"PUT\" | \"POST\";\n uploadUrl: string;\n headers?: Record<string, string>;\n fields?: Record<string, string>;\n key?: string;\n publicUrl?: string;\n type: AssetType;\n};\n\nexport type AssetReference = {\n id: string;\n type: AssetType;\n url: string;\n key?: string;\n mimeType?: string;\n size?: number;\n};\n\nexport interface StorageProvider {\n prepareUploads(files: UploadFile[]): Promise<UploadInstruction[]>;\n upload(instruction: UploadInstruction, blob: Blob, onProgress?: (progress: number) => void): Promise<AssetReference>;\n}\n\nexport type CapturedAsset = {\n id: string;\n type: AssetType;\n blob: Blob;\n previewUrl: string;\n mimeType: string;\n filename: string;\n size: number;\n};\n\nexport type DiagnosticsSnapshot = {\n url: string;\n referrer: string;\n timestamp: string;\n timezone: string;\n viewport: {\n width: number;\n height: number;\n pixelRatio: number;\n };\n browser: string;\n os: string;\n language: string;\n userAgent: string;\n userAgentData?: {\n brands?: Array<{\n brand: string;\n version: string;\n }>;\n mobile?: boolean;\n platform?: string;\n };\n appVersion?: string;\n environment?: ReportEnvironment;\n projectId?: string;\n logs?: ConsoleLogEntry[];\n requests?: NetworkRequestEntry[];\n navigationTiming?: {\n domComplete?: number;\n loadEventEnd?: number;\n responseEnd?: number;\n };\n};\n\nexport type ConsoleLogEntry = {\n level: \"log\" | \"info\" | \"warn\" | \"error\";\n message: string;\n timestamp: string;\n};\n\nexport type DiagnosticsPreview = {\n errorLogs: ConsoleLogEntry[];\n failedRequests: NetworkRequestEntry[];\n};\n\nexport type NetworkRequestEntry = {\n transport: \"fetch\" | \"xhr\";\n method: string;\n url: string;\n status?: number;\n ok?: boolean;\n durationMs: number;\n timestamp: string;\n error?: string;\n};\n\nexport type ReportDraft = {\n title: string;\n description: string;\n stepsToReproduce: string;\n expectedBehavior: string;\n actualBehavior: string;\n};\n\nexport type Reporter = {\n id?: string;\n name?: string;\n email?: string;\n role?: string;\n ip?: string;\n anonymous: boolean;\n};\n\nexport type CustomFormProps = {\n attributes: Record<string, unknown>;\n setAttributes: (next: Record<string, unknown>) => void;\n updateAttribute: (key: string, value: unknown) => void;\n};\n\nexport type CustomFormComponent = ComponentType<CustomFormProps>;\n\nexport type BugReportPayload = {\n issue: {\n title: string;\n description: string;\n projectId?: string;\n environment?: ReportEnvironment;\n appVersion?: string;\n assets: AssetReference[];\n };\n context: {\n url: string;\n referrer: string;\n timestamp: string;\n timezone: string;\n viewport: {\n width: number;\n height: number;\n pixelRatio: number;\n };\n client: {\n browser: string;\n os: string;\n language: string;\n userAgent: string;\n };\n userAgentData?: DiagnosticsSnapshot[\"userAgentData\"];\n performance: {\n navigationTiming?: DiagnosticsSnapshot[\"navigationTiming\"];\n };\n logs?: ConsoleLogEntry[];\n requests?: NetworkRequestEntry[];\n };\n reporter: Reporter;\n attributes: Record<string, unknown>;\n};\n\nexport type BugReportResponse = {\n id?: string;\n message?: string;\n [key: string]: unknown;\n};\n\nexport type BugReporterErrorCode =\n | \"VALIDATION_ERROR\"\n | \"CAPTURE_ERROR\"\n | \"RECORDING_ERROR\"\n | \"UPLOAD_ERROR\"\n | \"SUBMIT_ERROR\"\n | \"PERMISSION_DENIED\"\n | \"ABORTED\";\n\nexport class BugReporterError extends Error {\n readonly code: BugReporterErrorCode;\n readonly cause?: unknown;\n\n constructor(code: BugReporterErrorCode, message: string, cause?: unknown) {\n super(message);\n this.name = \"BugReporterError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\nexport type BugReporterConfig = {\n apiEndpoint: string;\n projectId?: string;\n appVersion?: string;\n environment?: ReportEnvironment;\n storage?: {\n mode: StorageMode;\n s3?: {\n presignEndpoint: string;\n publicBaseUrl?: string;\n };\n local?: {\n uploadEndpoint: string;\n publicBaseUrl?: string;\n };\n proxy?: {\n uploadEndpoint: string;\n };\n limits?: StorageLimits;\n };\n auth?: {\n headers?: Record<string, string>;\n withCredentials?: boolean;\n };\n theme?: ThemeConfig;\n features?: FeatureFlags;\n user?: {\n id?: string;\n email?: string;\n name?: string;\n role?: string;\n ip?: string;\n anonymous?: boolean;\n };\n attributes?: Record<string, unknown>;\n privacy?: {\n maskSelectors?: string[];\n redactTextPatterns?: Array<string | RegExp>;\n };\n diagnostics?: {\n consoleBufferSize?: number;\n requestBufferSize?: number;\n };\n hooks?: {\n beforeSubmit?: (payload: BugReportPayload) => Promise<BugReportPayload | null> | BugReportPayload | null;\n onSuccess?: (response: BugReportResponse) => void;\n onError?: (error: BugReporterError) => void;\n };\n};\n\nexport type BugReporterState = {\n isOpen: boolean;\n dockSide: DockSide;\n step: FlowStep;\n draft: ReportDraft;\n attributes: Record<string, unknown>;\n assets: CapturedAsset[];\n diagnostics?: DiagnosticsSnapshot;\n uploadProgress: number;\n isSubmitting: boolean;\n error?: string;\n};\n\nexport type BugReporterContextValue = {\n config: RequiredBugReporterConfig;\n state: BugReporterState;\n open: () => void;\n close: () => void;\n reset: () => void;\n setDockSide: (dockSide: DockSide) => void;\n setStep: (step: FlowStep) => void;\n updateDraft: (next: Partial<ReportDraft>) => void;\n setAttributes: (next: Record<string, unknown>) => void;\n updateAttribute: (key: string, value: unknown) => void;\n setScreenshot: (asset?: CapturedAsset) => void;\n setRecording: (asset?: CapturedAsset) => void;\n submit: () => Promise<void>;\n retrySubmit: () => Promise<void>;\n getDiagnosticsPreview: () => DiagnosticsPreview;\n};\n\nexport type RequiredBugReporterConfig = {\n apiEndpoint: string;\n projectId?: string;\n appVersion?: string;\n environment?: ReportEnvironment;\n storage: {\n mode: StorageMode;\n s3?: {\n presignEndpoint: string;\n publicBaseUrl?: string;\n };\n local?: {\n uploadEndpoint: string;\n publicBaseUrl?: string;\n };\n proxy?: {\n uploadEndpoint: string;\n };\n limits: Required<StorageLimits>;\n };\n auth: {\n headers: Record<string, string>;\n withCredentials: boolean;\n };\n theme: Required<ThemeConfig>;\n features: Required<FeatureFlags>;\n user?: {\n id?: string;\n email?: string;\n name?: string;\n role?: string;\n ip?: string;\n anonymous?: boolean;\n };\n attributes: Record<string, unknown>;\n privacy: {\n maskSelectors: string[];\n redactTextPatterns: Array<string | RegExp>;\n };\n diagnostics: {\n consoleBufferSize: number;\n requestBufferSize: number;\n };\n hooks: {\n beforeSubmit?: (payload: BugReportPayload) => Promise<BugReportPayload | null> | BugReportPayload | null;\n onSuccess?: (response: BugReportResponse) => void;\n onError?: (error: BugReporterError) => void;\n };\n};\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
export { react as React };
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
|
|
8
|
+
// src/types/index.ts
|
|
9
|
+
var BugReporterError = class extends Error {
|
|
10
|
+
constructor(code, message, cause) {
|
|
11
|
+
super(message);
|
|
12
|
+
__publicField(this, "code");
|
|
13
|
+
__publicField(this, "cause");
|
|
14
|
+
this.name = "BugReporterError";
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.cause = cause;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { BugReporterError, __publicField };
|
|
21
|
+
//# sourceMappingURL=chunk-S2YRP4GT.js.map
|
|
22
|
+
//# sourceMappingURL=chunk-S2YRP4GT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/index.ts"],"names":[],"mappings":";;;;;;;;AA+MO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EAI1C,WAAA,CAAY,IAAA,EAA4B,OAAA,EAAiB,KAAA,EAAiB;AACxE,IAAA,KAAA,CAAM,OAAO,CAAA;AAJf,IAAA,aAAA,CAAA,IAAA,EAAS,MAAA,CAAA;AACT,IAAA,aAAA,CAAA,IAAA,EAAS,OAAA,CAAA;AAIP,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF","file":"chunk-S2YRP4GT.js","sourcesContent":["import type { ComponentType } from \"react\";\n\nexport type StorageMode = \"s3-presigned\" | \"local-public\" | \"proxy\";\n\nexport type ReportEnvironment = \"development\" | \"staging\" | \"production\";\nexport type AssetType = \"screenshot\" | \"recording\" | \"attachment\";\nexport type FlowStep = \"describe\" | \"screenshot\" | \"recording\" | \"review\" | \"submitting\" | \"success\";\nexport type DockSide = \"left\" | \"right\" | \"top\" | \"bottom\";\nexport type LauncherPosition = \"bottom-right\" | \"bottom-left\" | \"top-right\" | \"top-left\";\nexport type ThemeMode = \"dark\" | \"light\";\n\nexport type FeatureFlags = {\n screenshot?: boolean;\n recording?: boolean;\n annotations?: boolean;\n consoleLogs?: boolean;\n networkInfo?: boolean;\n};\n\nexport type ThemeConfig = {\n primaryColor?: string;\n position?: LauncherPosition;\n zIndex?: number;\n borderRadius?: string;\n};\n\nexport type StorageLimits = {\n maxVideoSeconds?: number;\n maxVideoBytes?: number;\n maxScreenshotBytes?: number;\n};\n\nexport type UploadFile = {\n id: string;\n name: string;\n type: AssetType;\n mimeType: string;\n size: number;\n};\n\nexport type UploadInstruction = {\n id: string;\n method: \"PUT\" | \"POST\";\n uploadUrl: string;\n headers?: Record<string, string>;\n fields?: Record<string, string>;\n key?: string;\n publicUrl?: string;\n type: AssetType;\n};\n\nexport type AssetReference = {\n id: string;\n type: AssetType;\n url: string;\n key?: string;\n mimeType?: string;\n size?: number;\n};\n\nexport interface StorageProvider {\n prepareUploads(files: UploadFile[]): Promise<UploadInstruction[]>;\n upload(instruction: UploadInstruction, blob: Blob, onProgress?: (progress: number) => void): Promise<AssetReference>;\n}\n\nexport type CapturedAsset = {\n id: string;\n type: AssetType;\n blob: Blob;\n previewUrl: string;\n mimeType: string;\n filename: string;\n size: number;\n};\n\nexport type DiagnosticsSnapshot = {\n url: string;\n referrer: string;\n timestamp: string;\n timezone: string;\n viewport: {\n width: number;\n height: number;\n pixelRatio: number;\n };\n browser: string;\n os: string;\n language: string;\n userAgent: string;\n userAgentData?: {\n brands?: Array<{\n brand: string;\n version: string;\n }>;\n mobile?: boolean;\n platform?: string;\n };\n appVersion?: string;\n environment?: ReportEnvironment;\n projectId?: string;\n logs?: ConsoleLogEntry[];\n requests?: NetworkRequestEntry[];\n navigationTiming?: {\n domComplete?: number;\n loadEventEnd?: number;\n responseEnd?: number;\n };\n};\n\nexport type ConsoleLogEntry = {\n level: \"log\" | \"info\" | \"warn\" | \"error\";\n message: string;\n timestamp: string;\n};\n\nexport type DiagnosticsPreview = {\n errorLogs: ConsoleLogEntry[];\n failedRequests: NetworkRequestEntry[];\n};\n\nexport type NetworkRequestEntry = {\n transport: \"fetch\" | \"xhr\";\n method: string;\n url: string;\n status?: number;\n ok?: boolean;\n durationMs: number;\n timestamp: string;\n error?: string;\n};\n\nexport type ReportDraft = {\n title: string;\n description: string;\n stepsToReproduce: string;\n expectedBehavior: string;\n actualBehavior: string;\n};\n\nexport type Reporter = {\n id?: string;\n name?: string;\n email?: string;\n role?: string;\n ip?: string;\n anonymous: boolean;\n};\n\nexport type CustomFormProps = {\n attributes: Record<string, unknown>;\n setAttributes: (next: Record<string, unknown>) => void;\n updateAttribute: (key: string, value: unknown) => void;\n};\n\nexport type CustomFormComponent = ComponentType<CustomFormProps>;\n\nexport type BugReportPayload = {\n issue: {\n title: string;\n description: string;\n projectId?: string;\n environment?: ReportEnvironment;\n appVersion?: string;\n assets: AssetReference[];\n };\n context: {\n url: string;\n referrer: string;\n timestamp: string;\n timezone: string;\n viewport: {\n width: number;\n height: number;\n pixelRatio: number;\n };\n client: {\n browser: string;\n os: string;\n language: string;\n userAgent: string;\n };\n userAgentData?: DiagnosticsSnapshot[\"userAgentData\"];\n performance: {\n navigationTiming?: DiagnosticsSnapshot[\"navigationTiming\"];\n };\n logs?: ConsoleLogEntry[];\n requests?: NetworkRequestEntry[];\n };\n reporter: Reporter;\n attributes: Record<string, unknown>;\n};\n\nexport type BugReportResponse = {\n id?: string;\n message?: string;\n [key: string]: unknown;\n};\n\nexport type BugReporterErrorCode =\n | \"VALIDATION_ERROR\"\n | \"CAPTURE_ERROR\"\n | \"RECORDING_ERROR\"\n | \"UPLOAD_ERROR\"\n | \"SUBMIT_ERROR\"\n | \"PERMISSION_DENIED\"\n | \"ABORTED\";\n\nexport class BugReporterError extends Error {\n readonly code: BugReporterErrorCode;\n readonly cause?: unknown;\n\n constructor(code: BugReporterErrorCode, message: string, cause?: unknown) {\n super(message);\n this.name = \"BugReporterError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\nexport type BugReporterConfig = {\n apiEndpoint: string;\n projectId?: string;\n appVersion?: string;\n environment?: ReportEnvironment;\n storage?: {\n mode: StorageMode;\n s3?: {\n presignEndpoint: string;\n publicBaseUrl?: string;\n };\n local?: {\n uploadEndpoint: string;\n publicBaseUrl?: string;\n };\n proxy?: {\n uploadEndpoint: string;\n };\n limits?: StorageLimits;\n };\n auth?: {\n headers?: Record<string, string>;\n withCredentials?: boolean;\n };\n theme?: ThemeConfig;\n features?: FeatureFlags;\n user?: {\n id?: string;\n email?: string;\n name?: string;\n role?: string;\n ip?: string;\n anonymous?: boolean;\n };\n attributes?: Record<string, unknown>;\n privacy?: {\n maskSelectors?: string[];\n redactTextPatterns?: Array<string | RegExp>;\n };\n diagnostics?: {\n consoleBufferSize?: number;\n requestBufferSize?: number;\n };\n hooks?: {\n beforeSubmit?: (payload: BugReportPayload) => Promise<BugReportPayload | null> | BugReportPayload | null;\n onSuccess?: (response: BugReportResponse) => void;\n onError?: (error: BugReporterError) => void;\n };\n};\n\nexport type BugReporterState = {\n isOpen: boolean;\n dockSide: DockSide;\n step: FlowStep;\n draft: ReportDraft;\n attributes: Record<string, unknown>;\n assets: CapturedAsset[];\n diagnostics?: DiagnosticsSnapshot;\n uploadProgress: number;\n isSubmitting: boolean;\n error?: string;\n};\n\nexport type BugReporterContextValue = {\n config: RequiredBugReporterConfig;\n state: BugReporterState;\n open: () => void;\n close: () => void;\n reset: () => void;\n setDockSide: (dockSide: DockSide) => void;\n setStep: (step: FlowStep) => void;\n updateDraft: (next: Partial<ReportDraft>) => void;\n setAttributes: (next: Record<string, unknown>) => void;\n updateAttribute: (key: string, value: unknown) => void;\n setScreenshot: (asset?: CapturedAsset) => void;\n setRecording: (asset?: CapturedAsset) => void;\n submit: () => Promise<void>;\n retrySubmit: () => Promise<void>;\n getDiagnosticsPreview: () => DiagnosticsPreview;\n};\n\nexport type RequiredBugReporterConfig = {\n apiEndpoint: string;\n projectId?: string;\n appVersion?: string;\n environment?: ReportEnvironment;\n storage: {\n mode: StorageMode;\n s3?: {\n presignEndpoint: string;\n publicBaseUrl?: string;\n };\n local?: {\n uploadEndpoint: string;\n publicBaseUrl?: string;\n };\n proxy?: {\n uploadEndpoint: string;\n };\n limits: Required<StorageLimits>;\n };\n auth: {\n headers: Record<string, string>;\n withCredentials: boolean;\n };\n theme: Required<ThemeConfig>;\n features: Required<FeatureFlags>;\n user?: {\n id?: string;\n email?: string;\n name?: string;\n role?: string;\n ip?: string;\n anonymous?: boolean;\n };\n attributes: Record<string, unknown>;\n privacy: {\n maskSelectors: string[];\n redactTextPatterns: Array<string | RegExp>;\n };\n diagnostics: {\n consoleBufferSize: number;\n requestBufferSize: number;\n };\n hooks: {\n beforeSubmit?: (payload: BugReportPayload) => Promise<BugReportPayload | null> | BugReportPayload | null;\n onSuccess?: (response: BugReportResponse) => void;\n onError?: (error: BugReporterError) => void;\n };\n};\n"]}
|