Skip to content

Latest commit

 

History

History
116 lines (83 loc) · 4.93 KB

sendingData.md

File metadata and controls

116 lines (83 loc) · 4.93 KB

Sending data

Each project has keys under Settings, Client keys (DSN). The same public key works for every SDK.

Sentry SDKs (errors, tracing, logs)

Use the DSN from project settings. It has the form https://<public key>@<your host>/<project id>.

Sentry.init({
  dsn: "https://<public key>@tracelet.example.com/1",
  release: "shop@1.4.0",
  tracesSampleRate: 1.0,
  enableLogs: true,
});

Any official Sentry SDK works. Tracelet accepts errors, sessions, transactions, streamed spans and logs. Older SDKs that still send transactions keep working.

PostHog SDKs (product analytics, flags, replay)

posthog.init("phc_<public key>", { api_host: "https://tracelet.example.com" });

Events, people, groups, feature flags and remote config work as they do with PostHog. Flags evaluate with the same hashing as the PostHog SDKs, so a person gets the same variant on every SDK.

OpenTelemetry (traces and logs)

Send OTLP over HTTP, protobuf or JSON, to /v1/traces and /v1/logs, with the public key in a header:

OTEL_EXPORTER_OTLP_ENDPOINT=https://tracelet.example.com
OTEL_EXPORTER_OTLP_HEADERS=X-Tracelet-Key=<public key>

Authorization: Bearer <public key> works too. Logs written inside a span appear under that trace.

Source maps

Upload a build's bundles and maps once per release, then minified JavaScript frames show your source:

TRACELET_URL=https://tracelet.example.com TRACELET_TOKEN=tlk_... \
tracelet sourcemaps upload --project 1 --release shop@1.4.0 --url-prefix "~/static/js" ./dist

The token is an API key with project:write. Frames are matched by debug ID when your bundler injects one, otherwise by release and file URL. The release must match the SDK's release. Add --dry-run to list what would be uploaded without sending anything.

Session replay

Turn on Settings, Project, Session replay. PostHog SDKs pick it up within a minute and start recording. Recordings appear under Replays with an activity log of clicks, typing and page changes. Inputs are recorded as typed unless you mask them in the SDK (session_recording: { maskAllInputs: true }).

Cron monitors

Wrap scheduled jobs with the Sentry SDK. The first check-in that carries a monitor_config creates the monitor; later check-ins only need the slug:

import * as Sentry from "@sentry/node";

await Sentry.withMonitor("nightly-invoices", async () => {
  await sendInvoices();
}, { schedule: { type: "crontab", value: "0 3 * * *" }, timezone: "Europe/Amsterdam", checkinMargin: 5, maxRuntime: 30 });

Tracelet marks a run missed when no check-in arrives within the grace period after the expected time, and timed out when a run stays in progress longer than maxRuntime minutes. Alert rules with the trigger "A cron monitor fails or recovers" notify you after failure_issue_threshold failures in a row.

Surveys

posthog-js shows live surveys automatically. Create one in Surveys, launch it, and every page running posthog-js 1.x picks it up within a minute. Answers arrive as survey sent events and are broken down per question; open-text answers are masked for people without the pii:view permission.

Uptime checks

Add a URL under Uptime and Tracelet requests it on a schedule from the server itself, checking the status code and, optionally, a word in the response. Private and loopback addresses are refused unless TRACELET_ALLOW_PRIVATE_WEBHOOKS is on, the same rule as alert webhooks. Checks run every 30 seconds, 1, 5, 10 or 30 minutes, or hourly, with a 1 to 30 second timeout; results are kept for 90 days.

Experiments

An experiment is a multivariate feature flag plus a conversion event. Read the flag with posthog.getFeatureFlag(key); every SDK sends $feature_flag_called when it does, and Tracelet counts each person's first variant as their exposure. A person converts when they send the conversion event after that exposure. Results show each variant's conversion rate, a 95% credible interval and the chance that it is the best; a winner is called once every variant has 50 exposed people and one is ahead with 95% probability.

SQL

SQL runs ClickHouse SQL over the current project. The tables are events, persons, person_distinct_ids, error_events, spans and logs, each already limited to this project. Only one SELECT runs at a time; table functions, other databases, SETTINGS and server functions are refused. Queries stop after 30 seconds or 10,000 rows. SQL needs the query:run and pii:view permissions, because it reads raw events and people; export:run adds CSV export.

Cohorts

A cohort is a group of people matched by person properties (for example email contains @example.com) or by what they did (signed_up at least once in the last 30 days), combined with all or any. Use a cohort to filter insights, list its members, or target a feature flag. Flags can only use cohorts built from person properties, because those are checked on every flag request.