@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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import cors from "cors";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import multer from "multer";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
const app = express();
|
|
7
|
+
const port = Number(process.env.PORT || 4201);
|
|
8
|
+
const root = path.resolve(process.cwd(), "examples/backend-local/public");
|
|
9
|
+
const upload = multer({ dest: path.join(root, "uploads") });
|
|
10
|
+
|
|
11
|
+
app.use(cors());
|
|
12
|
+
app.use(express.json());
|
|
13
|
+
app.use("/public", express.static(root));
|
|
14
|
+
|
|
15
|
+
app.post("/api/uploads", upload.single("file"), (req, res) => {
|
|
16
|
+
if (!req.file) {
|
|
17
|
+
res.status(400).json({ error: "file is required" });
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const url = `http://localhost:${port}/public/uploads/${req.file.filename}`;
|
|
22
|
+
res.json({ url, key: `uploads/${req.file.filename}` });
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
app.post("/api/bug-reports", (req, res) => {
|
|
26
|
+
res.json({ id: crypto.randomUUID(), message: "received", payload: req.body });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
app.listen(port, () => {
|
|
30
|
+
console.log(`Local example backend listening on http://localhost:${port}`);
|
|
31
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# S3 Presign Example (Local Simulation)
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
cd examples/backend-s3-presign
|
|
5
|
+
npm install
|
|
6
|
+
npm start
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Endpoints:
|
|
10
|
+
- `POST /api/presign`
|
|
11
|
+
- `POST /upload-form`
|
|
12
|
+
- `POST /api/bug-reports`
|
|
13
|
+
|
|
14
|
+
This simulates presigned uploads locally while preserving the SDK contract.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import cors from "cors";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import multer from "multer";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
const app = express();
|
|
7
|
+
const port = Number(process.env.PORT || 4202);
|
|
8
|
+
const root = path.resolve(process.cwd(), "examples/backend-s3-presign/public");
|
|
9
|
+
const objectDir = path.join(root, "objects");
|
|
10
|
+
const upload = multer({ dest: objectDir });
|
|
11
|
+
|
|
12
|
+
app.use(cors());
|
|
13
|
+
app.use(express.json({ limit: "1mb" }));
|
|
14
|
+
app.use("/objects", express.static(objectDir));
|
|
15
|
+
|
|
16
|
+
app.post("/api/presign", (req, res) => {
|
|
17
|
+
const files = Array.isArray(req.body?.files) ? req.body.files : [];
|
|
18
|
+
const uploads = files.map((file) => {
|
|
19
|
+
const key = `${Date.now()}-${file.id}-${file.name.replace(/[^a-zA-Z0-9_.-]/g, "-")}`;
|
|
20
|
+
return {
|
|
21
|
+
id: file.id,
|
|
22
|
+
method: "POST",
|
|
23
|
+
uploadUrl: `http://localhost:${port}/upload-form`,
|
|
24
|
+
fields: { key },
|
|
25
|
+
key,
|
|
26
|
+
publicUrl: `http://localhost:${port}/objects/${key}`,
|
|
27
|
+
type: file.type
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
res.json({ uploads });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
app.post("/upload-form", upload.single("file"), (req, res) => {
|
|
35
|
+
if (!req.file || typeof req.body?.key !== "string") {
|
|
36
|
+
res.status(400).json({ error: "missing file or key" });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const finalPath = path.join(objectDir, req.body.key);
|
|
41
|
+
import("node:fs/promises")
|
|
42
|
+
.then((fs) => fs.rename(req.file.path, finalPath))
|
|
43
|
+
.then(() => res.status(204).send())
|
|
44
|
+
.catch(() => res.status(500).json({ error: "upload move failed" }));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
app.post("/api/bug-reports", (req, res) => {
|
|
48
|
+
res.json({ id: crypto.randomUUID(), message: "received", payload: req.body });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
app.listen(port, () => {
|
|
52
|
+
console.log(`Presign example backend listening on http://localhost:${port}`);
|
|
53
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Vite Sandbox
|
|
2
|
+
|
|
3
|
+
Small local app to manually test the `@fogg/bug-reporter` SDK.
|
|
4
|
+
|
|
5
|
+
## Run
|
|
6
|
+
|
|
7
|
+
From repo root:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm run sandbox:vite
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or directly:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd examples/sandbox-vite
|
|
17
|
+
npm install
|
|
18
|
+
npm run dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The sandbox mocks:
|
|
22
|
+
- `POST /sandbox/upload`
|
|
23
|
+
- `POST /sandbox/report`
|
|
24
|
+
|
|
25
|
+
So you can validate the full SDK flow without running a backend.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>bug-reporter sandbox</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|