autotel-tanstack 1.13.30 → 1.13.31

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 (150) hide show
  1. package/dist/auto.d.ts +8 -35
  2. package/dist/auto.d.ts.map +1 -0
  3. package/dist/auto.js +41 -22
  4. package/dist/auto.js.map +1 -1
  5. package/dist/browser/context.d.ts +50 -0
  6. package/dist/browser/context.d.ts.map +1 -0
  7. package/dist/browser/context.js +54 -2
  8. package/dist/browser/context.js.map +1 -1
  9. package/dist/browser/debug-headers.d.ts +10 -0
  10. package/dist/browser/debug-headers.d.ts.map +1 -0
  11. package/dist/browser/debug-headers.js +12 -2
  12. package/dist/browser/debug-headers.js.map +1 -1
  13. package/dist/browser/error-reporting.d.ts +39 -0
  14. package/dist/browser/error-reporting.d.ts.map +1 -0
  15. package/dist/browser/error-reporting.js +35 -2
  16. package/dist/browser/error-reporting.js.map +1 -1
  17. package/dist/browser/handlers.d.ts +14 -0
  18. package/dist/browser/handlers.d.ts.map +1 -0
  19. package/dist/browser/handlers.js +10 -2
  20. package/dist/browser/handlers.js.map +1 -1
  21. package/dist/browser/index.d.ts +11 -0
  22. package/dist/browser/index.js +12 -12
  23. package/dist/browser/loaders.d.ts +31 -0
  24. package/dist/browser/loaders.d.ts.map +1 -0
  25. package/dist/browser/loaders.js +29 -2
  26. package/dist/browser/loaders.js.map +1 -1
  27. package/dist/browser/metrics.d.ts +56 -0
  28. package/dist/browser/metrics.d.ts.map +1 -0
  29. package/dist/browser/metrics.js +48 -2
  30. package/dist/browser/metrics.js.map +1 -1
  31. package/dist/browser/middleware.d.ts +42 -0
  32. package/dist/browser/middleware.d.ts.map +1 -0
  33. package/dist/browser/middleware.js +36 -2
  34. package/dist/browser/middleware.js.map +1 -1
  35. package/dist/browser/server-functions.d.ts +14 -0
  36. package/dist/browser/server-functions.d.ts.map +1 -0
  37. package/dist/browser/server-functions.js +16 -2
  38. package/dist/browser/server-functions.js.map +1 -1
  39. package/dist/browser/testing.d.ts +85 -0
  40. package/dist/browser/testing.d.ts.map +1 -0
  41. package/dist/browser/testing.js +43 -2
  42. package/dist/browser/testing.js.map +1 -1
  43. package/dist/browser/types.d.ts +2 -0
  44. package/dist/browser/types.js +37 -2
  45. package/dist/browser/types.js.map +1 -1
  46. package/dist/context.d.ts +5 -3
  47. package/dist/context.d.ts.map +1 -0
  48. package/dist/context.js +112 -3
  49. package/dist/context.js.map +1 -1
  50. package/dist/debug-headers.d.ts +14 -14
  51. package/dist/debug-headers.d.ts.map +1 -0
  52. package/dist/debug-headers.js +62 -4
  53. package/dist/debug-headers.js.map +1 -1
  54. package/dist/env-BpFWNnpL.js +30 -0
  55. package/dist/env-BpFWNnpL.js.map +1 -0
  56. package/dist/error-reporting.d.ts +37 -37
  57. package/dist/error-reporting.d.ts.map +1 -0
  58. package/dist/error-reporting.js +154 -3
  59. package/dist/error-reporting.js.map +1 -1
  60. package/dist/handlers.d.ts +5 -4
  61. package/dist/handlers.d.ts.map +1 -0
  62. package/dist/handlers.js +192 -6
  63. package/dist/handlers.js.map +1 -1
  64. package/dist/index.d.ts +15 -16
  65. package/dist/index.d.ts.map +1 -0
  66. package/dist/index.js +14 -16
  67. package/dist/instrument-DS7YCE1R.d.ts +10 -0
  68. package/dist/instrument-DS7YCE1R.d.ts.map +1 -0
  69. package/dist/instrument-DdLlMfRi.js +80 -0
  70. package/dist/instrument-DdLlMfRi.js.map +1 -0
  71. package/dist/loaders-DrVVY25K.d.ts +2402 -0
  72. package/dist/loaders-DrVVY25K.d.ts.map +1 -0
  73. package/dist/loaders.d.ts +2 -116
  74. package/dist/loaders.js +234 -5
  75. package/dist/loaders.js.map +1 -1
  76. package/dist/metrics.d.ts +39 -39
  77. package/dist/metrics.d.ts.map +1 -0
  78. package/dist/metrics.js +144 -3
  79. package/dist/metrics.js.map +1 -1
  80. package/dist/middleware.d.ts +16 -15
  81. package/dist/middleware.d.ts.map +1 -0
  82. package/dist/middleware.js +290 -7
  83. package/dist/middleware.js.map +1 -1
  84. package/dist/route-filter-dLg-j3jR.js +33 -0
  85. package/dist/route-filter-dLg-j3jR.js.map +1 -0
  86. package/dist/server-functions.d.ts +4 -3
  87. package/dist/server-functions.d.ts.map +1 -0
  88. package/dist/server-functions.js +133 -5
  89. package/dist/server-functions.js.map +1 -1
  90. package/dist/testing.d.ts +164 -65
  91. package/dist/testing.d.ts.map +1 -0
  92. package/dist/testing.js +212 -147
  93. package/dist/testing.js.map +1 -1
  94. package/dist/types-BJ7FyVoX.d.ts +87 -0
  95. package/dist/types-BJ7FyVoX.d.ts.map +1 -0
  96. package/dist/types-BrccP0yX.js +38 -0
  97. package/dist/types-BrccP0yX.js.map +1 -0
  98. package/dist/types-pQgmQa4j.d.ts +154 -0
  99. package/dist/types-pQgmQa4j.d.ts.map +1 -0
  100. package/package.json +7 -7
  101. package/dist/browser/index.js.map +0 -1
  102. package/dist/chunk-7OXOAS64.js +0 -41
  103. package/dist/chunk-7OXOAS64.js.map +0 -1
  104. package/dist/chunk-A7WMQ2BC.js +0 -25
  105. package/dist/chunk-A7WMQ2BC.js.map +0 -1
  106. package/dist/chunk-CCME55EK.js +0 -28
  107. package/dist/chunk-CCME55EK.js.map +0 -1
  108. package/dist/chunk-CSFIPJC2.js +0 -11
  109. package/dist/chunk-CSFIPJC2.js.map +0 -1
  110. package/dist/chunk-DTZCOB4W.js +0 -32
  111. package/dist/chunk-DTZCOB4W.js.map +0 -1
  112. package/dist/chunk-EFSKEYDJ.js +0 -20
  113. package/dist/chunk-EFSKEYDJ.js.map +0 -1
  114. package/dist/chunk-EGRHWZRV.js +0 -3
  115. package/dist/chunk-EGRHWZRV.js.map +0 -1
  116. package/dist/chunk-ESU66L3L.js +0 -92
  117. package/dist/chunk-ESU66L3L.js.map +0 -1
  118. package/dist/chunk-EUYFVNYE.js +0 -16
  119. package/dist/chunk-EUYFVNYE.js.map +0 -1
  120. package/dist/chunk-FFQ4FJKE.js +0 -185
  121. package/dist/chunk-FFQ4FJKE.js.map +0 -1
  122. package/dist/chunk-G526TOMY.js +0 -96
  123. package/dist/chunk-G526TOMY.js.map +0 -1
  124. package/dist/chunk-I4LX3LOG.js +0 -35
  125. package/dist/chunk-I4LX3LOG.js.map +0 -1
  126. package/dist/chunk-JXO7H6KO.js +0 -10
  127. package/dist/chunk-JXO7H6KO.js.map +0 -1
  128. package/dist/chunk-KPXGFKPU.js +0 -193
  129. package/dist/chunk-KPXGFKPU.js.map +0 -1
  130. package/dist/chunk-LRA2UVVS.js +0 -210
  131. package/dist/chunk-LRA2UVVS.js.map +0 -1
  132. package/dist/chunk-MFYOV2SF.js +0 -32
  133. package/dist/chunk-MFYOV2SF.js.map +0 -1
  134. package/dist/chunk-MNP65ZX7.js +0 -21
  135. package/dist/chunk-MNP65ZX7.js.map +0 -1
  136. package/dist/chunk-NTY64BKS.js +0 -38
  137. package/dist/chunk-NTY64BKS.js.map +0 -1
  138. package/dist/chunk-UMEJU65Q.js +0 -34
  139. package/dist/chunk-UMEJU65Q.js.map +0 -1
  140. package/dist/chunk-UTPW3QRT.js +0 -52
  141. package/dist/chunk-UTPW3QRT.js.map +0 -1
  142. package/dist/chunk-V3RO5N2M.js +0 -8
  143. package/dist/chunk-V3RO5N2M.js.map +0 -1
  144. package/dist/chunk-XXBHZR3M.js +0 -99
  145. package/dist/chunk-XXBHZR3M.js.map +0 -1
  146. package/dist/chunk-YQYYPJCK.js +0 -37
  147. package/dist/chunk-YQYYPJCK.js.map +0 -1
  148. package/dist/index.js.map +0 -1
  149. package/dist/instrument-DRR7VL63.d.ts +0 -46
  150. package/dist/types-m5OjZJ-4.d.ts +0 -152
@@ -1,37 +0,0 @@
1
- // src/browser/testing.ts
2
- function createTestCollector() {
3
- return {
4
- getSpans: () => [],
5
- getSpansByName: () => [],
6
- clear: () => {
7
- },
8
- waitForSpans: async () => []
9
- };
10
- }
11
- function assertSpanCreated(collector, name) {
12
- }
13
- function assertSpanHasAttribute(collector, name, key, value) {
14
- }
15
- function createTestSpansRoute(createFileRoute, path) {
16
- throw new Error("createTestSpansRoute is server-only");
17
- }
18
- function createTestSpansHandlers() {
19
- return {
20
- GET(input) {
21
- return Response.json(
22
- { error: "createTestSpansHandlers is server-only" },
23
- { status: 404 }
24
- );
25
- },
26
- DELETE(input) {
27
- return Response.json(
28
- { error: "createTestSpansHandlers is server-only" },
29
- { status: 404 }
30
- );
31
- }
32
- };
33
- }
34
-
35
- export { assertSpanCreated, assertSpanHasAttribute, createTestCollector, createTestSpansHandlers, createTestSpansRoute };
36
- //# sourceMappingURL=chunk-YQYYPJCK.js.map
37
- //# sourceMappingURL=chunk-YQYYPJCK.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/browser/testing.ts"],"names":[],"mappings":";AA+BO,SAAS,mBAAA,GAAqC;AACnD,EAAA,OAAO;AAAA,IACL,QAAA,EAAU,MAAM,EAAC;AAAA,IACjB,cAAA,EAAgB,MAAM,EAAC;AAAA,IACvB,OAAO,MAAM;AAAA,IAAC,CAAA;AAAA,IACd,YAAA,EAAc,YAAY;AAAC,GAC7B;AACF;AAKO,SAAS,iBAAA,CACd,WACA,IAAA,EACM;AAIR;AAKO,SAAS,sBAAA,CACd,SAAA,EACA,IAAA,EACA,GAAA,EACA,KAAA,EACM;AAMR;AA8BO,SAAS,oBAAA,CACd,iBACA,IAAA,EACS;AAGT,EAAA,MAAM,IAAI,MAAM,qCAAqC,CAAA;AACvD;AAMO,SAAS,uBAAA,GAGd;AACA,EAAA,OAAO;AAAA,IACL,IAAI,KAAA,EAA+B;AAEjC,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,QACd,EAAE,OAAO,wCAAA,EAAyC;AAAA,QAClD,EAAE,QAAQ,GAAA;AAAI,OAChB;AAAA,IACF,CAAA;AAAA,IACA,OAAO,KAAA,EAA+B;AAEpC,MAAA,OAAO,QAAA,CAAS,IAAA;AAAA,QACd,EAAE,OAAO,wCAAA,EAAyC;AAAA,QAClD,EAAE,QAAQ,GAAA;AAAI,OAChB;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-YQYYPJCK.js","sourcesContent":["/**\n * Browser stub for testing module\n *\n * Testing utilities are server-side only.\n * In browser, these return no-op implementations.\n */\n\n/**\n * Test span structure (stub)\n */\nexport interface TestSpan {\n name: string;\n attributes: Record<string, unknown>;\n status: { code: number; message?: string };\n events: Array<{ name: string; attributes?: Record<string, unknown> }>;\n duration: number;\n}\n\n/**\n * Test collector structure (stub)\n */\nexport interface TestCollector {\n getSpans(): TestSpan[];\n getSpansByName(name: string): TestSpan[];\n clear(): void;\n waitForSpans(count: number, timeout?: number): Promise<TestSpan[]>;\n}\n\n/**\n * Browser stub: Returns empty collector\n */\nexport function createTestCollector(): TestCollector {\n return {\n getSpans: () => [],\n getSpansByName: () => [],\n clear: () => {},\n waitForSpans: async () => [],\n };\n}\n\n/**\n * Browser stub: No-op\n */\nexport function assertSpanCreated(\n collector: TestCollector,\n name: string,\n): void {\n void collector;\n void name;\n // No-op in browser\n}\n\n/**\n * Browser stub: No-op\n */\nexport function assertSpanHasAttribute(\n collector: TestCollector,\n name: string,\n key: string,\n value?: unknown,\n): void {\n void collector;\n void name;\n void key;\n void value;\n // No-op in browser\n}\n\n/**\n * Serialized span type (browser stub - mirrors server SerializedSpan).\n *\n * Defined as a `type` (not `interface`) so it is assignable to\n * `Record<string, unknown>` in TypeScript 6+ strict mode.\n */\nexport type SerializedSpan = {\n name: string;\n spanId: string;\n traceId: string;\n parentSpanId?: string;\n attributes?: Record<string, unknown>;\n status: { code: number; message?: string };\n durationMs: number;\n};\n\n/**\n * Accepts either a raw `Request` (legacy) or a TanStack Router context\n * object containing `{ request: Request }` (Router 1.168+).\n */\ntype HandlerInput = Request | { request: Request };\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype CreateFileRoute = (path: string) => (options: any) => any;\n\n/**\n * Browser stub: createTestSpansRoute is server-only.\n */\nexport function createTestSpansRoute(\n createFileRoute: CreateFileRoute,\n path?: string,\n): unknown {\n void createFileRoute;\n void path;\n throw new Error('createTestSpansRoute is server-only');\n}\n\n/**\n * Browser stub: test-spans handlers are server-only.\n * Returns no-op handlers that always return 404.\n */\nexport function createTestSpansHandlers(): {\n GET: (input: HandlerInput) => Response;\n DELETE: (input: HandlerInput) => Response;\n} {\n return {\n GET(input: HandlerInput): Response {\n void input;\n return Response.json(\n { error: 'createTestSpansHandlers is server-only' },\n { status: 404 },\n );\n },\n DELETE(input: HandlerInput): Response {\n void input;\n return Response.json(\n { error: 'createTestSpansHandlers is server-only' },\n { status: 404 },\n );\n },\n };\n}\n"]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
@@ -1,46 +0,0 @@
1
- import { AutotelConfig } from 'autotel';
2
-
3
- /**
4
- * Configurable tracing setup for TanStack Start.
5
- *
6
- * `instrument(options)` is a thin wrapper over autotel's `init` that adds the
7
- * TanStack defaults so apps don't hand-roll them:
8
- *
9
- * - service name defaults to `OTEL_SERVICE_NAME` or `'tanstack-start'`;
10
- * - `debug` resolves from `AUTOTEL_DEBUG` (`pretty` in dev when no endpoint set);
11
- * - when `E2E=1`, spans are captured by an `InMemorySpanExporter` exposed as
12
- * `globalThis.__testSpanExporter` (for span assertions) instead of shipping
13
- * over OTLP;
14
- * - it's idempotent — a second call is a no-op.
15
- *
16
- * Everything else — `endpoint`, `headers`, `subscribers`, `logs`,
17
- * `canonicalLogLines`, extra `spanProcessors`, … — passes straight through to
18
- * `init`, and the standard `OTEL_*` env vars are resolved by autotel core, so
19
- * apps never re-parse them.
20
- *
21
- * The zero-config `autotel-tanstack/auto` side-effect module is just
22
- * `instrument()` with no options.
23
- *
24
- * @example
25
- * ```ts
26
- * import { instrument } from 'autotel-tanstack';
27
- * import { PostHogSubscriber } from 'autotel-subscribers';
28
- *
29
- * instrument({
30
- * subscribers: process.env.POSTHOG_KEY
31
- * ? [new PostHogSubscriber({ apiKey: process.env.POSTHOG_KEY })]
32
- * : [],
33
- * logs: true,
34
- * canonicalLogLines: { enabled: true, rootSpansOnly: true },
35
- * });
36
- * ```
37
- *
38
- * @module
39
- */
40
-
41
- type InstrumentOptions = Omit<AutotelConfig, 'service'> & {
42
- service?: string;
43
- };
44
- declare function instrument(options?: InstrumentOptions): void;
45
-
46
- export { type InstrumentOptions as I, instrument as i };
@@ -1,152 +0,0 @@
1
- import { Attributes } from '@opentelemetry/api';
2
-
3
- /**
4
- * Configuration options for TanStack Start instrumentation
5
- */
6
- interface TanStackInstrumentationConfig {
7
- /**
8
- * Service name for spans
9
- * @default process.env.OTEL_SERVICE_NAME || 'tanstack-start'
10
- */
11
- service?: string;
12
- /**
13
- * Whether to capture function arguments as span attributes
14
- * Warning: May contain PII, review before enabling in production
15
- * @default true
16
- */
17
- captureArgs?: boolean;
18
- /**
19
- * Whether to capture function results as span attributes
20
- * Warning: May contain PII, disable in production
21
- * @default false
22
- */
23
- captureResults?: boolean;
24
- /**
25
- * Whether to capture errors and record exceptions
26
- * @default true
27
- */
28
- captureErrors?: boolean;
29
- /**
30
- * HTTP headers to capture as span attributes
31
- * @default ['x-request-id']
32
- */
33
- captureHeaders?: string[];
34
- /**
35
- * URL paths to exclude from tracing (glob patterns)
36
- * @default []
37
- */
38
- excludePaths?: (string | RegExp)[];
39
- /**
40
- * Sampling strategy
41
- * - 'always': Sample all requests (100%)
42
- * - 'adaptive': Use autotel's adaptive sampling (errors + slow = 100%, baseline 10%)
43
- * - 'never': Disable sampling (for testing/debugging)
44
- * @default 'adaptive'
45
- */
46
- sampling?: 'always' | 'adaptive' | 'never';
47
- /**
48
- * Custom function to extract additional span attributes
49
- */
50
- customAttributes?: (context: {
51
- type: 'request' | 'serverFn' | 'loader' | 'beforeLoad' | 'middleware';
52
- name: string;
53
- request?: Request;
54
- args?: unknown;
55
- result?: unknown;
56
- }) => Attributes;
57
- }
58
- /**
59
- * Configuration specific to tracing middleware
60
- */
61
- interface TracingMiddlewareConfig extends TanStackInstrumentationConfig {
62
- /**
63
- * Type of middleware
64
- * - 'request': For global request middleware (routes, SSR)
65
- * - 'function': For server function middleware
66
- * @default 'request'
67
- */
68
- type?: 'request' | 'function';
69
- }
70
- /**
71
- * Configuration for server function tracing
72
- */
73
- interface TraceServerFnConfig {
74
- /**
75
- * Explicit name for the span
76
- * If not provided, will attempt to infer from function name
77
- */
78
- name?: string;
79
- /**
80
- * Whether to capture function arguments
81
- * @default true
82
- */
83
- captureArgs?: boolean;
84
- /**
85
- * Whether to capture function results
86
- * @default false
87
- */
88
- captureResults?: boolean;
89
- }
90
- /**
91
- * Configuration for loader tracing
92
- */
93
- interface TraceLoaderConfig {
94
- /**
95
- * Explicit name for the span
96
- * If not provided, will use route ID
97
- */
98
- name?: string;
99
- /**
100
- * Whether to capture route params
101
- * @default true
102
- */
103
- captureParams?: boolean;
104
- /**
105
- * Whether to capture loader result
106
- * @default false
107
- */
108
- captureResult?: boolean;
109
- }
110
- /**
111
- * Configuration for handler wrapper
112
- */
113
- interface WrapStartHandlerConfig extends TanStackInstrumentationConfig {
114
- /**
115
- * OTLP endpoint URL
116
- * @default process.env.OTEL_EXPORTER_OTLP_ENDPOINT
117
- */
118
- endpoint?: string;
119
- /**
120
- * OTLP headers (e.g., for authentication)
121
- * @default parsed from process.env.OTEL_EXPORTER_OTLP_HEADERS
122
- */
123
- headers?: Record<string, string>;
124
- }
125
- /**
126
- * Default configuration values
127
- */
128
- declare const DEFAULT_CONFIG: Required<Omit<TanStackInstrumentationConfig, 'customAttributes' | 'service'>>;
129
- /**
130
- * Span attribute keys following OpenTelemetry semantic conventions
131
- */
132
- declare const SPAN_ATTRIBUTES: {
133
- readonly HTTP_REQUEST_METHOD: "http.request.method";
134
- readonly HTTP_RESPONSE_STATUS_CODE: "http.response.status_code";
135
- readonly URL_PATH: "url.path";
136
- readonly URL_QUERY: "url.query";
137
- readonly URL_FULL: "url.full";
138
- readonly RPC_SYSTEM: "rpc.system";
139
- readonly RPC_METHOD: "rpc.method";
140
- readonly TANSTACK_TYPE: "tanstack.type";
141
- readonly TANSTACK_SERVER_FN_NAME: "tanstack.server_function.name";
142
- readonly TANSTACK_SERVER_FN_METHOD: "tanstack.server_function.method";
143
- readonly TANSTACK_SERVER_FN_ARGS: "tanstack.server_function.args";
144
- readonly TANSTACK_SERVER_FN_RESULT: "tanstack.server_function.result";
145
- readonly TANSTACK_LOADER_ROUTE_ID: "tanstack.loader.route_id";
146
- readonly TANSTACK_LOADER_TYPE: "tanstack.loader.type";
147
- readonly TANSTACK_LOADER_PARAMS: "tanstack.loader.params";
148
- readonly TANSTACK_MIDDLEWARE_NAME: "tanstack.middleware.name";
149
- readonly TANSTACK_REQUEST_DURATION_MS: "tanstack.request.duration_ms";
150
- };
151
-
152
- export { DEFAULT_CONFIG as D, SPAN_ATTRIBUTES as S, type TanStackInstrumentationConfig as T, type WrapStartHandlerConfig as W, type TraceLoaderConfig as a, type TraceServerFnConfig as b, type TracingMiddlewareConfig as c };