@eloquentai/chat-sdk 0.37.0-dev.2 → 0.37.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ import { ErrorEvent } from '@sentry/react';
2
+ import { SdkError } from '../contexts/error-handling/error-context';
3
+ /** Who is using the widget; useChat sets it once the identity resolves. */
4
+ interface ReportedUser {
5
+ userId: string;
6
+ deviceId: string;
7
+ environment: "test" | "live";
8
+ }
9
+ export declare function setReportedUser(user: ReportedUser): void;
10
+ /**
11
+ * Reports an error banner the customer is looking at. Called by ErrorProvider
12
+ * for every banner; never throws. A failed API call is titled by the server's
13
+ * reason ("Chat is closed"), or by status and endpoint (ids replaced by `:id`)
14
+ * when the body has none, with status, endpoint and chat id as tags. Any other
15
+ * banner is titled by its text.
16
+ */
17
+ export declare function reportErrorBanner(banner: SdkError, cause: unknown, appId: string): void;
18
+ /**
19
+ * The client's beforeSend: drops reports past MAX_REPORTS_PER_PAGE and keeps
20
+ * only this widget's data. On a host page that runs the same Sentry version,
21
+ * Sentry merges the host's scope (breadcrumbs, user, tags, extras, contexts)
22
+ * into our events before this runs.
23
+ */
24
+ export declare function createReportFilter(): (event: ErrorEvent) => ErrorEvent | null;
25
+ export {};
@@ -1,10 +1,20 @@
1
1
  export declare class NetworkError extends Error {
2
2
  constructor(message: string);
3
3
  }
4
+ /**
5
+ * A failed response's JSON body: the chat API's coded `errors`, or Nest's
6
+ * default `{ message, error, statusCode }`.
7
+ */
8
+ export interface ApiErrorBody {
9
+ errors?: Record<string, string | number>[];
10
+ message?: string | string[];
11
+ }
4
12
  export declare class ServerError extends Error {
5
13
  status: number;
6
- response: Record<string, Record<string, string | number>[]>;
7
- constructor(status: number, message: string, response: Record<string, Record<string, string | number>[]>);
14
+ response: ApiErrorBody;
15
+ /** The failed API call, e.g. `POST /v3/chat/<chat_id>`; unset for external URLs. */
16
+ endpoint?: string;
17
+ constructor(status: number, message: string, response: ApiErrorBody, endpoint?: string);
8
18
  }
9
19
  export interface HttpClientConfig {
10
20
  baseURL: string;
@@ -0,0 +1,6 @@
1
+ import { MessageData } from '../types/message';
2
+ /**
3
+ * A message's stable identity on screen: the id it was first shown under,
4
+ * which survives it taking its server id later (see `MessageData.localId`).
5
+ */
6
+ export declare function messageKey(message: MessageData): string;