Skip to content

PRs Detection Error Reporting System

JElsheikh edited this page Nov 8, 2025 · 1 revision

Detection Error Reporting System

Overview

This document describes the error reporting system implemented to help debug GitLab merge request detection issues across different GitLab versions and configurations.

Purpose

Users on certain GitLab versions (especially self-hosted enterprise instances) experience detection failures where the extension doesn't recognize their MR pages. This system collects comprehensive environment data to help identify patterns and fix detection logic.

Architecture

1. Error Reporter Module (services/error-reporter.js)

A modular, reusable service that:

  • Safely collects comprehensive debug information about the page
  • Uses defensive coding (optional chaining, nullish coalescing) to prevent errors
  • Sends data to background script for forwarding to cloud function

Key Features:

  • Safe DOM element detection
  • URL pattern analysis
  • Platform detector state capture
  • GitLab version detection via meta tags
  • Browser and extension info collection

2. Integration Points

Error reporting is triggered at these key detection failure points:

content.js

  1. Detection failure - "Current page does not need button"
  2. Panel injection blocked - Not on supported page
  3. User clicked AI Review on unsupported page
  4. Platform initialization error

platform-detector.js

  1. GitLab MR info extraction error

3. Background Message Handler (background.js)

Added handler for LOG_DETECTION_ISSUE message type (line ~528):

  • Extracts user email from storage
  • Forwards debug data to cloud function
  • Handles anonymous users gracefully

Data Collected

Critical Fields for Debugging

  1. URL Information

    • Full URL, hostname, pathname, search params
    • Essential for understanding URL variations
  2. Path Analysis

    • Tests for /merge_requests/, /-/merge_requests/, etc.
    • Identifies which patterns match/fail
    • Extracts MR ID from path
  3. DOM Elements

    • Checks for GitLab-specific CSS classes
    • Helps distinguish URL issues from DOM issues
    • Detects different GitLab UI versions
  4. Meta Tags

    • Generator tag often contains GitLab version
    • Example: "GitLab 14.5.2"
  5. Platform Detector State

    • Full detection result object
    • Shows why detection failed
  6. Custom Domains

    • Lists user-configured GitLab domains
    • Helps identify registration issues