Skip to content

Sentry 2#1657

Merged
simo6529 merged 2 commits intomainfrom
sentry-2
Dec 17, 2025
Merged

Sentry 2#1657
simo6529 merged 2 commits intomainfrom
sentry-2

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Dec 17, 2025

Summary by CodeRabbit

  • Tests

    • Added comprehensive test coverage for error filtering functionality.
  • Improvements

    • Refined error monitoring by filtering out non-critical notifications from the browser extension, reducing noise and ensuring you receive only actionable error reports relevant to your application.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Simo <simo@6529.io>
Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 17, 2025

Walkthrough

This pull request introduces a centralized Sentry event filtering utility for filename exceptions and refactors existing filtering logic to use it. A new utils/sentry-client-filters.ts module is created with types, internal helpers, and a public API. The instrumentation-client.ts is updated to use this utility. Tests and documentation are added to track the work.

Changes

Cohort / File(s) Summary
Sentry Filtering Utility
utils/sentry-client-filters.ts
New utility module exporting SentryStackFrame and SentryEventHint types. Introduces public function shouldFilterByFilenameExceptions() to detect matching filename exceptions in stack frames or exception stacks. Internal helpers shouldFilterFilenameExceptions() and shouldFilterExceptionStack() encapsulate respective checks. Exports __testing hook with filename exceptions for testing.
Filtering Tests
__tests__/utils/sentry-client-filters.test.ts
New test suite verifying shouldFilterByFilenameExceptions() correctly returns true/false based on filename matches in frames and exception stacks, and that extensionServiceWorker.js is in the filename exceptions collection.
Client Refactoring
instrumentation-client.ts
Refactored to import and delegate stack-frame filtering to shouldFilterByFilenameExceptions(). Removed local filenameExceptions constant and shouldFilterFilenameExceptions() function. Updated shouldFilterEvent() to use centralized utility.
Documentation & Tracking
codex/STATE.md, codex/tickets/TKT-0037.md
Added TKT-0037 state board entry (Status: Review, Priority: P1) and corresponding ticket documentation describing the feature to filter extensionServiceWorker Sentry noise, including plan, acceptance criteria, and context.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus areas:
    • Logic correctness in shouldFilterByFilenameExceptions() for both frame-based and exception-stack-based filtering
    • Type definitions (SentryStackFrame, SentryEventHint) and their usage patterns
    • Equivalence verification between the refactored instrumentation-client.ts logic and the original local implementation
    • Test coverage completeness for the new utility module

Suggested reviewers

  • ragnep
  • GelatoGenesis

Poem

🐰 A rabbit hops through Sentry's noise,
With filters centralized—oh joy!
From service workers, we filter with grace,
One utility now holds the place.
Stack frames and exceptions aligned,
Cleaner code, peace of mind! 🌙✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Sentry 2' is vague and generic, providing no meaningful information about what the changeset accomplishes. Use a more descriptive title that reflects the main change, such as 'Filter extensionServiceWorker Sentry noise' or 'Add filename-based Sentry event filtering'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sentry-2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
__tests__/utils/sentry-client-filters.test.ts (2)

7-16: Consider using proper type instead of as any.

The test correctly validates frame-based filtering, but the as any type assertion bypasses type safety. Consider importing and using SentryStackFrame from the utility module.

Apply this diff to improve type safety:

+import {
+  __testing,
+  shouldFilterByFilenameExceptions,
+  SentryStackFrame,
+} from "@/utils/sentry-client-filters";

  it("filters events when a stack frame matches a filename exception", () => {
    // Arrange
-    const frames = [{ filename: "app:///extensionServiceWorker.js" } as any];
+    const frames: SentryStackFrame[] = [{ filename: "app:///extensionServiceWorker.js" }];

    // Act
    const result = shouldFilterByFilenameExceptions(frames);

    // Assert
    expect(result).toBe(true);
  });

32-41: Consider using proper type instead of as any.

Same as the earlier test, consider using SentryStackFrame type instead of as any for better type safety.

Apply this diff:

  it("does not filter when frames do not match any filename exception", () => {
    // Arrange
-    const frames = [{ filename: "app:///main.js" } as any];
+    const frames: SentryStackFrame[] = [{ filename: "app:///main.js" }];

    // Act
    const result = shouldFilterByFilenameExceptions(frames);

    // Assert
    expect(result).toBe(false);
  });
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0e9672c and 3ab0c7e.

📒 Files selected for processing (5)
  • __tests__/utils/sentry-client-filters.test.ts (1 hunks)
  • codex/STATE.md (1 hunks)
  • codex/tickets/TKT-0037.md (1 hunks)
  • instrumentation-client.ts (2 hunks)
  • utils/sentry-client-filters.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (11)
codex/**/*.{md,yml,yaml}

📄 CodeRabbit inference engine (AGENTS.md)

Review codex/STATE.md at the start of every workstream; keep tickets in sync with codex/tickets/; author new tickets with provided template, keep alphabetical YAML front matter, and log timestamped updates

Files:

  • codex/tickets/TKT-0037.md
  • codex/STATE.md
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Do not include any comments in the code; it should be self-explanatory
Write correct, up-to-date, bug-free, fully componentized, secure, and efficient code
Include all required imports and ensure proper naming of key components
Use NextJS features that match the current version

**/*.{ts,tsx,js,jsx}: Replace <img> elements with <Image /> from next/image to satisfy @next/next/no-img-element ESLint rule
Use <Link href="/path"> from Next.js for internal navigation instead of plain HTML links to satisfy @next/next/no-html-link-for-pages ESLint rule

Files:

  • __tests__/utils/sentry-client-filters.test.ts
  • instrumentation-client.ts
  • utils/sentry-client-filters.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,jsx,ts,tsx}: Code must satisfy ESLint (Next's Core Web Vitals + React Hooks)
Use framework APIs: internal links should use <Link>, images should use next/image, and adopt Next's ESLint rules (Core Web Vitals)

**/*.{js,jsx,ts,tsx}: Code must satisfy ESLint (Next's Core Web Vitals + React Hooks rules)
Follow existing code style and naming conventions; maintain clean code standards (measured by SonarQube)

Files:

  • __tests__/utils/sentry-client-filters.test.ts
  • instrumentation-client.ts
  • utils/sentry-client-filters.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Must pass tsc --noEmit type checking
Prefer direct named imports for React hooks and types (import { useMemo, useRef, FC, etc. } from "react") over React. namespace usage (React.useMemo, React.useRef, etc.)
If the react-hooks/exhaustive-deps lint rule is triggered: if the Effect only derives state, remove the Effect and compute during render; if listening to an external system and needing fresh props/state, wrap non-reactive logic in useEffectEvent

**/*.{ts,tsx}: Must pass tsc --noEmit for TypeScript type checking
Prefer Server Components over Client Components; use Server Functions/Server Actions ('use server') for mutations
Remove unnecessary Effects; if Effect only derives state, compute during render instead
Use useEffectEvent for non-reactive logic inside Effects to avoid unnecessary re-runs
Use framework APIs: <Link> for internal links, next/image for images, adopt Next's ESLint rules
Use 'use cache' directive and Cache Components features for explicit opt-in caching in Next.js 16
Use TypeScript and React functional components with hooks
When parsing Seize URLs or similar, fail fast if base origin is unavailable; do not fall back to placeholder origins
Replace <img> elements with <Image /> from next/image
Use <Link href="/path"> for internal navigation instead of plain HTML links
Move data fetches to Server Components; handle mutations through Server Functions/Server Actions with 'use server' directive

Files:

  • __tests__/utils/sentry-client-filters.test.ts
  • instrumentation-client.ts
  • utils/sentry-client-filters.ts
**/@(__tests__|*.test).{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Tests should live in __tests__/ or ComponentName.test.tsx; mock external dependencies and APIs in tests

Files:

  • __tests__/utils/sentry-client-filters.test.ts
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (GEMINI.md)

Place tests in __tests__/ directory or as ComponentName.test.tsx alongside components

Files:

  • __tests__/utils/sentry-client-filters.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (GEMINI.md)

Mock external dependencies and APIs in tests

Files:

  • __tests__/utils/sentry-client-filters.test.ts
__tests__/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (tests/AGENTS.md)

Use Jest + ts-jest for TypeScript testing

Files:

  • __tests__/utils/sentry-client-filters.test.ts
__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (tests/AGENTS.md)

Functions must have ≤ 15 cognitive complexity; extract deep ternaries (>3 levels) and break down complex logic

Files:

  • __tests__/utils/sentry-client-filters.test.ts
__tests__/**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (tests/AGENTS.md)

__tests__/**/*.{ts,tsx,js}: Prefer for...of loops over forEach as it allows break/continue and works with async/await
Use array.at(-1) and array.at(-2) instead of index-based array access for negative indexing
Use String.prototype.replaceAll() instead of replace() for global string replacements
Use globalThis.fetch() instead of direct fetch() calls
Organize imports with one import per module in order: external → internal → types, with no duplicates
Use element.remove() instead of parent.removeChild(element) for DOM manipulation
Catch errors only when meaningful; no empty catch blocks; log errors with context
Avoid double negatives in code; prefer explicit logic and remove redundant annotations; use optional chaining (?.)

Files:

  • __tests__/utils/sentry-client-filters.test.ts
@(instrumentation-client.ts|sentry.server.config.ts|sentry.edge.config.ts)

📄 CodeRabbit inference engine (AGENTS.md)

Errors should be filtered in the Sentry beforeSend callback; client-side filtering happens in instrumentation-client.ts, server-side in sentry.server.config.ts, and edge runtime in sentry.edge.config.ts

Files:

  • instrumentation-client.ts
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T14:52:34.271Z
Learning: Applies to @(instrumentation-client.ts|sentry.server.config.ts|sentry.edge.config.ts) : Errors should be filtered in the Sentry `beforeSend` callback; client-side filtering happens in `instrumentation-client.ts`, server-side in `sentry.server.config.ts`, and edge runtime in `sentry.edge.config.ts`
📚 Learning: 2025-12-03T14:52:34.271Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T14:52:34.271Z
Learning: Applies to @(instrumentation-client.ts|sentry.server.config.ts|sentry.edge.config.ts) : Errors should be filtered in the Sentry `beforeSend` callback; client-side filtering happens in `instrumentation-client.ts`, server-side in `sentry.server.config.ts`, and edge runtime in `sentry.edge.config.ts`

Applied to files:

  • codex/tickets/TKT-0037.md
  • __tests__/utils/sentry-client-filters.test.ts
  • instrumentation-client.ts
  • utils/sentry-client-filters.ts
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/*.{ts,tsx,js} : Avoid double negatives in code; prefer explicit logic and remove redundant annotations; use optional chaining (`?.`)

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-03T14:52:34.271Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T14:52:34.271Z
Learning: Applies to **/@(__tests__|*.test).{ts,tsx} : Tests should live in `__tests__/` or `ComponentName.test.tsx`; mock external dependencies and APIs in tests

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/__tests__/**/*.test.{ts,tsx,js} : Test high-risk areas including happy path workflows, invalid input errors, edge cases/boundaries, component & API interactions, and performance/security when relevant

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/__tests__/**/*.test.{ts,tsx,js} : Keep tests independent, deterministic, and fast with production-like data

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/*.{ts,tsx,js} : Catch errors only when meaningful; no empty catch blocks; log errors with context

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/__tests__/**/*.test.{ts,tsx,js} : All tests must live in `__tests__`, mirroring source folders (`components`, `contexts`, `hooks`, `utils`)

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-05T10:55:30.871Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-12-05T10:55:30.871Z
Learning: Applies to **/__tests__/**/*.{ts,tsx} : Place tests in `__tests__/` directory or as `ComponentName.test.tsx` alongside components

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-05T10:55:43.476Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: __tests__/AGENTS.md:0-0
Timestamp: 2025-12-05T10:55:43.476Z
Learning: Applies to __tests__/**/__tests__/**/*.test.{ts,tsx,js} : Write tests following Arrange – Act – Assert pattern with one behaviour per test and clear, descriptive names

Applied to files:

  • __tests__/utils/sentry-client-filters.test.ts
📚 Learning: 2025-12-03T14:52:34.271Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-03T14:52:34.271Z
Learning: Applies to codex/**/*.{md,yml,yaml} : Review `codex/STATE.md` at the start of every workstream; keep tickets in sync with `codex/tickets/`; author new tickets with provided template, keep alphabetical YAML front matter, and log timestamped updates

Applied to files:

  • codex/STATE.md
📚 Learning: 2025-11-25T08:36:33.029Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: .cursor/rules/self_improve.mdc:0-0
Timestamp: 2025-11-25T08:36:33.029Z
Learning: Monitor code review comments, track common development questions, update rules after major refactors, add links to relevant documentation, and cross-reference related rules for continuous improvement

Applied to files:

  • codex/STATE.md
📚 Learning: 2025-11-25T08:36:24.149Z
Learnt from: CR
Repo: 6529-Collections/6529seize-frontend PR: 0
File: .cursor/rules/dev_workflow.mdc:0-0
Timestamp: 2025-11-25T08:36:24.149Z
Learning: Applies to .cursor/rules/**/*.mdc : After subtask implementation is complete, review code changes and chat history to identify new code patterns and conventions, then create or update Cursor rules in `.cursor/rules/` directory to capture these patterns following cursor_rules.mdc and self_improve.mdc guidelines

Applied to files:

  • codex/STATE.md
🧬 Code graph analysis (2)
__tests__/utils/sentry-client-filters.test.ts (1)
utils/sentry-client-filters.ts (2)
  • shouldFilterByFilenameExceptions (35-40)
  • __testing (42-42)
instrumentation-client.ts (1)
utils/sentry-client-filters.ts (1)
  • shouldFilterByFilenameExceptions (35-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
codex/STATE.md (1)

43-43: LGTM!

The new ticket entry is properly formatted, follows alphabetical ordering, and includes all required metadata fields.

__tests__/utils/sentry-client-filters.test.ts (3)

18-30: LGTM!

This test effectively validates stack-based filtering by constructing a realistic error with a stack trace containing the target filename pattern.


43-55: LGTM!

This test provides good coverage of the negative case where the exception stack does not contain any filtered filenames.


57-66: LGTM!

This test validates that the specific filename pattern from TKT-0037 is included in the filter list, directly addressing the ticket's requirements.

utils/sentry-client-filters.ts (4)

1-5: LGTM!

The type definitions are minimal, focused, and align with Sentry SDK structures. They provide sufficient type safety for the filtering logic.


7-7: LGTM!

The filename exceptions list appropriately targets common browser extension patterns that generate noise in Sentry, including the specific extensionServiceWorker.js mentioned in TKT-0037.


9-33: LGTM!

Both helper functions use defensive programming with appropriate early returns and handle edge cases properly. The dual check of filename and abs_path in frames provides good coverage, and the string-based stack matching is appropriate for stack trace analysis.


35-42: LGTM!

The public API appropriately combines both filtering strategies with OR logic, and the __testing export follows best practices for exposing internal state to tests without polluting the public API.

instrumentation-client.ts (2)

10-10: LGTM!

The import correctly uses a direct named import with the project's path alias convention.


68-69: LGTM!

The refactored code correctly delegates to the centralized utility, passing both the extracted frames and the hint. This aligns with the established pattern of filtering errors in the Sentry beforeSend callback. Based on learnings, client-side filtering happens in instrumentation-client.ts.

codex/tickets/TKT-0037.md (3)

1-8: LGTM!

The YAML front matter follows the required template with alphabetically ordered fields, proper date format, and valid metadata values. As per coding guidelines, codex tickets should maintain alphabetical YAML front matter.


32-34: LGTM!

The log entry follows the required format with an ISO 8601 timestamp and accurately describes the changes implemented in this PR. As per coding guidelines, tickets should log timestamped updates.


14-19: Ticket follows template and documents plan correctly.

The unchecked items on lines 18–19 are implementation milestones, not prerequisites for this ticket file. The Plan shows completed work (lines 16–17 ✓); the remaining items represent pre-merge verification (run tests) and post-merge validation (production Sentry check). No action needed on the ticket file itself.

Likely an incorrect or invalid review comment.

@simo6529 simo6529 merged commit d38782e into main Dec 17, 2025
9 checks passed
@simo6529 simo6529 deleted the sentry-2 branch December 17, 2025 10:05
@coderabbitai coderabbitai Bot mentioned this pull request Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants