@temps-sdk/cli 0.1.37 → 0.1.38
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/index.js +14295 -25419
- package/dist/skills/temps/SKILL.md +140 -0
- package/dist/skills/temps/agents/openai.yaml +7 -0
- package/dist/skills/temps/evals/evals.json +95 -0
- package/dist/skills/temps/howtos/backup-recovery.md +41 -0
- package/dist/skills/temps/howtos/ci-automation.md +18 -0
- package/dist/skills/temps/howtos/deploy-application.md +29 -0
- package/dist/skills/temps/howtos/diagnose-deployment.md +17 -0
- package/dist/skills/temps/howtos/framework-routing.md +28 -0
- package/dist/skills/temps/howtos/javascript-typescript.md +57 -0
- package/dist/skills/temps/howtos/managed-services.md +83 -0
- package/dist/skills/temps/howtos/observability-onboarding.md +52 -0
- package/dist/skills/temps/howtos/projects-and-monorepos.md +49 -0
- package/dist/skills/temps/howtos/python.md +42 -0
- package/dist/skills/temps/howtos/rust.md +30 -0
- package/dist/skills/temps/references/cli-runtime.md +68 -0
- package/dist/skills/temps/references/commands/INDEX.md +97 -0
- package/dist/skills/temps/references/commands/access.md +49 -0
- package/dist/skills/temps/references/commands/ai.md +43 -0
- package/dist/skills/temps/references/commands/alarms.md +87 -0
- package/dist/skills/temps/references/commands/analytics.md +369 -0
- package/dist/skills/temps/references/commands/apikeys.md +96 -0
- package/dist/skills/temps/references/commands/audit.md +41 -0
- package/dist/skills/temps/references/commands/backups.md +263 -0
- package/dist/skills/temps/references/commands/cloud.md +371 -0
- package/dist/skills/temps/references/commands/cluster.md +31 -0
- package/dist/skills/temps/references/commands/configure.md +55 -0
- package/dist/skills/temps/references/commands/containers.md +110 -0
- package/dist/skills/temps/references/commands/context.md +49 -0
- package/dist/skills/temps/references/commands/custom-domains.md +98 -0
- package/dist/skills/temps/references/commands/data.md +90 -0
- package/dist/skills/temps/references/commands/delivery-profiles.md +69 -0
- package/dist/skills/temps/references/commands/delivery.md +116 -0
- package/dist/skills/temps/references/commands/deploy-image.md +23 -0
- package/dist/skills/temps/references/commands/deploy-local-image.md +28 -0
- package/dist/skills/temps/references/commands/deploy-static.md +23 -0
- package/dist/skills/temps/references/commands/deploy.md +21 -0
- package/dist/skills/temps/references/commands/deployments.md +172 -0
- package/dist/skills/temps/references/commands/dns-provider.md +196 -0
- package/dist/skills/temps/references/commands/dns.md +181 -0
- package/dist/skills/temps/references/commands/domains.md +187 -0
- package/dist/skills/temps/references/commands/drop.md +21 -0
- package/dist/skills/temps/references/commands/dsn.md +84 -0
- package/dist/skills/temps/references/commands/email-domains.md +160 -0
- package/dist/skills/temps/references/commands/email-providers.md +91 -0
- package/dist/skills/temps/references/commands/emails.md +79 -0
- package/dist/skills/temps/references/commands/env-pull.md +16 -0
- package/dist/skills/temps/references/commands/env-push.md +17 -0
- package/dist/skills/temps/references/commands/environments.md +252 -0
- package/dist/skills/temps/references/commands/errors.md +250 -0
- package/dist/skills/temps/references/commands/facets.md +57 -0
- package/dist/skills/temps/references/commands/flags.md +143 -0
- package/dist/skills/temps/references/commands/funnels.md +92 -0
- package/dist/skills/temps/references/commands/incidents.md +111 -0
- package/dist/skills/temps/references/commands/init.md +16 -0
- package/dist/skills/temps/references/commands/instances.md +56 -0
- package/dist/skills/temps/references/commands/instantiations.md +53 -0
- package/dist/skills/temps/references/commands/ip-access.md +153 -0
- package/dist/skills/temps/references/commands/link.md +15 -0
- package/dist/skills/temps/references/commands/load-balancer.md +73 -0
- package/dist/skills/temps/references/commands/login.md +17 -0
- package/dist/skills/temps/references/commands/logout.md +16 -0
- package/dist/skills/temps/references/commands/logs.md +167 -0
- package/dist/skills/temps/references/commands/mcp-servers.md +70 -0
- package/dist/skills/temps/references/commands/mcp.md +65 -0
- package/dist/skills/temps/references/commands/metrics.md +79 -0
- package/dist/skills/temps/references/commands/migrate.md +109 -0
- package/dist/skills/temps/references/commands/monitors.md +92 -0
- package/dist/skills/temps/references/commands/nodes.md +200 -0
- package/dist/skills/temps/references/commands/notification-preferences.md +47 -0
- package/dist/skills/temps/references/commands/notifications.md +211 -0
- package/dist/skills/temps/references/commands/open.md +17 -0
- package/dist/skills/temps/references/commands/otel-forward.md +210 -0
- package/dist/skills/temps/references/commands/otel.md +38 -0
- package/dist/skills/temps/references/commands/platform.md +147 -0
- package/dist/skills/temps/references/commands/plugin.md +193 -0
- package/dist/skills/temps/references/commands/presets.md +35 -0
- package/dist/skills/temps/references/commands/project-groups.md +255 -0
- package/dist/skills/temps/references/commands/projects.md +270 -0
- package/dist/skills/temps/references/commands/providers.md +277 -0
- package/dist/skills/temps/references/commands/proxy-logs.md +85 -0
- package/dist/skills/temps/references/commands/revenue.md +48 -0
- package/dist/skills/temps/references/commands/rollback.md +18 -0
- package/dist/skills/temps/references/commands/runtime-logs.md +21 -0
- package/dist/skills/temps/references/commands/sandbox.md +428 -0
- package/dist/skills/temps/references/commands/scans.md +113 -0
- package/dist/skills/temps/references/commands/secrets.md +65 -0
- package/dist/skills/temps/references/commands/server.md +50 -0
- package/dist/skills/temps/references/commands/services.md +636 -0
- package/dist/skills/temps/references/commands/session-replay.md +76 -0
- package/dist/skills/temps/references/commands/settings.md +84 -0
- package/dist/skills/temps/references/commands/setup.md +25 -0
- package/dist/skills/temps/references/commands/skills.md +87 -0
- package/dist/skills/temps/references/commands/start.md +20 -0
- package/dist/skills/temps/references/commands/status-pages.md +188 -0
- package/dist/skills/temps/references/commands/status.md +17 -0
- package/dist/skills/temps/references/commands/stop.md +16 -0
- package/dist/skills/temps/references/commands/teams.md +129 -0
- package/dist/skills/temps/references/commands/templates.md +61 -0
- package/dist/skills/temps/references/commands/tokens.md +77 -0
- package/dist/skills/temps/references/commands/traces.md +42 -0
- package/dist/skills/temps/references/commands/traefik-discovery.md +113 -0
- package/dist/skills/temps/references/commands/up.md +25 -0
- package/dist/skills/temps/references/commands/users.md +99 -0
- package/dist/skills/temps/references/commands/webhooks.md +165 -0
- package/dist/skills/temps/references/commands/whoami.md +15 -0
- package/dist/skills/temps/references/commands/workflow.md +42 -0
- package/dist/skills/temps/references/observability/analytics.md +146 -0
- package/dist/skills/temps/references/observability/error-tracking.md +73 -0
- package/dist/skills/temps/references/observability/hygiene.md +112 -0
- package/dist/skills/temps/references/observability/logs.md +43 -0
- package/dist/skills/temps/references/observability/metrics.md +41 -0
- package/dist/skills/temps/references/observability/tracing.md +392 -0
- package/dist/skills/temps/references/runtime-contract.md +115 -0
- package/dist/skills/temps/references/workflows/platform-operations.md +154 -0
- package/dist/skills/temps/scripts/__pycache__/generate_command_references.cpython-314.pyc +0 -0
- package/dist/skills/temps/scripts/__pycache__/test_generate_command_references.cpython-314.pyc +0 -0
- package/dist/skills/temps/scripts/__pycache__/test_validate_skill.cpython-314.pyc +0 -0
- package/dist/skills/temps/scripts/__pycache__/validate_skill.cpython-314.pyc +0 -0
- package/dist/skills/temps/scripts/detect_project_capabilities.py +239 -0
- package/dist/skills/temps/scripts/generate_command_references.py +144 -0
- package/dist/skills/temps/scripts/test_detect_project_capabilities.py +124 -0
- package/dist/skills/temps/scripts/test_generate_command_references.py +128 -0
- package/dist/skills/temps/scripts/test_validate_skill.py +84 -0
- package/dist/skills/temps/scripts/validate_skill.py +111 -0
- package/package.json +2 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Analytics
|
|
2
|
+
|
|
3
|
+
For React apps, use the **add-react-analytics** skill for step-by-step provider/hook setup (`@temps-sdk/react-analytics`, `TempsAnalyticsProvider`, `useTrackEvent`, `useAnalytics`, session recording). That's currently the only official SDK — there is no Temps analytics SDK for other languages/frameworks. This file covers the underlying ingestion API so any language can send events directly over HTTP, the same way [error tracking](error-tracking.md) and [traces](tracing.md) are protocol-level rather than SDK-locked.
|
|
4
|
+
|
|
5
|
+
## Ingestion endpoints
|
|
6
|
+
|
|
7
|
+
Routes are registered as `/_temps/event` and `/projects/{project_id}/events/ingest` inside the crate, but the console server nests every plugin's routes under `/api` (`temps-cli/src/commands/serve/console.rs`), so the real externally-reachable paths are:
|
|
8
|
+
|
|
9
|
+
- `POST /api/_temps/event` — public, unauthenticated, reachable from any HTTP client (not just browsers). Body: `EventMetricsPayload` JSON.
|
|
10
|
+
- `POST /api/projects/{project_id}/events/ingest` — authenticated, for server-side/backend event submission. Body: `ConsoleEventPayload` JSON.
|
|
11
|
+
|
|
12
|
+
Both funnel through the same write path (`AnalyticsEventsService`) into an outbox table in Postgres; a background worker fans events out to ClickHouse if it's configured for the instance — a just-recorded event can take a few seconds to reach ClickHouse-backed dashboard views even though it's already durably written.
|
|
13
|
+
|
|
14
|
+
Implemented in `temps-analytics-events` crate: `src/handlers/events_handler.rs` (`record_event_metrics` for the public endpoint at line 646, `record_console_event` for the authenticated one at line 843, route table at line 1085), `src/types/requests.rs` (payload structs, lines 175–229).
|
|
15
|
+
|
|
16
|
+
### `EventMetricsPayload` (public endpoint)
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"event_name": "page_view", // required
|
|
21
|
+
"event_data": {}, // required, arbitrary JSON
|
|
22
|
+
"request_path": "/products", // required
|
|
23
|
+
"request_query": "?sort=asc", // required (empty string if none)
|
|
24
|
+
"screen_width": 1920, // optional
|
|
25
|
+
"screen_height": 1080, // optional
|
|
26
|
+
"viewport_width": 1920, // optional
|
|
27
|
+
"viewport_height": 1080, // optional
|
|
28
|
+
"language": "en-US", // optional
|
|
29
|
+
"page_title": "Products", // optional
|
|
30
|
+
"referrer": "https://google.com", // optional, falls back to the Referer header
|
|
31
|
+
"ttfb": 100.5, // optional, Web Vitals (ms)
|
|
32
|
+
"lcp": 2500.0, "fid": 50.0, "fcp": 800.0, "inp": 150.0, // optional, Web Vitals (ms)
|
|
33
|
+
"cls": 0.1 // optional, Web Vitals (score, unitless)
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
There is no `project_id` field — the project is resolved server-side from the request's `Host` header via the deployment route table. This means calling `/api/_temps/event` **only works if the request's Host header matches a domain Temps already routes to a deployment** (the deployed app's own domain, or a Temps-assigned preview domain). A backend script running outside that domain can't just POST to the Temps console host and expect this to resolve — use the authenticated endpoint instead for out-of-band server-side event submission.
|
|
38
|
+
|
|
39
|
+
### `ConsoleEventPayload` (authenticated endpoint)
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"event_name": "purchase", // required
|
|
44
|
+
"event_data": { "amount": 49.99 }, // optional, defaults to {}
|
|
45
|
+
"environment_id": 42, // required
|
|
46
|
+
"deployment_id": 100, // required
|
|
47
|
+
"visitor_id": null, // optional, encrypted _temps_visitor_id cookie value (pass through if your backend read it from the user's request)
|
|
48
|
+
"session_id": null, // optional, encrypted _temps_sid cookie value
|
|
49
|
+
"request_path": "/checkout", // optional, defaults to "/"
|
|
50
|
+
"request_query": "" // optional, defaults to ""
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`project_id` goes in the URL path, `environment_id`/`deployment_id` go in the body — all three are required to attribute the event correctly.
|
|
55
|
+
|
|
56
|
+
## Auth
|
|
57
|
+
|
|
58
|
+
- `/api/_temps/event` is intentionally public/unauthenticated. Host-header project resolution attributes an event to a project; it does not prove the event came from a genuine browser/user.
|
|
59
|
+
- `/api/projects/{project_id}/events/ingest` requires a bearer token (session cookie, `tk_` API key, or `dt_` deployment token — all three work) with `AnalyticsWrite` permission scoped to that project. A token bound to a different project is rejected.
|
|
60
|
+
|
|
61
|
+
### Trust boundary
|
|
62
|
+
|
|
63
|
+
Treat public browser analytics as untrusted input:
|
|
64
|
+
|
|
65
|
+
- Never drive billing, authorization, entitlements, inventory, or authoritative revenue from `/api/_temps/event`.
|
|
66
|
+
- Send conversion-critical events from authenticated server code after the business transaction commits.
|
|
67
|
+
- Deduplicate in application business storage or an outbox before calling Temps when retries can create duplicates. Temps does not enforce idempotency from an identifier placed in `event_data`.
|
|
68
|
+
- Validate event names and allowlist bounded properties server-side for authoritative events.
|
|
69
|
+
|
|
70
|
+
## Quickstart: send analytics from any language
|
|
71
|
+
|
|
72
|
+
Since there's no per-language SDK, the pattern is a plain HTTP POST — the same shape regardless of language:
|
|
73
|
+
|
|
74
|
+
**From a backend already deployed on Temps** (has `TEMPS_API_URL` and `TEMPS_API_TOKEN` auto-injected — see the top-level [SKILL.md](../../SKILL.md) quickstart), record a custom server-side event with any HTTP client:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
curl -X POST "$TEMPS_API_URL/projects/$TEMPS_PROJECT_ID/events/ingest" \
|
|
78
|
+
-H "Authorization: Bearer $TEMPS_API_TOKEN" \
|
|
79
|
+
-H "Content-Type: application/json" \
|
|
80
|
+
-d '{
|
|
81
|
+
"event_name": "purchase",
|
|
82
|
+
"event_data": {"amount": 49.99, "currency": "USD"},
|
|
83
|
+
"environment_id": '"$TEMPS_ENVIRONMENT_ID"',
|
|
84
|
+
"deployment_id": '"$TEMPS_DEPLOYMENT_ID"'
|
|
85
|
+
}'
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`TEMPS_API_TOKEN` is currently a non-expiring deployment token with broad permissions, not an analytics-only key. Keep it server-side, never log or forward it, and never reuse it in browser code. Prefer a separately managed, purpose-scoped credential when the endpoint and deployment workflow support one; otherwise limit this call site and rotate the deployment credential after suspected exposure.
|
|
89
|
+
|
|
90
|
+
The equivalent in any language is just an authenticated JSON POST — Python (`requests.post(...)`), Go (`net/http` + `encoding/json`), Ruby (`Net::HTTP` or `httparty`), PHP (`curl_init`/Guzzle), Java (`HttpClient`), .NET (`HttpClient`), Rust (`reqwest`): no client library is needed because this is a plain REST call, not a protocol requiring a purpose-built SDK.
|
|
91
|
+
|
|
92
|
+
`environment_id`/`deployment_id`/`project_id` are **not** currently among the auto-injected env vars (unlike `TEMPS_API_URL`/`TEMPS_API_TOKEN`) — read them from the Temps dashboard (**Project Settings**) or from whatever IDs your deployment automation already has on hand, and set them yourself (e.g. as regular env vars) if a backend needs to call this endpoint repeatedly.
|
|
93
|
+
|
|
94
|
+
For browser-side tracking in a non-React frontend (vanilla JS, Vue, Svelte, a mobile app's WebView), POST directly to `/api/_temps/event` with `fetch`/`XMLHttpRequest`/equivalent using the `EventMetricsPayload` shape above — no auth needed, but it only resolves a project when the request's `Host` matches a routed deployment domain, so this only works called from code actually running on/against the deployed app's own origin.
|
|
95
|
+
|
|
96
|
+
Do not place secrets, emails, raw identifiers, payment data, or sensitive URL query values in `event_data`, `request_query`, URLs, or referrers. The endpoint stores application-provided event data; see [hygiene.md](hygiene.md).
|
|
97
|
+
|
|
98
|
+
## Review Performance Insights from the CLI
|
|
99
|
+
|
|
100
|
+
Use `analytics performance` (alias `speed`) to query the same real-user Web
|
|
101
|
+
Vitals surface as the project's Performance Insights page. Compare desktop and
|
|
102
|
+
mobile with identical windows and segment filters:
|
|
103
|
+
|
|
104
|
+
After runtime help confirms support, append either
|
|
105
|
+
`analytics performance -p my-app --period 7d --device desktop` or
|
|
106
|
+
`analytics performance -p my-app --period 7d --device mobile` to the verified,
|
|
107
|
+
pinned invocation from [../cli-runtime.md](../cli-runtime.md).
|
|
108
|
+
|
|
109
|
+
Add `--group-by path` to locate slow pages, or group by `country`, `region`,
|
|
110
|
+
`city`, `device_type`, `browser`, or `operating_system`. Narrow the same query
|
|
111
|
+
with `--environment-id`, `--deployment-id`, `--path`, `--country`, `--region`,
|
|
112
|
+
`--city`, `--browser`, or `--os`. Use paired RFC 3339 `--start-date` and
|
|
113
|
+
`--end-date` values for an exact comparison window. Bot samples are excluded by
|
|
114
|
+
default; include them only deliberately with `--include-bots`. Use `--json` for
|
|
115
|
+
the aggregate percentiles, time series, and optional breakdown payload.
|
|
116
|
+
|
|
117
|
+
Do not confuse this with `metrics query`, which reads OpenTelemetry application
|
|
118
|
+
metrics, or `analytics top devices`, which reports traffic counts rather than
|
|
119
|
+
browser performance. Runtime `--help` is authoritative; do not substitute an
|
|
120
|
+
ambient executable while the reviewed pinned version predates the command.
|
|
121
|
+
|
|
122
|
+
## What belongs here vs. other pillars
|
|
123
|
+
|
|
124
|
+
- Page views, custom product events ("signed up", "clicked upgrade"), scroll/engagement/Web Vitals — all analytics.
|
|
125
|
+
- Session replay is bundled under analytics (`SessionRecordingProvider` in the React SDK), separate from error-tracking's replay-on-error integration — the two are independent capture paths even though both are called "replay."
|
|
126
|
+
- Don't route business events through OTEL logs or traces — analytics has its own dashboard, retention, and ClickHouse fan-out tuned for high-volume event data; OTEL logs/traces are not.
|
|
127
|
+
|
|
128
|
+
## Session replay acceptance criteria
|
|
129
|
+
|
|
130
|
+
Do not enable replay until all of these hold:
|
|
131
|
+
|
|
132
|
+
- Recording is off until the required consent exists.
|
|
133
|
+
- `maskAllInputs` is enabled.
|
|
134
|
+
- Authentication, payment, medical, account, admin, and secrets-management routes/elements are blocked or masked.
|
|
135
|
+
- The recorder that is actually mounted responds to consent changes; a separate control-hook state is not sufficient evidence.
|
|
136
|
+
- A replay containing synthetic sensitive values has been inspected in Temps and the values are absent.
|
|
137
|
+
|
|
138
|
+
Do not treat the current standalone `useSessionRecordingControl` hook as the consent boundary: it owns state independently from the mounted recorder. Consent must mount/start and stop/unmount the actual recording provider until the SDK exposes one shared control path.
|
|
139
|
+
|
|
140
|
+
## Gotchas
|
|
141
|
+
|
|
142
|
+
- **Browser events not appearing**: check the Network tab for calls to `/api/_temps/event` first — if the request never fires, it's a client wiring issue (provider not mounted, `basePath` misconfigured), not a server-side ingestion problem. If it fires but 404s, the request's Host header doesn't match a routed deployment.
|
|
143
|
+
- **Server-side events silently rejected**: `/api/projects/{project_id}/events/ingest` requires real auth with `AnalyticsWrite` permission — a missing/expired token, or a token scoped to a different project, returns an auth error, unlike the public beacon endpoint.
|
|
144
|
+
- **ClickHouse-backed views lagging**: events land in the Postgres outbox immediately but ClickHouse fan-out is asynchronous via a background worker — a just-fired event may take a few seconds to appear in ClickHouse-backed dashboard views even though it's already durably recorded.
|
|
145
|
+
- **Public event totals disagree with revenue/orders**: expected if the browser endpoint was blocked, retried, or forged. Use authenticated backend events as the authoritative source.
|
|
146
|
+
- **Consent UI says replay is off but events still arrive**: verify the mounted recorder and the consent control share the same state; do not rely on UI state alone.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Error Tracking
|
|
2
|
+
|
|
3
|
+
For step-by-step SDK init per language/framework, use the **add-error-tracking** skill — it covers Next.js, React, Vue, Svelte, Angular, Node, React Native, Python, Go, Rust, Ruby, Java, PHP, .NET, Flutter with copy-paste snippets. This file covers the ingestion internals worth knowing when debugging or reviewing that setup.
|
|
4
|
+
|
|
5
|
+
**Apps deployed on Temps get the DSN for free, with no build-time-vs-runtime gap**: every deployment automatically has `SENTRY_DSN` injected — and, when the build preset needs one, the framework-specific public-prefixed variant (`NEXT_PUBLIC_SENTRY_DSN`, `VITE_SENTRY_DSN`, etc.) too. Temps injects both as a Docker `--build-arg` *and* as a container runtime env var (`temps-deployments::workflow_planner::gather_environment_variables`, threaded to `docker.rs`'s `buildargs` and `env` respectively), so client bundlers that inline public env vars at build time see the real value — there's no scenario where the DSN "isn't available yet" during the build. No dashboard copy-paste needed, and never hardcode a DSN or ask the user for one to hardcode — see the top-level [SKILL.md](../../SKILL.md) quickstart for the exact framework mapping and the scope of this auto-injection (it doesn't cover apps built outside Temps' own deploy pipeline, including Temps' own console).
|
|
6
|
+
|
|
7
|
+
## How it works
|
|
8
|
+
|
|
9
|
+
Temps is Sentry wire-compatible: it implements Sentry's ingestion protocol server-side, so the official Sentry SDK for any platform works unmodified against a Temps DSN. There is no Temps-specific error-tracking SDK.
|
|
10
|
+
|
|
11
|
+
DSN format:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
https://<public_key>@<temps-host>/<project_id>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The `public_key` is per-project and derived from the DB; the `secret_key` (if any) is never exposed in API responses.
|
|
18
|
+
|
|
19
|
+
The DSN public key is intentionally safe for browser write-only ingestion. It is not equivalent to a `dt_` deployment token or `tk_` API key, which are server-only machine credentials.
|
|
20
|
+
|
|
21
|
+
## Release auto-injection
|
|
22
|
+
|
|
23
|
+
Temps also auto-injects `SENTRY_RELEASE` (the deployment's commit SHA) alongside `SENTRY_DSN` for apps deployed through Temps (`workflow_planner.rs:1066-1070,1895-1920`) — every official Sentry SDK reads `SENTRY_RELEASE` from the environment when `release` isn't explicitly set in `Sentry.init()`, tagging events with the correct release automatically. **Don't hardcode a `release` value in `Sentry.init()`** — doing so overrides the injected value and breaks the dashboard's ability to join a stack frame back to its source (**Error Tracking → Source Context**). Leave `release` unset and let the SDK pick up `SENTRY_RELEASE` on its own.
|
|
24
|
+
|
|
25
|
+
## Ingestion endpoints
|
|
26
|
+
|
|
27
|
+
Routes are registered as `/{project_id}/store/` etc. inside the crate, but the console server nests every plugin's routes under `/api` (`temps-cli/src/commands/serve/console.rs`), so the real externally-reachable paths are:
|
|
28
|
+
|
|
29
|
+
- `POST /api/{project_id}/store/` — JSON event ingestion (legacy Sentry envelope-less format)
|
|
30
|
+
- `POST /api/{project_id}/envelope/` — binary/newline-delimited envelope ingestion (what modern Sentry SDKs use by default)
|
|
31
|
+
- `POST /api/0/projects/{org_slug}/{project_slug}/releases/{version}/files/` — source map upload, `sentry-cli`-compatible (multipart form: `file`, `name`, `dist`, `header`)
|
|
32
|
+
|
|
33
|
+
This matches standard Sentry SDK behavior unmodified: every conforming Sentry SDK inserts `api/` itself when building the request URL from a DSN, so a DSN of the form `https://<public_key>@<temps-host>/<project_id>` (no `/api` in the DSN) already produces exactly these URLs — nothing Temps-specific to configure. The `/api` prefix only matters if hand-rolling a raw HTTP request (e.g. `curl`) to test ingestion without going through a real SDK.
|
|
34
|
+
|
|
35
|
+
Implemented in `temps-error-tracking` crate: `src/sentry/handlers.rs`, `src/sentry/service.rs`, `src/sentry/envelope.rs`.
|
|
36
|
+
|
|
37
|
+
## Auth
|
|
38
|
+
|
|
39
|
+
Any of these are accepted, in priority order:
|
|
40
|
+
- `X-Sentry-Auth: Sentry sentry_key=<public_key>,sentry_version=7` header (what Sentry SDKs send by default)
|
|
41
|
+
- `Authorization: Bearer <public_key>` or `Authorization: DSN <token>`
|
|
42
|
+
- `sentry_key` query parameter (fallback, used by some old SDKs)
|
|
43
|
+
- Deployment tokens (`dt_*`) are also accepted and hash-validated against the DB
|
|
44
|
+
|
|
45
|
+
## Limits
|
|
46
|
+
|
|
47
|
+
- Request body: 2 MiB compressed, 10 MiB decompressed (`SENTRY_INGEST_BODY_LIMIT`) — guards against decompression bombs.
|
|
48
|
+
- gzip `Content-Encoding` is supported and decoded with a size guard.
|
|
49
|
+
|
|
50
|
+
## Sensitive data
|
|
51
|
+
|
|
52
|
+
Temps stores the event the SDK sends, so scrub it before export:
|
|
53
|
+
|
|
54
|
+
- Keep legacy `sendDefaultPii` false/undefined, or use the SDK's current granular `dataCollection` allow/deny configuration.
|
|
55
|
+
- Do not collect authorization/cookie headers, HTTP bodies, sensitive query parameters, database parameter values, passwords, tokens, payment data, or raw GenAI inputs/outputs by default.
|
|
56
|
+
- Use `beforeSend` (or the language SDK's equivalent event processor) to remove unsafe request, user, breadcrumb, context, and extra fields after integrations have populated the event.
|
|
57
|
+
- Prefer allowlisting required fields. Returning `null` from `beforeSend` should drop an event that cannot be made safe.
|
|
58
|
+
- Test with synthetic canary secrets and inspect the stored event in Temps.
|
|
59
|
+
|
|
60
|
+
See [hygiene.md](hygiene.md) for the cross-pillar policy.
|
|
61
|
+
|
|
62
|
+
## Response shape
|
|
63
|
+
|
|
64
|
+
- Store/Envelope: `{"id": "<event_uuid>"}`, HTTP 200
|
|
65
|
+
- Source maps: `{"id": ..., "name": ..., "dist": ..., "headers": {...}, "size": ..., "sha1": ..., "date_created": ...}`
|
|
66
|
+
|
|
67
|
+
## Gotchas
|
|
68
|
+
|
|
69
|
+
- **Nothing shows up**: the SDK must be initialized before any code that could throw — for Node, `Sentry.init` must be the first import in the entrypoint, not somewhere mid-file.
|
|
70
|
+
- **Browser apps not reporting**: the DSN env var needs the bundler's public prefix (`NEXT_PUBLIC_`, `VITE_`, `PUBLIC_`) to reach the client bundle; a plain `SENTRY_DSN` won't be inlined into browser code.
|
|
71
|
+
- **Minified stack traces**: upload source maps via `sentry-cli sourcemaps upload` in CI, or through **Error Tracking → Source Maps** in the dashboard — the release version passed to the SDK must match the release the source maps were uploaded under.
|
|
72
|
+
- **Production events missing but local ones work**: the deployment's env vars are separate from local `.env` files — confirm the DSN is actually set in the deployed environment, not just locally.
|
|
73
|
+
- **Unexpected PII**: inspect the SDK's resolved data-collection settings and the post-integration `beforeSend` event; initializing the SDK with defaults does not prove application-added extras/breadcrumbs are safe.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Telemetry Hygiene and Production Guardrails
|
|
2
|
+
|
|
3
|
+
Read this file whenever adding or reviewing error tracking, traces, metrics, OTLP logs, analytics, or session replay. Temps stores what applications send; filtering sensitive or unbounded data is primarily the application's responsibility.
|
|
4
|
+
|
|
5
|
+
## Credential and trust boundaries
|
|
6
|
+
|
|
7
|
+
Classify telemetry credentials before wiring an exporter:
|
|
8
|
+
|
|
9
|
+
| Value | Browser-safe? | Rule |
|
|
10
|
+
|---|---:|---|
|
|
11
|
+
| Sentry-compatible DSN public key | Yes | A client-write identifier, not a control-plane credential; still configure it through the platform instead of hardcoding it |
|
|
12
|
+
| Public `/api/_temps/event` analytics endpoint | Yes, but untrusted | Host-based attribution is not proof that an event came from a genuine user |
|
|
13
|
+
| `dt_` deployment token | No | Permanent machine credential; server-side only |
|
|
14
|
+
| `tk_` API key | No | Server-side only |
|
|
15
|
+
| `OTEL_EXPORTER_OTLP_HEADERS` / `TEMPS_API_TOKEN` | No | Contains a live bearer token; never expose to client code |
|
|
16
|
+
|
|
17
|
+
Build-time availability does not make a server credential browser-safe. Never:
|
|
18
|
+
|
|
19
|
+
- Give `dt_`, `tk_`, `TEMPS_API_TOKEN`, or `OTEL_EXPORTER_OTLP_HEADERS` a `NEXT_PUBLIC_`, `VITE_`, `PUBLIC_`, or similar prefix.
|
|
20
|
+
- Read those values from a client component or bundle.
|
|
21
|
+
- Put them in browser/mobile OTLP exporter configuration.
|
|
22
|
+
|
|
23
|
+
Browser or mobile OTLP must go through an application backend or collector that adds authentication server-side. Until Temps offers a restricted public OTLP write key and browser CORS support, direct client OTLP is unsupported.
|
|
24
|
+
|
|
25
|
+
## Sensitive-data policy
|
|
26
|
+
|
|
27
|
+
Redact before export. Temps does not provide a universal server-side scrubber for arbitrary telemetry payloads.
|
|
28
|
+
|
|
29
|
+
Do not send:
|
|
30
|
+
|
|
31
|
+
- Authorization, cookie, API-key, or session headers.
|
|
32
|
+
- Passwords, access/refresh tokens, private keys, or connection strings.
|
|
33
|
+
- Raw request/response bodies or database parameter values by default.
|
|
34
|
+
- Payment, medical, authentication, or other regulated data.
|
|
35
|
+
- Email addresses, full IP addresses, or stable user identifiers unless the product has an explicit lawful need and retention policy.
|
|
36
|
+
- Raw GenAI prompts/completions unless users knowingly opted in and a redaction policy is enforced.
|
|
37
|
+
- Sensitive URL query parameters or fragments.
|
|
38
|
+
|
|
39
|
+
Prefer allowlisting safe attributes over maintaining an ever-growing denylist. Use SDK processors/hooks such as Sentry `beforeSend`, OTel span/log processors, and analytics payload builders. Keep legacy Sentry `sendDefaultPii` false/undefined or use the current granular `dataCollection` allow/deny settings.
|
|
40
|
+
|
|
41
|
+
Test redaction with synthetic canary values that look like tokens, emails, and card numbers, then inspect the actual stored event/span/log/replay.
|
|
42
|
+
|
|
43
|
+
## Session replay
|
|
44
|
+
|
|
45
|
+
Session replay is the highest-risk signal because the backend stores captured rrweb events. Treat it as a separate privacy feature:
|
|
46
|
+
|
|
47
|
+
- Keep recording disabled by default.
|
|
48
|
+
- Obtain the required consent before mounting or starting the recorder.
|
|
49
|
+
- Use `maskAllInputs: true`.
|
|
50
|
+
- Block or mask authentication, payment, medical, account, admin, and secrets-management UI.
|
|
51
|
+
- Exclude sensitive paths explicitly.
|
|
52
|
+
- Verify the active recorder actually responds to the consent state; do not claim compliance from a disconnected control hook.
|
|
53
|
+
- Inspect a replay made with synthetic sensitive values before production rollout.
|
|
54
|
+
|
|
55
|
+
Do not use the current standalone `useSessionRecordingControl` hook as proof that recording stopped: its state is independent from the mounted recorder. Consent must control the actual provider lifecycle until the SDK exposes one shared control path.
|
|
56
|
+
|
|
57
|
+
## Cardinality and naming
|
|
58
|
+
|
|
59
|
+
Unbounded dimensions make telemetry expensive and hard to query across every pillar:
|
|
60
|
+
|
|
61
|
+
- Name server spans with route templates (`GET /users/:id`), not raw paths (`GET /users/123`) or full URLs.
|
|
62
|
+
- Never use user IDs, session IDs, request IDs, UUIDs, emails, raw SQL, raw queries, or error messages as metric labels.
|
|
63
|
+
- Keep metric label sets small and bounded.
|
|
64
|
+
- Keep analytics event names stable (`purchase_completed`); put only bounded dimensions in properties.
|
|
65
|
+
- Allowlist span and log attributes, and drop high-cardinality auto-instrumentation fields before export.
|
|
66
|
+
- Keep `service.name` stable per service. Put version and environment in their dedicated resource attributes.
|
|
67
|
+
|
|
68
|
+
## Production volume controls
|
|
69
|
+
|
|
70
|
+
Use batching in production. Configure sampling deliberately rather than inheriting an SDK's development defaults:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
OTEL_TRACES_SAMPLER=parentbased_traceidratio
|
|
74
|
+
OTEL_TRACES_SAMPLER_ARG=0.05
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Choose the ratio from traffic volume and debugging needs; `0.05` is an example, not a universal default. Preserve parent sampling decisions across services.
|
|
78
|
+
|
|
79
|
+
Also:
|
|
80
|
+
|
|
81
|
+
- Exclude health checks, static assets, and other known low-value traffic at the source.
|
|
82
|
+
- Disable noisy middleware/socket instrumentations when they do not answer a real operational question.
|
|
83
|
+
- Prefer batch span/log processors with bounded queues and export timeouts.
|
|
84
|
+
- Call the SDK's shutdown/flush path during `SIGTERM`; otherwise the last buffered telemetry is lost.
|
|
85
|
+
- Treat exporter failure as observable but non-fatal to normal request handling.
|
|
86
|
+
|
|
87
|
+
## Trace propagation and baggage
|
|
88
|
+
|
|
89
|
+
Distributed traces require the application SDK to extract inbound and inject outbound W3C `traceparent`/`tracestate` headers. Temps configures export destinations; it does not add propagation to application HTTP clients.
|
|
90
|
+
|
|
91
|
+
Verify propagation across project/service boundaries. Logs emitted inside a request should carry the active `trace_id` and `span_id`. Background jobs should start or continue an explicit span rather than assuming request-local context survives queue boundaries.
|
|
92
|
+
|
|
93
|
+
Baggage crosses process boundaries and must not carry secrets or PII. Clear or allowlist baggage before calling an untrusted service.
|
|
94
|
+
|
|
95
|
+
## Analytics is not an authority
|
|
96
|
+
|
|
97
|
+
The public analytics endpoint is intentionally unauthenticated. Treat browser events as user-controlled input:
|
|
98
|
+
|
|
99
|
+
- Do not use them as the source of truth for billing, authorization, entitlements, inventory, or authoritative revenue.
|
|
100
|
+
- Send conversion-critical events from the authenticated backend endpoint after the server has committed the business action.
|
|
101
|
+
- Deduplicate in application business storage or an outbox before posting where retries are possible. Temps analytics ingest does not enforce idempotency from a business-event identifier in `event_data`.
|
|
102
|
+
|
|
103
|
+
## Hygiene verification
|
|
104
|
+
|
|
105
|
+
Before considering telemetry production-ready:
|
|
106
|
+
|
|
107
|
+
1. Search built client assets for `dt_`, `tk_`, `TEMPS_API_TOKEN`, and OTLP authorization headers.
|
|
108
|
+
2. Exercise a normal request and verify route-template span naming and trace propagation.
|
|
109
|
+
3. Send synthetic sensitive values through error, log, trace, analytics, and replay paths; verify they are absent or masked.
|
|
110
|
+
4. Load-test representative traffic and inspect span/metric/event cardinality.
|
|
111
|
+
5. Send `SIGTERM` with telemetry buffered and confirm shutdown flushes it within the runtime deadline.
|
|
112
|
+
6. Confirm authoritative business events originate from authenticated server code.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# OTEL Logs
|
|
2
|
+
|
|
3
|
+
Temps ingests standard OTLP/HTTP (protobuf) log exports. Use a standard OpenTelemetry logs SDK/exporter (or a logging bridge that emits OTLP logs); there is no Temps-specific logging SDK.
|
|
4
|
+
|
|
5
|
+
## Endpoints
|
|
6
|
+
|
|
7
|
+
Routes are registered as `/otel/v1/logs` inside the crate, but the console server nests every plugin's routes under `/api`, so the real externally-reachable paths are:
|
|
8
|
+
|
|
9
|
+
- Header-based: `POST /api/otel/v1/logs`
|
|
10
|
+
- Path-based: `POST /api/otel/v1/{project_id}/{environment_id}/{deployment_id}/logs`
|
|
11
|
+
|
|
12
|
+
Same auth, rate limit, and opt-in quota model as traces/metrics — see the shared-facts section in the top-level SKILL.md.
|
|
13
|
+
|
|
14
|
+
Implemented in `temps-otel` crate: `src/handlers/ingest_handler.rs` (log export handling).
|
|
15
|
+
|
|
16
|
+
## Payload
|
|
17
|
+
|
|
18
|
+
Standard `ExportLogsServiceRequest` protobuf: `SeverityNumber`, `Body`, `Attributes`, `Timestamp`, and optionally `TraceId`/`SpanId`.
|
|
19
|
+
|
|
20
|
+
**Always set `trace_id`/`span_id` on log records emitted from within a traced request** — this is what lets the Temps dashboard join a log line to the trace it happened during. Without it, the log is stored but orphaned from any trace context.
|
|
21
|
+
|
|
22
|
+
Application stdout/stderr is captured as container logs. Use OTLP logs when structured severity, attributes, and trace correlation are required; do not write production logs only to container-local files.
|
|
23
|
+
|
|
24
|
+
## Sensitive data and cardinality
|
|
25
|
+
|
|
26
|
+
Temps stores log bodies and attributes supplied by the exporter. Apply [hygiene.md](hygiene.md):
|
|
27
|
+
|
|
28
|
+
- Never log authorization/cookie headers, passwords, tokens, private keys, connection strings, payment data, raw bodies, or unredacted GenAI prompts/completions.
|
|
29
|
+
- Prefer structured allowlisted fields over serializing entire request/user objects.
|
|
30
|
+
- Keep attribute keys stable and values bounded. Do not turn user/session/request IDs, UUIDs, emails, raw queries, or stack traces into indexed dimensions.
|
|
31
|
+
- Redact in the logger/OTel processor before export, then verify with synthetic canary secrets.
|
|
32
|
+
|
|
33
|
+
## Storage and retention
|
|
34
|
+
|
|
35
|
+
- WARN/ERROR/FATAL-severity logs are stored in the primary time-series store (TimescaleDB/ClickHouse depending on backend config) for querying in the dashboard.
|
|
36
|
+
- All logs (including INFO/DEBUG) are optionally archived to S3 if `TEMPS_OTEL_S3_BUCKET` and credentials are configured — this is opt-in, not default.
|
|
37
|
+
|
|
38
|
+
## Gotchas
|
|
39
|
+
|
|
40
|
+
- **Low-severity logs not visible in dashboard queries**: only WARN+ severity is guaranteed to be in the queryable store by default; INFO/DEBUG logs may only exist in S3 archive if configured, otherwise they may not be retained at all. Don't rely on DEBUG-level logs being queryable in the dashboard unless S3 archival is set up.
|
|
41
|
+
- **Logs not correlating with traces**: verify `trace_id`/`span_id` are actually populated on the log record — most OTel logging bridges only auto-populate these when the log call happens inside an active span context (e.g., inside a request handler wrapped by the tracing middleware), not from a background job with no active span.
|
|
42
|
+
- **Use logs for structured record-keeping, not exception capture** — an uncaught exception belongs in error tracking (see [error-tracking.md](error-tracking.md)), not as an ERROR-level log line; you lose stack-trace grouping, source maps, and error-group deduplication if you only log it.
|
|
43
|
+
- **Shutdown loses the last logs**: batch log processors buffer records. Flush/shut down the provider during `SIGTERM` within Temps' runtime deadline.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Metrics
|
|
2
|
+
|
|
3
|
+
Temps ingests standard OTLP/HTTP (protobuf) metrics exports — counters, gauges, histograms, summaries — through the same ingestion pipeline as traces and logs. Use a standard OpenTelemetry metrics SDK/exporter; there is no Temps-specific metrics SDK.
|
|
4
|
+
|
|
5
|
+
## Endpoints
|
|
6
|
+
|
|
7
|
+
Routes are registered as `/otel/v1/metrics` inside the crate, but the console server nests every plugin's routes under `/api`, so the real externally-reachable paths are:
|
|
8
|
+
|
|
9
|
+
- Header-based: `POST /api/otel/v1/metrics`
|
|
10
|
+
- Path-based: `POST /api/otel/v1/{project_id}/{environment_id}/{deployment_id}/metrics`
|
|
11
|
+
|
|
12
|
+
Metrics use the same header forms (`Authorization: Bearer <token>` or `X-Temps-Api-Key`), rate limit (1000 req/60s/token), and opt-in quota as traces/logs. Token scope differs: `tk_` and `dt_` are server credentials used across application OTLP signals, while `si_` is accepted only for infrastructure metrics and must not be used for traces or logs. See the shared-facts section in the top-level SKILL.md.
|
|
13
|
+
|
|
14
|
+
Implemented in `temps-otel` crate: `src/handlers/ingest_handler.rs`; validation in `temps-metrics` crate: `src/store/timescale.rs`.
|
|
15
|
+
|
|
16
|
+
## Metric name validation
|
|
17
|
+
|
|
18
|
+
Metric names must match `[a-zA-Z0-9_.:- ]` — alphanumeric plus underscore, dot, colon, hyphen (spaces are in the character class but not meaningfully supported). Names that fail this check are logged with a warning and silently dropped at ingest, not stored anywhere.
|
|
19
|
+
|
|
20
|
+
This is **not** a curated allowlist like Prometheus recording rules — any name matching the pattern is accepted and stored. The "allowlist" language sometimes used for this internally refers to the validation gate, not a fixed list of permitted metric names.
|
|
21
|
+
|
|
22
|
+
## Label handling
|
|
23
|
+
|
|
24
|
+
- Max 64 labels per data point (`MAX_LABELS_PER_POINT`).
|
|
25
|
+
- Max 1024 bytes per label key or value.
|
|
26
|
+
- Any label whose key starts with `temps.` is silently stripped before storage — this namespace is reserved for Temps' own internal routing attributes, so don't rely on setting `temps.*` labels from app code; they will not persist.
|
|
27
|
+
- Use a small allowlist of bounded dimensions. Never use user IDs, session IDs, request IDs, UUIDs, emails, raw URLs/queries, or error messages as labels.
|
|
28
|
+
- For HTTP metrics, use route templates such as `/users/:id`, not raw request paths.
|
|
29
|
+
|
|
30
|
+
## Storage split
|
|
31
|
+
|
|
32
|
+
- Scalar points (counters, gauges) go into a `service_metrics` table.
|
|
33
|
+
- Histogram/summary points (multi-valued aggregations) are excluded from `service_metrics` but retained in `otel_metrics` — if a custom histogram metric doesn't appear in a scalar-only view, check the histogram-specific store/dashboard instead.
|
|
34
|
+
|
|
35
|
+
## Gotchas
|
|
36
|
+
|
|
37
|
+
- **Metric silently missing, no error**: check the name against the character-set regex first — invalid names fail closed with only a server-side warning log, no error surfaced to the exporter.
|
|
38
|
+
- **Custom label not showing up**: confirm it doesn't start with `temps.` — those are dropped by design, not a bug.
|
|
39
|
+
- **High-cardinality metric spiking storage**: cardinality isn't capped by a distinct-value allowlist, only by per-point label count/size — a metric with a label like `user_id` can still blow up cardinality. Prefer bucketing or dropping high-cardinality labels client-side before export rather than relying on server-side protection.
|
|
40
|
+
|
|
41
|
+
See [hygiene.md](hygiene.md) for cross-pillar naming, sampling, and sensitive-data rules.
|