import type { LighthouseReport, QuickTestSummary, RequestListObject } from "./ResponseTypes"; import { AnalysisResultObject } from "./ResponseTypes"; type DebugBearRumFilterValue = string | number | null | string[] | number[] | { from?: number; to?: number; }; type DebugBearRumFilterWithType = { value: DebugBearRumFilterValue; type: "is" | "isNot" | "matches" | "doesNotMatch"; }; export declare class DebugBear { pages: PagesApiClient; projects: ProjectsApiClient; annotations: AnnotationsApiClient; analyses: AnalysesApiClient; quickTests: QuickTestsApiClient; constructor(apiKey?: string | undefined); } declare class ApiClientObject { toJSON(): this & { _apiClient: undefined; }; } declare class ProjectObject extends ApiClientObject { private _apiClient; id: string; name: string; pages: PageObject[]; constructor(_apiClient: DebugBear, data: any); createPage(options: CreatePageOptions): Promise; deletePage(pageId: string): Promise; delete(): Promise; } interface CreatePageOptions { name: string; url: string; testScheduleName?: string; deviceName?: string; region?: ServerRegion; tags?: string[]; advancedSettings?: string[]; } interface GetMetricsOptions { from: Date; to: Date; environments?: "all"; } interface PageObject { id: string; name: string; region: ServerRegion; url: string; tags: []; device: { id: string; name: string; rtt: number; bandwidthKbps: number; formFactor: "mobile" | "desktop"; }; testSchedules: { id: string; name: string; everyNHours: number; times: string[]; days: number[]; }[]; advancedSettings: { name: string; type: string; config: object; }[]; } type ServerRegion = "us-east" | "us-ca" | "us-west" | "us-central" | "uk" | "australia" | "japan" | "germany" | "brazil" | "finland" | "india" | "singapore" | "canada" | "poland" | "spain" | "italy" | "france" | "netherlands" | "switzerland" | "taiwan" | "israel" | "southafrica" | "qatar" | "hongkong" | "mexico" | "chile" | "southkorea" | "indonesia" | "sweden" | "belgium"; declare class ProjectsApiClient extends ApiClientObject { private apiKey; private _apiClient; constructor(apiKey: string, _apiClient: DebugBear); get(projectId: string): Promise; list(): Promise; create({ name }: { name: string; }): Promise; delete(projectId: string): Promise; getPageMetrics(projectId: string, { before }?: { before?: Date; }): Promise<{ page: PageObject; metrics: any; }[]>; private static normalizeFilterValue; /** * Get RUM metrics for a project with optional filtering and grouping * @param projectId - The project ID * @param options - Query options * @param options.from - Start date for the query * @param options.to - End date for the query * @param options.groupBy - Field to group results by * @param options.maxCategories - The maximum number of categories to return for the groupBy parameter. Default is 20, max is 500. If there are more categories than this, the top categories according to the group by settings (default is number of experiences descending). If there are fewer categories than this, all categories will be returned regardless of other parameters. * @param options.metrics - Array of metrics to return * @param options.orderBy - Whether to order the results by count of experiences in each category ("count") or by the value of the metric being grouped by (e.g. LCP value if grouping by URL) ("value"). Default is "count". * @param options.orderByDirection - Sort direction (asc or desc) default is desc * @param options.filters - Filters to apply to the data. The key is the name of the field to filter by and the value is the value to filter by. Examples: * - `{ urlPath: "/project/2" }` - would only return data for the URL "/project/2" * - `{ urlPath: ["/project/2", "/project/3"] }` - would return data for both "/project/2" and "/project/3" * - `{ urlPath: ["/project/2", "/project/3"], urlPath_type: "isNot" }` - would return data for paths that do not match "/project/2" and "/project/3" * - `{ urlPath: "/project/*\/subPath", urlPath_type: "matches" }` - would return data for paths that match the wildcard pattern "/project/*\/subPath" * - `{ urlPath: { value: ["/project/2", "/project/3"], type: "isNot" } }` - type can also be provided within the metric object. This would return data for paths that do not match "/project/2" and "/project/3" * - `{ lcp: { from: 1000, to: 2000 } }` - would return data for LCP between 1000 and 2000 ms * - `{ lcp: { from: 1000, to: 2000 } }` - would return data for LCP between 1000 and 2000 ms * - `{ lcp: { from: 1000 } }` - would return data for LCP greater than or equal to 1000 ms * - `{ lcp: { to: 2000 } }` - would return data for LCP less than or equal to 2000 ms * - `{ device: ["mobile"] }` - would return data for mobile devices * - `{ urlPath: "/project/2", device: ["mobile"] }` - You can combine multiple filters together to further narrow down the data returned. For example, this would return data for the URL "/project/2" on mobile devices only. * @param options.stat - Statistical aggregation to use (p50, p75, p90, p95, avg) */ getRumMetrics(projectId: string, { from, to, groupBy, maxCategories, metrics, orderBy, orderByDirection, filters, stat, }?: { from?: Date; to?: Date; groupBy?: string; filters?: Record; maxCategories?: number; metrics?: string[]; orderBy?: "count" | "value"; orderByDirection?: "asc" | "desc"; stat?: "p50" | "p75" | "p90" | "p95" | "avg" | "sum"; }): Promise; /** * Get individual RUM page views for a project. Returns up to 5000 of the * most recent page views, ordered by date descending. * @param projectId - The project ID * @param options.from - Start date for the query (must be set together with `to`) * @param options.to - End date for the query (must be set together with `from`) * @param options.count - Maximum number of page views to return (default 5000, max 5000) * @param options.filters - Filters to apply, using the same shape as `getRumMetrics`'s `filters` option (e.g. `{ device: "mobile" }`, `{ urlPath: { value: "/foo", type: "matches" } }`, `{ lcp: { from: 1000, to: 2000 } }`) */ getRumPageViews(projectId: string, { from, to, count, filters, }?: { from?: Date; to?: Date; count?: number; filters?: Record; }): Promise; } declare class PagesApiClient { private apiKey; constructor(apiKey: string); analyze(pageId: number, options?: { commitHash?: string; commitBranch?: string; baseHash?: string; baseBranch?: string; url?: string; baseUrl?: string; path?: string; repoOwner?: string; repoName?: string; buildTitle?: string; cookies?: { name: string; value: string; domain: string; path: string; }[]; customHeaders?: { [key: string]: string; }; userFlowReplacements?: { [key: string]: string; }; inferBuildInfo?: boolean; ngrokWebPort?: number; substituteDocument?: { body?: string; duration?: number; }; runTestNTimes?: number; }): Promise<{ url: string; id: string; commitBranch: string | null; commitHash: string | null; buildTitle: string | null; baseHash: string | null; baseBranch: string | null; repoName: string | null; repoOwner: string | null; waitForResult: () => Promise; }>; analyzeBulk(pageIds: number[]): Promise<{ waitForResult: () => Promise<{ hasFinished: boolean; results: AnalysisResultObject[]; }>; }>; create(projectId: string, { name, url, testScheduleName, deviceName, region, advancedSettings, tags, }: Pick): Promise; update(pageId: number, { name, url, testScheduleName, deviceName, region, advancedSettings, tags, }: Partial): Promise; delete(pageId: string): Promise; getMetrics(pageId: string, { from, to, environments }: GetMetricsOptions): Promise; } declare class AnnotationsApiClient extends ApiClientObject { private apiKey; private _apiClient; constructor(apiKey: string, _apiClient: DebugBear); list(projectId: string): Promise; create(projectId: any, { title, description, pageFilter, date, }: { title: string; description: string; pageFilter: string; date: string | Date; }): Promise; } declare class AnalysesApiClient { private readonly apiKey; constructor(apiKey: string); /** * Get the basic info for a specific analysis (status, metrics, build, * commit, etc.). Use this when you already have an analysis ID from an * earlier run, a webhook payload, or a dashboard URL and don't want to * trigger a new test. * @param analysisId The analysis ID * @returns The analysis result object */ get(analysisId: string | number): Promise; /** * Get the request list for a specific analysis * @param analysisId The analysis ID * @returns Array of request objects with timing and metadata information */ getRequests(analysisId: string | number): Promise; /** * Get the Lighthouse report (LHR) for a specific analysis * @param analysisId The analysis ID * @returns The full Lighthouse report JSON */ getLighthouseReport(analysisId: string | number): Promise; } declare class QuickTestsApiClient { private readonly apiKey; constructor(apiKey: string); /** * Trigger one or more quick tests against arbitrary URLs without * adding them to monitoring. Returns the created QuickTest summaries * plus a `waitForResults` helper that polls until all of them finish. * * Each test entry must specify a `url`. `region` defaults to * "us-east"; `device` defaults to the project's "Mobile" device (or * the first configured device if there's no "Mobile") when omitted. * * @param projectId The project to run the quick tests under * @param tests Array of test specs */ run(projectId: string | number, tests: { url: string; region?: string; device?: string; }[]): Promise<{ quickTests: QuickTestSummary[]; waitForResults: (options?: { onProgress?: (status: { finished: number; total: number; newlyFinished: QuickTestSummary[]; quickTests: QuickTestSummary[]; }) => void; }) => Promise<{ hasFinished: boolean; quickTests: QuickTestSummary[]; }>; }>; /** * Get the summary for a single quick test by ID. Same shape as the * objects returned by `run` / `list` / `waitForResults`. */ get(projectId: string | number, quickTestId: string | number): Promise; /** * Get the network request waterfall for a finished quick test. */ getRequests(projectId: string | number, quickTestId: string | number): Promise; /** * Get the full Lighthouse report (LHR) for a finished quick test. */ getLighthouseReport(projectId: string | number, quickTestId: string | number): Promise; /** * List quick tests for a project, most-recent first. The server * returns 100 results by default; pass `limit` to override (max 1000). */ list(projectId: string | number, options?: { limit?: number; }): Promise; } export {};