feat(telemetry): add centralized Exceptionless dogfooding for SvelteKit frontend#2254
Open
niemyjski wants to merge 3 commits into
Open
feat(telemetry): add centralized Exceptionless dogfooding for SvelteKit frontend#2254niemyjski wants to merge 3 commits into
niemyjski wants to merge 3 commits into
Conversation
…it app Instruments framework boundaries (not individual components) to track: - Page views with normalized routes (IDs replaced with :id) - Session lifecycle tied to auth state changes - API failures (5xx/429) with 30s deduplication - 404 not-found events via +error.svelte - Product action helpers (withTelemetryAction/trackBigAction) All telemetry is fail-safe (never throws), sanitizes PII aggressively, and uses low-cardinality event names for efficient aggregation.
Add trackBigAction calls to onSuccess callbacks for: - Auth: login, logout, signup, forgot-password - Organizations: create, delete, invite-user - Stacks: mark-fixed, snooze, delete, add-reference - Projects: create, delete - Saved Views: create, update, delete - Webhooks: create, delete - Tokens: create, delete Also mock @exceptionless/browser in server test setup to prevent transitive import failures from stacktrace-js in Node.js.
- Remove production debug logging (@@log:* debug → dev-only) - Replace hardcoded version '8.0.0' with env.PUBLIC_APP_VERSION - handleError now returns { errorId, message } per SvelteKit spec - Fix OBJECTID/UUID regex: use per-segment matching to prevent partial hex string replacement (507f...extra no longer becomes :idextra) - Fix toPageEventName: produce 'ui.page.events' not 'ui.page./events' - Fix session end on logout: move <Telemetry> outside {#if isAuthenticated} so the userId→undefined transition fires endSession() correctly - Add sessionStorage guard in Telemetry.svelte to prevent duplicate startSession() calls on HMR reloads and component remounts - Add module-level guard for useMiddleware registrations in layout to prevent double middleware execution on re-instantiation - Fix +error.svelte: deduplicate 404 tracking per path on re-renders - Add nested object sanitization in sanitizeProperties() - Omit null/undefined values from sanitized properties - Capture errorType (not message) in withTelemetryAction failure - Add no-op isEnabled() guard gating all telemetry on API key presence - Use void on all .submit() Promise returns - Fix all lint errors: import order, curly braces, sort-objects, sort-modules, unnecessary regex escapes - Update tests: 298 passing (was 287) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements end-to-end Exceptionless telemetry for the Svelte 5 / SvelteKit frontend, then applies a thorough adversarial code review pass fixing all identified issues.
What changed
New:
src/lib/telemetry/exceptionless.client.ts— Central module; page views, session lifecycle, 404s, API failure tracking, big product actions. Gated byisEnabled()so no-ops if API key is absent.Telemetry.svelte— Reactive component; starts/ends sessions, tracks page views on SPA navigation. Mounted outside{#if isAuthenticated}so logout transition fires correctly.sanitize.ts— PII sanitizer; redacts emails, tokens (≥32 chars), phone numbers, IPs, SSNs; recursively sanitizes nested objects; caps string/object sizes.route.ts— Path normalizer; per-segment ObjectId/UUID replacement (no partial-hex false matches), producesui.page.eventsformat (no leading slash).action.ts—trackBigAction()helper +withTelemetryAction()wrapper that tracks both success and failure witherrorType.Updated: hooks + layouts
hooks.client.ts— Exceptionlessstartup()ininit; dev-only debug logging; version fromenv.PUBLIC_APP_VERSION;handleErrorreturns{ errorId, message }per SvelteKit spec.+layout.svelte— Module-level guards prevent doubleuseMiddlewareregistration on re-instantiation;<Telemetry>moved outside{#if isAuthenticated}.+error.svelte— New file; 404 tracking with per-path dedup.Updated: feature API files (big product actions)
Auth, organizations, projects, stacks, saved-views, webhooks, tokens — all major mutations instrumented with
trackBigAction().Fixes applied (staff-engineer review)
@@log:*debug in productionversion = '8.0.0'env.PUBLIC_APP_VERSIONhandleErrordidn't return{ errorId, message }HandleClientError<Telemetry>inside{#if isAuthenticated}userIdpropuseMiddlewaredouble-registration/^[0-9a-f]{24}$/itoPageEventNameleading slashrootlastTrackedNotFoundPathdedupex_session_activekey guardsstartSession()errorTypeerror.nameaserrorTypeisEnabled()guard.submit()Promisesvoidadded throughoutDogfood verification ✅
Tested against live app with real API key. Events confirmed in Exceptionless:
ui.page.issues— page view on navigateui.page.events— page viewui.page.sessions— page viewui.page.project.:id.configure— dynamic segment normalized correctlysessionevents — start/end viaTelemetry.svelteui.action.project.create— project createdui.action.stack.mark-fixed— stack marked fixed404type event with source/this-page-does-not-exist— not-found trackingTest coverage
298 tests pass (287 before → +11 new tests).