import { AnyValueMap } from '@opentelemetry/api-logs';
import { DestroyRef } from '@angular/core';
import { EnvironmentProviders } from '@angular/core';
import { ErrorHandler } from '@angular/core';
import { FirebaseApp } from '@firebase/app';
import { Router } from '@angular/router';
/**
* An instance of the Firebase Crashlytics SDK.
*
* Do not create this instance directly. Instead, use {@link getCrashlytics | getCrashlytics()}.
*
* @beta
*/
export declare interface Crashlytics {
/**
* The {@link @firebase/app#FirebaseApp} this {@link Crashlytics} instance is associated with.
*/
app: FirebaseApp;
}
/**
* (EXPERIMENTAL) An opaque feature plugin object returned by Crashlytics feature factory functions
* such as {@link breadcrumbs}.
*
* @public
*/
export declare interface CrashlyticsFeature {
}
/**
* Options for initializing the Crashlytics service using {@link getCrashlytics | getCrashlytics()}.
*
* @beta
*/
export declare interface CrashlyticsOptions {
/**
* The URL for the endpoint to which Crashlytics data should be sent, in the OpenTelemetry format.
* By default, data will be sent to Firebase.
*/
endpointUrl?: string;
/**
* The Google Cloud region where the Crashlytics data should be sent.
*
* By default, data will be sent to the "global" region.
*
* Refer to https://cloud.google.com/logging/docs/regions for the list of available regions.
*/
region?: string;
/**
* The version of the application. This should be a unique string that identifies the snapshot of
* code to be deployed, such as "1.0.2". If not specified, other default locations will be checked
* for an identifier. Setting a value here takes precedence over any other values.
*/
appVersion?: string;
/**
* Base set of custom attributes to send with automatic error collection.
* Key-value pairs defined here will be sent with all error logs.
* If custom attributes are also specified in `recordError()` or `log()`, those values will
* take precedence over the base set defined here.
*/
customAttributes?: AnyValueMap;
/**
* Whether to register the underlying OpenTelemetry LoggerProvider globally with the OpenTelemetry API
* (`logs.setGlobalLoggerProvider()`).
*
* When enabled, other OpenTelemetry instrumentations (such as Core Web Vitals, Console, or Fetch)
* and custom application loggers can automatically route logs through Firebase Crashlytics.
*
* Defaults to `false`.
*/
registerGlobalLoggerProvider?: boolean;
/**
* Automatically capture uncaught browser exceptions ('error' and
* 'unhandledrejection' window events).
*
* Defaults to `true`.
*/
captureUnhandledErrors?: boolean;
/**
* (EXPERIMENTAL) Optional list of Crashlytics features (such as {@link breadcrumbs}) to enable.
*
* When {@link breadcrumbs} is included, Crashlytics collects OpenTelemetry spans (such as Fetch,
* XMLHttpRequest, and Document Load) and breadcrumb logs (such as navigation events, Web Vitals,
* user actions, and visibility lifecycle events), buffering them in memory and exporting them
* when an error occurs.
*
* @example
* ```ts
* import { getCrashlytics, breadcrumbs } from 'firebase/crashlytics';
*
* const crashlytics = getCrashlytics(app, {
* features: [breadcrumbs()]
* });
* ```
*
* @public
*/
features?: CrashlyticsFeature[];
}
/**
* A custom ErrorHandler that captures uncaught errors and sends them to Firebase Crashlytics.
*
* @internal
*/
export declare class FirebaseErrorHandler implements ErrorHandler {
private readonly injector;
private _router?;
private readonly crashlytics;
constructor(app: FirebaseApp, crashlyticsOptions?: CrashlyticsOptions);
handleError(error: unknown): void;
}
/**
* Extracts the raw path portion from a full URL by stripping query parameters, hashes, and matrix parameters.
*
* @internal
*/
export declare function getRawPath(url: string): string;
/**
* Constructs the safe, templated route path from the router state.
* Example output: '/users/:id/posts'
*
* @internal
*/
export declare function getSafeRoutePath(router: Router): string;
/**
* Registers Firebase Crashlytics error handling and route tracking providers for an Angular application.
*
* @example
* Basic usage:
* ```typescript
* import { ApplicationConfig } from '@angular/core';
* import { provideRouter } from '@angular/router';
* import { provideCrashlytics } from 'firebase/crashlytics/angular';
* import { app } from '../lib/firebase';
* import { routes } from './app.routes';
*
* export const appConfig: ApplicationConfig = {
* providers: [
* provideRouter(routes),
* provideCrashlytics(() => app)
* ]
* };
* ```
*
* @example
* Providing telemetry options:
* ```typescript
* import { ApplicationConfig } from '@angular/core';
* import { provideRouter } from '@angular/router';
* import { provideCrashlytics } from 'firebase/crashlytics/angular';
* import { app } from '../lib/firebase';
* import { routes } from './app.routes';
*
* export const appConfig: ApplicationConfig = {
* providers: [
* provideRouter(routes),
* provideCrashlytics(() => app, { appVersion: '1.2.3' })
* ]
* };
* ```
*
* @param getAppFn - A factory function that returns the {@link @firebase/app#FirebaseApp} instance to use.
* @param options - Optional. {@link CrashlyticsOptions} that configure the Crashlytics instance.
* @returns An {@link @angular/core#EnvironmentProviders} instance to include in `ApplicationConfig.providers`.
*
* @beta
*/
export declare function provideCrashlytics(getAppFn: () => FirebaseApp, options?: CrashlyticsOptions): EnvironmentProviders;
/**
* Configures automatic Angular router navigation tracking for Firebase Crashlytics.
*
* This function subscribes to router navigation events, keeps the Crashlytics route path attribute
* updated, and logs view boundary telemetry automatically.
*
* @example
* ```typescript
* import { ApplicationConfig, ErrorHandler, inject, DestroyRef } from '@angular/core';
* import { Router } from '@angular/router';
* import { FirebaseErrorHandler, setupCrashlyticsRoutes } from 'firebase/crashlytics/angular';
*
* export const appConfig: ApplicationConfig = {
* providers: [
* {
* provide: ErrorHandler,
* useFactory: () => new FirebaseErrorHandler(firebaseApp)
* },
* provideEnvironmentInitializer(() => {
* inject(ErrorHandler);
* setupCrashlyticsRoutes({
* firebaseApp,
* router: inject(Router),
* destroyRef: inject(DestroyRef)
* });
* })
* ]
* };
* ```
*
* @param firebaseApp - The {@link @firebase/app#FirebaseApp} instance to use.
* @param router - The Angular {@link @angular/router#Router} instance to subscribe to.
* @param destroyRef - The {@link @angular/core#DestroyRef} instance to bind teardown logic to.
* @param crashlyticsOptions - Optional. {@link CrashlyticsOptions} that configure the Crashlytics instance.
*
* @internal
*/
export declare function setupCrashlyticsRoutes({ firebaseApp, router, destroyRef, crashlyticsOptions }: {
firebaseApp: FirebaseApp;
router: Router;
destroyRef: DestroyRef;
crashlyticsOptions?: CrashlyticsOptions;
}): void;
export { }