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.
| Hook | What 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>;
}| Field | Type | Description |
|---|---|---|
client | SigSentryClient | The 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
| Field | Type | Description |
|---|---|---|
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 |
status | SigSentryStatus | One of 'idle', 'received', 'processing', 'complete', 'failed' |
result | AnalysisResult | null | The latest finished result, or null |
error | ApiError | null | The latest error, or null |
isLoading | boolean | true 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
});| Field | Type | Required | Description |
|---|---|---|---|
description | string | yes | Free text describing the issue |
timeStart | Date | yes | Start of the time window |
timeEnd | Date | yes | End of the time window |
screenshot | File | no | Optional screenshot upload |
metadata | Record<string, string> | no | Arbitrary 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.',
});| Field | Type | Description |
|---|---|---|
accuracy | 'correct' | 'partially_correct' | 'incorrect' | Required |
comment | string | Optional free text |
Status values
status is one of five values you can switch on for UI:
| Value | Meaning |
|---|---|
idle | No analysis is in flight |
received | The request reached SigSentry; processing is starting |
processing | The diagnosis is being prepared |
complete | The analysis finished and result is populated |
failed | The analysis errored — see error |
const STAGE_LABEL: Record<SigSentryStatus, string> = {
idle: 'Ready',
received: 'Starting…',
processing: 'Analyzing…',
complete: 'Done',
failed: 'Failed',
};