autotel-tanstack 1.14.3 → 1.14.5

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 (2) hide show
  1. package/README.md +38 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -19,6 +19,25 @@ npm install autotel-tanstack autotel
19
19
  pnpm add autotel-tanstack autotel
20
20
  ```
21
21
 
22
+ ### Bundling
23
+
24
+ `autotel` is Node-only and should stay a runtime dependency of the server bundle rather than be bundled. Externalize it in the **`ssr` environment only**. A top-level `build.rollupOptions.external` also applies to the client build, where an external is left as a bare specifier the browser cannot resolve. Browser-safe subpaths such as `autotel/feature-flags` (pulled in by `autotel-posthog`) must be bundled on the client.
25
+
26
+ ```ts
27
+ // vite.config.ts
28
+ export default defineConfig({
29
+ environments: {
30
+ ssr: {
31
+ build: {
32
+ rollupOptions: {
33
+ external: (id) => id === 'autotel' || id.startsWith('autotel/'),
34
+ },
35
+ },
36
+ },
37
+ },
38
+ });
39
+ ```
40
+
22
41
  ## Quick Start
23
42
 
24
43
  ### TanStack-Native Setup (Recommended)
@@ -248,6 +267,25 @@ describe('MyServerFunction', () => {
248
267
  });
249
268
  ```
250
269
 
270
+ ### End-to-end: `E2E=1`
271
+
272
+ With `E2E=1` in the server's environment, `instrument()` replaces the OTLP exporter with an `InMemorySpanExporter` on `globalThis.__testSpanExporter`, and `createTestSpansHandlers()` from `autotel-tanstack/testing` serves it as a route:
273
+
274
+ ```typescript
275
+ // src/routes/api/test-spans.ts
276
+ import { createFileRoute } from '@tanstack/react-router';
277
+ import { createTestSpansHandlers } from 'autotel-tanstack/testing';
278
+
279
+ const { GET, DELETE } = createTestSpansHandlers();
280
+ export const Route = createFileRoute('/api/test-spans')({
281
+ server: { handlers: { GET, DELETE } },
282
+ });
283
+ ```
284
+
285
+ A spec `DELETE`s before acting and `GET`s after to assert on the spans a browser interaction produced. Start the app under test with `E2E=1` from Playwright's `webServer`; a dev server that is already running on the port has the OTLP exporter, not the in-memory one, and `reuseExistingServer` will pick it.
286
+
287
+ `instrument()` is idempotent and `init` runs once per process, so a change to its options needs the dev server restarted rather than saved.
288
+
251
289
  ## Supported Frameworks
252
290
 
253
291
  - **@tanstack/react-start** ^1.139.14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autotel-tanstack",
3
- "version": "1.14.3",
3
+ "version": "1.14.5",
4
4
  "description": "OpenTelemetry instrumentation for TanStack Start - automatic tracing for server functions, middleware, and route loaders",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -120,8 +120,8 @@
120
120
  "license": "Apache-2.0",
121
121
  "dependencies": {
122
122
  "@opentelemetry/api": "^1.9.1",
123
- "autotel": "7.7.0",
124
- "autotel-adapters": "2.0.19",
123
+ "autotel": "7.8.0",
124
+ "autotel-adapters": "2.0.21",
125
125
  "autotel-edge": "5.1.1"
126
126
  },
127
127
  "peerDependencies": {