next-plugin-agent-tail 0.1.1 → 0.2.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/dist/handler.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { format_log_line } from "agent-tail-core";
1
+ import { format_log_line, should_exclude } from "agent-tail-core";
2
2
  import fs from "node:fs";
3
3
 
4
4
  //#region src/handler.ts
@@ -12,7 +12,10 @@ async function POST(request) {
12
12
  const log_path = process.env.__BROWSER_LOGS_PATH;
13
13
  if (!log_path) return new Response("Browser logs not configured", { status: 500 });
14
14
  try {
15
- const lines = (await request.json()).map(format_log_line).join("");
15
+ const excludes = JSON.parse(process.env.__BROWSER_LOGS_EXCLUDES || "[]");
16
+ let entries = await request.json();
17
+ if (excludes.length) entries = entries.filter((e) => !should_exclude(e.args.join(" "), excludes));
18
+ const lines = entries.map(format_log_line).join("");
16
19
  fs.appendFileSync(log_path, lines);
17
20
  return new Response(null, { status: 204 });
18
21
  } catch {
@@ -36,7 +39,10 @@ function pages_handler(req, res) {
36
39
  return;
37
40
  }
38
41
  try {
39
- const lines = (typeof req.body === "string" ? JSON.parse(req.body) : req.body).map(format_log_line).join("");
42
+ const excludes = JSON.parse(process.env.__BROWSER_LOGS_EXCLUDES || "[]");
43
+ let entries = typeof req.body === "string" ? JSON.parse(req.body) : req.body;
44
+ if (excludes.length) entries = entries.filter((e) => !should_exclude(e.args.join(" "), excludes));
45
+ const lines = entries.map(format_log_line).join("");
40
46
  fs.appendFileSync(log_path, lines);
41
47
  } catch {}
42
48
  res.status(204).end();
package/dist/index.mjs CHANGED
@@ -13,7 +13,8 @@ function with_browser_logs(next_config = {}, user_options) {
13
13
  env: {
14
14
  ...next_config.env,
15
15
  __BROWSER_LOGS_ENDPOINT: options.endpoint,
16
- __BROWSER_LOGS_PATH: log_path
16
+ __BROWSER_LOGS_PATH: log_path,
17
+ __BROWSER_LOGS_EXCLUDES: JSON.stringify(options.excludes)
17
18
  },
18
19
  webpack(config, context) {
19
20
  if (typeof next_config.webpack === "function") config = next_config.webpack(config, context);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next-plugin-agent-tail",
3
3
  "type": "module",
4
- "version": "0.1.1",
4
+ "version": "0.2.0",
5
5
  "description": "Next.js plugin for agent-tail — pipes browser console logs to files on disk during development.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "dependencies": {
41
- "agent-tail-core": "^0.1.1"
41
+ "agent-tail-core": "^0.2.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "next": ">=13.0.0"