SigSentrySigSentry

Hooks

useSigSentry and useSigSentryContext — programmatic access to the analysis flow for custom UIs

Two hooks back the entire SDK. Use them when the bundled components don't fit your design.

HookWhat it returns
useSigSentryContext()The configured SigSentryClient and current theme
useSigSentry({ client })An analysis state machine — submit, follow up, feedback

Both must be used inside a <SigSentryProvider>.

useSigSentryContext()

Returns { client, theme }. Useful when you want the underlying client directly — for example, listing past analyses or integrating with your own state library.

import { useSigSentryContext } from '@sigsentry/react';

export function AnalysisCount(): JSX.Element {
  const { client } = useSigSentryContext();
  // client is a SigSentryClient instance from @sigsentry/core
  // ...
  return <span>...</span>;
}
FieldTypeDescription
clientSigSentryClientThe configured API client
theme'light' | 'dark' | 'auto'The theme set on the provider

useSigSentry({ client })

The main hook for building a custom analysis UI. It owns the analysis lifecycle — loading, streamed status updates, the final result, and follow-up state.

import { useSigSentry, useSigSentryContext } from '@sigsentry/react';

export function CustomFlow(): JSX.Element {
  const { client } = useSigSentryContext();
  const {
    submitAnalysis,
    askFollowUp,
    submitFeedback,
    status,
    result,
    error,
    isLoading,
  } = useSigSentry({ client });

  async function run(): Promise<void> {
    await submitAnalysis({
      description: 'Checkout returning 500 errors',
      timeStart: new Date(Date.now() - 60 * 60 * 1000),
      timeEnd: new Date(),
    });
  }

  return (
    <div>
      <button onClick={run} disabled={isLoading}>
        {isLoading ? `Working… (${status})` : 'Analyze'}
      </button>
      {error && <p role="alert">{error.message}</p>}
      {result && <pre>{result.summary}</pre>}
    </div>
  );
}

Returned API

FieldTypeDescription
submitAnalysis(input) => Promise<void>Start a new analysis. Resets result and error.
askFollowUp(question: string) => Promise<ApiResponse<FollowUpResult> | null>Ask a follow-up about the most recent result
submitFeedback(feedback) => Promise<ApiResponse<void> | null>Submit accuracy feedback for the most recent result
statusSigSentryStatusOne of 'idle', 'received', 'processing', 'complete', 'failed'
resultAnalysisResult | nullThe latest finished result, or null
errorApiError | nullThe latest error, or null
isLoadingbooleantrue while an analysis is in flight

submitAnalysis(input)

Starts a new analysis and streams status updates into status until the result lands in result.

await submitAnalysis({
  description: 'API gateway 502s after deploy',
  timeStart: new Date('2026-04-25T14:00:00Z'),
  timeEnd: new Date('2026-04-25T14:30:00Z'),
  screenshot: file, // optional File object
});
FieldTypeRequiredDescription
descriptionstringyesFree text describing the issue
timeStartDateyesStart of the time window
timeEndDateyesEnd of the time window
screenshotFilenoOptional screenshot upload
metadataRecord<string, string>noArbitrary key/value tags stored with the analysis

askFollowUp(question)

Asks a follow-up question against the most recent analysis. Returns null if no analysis has completed yet.

const response = await askFollowUp('Which deploy introduced this?');
if (response?.success) {
  console.log(response.data.answer);
}

submitFeedback(feedback)

Records accuracy feedback against the most recent analysis. Used to improve future suggestions for your team.

await submitFeedback({
  accuracy: 'partially_correct',
  comment: 'Right service, wrong root cause.',
});
FieldTypeDescription
accuracy'correct' | 'partially_correct' | 'incorrect'Required
commentstringOptional free text

Status values

status is one of five values you can switch on for UI:

ValueMeaning
idleNo analysis is in flight
receivedThe request reached SigSentry; processing is starting
processingThe diagnosis is being prepared
completeThe analysis finished and result is populated
failedThe analysis errored — see error
const STAGE_LABEL: Record<SigSentryStatus, string> = {
  idle: 'Ready',
  received: 'Starting…',
  processing: 'Analyzing…',
  complete: 'Done',
  failed: 'Failed',
};