Skip to content
← Public packages

@kentcdodds/sentry

Inspect Sentry organizations, projects, issues, and event summaries.

src/types.ts

170 lines · 3.3 KB · TypeScript
export type JsonRecord = Record<string, unknown>

export type SentryOrganization = JsonRecord & {
  slug: string
  name?: string
}

export type SentryProject = JsonRecord & {
  slug: string
  name?: string
  id?: string
}

export type SentryIssue = JsonRecord & {
  id: string
  title?: string
  shortId?: string
  status?: string
  permalink?: string
}

export type SentryEvent = JsonRecord & {
  id?: string
  eventID?: string
  title?: string
  message?: string
  entries?: unknown[]
  tags?: unknown
  contexts?: unknown
}

export type SearchIssuesInput = {
  orgSlug: string
  query?: string
  statsPeriod?: string
  limit?: number
  project?: string | number | Array<string | number>
  projectSlug?: string
  cursor?: string
}

export type SearchIssuesWithLatestSummariesInput = SearchIssuesInput & {
  summaryOptions?: SummarizeIssueEventOptions
}

export type ResolveProjectInput = {
  orgSlug: string
  projectSlug?: string
  projectId?: string | number
}

export type ListProjectsInput = {
  orgSlug: string
}

export type IssueInput = {
  issueId: string | number
}

export type IssueEventsInput = IssueInput & {
  limit?: number
  cursor?: string
}

export type SummarizeIssueEventOptions = {
  maxBreadcrumbs?: number
  maxFramesPerException?: number
}

export type SentryExceptionSummary = {
  type?: string
  value?: string
  module?: string
  mechanism?: unknown
  frameCount: number
  frames: Array<{
    function?: string
    module?: string
    filename?: string
    absPath?: string
    lineNo?: number
    colNo?: number
    inApp?: boolean
    contextLine?: string
  }>
}

export type SentryBreadcrumbSummary = {
  timestamp?: string
  type?: string
  category?: string
  level?: string
  message?: string
  data?: unknown
}

export type SentryEventSummary = {
  id?: string
  eventId?: string
  title?: string
  message?: string
  culprit?: string
  platform?: string
  projectId?: string
  groupId?: string
  release?: string
  environment?: string
  timestamp?: string
  exceptionChain: SentryExceptionSummary[]
  tags: Record<string, unknown>
  breadcrumbs: SentryBreadcrumbSummary[]
  contexts: JsonRecord
  contextKeys: string[]
  user?: unknown
  request?: unknown
}

export type SentryPaginationLink = {
  cursor?: string
  hasResults: boolean
  url?: string
}

export type SentryPage<T> = {
  items: T
  next?: SentryPaginationLink
  previous?: SentryPaginationLink
}

export type IssueWithLatestSummary = {
  issue: SentryIssue
  latestEventSummary: SentryEventSummary | null
  latestEventError?: {
    name?: string
    message: string
    status?: number
  }
}

export type IssueTriageInput = IssueInput & {
  recentEventLimit?: number
  options?: SummarizeIssueEventOptions
}

export type IssueTriage = {
  issue: {
    id: string
    shortId?: string
    title?: string
    status?: string
    level?: string
    permalink?: string
    firstSeen?: string
    lastSeen?: string
    count?: string | number
    userCount?: string | number
    project?: unknown
    assignedTo?: unknown
  }
  latestEventSummary: SentryEventSummary | null
  recentEventSummaries: SentryEventSummary[]
  signals: {
    exceptionTypes: string[]
    likelyCulprit?: string
    topInAppFrames: SentryExceptionSummary['frames']
    tagKeys: string[]
    contextKeys: string[]
    recentBreadcrumbs: SentryBreadcrumbSummary[]
  }
}