@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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +114 -0
  3. package/dist/chunk-6TCI6T2U.cjs +45 -0
  4. package/dist/chunk-6TCI6T2U.cjs.map +1 -0
  5. package/dist/chunk-S2YRP4GT.js +22 -0
  6. package/dist/chunk-S2YRP4GT.js.map +1 -0
  7. package/dist/index.cjs +1963 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +331 -0
  10. package/dist/index.d.ts +331 -0
  11. package/dist/index.js +1956 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/recording-ML63ZQ6A.cjs +120 -0
  14. package/dist/recording-ML63ZQ6A.cjs.map +1 -0
  15. package/dist/recording-YSR6IORT.js +118 -0
  16. package/dist/recording-YSR6IORT.js.map +1 -0
  17. package/dist/screenshot-F4W72WRK.js +176 -0
  18. package/dist/screenshot-F4W72WRK.js.map +1 -0
  19. package/dist/screenshot-FRAZAS6B.cjs +178 -0
  20. package/dist/screenshot-FRAZAS6B.cjs.map +1 -0
  21. package/dist/styles/index.css +495 -0
  22. package/dist/styles/index.css.map +1 -0
  23. package/dist/styles/index.d.cts +2 -0
  24. package/dist/styles/index.d.ts +2 -0
  25. package/docs/backend-local.md +16 -0
  26. package/docs/backend-s3.md +31 -0
  27. package/docs/browser-compatibility.md +8 -0
  28. package/docs/framework-cra.md +10 -0
  29. package/docs/framework-nextjs.md +16 -0
  30. package/docs/framework-remix.md +6 -0
  31. package/docs/framework-vite.md +21 -0
  32. package/docs/known-limitations.md +6 -0
  33. package/docs/quickstart.md +26 -0
  34. package/docs/security.md +9 -0
  35. package/examples/backend-local/README.md +11 -0
  36. package/examples/backend-local/package.json +13 -0
  37. package/examples/backend-local/src/server.mjs +31 -0
  38. package/examples/backend-s3-presign/README.md +14 -0
  39. package/examples/backend-s3-presign/package.json +13 -0
  40. package/examples/backend-s3-presign/src/server.mjs +53 -0
  41. package/examples/sandbox-vite/README.md +25 -0
  42. package/examples/sandbox-vite/index.html +12 -0
  43. package/examples/sandbox-vite/package-lock.json +1880 -0
  44. package/examples/sandbox-vite/package.json +24 -0
  45. package/examples/sandbox-vite/src/App.tsx +200 -0
  46. package/examples/sandbox-vite/src/main.tsx +10 -0
  47. package/examples/sandbox-vite/src/sandbox.css +74 -0
  48. package/examples/sandbox-vite/tsconfig.json +14 -0
  49. package/examples/sandbox-vite/vite.config.ts +9 -0
  50. package/package.json +93 -0
@@ -0,0 +1,11 @@
1
+ # Local Backend Example
2
+
3
+ ```bash
4
+ cd examples/backend-local
5
+ npm install
6
+ npm start
7
+ ```
8
+
9
+ Endpoints:
10
+ - `POST /api/uploads` (multipart form)
11
+ - `POST /api/bug-reports`
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "bug-reporter-backend-local-example",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "start": "node src/server.mjs"
7
+ },
8
+ "dependencies": {
9
+ "cors": "^2.8.5",
10
+ "express": "^4.21.2",
11
+ "multer": "^1.4.5-lts.2"
12
+ }
13
+ }
@@ -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,13 @@
1
+ {
2
+ "name": "bug-reporter-backend-s3-example",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "start": "node src/server.mjs"
7
+ },
8
+ "dependencies": {
9
+ "cors": "^2.8.5",
10
+ "express": "^4.21.2",
11
+ "multer": "^1.4.5-lts.2"
12
+ }
13
+ }
@@ -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>