> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Daily Sentry Error Fixes

export const UseCaseHero = ({title, description, prompt, category, features, devinUrl, agent, intent, playbookId, type}) => {
  const encodedPrompt = encodeURIComponent(prompt || '');
  const tag = 'docs-use-case-gallery';
  const utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=hero-cta';
  const agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  const devinHref = type === 'schedule' ? 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + (prompt ? '&prompt=' + encodedPrompt : '') : type === 'review' ? 'https://app.devin.ai/review?' + utm : agent === 'ada' ? 'https://app.devin.ai/search?' + utm + '&noSubmit=true' + (prompt ? '&prompt=' + encodedPrompt : '') : devinUrl ? devinUrl.includes('?') ? devinUrl + '&' + utm + agentParams : devinUrl + '?' + utm + agentParams : prompt ? 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encodedPrompt : 'https://app.devin.ai/?' + utm + agentParams;
  const buttonLabel = type === 'schedule' ? 'Schedule in Devin ↗' : type === 'review' ? 'Set Up Devin Review ↗' : agent === 'advanced' ? 'Try in Devin ↗' : agent === 'dana' ? 'Try in Dana ↗' : agent === 'ada' ? 'Try in Ask Devin ↗' : 'Try in Devin ↗';
  const featureList = features ? features.split(',').map(f => f.trim()) : [];
  return <div className="uc-hero">
      <div className="uc-hero-inner">
        <div className="uc-hero-left">
          <h1 className="uc-hero-title">{title}</h1>
          <p className="uc-hero-desc">{description}</p>
          <div>
            <a href={devinHref} target="_blank" rel="noopener noreferrer" className="try-in-devin-btn">
              {buttonLabel}
            </a>
          </div>
        </div>
        <div className="uc-hero-meta">
          <div className="uc-meta-item">
            <span className="uc-meta-label">Author</span>
            <span className="uc-meta-value">Cognition</span>
          </div>
          <div className="uc-meta-item">
            <span className="uc-meta-label">Category</span>
            <span className="uc-meta-value">{category}</span>
          </div>
          {featureList.length > 0 && <div className="uc-meta-item">
              <span className="uc-meta-label">Features</span>
              <span className="uc-meta-value">{featureList.join(', ')}</span>
            </div>}
        </div>
      </div>
    </div>;
};

export const PromptBlock = ({children, type, agent, intent, playbookId}) => {
  var utm = 'utm_source=docs&utm_medium=use-case-gallery&utm_campaign=prompt-block';
  var tag = 'docs-use-case-gallery';
  var agentParams = (agent ? '&agent=' + agent : '') + (intent ? '&intent=' + intent : '') + (playbookId ? '&playbookId=' + playbookId : '');
  var label = type === 'schedule' ? 'Schedule in Devin' : type === 'playbook' ? 'Create Playbook' : type === 'knowledge' ? 'Add to Knowledge' : agent === 'advanced' ? 'Try in Devin' : agent === 'dana' ? 'Try in Dana' : agent === 'ada' ? 'Try in Ask Devin' : 'Try in Devin';
  var buildUrl = function (text) {
    var encoded = encodeURIComponent(text);
    if (type === 'schedule') return 'https://app.devin.ai/settings/schedules/create?' + utm + agentParams + '&prompt=' + encoded;
    if (type === 'playbook') return 'https://app.devin.ai/settings/playbooks/create?' + utm + '&body=' + encoded;
    if (type === 'knowledge') return 'https://app.devin.ai/knowledge?' + utm + '&body=' + encoded;
    if (agent === 'ada') return 'https://app.devin.ai/search?' + utm + '&noSubmit=true&prompt=' + encoded;
    return 'https://app.devin.ai/?tags=' + tag + '&' + utm + agentParams + '&prompt=' + encoded;
  };
  const ref = React.useRef(null);
  const [href, setHref] = React.useState('#');
  React.useEffect(() => {
    if (!ref.current) return;
    var codeEl = ref.current.querySelector('pre code');
    if (codeEl) {
      var text = codeEl.textContent.trim();
      if (text) setHref(buildUrl(text));
    }
    var header = ref.current.querySelector('[data-component-part="code-block-header"]');
    if (header && !header.querySelector('.prompt-block-devin-link')) {
      var link = document.createElement('a');
      link.href = href;
      link.target = '_blank';
      link.rel = 'noopener noreferrer';
      link.className = 'prompt-block-devin-link';
      link.style.cssText = 'display:inline-flex;align-items:center;gap:6px;text-decoration:none;color:#fff;font-size:11px;font-weight:500;padding:4px 10px;border-radius:6px;white-space:nowrap;background:#317CFF;transition:background 0.2s;margin-left:8px;';
      link.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg> ' + label;
      link.onmouseenter = function () {
        link.style.background = '#2968D9';
      };
      link.onmouseleave = function () {
        link.style.background = '#317CFF';
      };
      header.appendChild(link);
    }
    var existingLink = ref.current.querySelector('.prompt-block-devin-link');
    if (existingLink && href !== '#') existingLink.href = href;
  });
  return <div className="prompt-block" ref={ref}>{children}</div>;
};

<UseCaseHero title="Daily Sentry Error Fixes" description="Schedule a daily Devin session that pulls new Sentry errors overnight, spawns a fix session for each, and has PRs ready by morning." prompt="Use the Sentry MCP to pull all unresolved errors from the past 24 hours in the payments-api project, sorted by event count. For the top 5 errors, investigate the stack trace and root cause, then start a Devin session for each one to open a PR with a fix and regression test. Skip errors tagged wontfix or expected-behavior." category="Automations" features="Schedules, MCP, Advanced" type="schedule" agent="advanced" />

<div className="uc-detail-wrapper">
  <Tip>For a more detailed Sentry integration guide, [click here](/enterprise/integrations/sentry).</Tip>

  <Steps>
    <Step title="Connect the Sentry MCP">
      Before creating your schedule, Devin needs access to your Sentry data.

      1. Go to **Settings > Connections > MCP servers** and search for **Sentry**
      2. Click **Enable** and authenticate via OAuth — this grants Devin read access to your Sentry issues, events, and stack traces
      3. Click **Test listing tools** to verify the connection is working

      Once connected, Devin can query your Sentry projects, pull issue details and stack traces, and read breadcrumbs — all from within a session. Learn more about [configuring MCP servers](/work-with-devin/mcp).
    </Step>

    <Step title="Create the schedule">
      Go to **Settings > [Schedules](/product-guides/scheduled-sessions)** and click **Create schedule**.

      * **Name**: `Daily Sentry remediation — payments-api`
      * **Frequency**: Daily at 6:00 AM (so fix PRs are ready before standup)
      * **Agent**: Devin — this lets Devin spawn a separate session for each error, so fixes run in parallel
      * **Slack channel**: Select a channel (e.g., `#sentry-fixes`) so your team gets notified when the run completes and PRs are ready for review
      * **Prompt**:

      <PromptBlock type="schedule" agent="advanced">
        ```txt Daily Sentry remediation theme={null}
        Use the Sentry MCP to pull all unresolved errors from the past
        24 hours in the payments-api project, sorted by event count.
        Skip errors tagged `wontfix` or `expected-behavior`.

        For the top 5 errors:
        1. Pull the full stack trace and breadcrumbs
        2. Find the relevant source files in our repo
        3. Identify the root cause
        4. Start a Devin session to open a PR with a fix and a regression
           test, linking the Sentry issue URL in the PR description

        Post a summary of all errors and their PRs to Slack.

        If I leave feedback on any of the PRs (e.g., marking a fix as a
        false positive, requesting a different approach, or approving a
        pattern), create a Knowledge entry capturing that feedback so
        future runs handle similar errors correctly.
        ```
      </PromptBlock>
    </Step>

    <Step title="Seed Knowledge from your codebase and past fixes">
      Devin writes better fixes when it understands your app's error patterns. Instead of writing Knowledge entries yourself, ask Devin in any session to investigate your codebase and past fixes, then let it create the Knowledge:

      <PromptBlock agent="advanced">
        ```txt Learn our error patterns and create Knowledge theme={null}
        Investigate our payments-api codebase and build Knowledge entries
        for common error patterns:

        1. Read recent merged PRs that fixed Sentry errors — look for
           patterns in what broke and how it was fixed
        2. Check resolved Sentry issues for recurring root causes
           (null checks, N+1 queries, missing error boundaries)
        3. Review our error handling conventions in the codebase —
           which wrapper classes we use, how we log errors, our
           retry/fallback patterns

        For each pattern you find, create a Knowledge entry with a
        specific trigger (e.g., "TypeError in checkout", "database
        timeout in reports") and actionable fix guidance.
        ```
      </PromptBlock>

      These entries are automatically recalled when Devin encounters matching errors during scheduled runs — and the scheduled prompt above tells Devin to update Knowledge based on your PR feedback, so it improves over time.
    </Step>

    <Step title="What a typical run produces">
      Each morning, Devin processes the overnight error queue and opens targeted PRs. Here's what a real session output looks like:

      ```
      Processed 5 Sentry errors from payments-api (past 24h):

      1. TypeError: Cannot read property 'last4' of null (1,892 events)
         Root cause: Stripe webhook delivers `payment_method: null` for
         bank transfer payments. CheckoutReceipt.tsx:34 destructures
         without a null check.
         PR #612: Add null safety to CheckoutReceipt, show "Bank Transfer"
         fallback for non-card payments.

      2. TimeoutError: Query timeout after 30s on /api/invoices (743 events)
         Root cause: N+1 query in InvoiceService.getMonthly() — each
         line item triggers a separate product lookup.
         PR #613: Add eager loading for invoice line items with
         Sequelize `include`.

      3. RangeError: Maximum call stack size exceeded (412 events)
         Root cause: Circular reference in refund.toJSON() when a
         refund references its parent transaction which references
         the refund.
         PR #614: Break circular ref with a custom serializer,
         add max-depth test.

      4-5. Two lower-frequency validation errors — PRs #615, #616.
      ```

      Each PR includes the Sentry issue link, a description of the root cause, the fix, and a test that would have caught the original error.
    </Step>

    <Step title="Tune and iterate">
      After a week of runs, review what's working and adjust:

      **Scope the error count.** Start with `top 5` errors per run. If Devin consistently produces mergeable PRs, increase to 8-10. If fixes need heavy revision, reduce to 3.

      **Filter by project or tag.** Narrow the prompt to specific Sentry projects (`payments-api`, `web-frontend`) or exclude noisy tags. You can create separate schedules per project if error volumes differ.

      **Learn from results.** After a couple of weeks, ask Devin to analyze which fixes actually shipped and turn that into Knowledge:

      <PromptBlock agent="advanced">
        ```txt Analyze Sentry fix outcomes and update Knowledge theme={null}
        Look at all PRs Devin opened for Sentry errors in the last 2 weeks.
        For each PR, check whether it was merged or closed.

        Identify themes and learnings — which fix patterns worked, which
        approaches were rejected, what types of errors were false positives,
        and where Devin lacked context. Then update your Knowledge
        accordingly: create new entries, edit existing ones, or delete
        entries that led to bad fixes.
        ```
      </PromptBlock>
    </Step>
  </Steps>
</div>
