> For the complete documentation index, see [llms.txt](https://docs.pharos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pharos.ai/platform-overview/pharos-platform-architecture/logs/log-ingestion-methods/automated-error-tracking.md).

# Automated Error Tracking

Understand how Pharos automatically tracks errors from Salesforce events and emails without any configuration.

**Zero-configuration observability foundation.** The moment you install Pharos, it captures unhandled exceptions across Apex, Flows, and bulk operations—no code changes, setup wizards, or configuration required.

## What Gets Tracked Automatically

Pharos monitors multiple Salesforce subsystems to capture failures that would otherwise remain hidden:

### Apex Exceptions

Pharos automatically captures Apex exceptions from every execution context:

| Context             | What's Captured                         | Value                       |
| ------------------- | --------------------------------------- | --------------------------- |
| **Triggers**        | Silent failures breaking data workflows | Detect broken automation    |
| **Batch Jobs**      | Errors during overnight processing      | Catch background failures   |
| **Queueable Jobs**  | Async processing failures               | Monitor async operations    |
| **Scheduled Jobs**  | Timeouts, governor limit violations     | Track scheduled reliability |
| **Classes/Methods** | Any unhandled exception                 | Baseline code coverage      |

**For every Apex exception, Pharos captures:**

* ✅ Complete stack trace with line numbers
* ✅ Variable values at failure point (when available)
* ✅ Governor limit consumption at error time
* ✅ User context and session details
* ✅ Related record IDs and object types

### Flow and Process Builder Failures

Native Salesforce delivers cryptic, text-only error emails with no visual context; Pharos presents an interactive visual debugger that shows the execution path instead.

{% hint style="success" %}
**Game Changer for Admins:** Visual Flow Debugger transforms cryptic error emails into clear diagrams—Admins can troubleshoot without developer assistance.
{% endhint %}

**Captured for every Flow failure:**

* Flow name, version, and failed element
* Variable values at failure point
* Decision criteria outcomes
* Complete execution path visualization

### Bulk API Failures

Data Loader and integration failures hide silently in job queues, so Pharos uses active mining to surface them immediately.

| What's Captured    | Level      | Details                                     |
| ------------------ | ---------- | ------------------------------------------- |
| **Job Summary**    | Overall    | Success/failure rates, timing               |
| **Record Errors**  | Individual | Record ID, failed field, error type         |
| **Error Patterns** | Analysis   | Common validation issues, systemic problems |

{% hint style="info" %}
**Integration Monitoring:** Bulk failures often indicate systemic data quality or synchronization issues—early detection prevents cascading problems.
{% endhint %}

### Batch Job Errors

Async batch jobs often run during off-hours, so their failures go unnoticed; Pharos monitors them and surfaces errors immediately.

**Captured details:**

* Batch class name and failed method (start/execute/finish)
* Batch size and scope at failure
* Complete exception with stack trace
* Timing and governor limit context

### Email2Case and Web2Lead Failures

Email2Case and Web2Lead are critical entry points for customer data, so failures here mean lost opportunities.

| Failure Type              | Impact            | Pharos Detection               |
| ------------------------- | ----------------- | ------------------------------ |
| Email parsing errors      | Cases not created | ✅ Immediate alert              |
| Validation rule failures  | Leads dropped     | ✅ Captured with details        |
| Required field violations | Silent failures   | ✅ Full context provided        |
| Assignment rule issues    | No owner assigned | ✅ Configuration fix identified |

## How Automated Collection Works

Three mechanisms operate continuously in the background, each covering what the others can't reach:

| Mechanism            | What It Captures                                                                           | Timing                  |
| -------------------- | ------------------------------------------------------------------------------------------ | ----------------------- |
| **Email Monitoring** | Apex exceptions and Flow / Process Builder failures, via the exception email pipeline      | As emails are delivered |
| **Platform Events**  | Triton-instrumented logs, and batch errors where the job implements `RaisesPlatformEvents` | Near real-time          |
| **Periodic Mining**  | Bulk API jobs, failed async jobs, Email2Case and Web2Lead failures                         | Scheduled, periodic     |

### Email Monitoring

Pharos adds its own email service address to the **Apex Exception Email** recipient list, so Salesforce sends it a copy of every exception notification alongside your existing recipients:

1. Salesforce generates the exception email and delivers it to all recipients, Pharos included
2. Pharos stores the raw message as an Inbound Email record, then parses it into an enriched log

Pharos is an additional recipient, not an interceptor — it neither removes existing recipients nor changes how Salesforce delivers these emails, so your team keeps receiving them exactly as before. Suppressing them is possible only by editing the recipient list in Salesforce Setup yourself, which isn't recommended: the emails are a useful fallback, and keeping them costs you nothing.

**Result:** noisy, unstructured emails become queryable, actionable log records.

### Platform Event Monitoring

Platform events are the programmatic ingestion path. Logs written by [Triton](https://docs.pharos.ai/platform-overview/pharos-platform-architecture/logs/log-ingestion-methods/pharos-triton-instrumentation.md) instrumentation arrive this way, as do batch job errors where the batch class implements `Database.RaisesPlatformEvents` — Salesforce publishes a `BatchApexErrorEvent` in that case, which Pharos consumes.

The distinction matters when you're deciding what to instrument: batch failures reach Pharos automatically only if the class opts into platform events. Otherwise they surface through periodic mining instead, which is slower but requires no code change.

### Periodic Mining

Periodic mining covers the subsystems that emit no real-time signal at all. A scheduled job polls for failures that would otherwise go unnoticed:

* Bulk API job results
* Failed async jobs (`AsyncApexJob` records in a Failed state)
* Email2Case and Web2Lead conversion failures

The cadence is periodic rather than instantaneous, and in some cases configurable, so treat mined errors as arriving with a lag rather than the moment they happen.

{% hint style="info" %}
**Minimal Performance Impact:** All three mechanisms run asynchronously, outside your users' transactions. Capture doesn't add processing time to the operation that failed.
{% endhint %}

## What Automated Collection Captures

Every log created through automated error tracking is enriched with contextual metadata to support efficient debugging:

| Data Category         | Examples                                                           |
| --------------------- | ------------------------------------------------------------------ |
| **Error Details**     | Exception type, error message, stack trace, line number            |
| **Execution Context** | Apex class/trigger name, Flow name/version, Batch job class        |
| **User Context**      | User ID, username, profile, role, session ID                       |
| **Record Context**    | Affected record IDs, object types, field values (if available)     |
| **Governor Limits**   | CPU time consumed, SOQL queries used, DML statements, heap size    |
| **Environment**       | Org ID, environment type (production/sandbox), timestamp, timezone |
| **Entry Point**       | How the error was detected (email, platform event, mining job)     |

This enrichment happens automatically—you don't need to manually instrument code or configure data collection. Pharos captures this context at the moment of failure, creating an immutable snapshot that supports debugging days or weeks later.

## Limitations of Automated Collection

Automated collection has known limitations, each of which Triton instrumentation can address:

| Limitation                      | Why It Matters                  | Solution                                 |
| ------------------------------- | ------------------------------- | ---------------------------------------- |
| **❌ Only unhandled exceptions** | Try-catch blocks hide errors    | 🛠️ Use Triton to log handled exceptions |
| **❌ No custom events**          | Can't track business milestones | 🛠️ Use Triton for success logging       |
| **❌ Limited performance data**  | Only captures at error time     | 🛠️ Use Triton for continuous monitoring |
| **❌ No transaction tracing**    | Can't link related events       | 🛠️ Use Triton transaction IDs           |

{% hint style="warning" %}
**Critical Gap: Try-Catch Blocks Create Blind Spots**

Many integration implementations catch all exceptions to prevent rollbacks. Without explicit Triton logging, these failures are **completely invisible**.

```apex
// INVISIBLE to automated tracking
try {
    callExternalAPI();
} catch (Exception e) {
    // Error caught but not logged - Pharos never sees it
}
```

{% endhint %}

## Use Cases

Automated collection delivers value across several common scenarios:

| Use Case                       | Value                                  | Why Automated Collection Works                     |
| ------------------------------ | -------------------------------------- | -------------------------------------------------- |
| **Production Error Detection** | Catch errors before users complain     | Zero-config monitoring of all unhandled exceptions |
| **Declarative Automation**     | Admins troubleshoot Flows without code | Visual debugger transforms cryptic emails          |
| **Integration Monitoring**     | Detect sync failures early             | Bulk API mining surfaces hidden errors             |
| **Baseline Observability**     | Safety net across entire org           | Catches errors in uninstrumented code paths        |

## Best Practices

A few practices help you get the most from automated collection:

| Practice                     | Why                              | Implementation                             |
| ---------------------------- | -------------------------------- | ------------------------------------------ |
| **✅ Enable Everywhere**      | Zero config, minimal overhead    | Production + all sandboxes + scratch orgs  |
| **✅ Review Regularly**       | Detection without action = noise | Weekly/biweekly triage using Issue Tracker |
| **✅ Configure Retention**    | Manage storage consumption       | 30-90 days standard, archive critical logs |
| **✅ Supplement with Triton** | Fill gaps in critical paths      | Add instrumentation for handled exceptions |

{% hint style="success" %}
**Pro Tip:** Run automated collection alone for Month 1. Identify which errors are most frequent, then prioritize Triton instrumentation for those high-impact areas. This data-driven approach maximizes ROI.
{% endhint %}

## Summary

**Automated Error Tracking = Zero-config baseline observability**

✅ **Immediate Value:** Captures unhandled exceptions across Apex, Flows, bulk operations\
✅ **No Maintenance:** No code changes or ongoing configuration required\
⚠️ **Known Limitations:** Can't see handled exceptions or custom events (use Triton for those)

**For most organizations:** Automated collection alone justifies Pharos adoption. Triton enhances critical paths.
