Skip to content

feat: only send unknown or intentionally tracked errors to Segment #131

@angeloashmore

Description

@angeloashmore

Problem

Currently, all errors are sent to Segment via segmentTrackEnd(command, { error }) in src/index.ts:195 — including expected errors like CommandError (user input mistakes), UnauthorizedRequestError (not logged in), MissingPrismicConfigError (no config file), etc. These are not useful for analytics and add noise.

Sentry already handles this correctly: only unexpected errors (i.e. bugs) are sent to Sentry (line 238), while known error types are caught earlier and shown to the user with a helpful message.

Segment should follow the same pattern: only send errors that are either unknown (possible bugs) or intentionally opted in for tracking.

Current behavior

Error occurs
  → segmentTrackEnd(command, { error })  // ALL errors sent to Segment
  → error classified by instanceof checks
    → known error → console.error + return (no Sentry)
    → unknown error → Sentry + throw

Desired behavior

Error occurs
  → error classified by instanceof checks
    → known error → console.error + return (no Segment, no Sentry)
    → intentionally tracked error → Segment only (no Sentry)
    → unknown error → Segment + Sentry + throw

Known/expected errors that should not be sent to Segment:

  • CommandError — user input/argument errors
  • UnauthorizedRequestError / ForbiddenRequestError — not logged in
  • NotFoundRequestError — resource doesn't exist
  • InvalidPrismicConfigError / MissingPrismicConfigError — config issues
  • TypeBuilderRequiredError — feature not available yet

Errors that should be sent to Segment (but not Sentry):

  • NoSupportedFrameworkError — useful to track how often the CLI is used outside of supported projects

Reference

Slice Machine follows this pattern: auth errors and user-initiated aborts are excluded from Sentry, and Segment only receives structured lifecycle events with success: false — not raw error payloads for expected failures.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions