@traceten/ai-crawl 0.1.0 → 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/CHANGELOG.md CHANGED
@@ -5,7 +5,18 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
- ## [0.1.0] - Unreleased
8
+ ## [0.1.1] - 2026-09-05
9
+
10
+ ### Changed
11
+
12
+ - Delivery timeout raised from 1500 ms to 5000 ms. Reports are scheduled off
13
+ the host response path in every adapter, so the old value delayed nothing and
14
+ bounded nothing useful. It did abort reports the ingest edge was still
15
+ answering: measured against a real deployment, roughly 15% of reports were
16
+ lost sequentially and 32% under concurrency, each one a client-side
17
+ `TimeoutError`. Those crawls are now delivered.
18
+
19
+ ## [0.1.0] - 2026-09-05
9
20
 
10
21
  Initial public release.
11
22
 
package/README.md CHANGED
@@ -21,7 +21,8 @@ Provider, category (answer fetch, search index, training, other), verification a
21
21
 
22
22
  - Never blocks the response. Never throws per-request. Failure is silent.
23
23
  - Zero runtime dependencies.
24
- - 1500 ms delivery timeout, `keepalive: true`.
24
+ - 5000 ms delivery timeout, `keepalive: true`. Delivery is scheduled off your
25
+ response path, so this bounds a background task and never delays a response.
25
26
  - Requires Node 18+ or an edge runtime with `fetch`.
26
27
  - Each adapter bundle is under 8 KB gzipped (CI-enforced).
27
28
 
package/dist/report.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Payload construction + delivery.
3
3
  *
4
- * Contract: never throws, never blocks the response, 1500 ms
4
+ * Contract: never throws, never blocks the response, 5000 ms
5
5
  * timeout, `keepalive: true`, snake_case on the wire. Delivery failures are
6
6
  * silent — a broken analytics call must never surface on a customer's site.
7
7
  *
@@ -10,7 +10,25 @@
10
10
  * told from a delivered one, and a bad token reads as "no crawlers visited".
11
11
  */
12
12
  import type { AiCrawlWirePayload, ResolvedAiCrawlConfig } from "./types.js";
13
- export declare const REPORT_TIMEOUT_MS = 1500;
13
+ /**
14
+ * Delivery budget for one report.
15
+ *
16
+ * Generous ON PURPOSE. Every adapter schedules delivery off the host's
17
+ * response path - `event.waitUntil()` on Next and both Cloudflare adapters,
18
+ * bare `void sendReport(...)` on Express and Hono - so this value never adds
19
+ * a millisecond to your response. It bounds a background task, not a request.
20
+ *
21
+ * It was 1500, chosen as though it were on the response path. It is not, and
22
+ * Traceten's edge grants itself time for a rate-limiter check before its 204.
23
+ * At 1500 the two were close enough that ordinary edge latency aborted the
24
+ * report client-side before the edge's own fail-open could answer, so the
25
+ * crawl was lost rather than degraded. Measured against a real deployment,
26
+ * 2026-09-05: ~15% of reports lost sequentially, ~32% under 8-way
27
+ * concurrency, every one a client-side TimeoutError.
28
+ *
29
+ * If you ever move delivery ONTO your response path, lower this.
30
+ */
31
+ export declare const REPORT_TIMEOUT_MS = 5000;
14
32
  /** Rebuild the reported URL against `publicOrigin` when configured. Never throws. */
15
33
  export declare function buildReportUrl(cfg: ResolvedAiCrawlConfig, url: string): string;
16
34
  export interface ReportInput {
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAEV,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAa9E;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAA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O,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,IAAI,CAAC,CAsCf"}
package/dist/report.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Payload construction + delivery.
3
3
  *
4
- * Contract: never throws, never blocks the response, 1500 ms
4
+ * Contract: never throws, never blocks the response, 5000 ms
5
5
  * timeout, `keepalive: true`, snake_case on the wire. Delivery failures are
6
6
  * silent — a broken analytics call must never surface on a customer's site.
7
7
  *
@@ -9,7 +9,25 @@
9
9
  * or a network failure to the caller. Without it a rejected report cannot be
10
10
  * told from a delivered one, and a bad token reads as "no crawlers visited".
11
11
  */
12
- export const REPORT_TIMEOUT_MS = 1500;
12
+ /**
13
+ * Delivery budget for one report.
14
+ *
15
+ * Generous ON PURPOSE. Every adapter schedules delivery off the host's
16
+ * response path - `event.waitUntil()` on Next and both Cloudflare adapters,
17
+ * bare `void sendReport(...)` on Express and Hono - so this value never adds
18
+ * a millisecond to your response. It bounds a background task, not a request.
19
+ *
20
+ * It was 1500, chosen as though it were on the response path. It is not, and
21
+ * Traceten's edge grants itself time for a rate-limiter check before its 204.
22
+ * At 1500 the two were close enough that ordinary edge latency aborted the
23
+ * report client-side before the edge's own fail-open could answer, so the
24
+ * crawl was lost rather than degraded. Measured against a real deployment,
25
+ * 2026-09-05: ~15% of reports lost sequentially, ~32% under 8-way
26
+ * concurrency, every one a client-side TimeoutError.
27
+ *
28
+ * If you ever move delivery ONTO your response path, lower this.
29
+ */
30
+ export const REPORT_TIMEOUT_MS = 5000;
13
31
  /** Rebuild the reported URL against `publicOrigin` when configured. Never throws. */
14
32
  export function buildReportUrl(cfg, url) {
15
33
  try {
@@ -44,7 +62,7 @@ export function buildPayload(cfg, input) {
44
62
  }
45
63
  return payload;
46
64
  }
47
- /** Abort signal with a 1500 ms timeout, where the runtime supports it. */
65
+ /** Abort signal with the delivery timeout, where the runtime supports it. */
48
66
  function timeoutSignal() {
49
67
  try {
50
68
  if (typeof AbortSignal !== "undefined" && typeof AbortSignal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/ai-crawl",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "Traceten server-side AI crawler tracking — see the GPTBot/ClaudeBot/PerplexityBot crawls that browser JavaScript can never see. Five adapters, zero dependencies, never blocks a response.",
6
6
  "keywords": [
package/src/report.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Payload construction + delivery.
3
3
  *
4
- * Contract: never throws, never blocks the response, 1500 ms
4
+ * Contract: never throws, never blocks the response, 5000 ms
5
5
  * timeout, `keepalive: true`, snake_case on the wire. Delivery failures are
6
6
  * silent — a broken analytics call must never surface on a customer's site.
7
7
  *
@@ -16,7 +16,25 @@ import type {
16
16
  ResolvedAiCrawlConfig,
17
17
  } from "./types.js";
18
18
 
19
- export const REPORT_TIMEOUT_MS = 1500;
19
+ /**
20
+ * Delivery budget for one report.
21
+ *
22
+ * Generous ON PURPOSE. Every adapter schedules delivery off the host's
23
+ * response path - `event.waitUntil()` on Next and both Cloudflare adapters,
24
+ * bare `void sendReport(...)` on Express and Hono - so this value never adds
25
+ * a millisecond to your response. It bounds a background task, not a request.
26
+ *
27
+ * It was 1500, chosen as though it were on the response path. It is not, and
28
+ * Traceten's edge grants itself time for a rate-limiter check before its 204.
29
+ * At 1500 the two were close enough that ordinary edge latency aborted the
30
+ * report client-side before the edge's own fail-open could answer, so the
31
+ * crawl was lost rather than degraded. Measured against a real deployment,
32
+ * 2026-09-05: ~15% of reports lost sequentially, ~32% under 8-way
33
+ * concurrency, every one a client-side TimeoutError.
34
+ *
35
+ * If you ever move delivery ONTO your response path, lower this.
36
+ */
37
+ export const REPORT_TIMEOUT_MS = 5000;
20
38
 
21
39
  /** Rebuild the reported URL against `publicOrigin` when configured. Never throws. */
22
40
  export function buildReportUrl(cfg: ResolvedAiCrawlConfig, url: string): string {
@@ -60,7 +78,7 @@ export function buildPayload(cfg: ResolvedAiCrawlConfig, input: ReportInput): Ai
60
78
  return payload;
61
79
  }
62
80
 
63
- /** Abort signal with a 1500 ms timeout, where the runtime supports it. */
81
+ /** Abort signal with the delivery timeout, where the runtime supports it. */
64
82
  function timeoutSignal(): AbortSignal | undefined {
65
83
  try {
66
84
  if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {