mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat(telemetry): Sentry + PostHog quality pass (#546)
Comprehensive telemetry quality improvements across Sentry and PostHog, grounded in an audit of the live data plus current best-practice research. Sentry: job_id/instance_id tags, operational fingerprinting, PII-safe settings context on bug events, web tag population + extension-noise filtering, an early-crash buffer, http status/method kept on breadcrumbs, and a gated-off-by-default performance-tracing re-enable (tracesSampler that zeroes db/redis/queue-poll root spans + drops the Redis integration) with worker job spans and canonical-host cron monitors. PostHog: history_change SPA pageviews, instance_id super property for fleet rollups, enriched tool_used (formats, byte sizes, is_batch, execution_hint, real error_kind taxonomy), the previously-dead result_saved/batch_processed/ai_bundle_prompted events fired, search click-through, editor + Automate authoring + auth instrumentation, a before_send PII boundary, and minimal opt-in landing-site pageviews.
This commit is contained in:
+10
-6
@@ -20,7 +20,7 @@ import { closeWorkers, startWorkers } from "./jobs/worker.js";
|
||||
import { initAnalytics, shutdownAnalytics, trackEvent } from "./lib/analytics.js";
|
||||
import { shouldRunStartupCleanup } from "./lib/cleanup.js";
|
||||
import { buildCsp } from "./lib/csp.js";
|
||||
import { reportError } from "./lib/error-report.js";
|
||||
import { reportError, setSentryInstanceTag } from "./lib/error-report.js";
|
||||
import { stripInternalPaths } from "./lib/errors.js";
|
||||
import {
|
||||
acquireInstallLock,
|
||||
@@ -180,17 +180,21 @@ if (env.AUTH_ENABLED) {
|
||||
await ensureAnonymousUser();
|
||||
}
|
||||
|
||||
async function ensureInstanceId() {
|
||||
async function ensureInstanceId(): Promise<string> {
|
||||
const [existing] = await db
|
||||
.select()
|
||||
.from(schema.settings)
|
||||
.where(eq(schema.settings.key, "instance_id"));
|
||||
if (!existing) {
|
||||
await db.insert(schema.settings).values({ key: "instance_id", value: randomUUID() });
|
||||
}
|
||||
if (existing) return existing.value;
|
||||
const value = randomUUID();
|
||||
await db.insert(schema.settings).values({ key: "instance_id", value });
|
||||
return value;
|
||||
}
|
||||
|
||||
await ensureInstanceId();
|
||||
// Tag every Sentry event with the anonymized instance id so triage can tell one
|
||||
// broken install from the whole fleet, and cross-reference an event to the same
|
||||
// instance_id used by the PostHog server-side stream.
|
||||
await setSentryInstanceTag(await ensureInstanceId());
|
||||
|
||||
async function ensureDefaultSettings() {
|
||||
const defaults: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user