> Documentation index: https://firebase.google.com/docs/reference/js/llms.txt

The Firebase Crashlytics Web SDK. This product is currently in public preview.

## Functions

| Function | Description |
|---|---|
| **function(app, ...)** |   |
| [getCrashlytics(app, options)](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#getcrashlytics_a9d22a1) | ***(Public Preview)*** Returns the default [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) instance that is associated with the provided [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface). If no instance exists, initializes a new instance with the default settings. |
| **function()** |   |
| [breadcrumbs()](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#breadcrumbs) | **(EXPERIMENTAL)** Enables Crashlytics breadcrumb and trace telemetry collection when passed in [CrashlyticsOptions.features](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsoptions.md.txt#crashlyticsoptionsfeatures).When enabled, 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. |
| **function(crashlytics, ...)** |   |
| [flush(crashlytics)](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#flush_16fdf66) | ***(Public Preview)*** Flushes all enqueued Crashlytics data immediately, instead of waiting for default batching. |
| [log(crashlytics, message, attributes)](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#log_5ba066c) | **(EXPERIMENTAL)** Queues a log message to be uploaded to the Firebase Crashlytics API. |
| [recordError(crashlytics, error, attributes)](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#recorderror_71ca165) | ***(Public Preview)*** Queues an error to be uploaded to the Firebase Crashlytics API. |

## Interfaces

| Interface | Description |
|---|---|
| [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) | ***(Public Preview)*** An instance of the Firebase Crashlytics SDK.Do not create this instance directly. Instead, use [getCrashlytics()](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#getcrashlytics_a9d22a1). |
| [CrashlyticsFeature](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsfeature.md.txt#crashlyticsfeature_interface) | **(EXPERIMENTAL)** An opaque feature plugin object returned by Crashlytics feature factory functions such as [breadcrumbs()](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#breadcrumbs). |
| [CrashlyticsOptions](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsoptions.md.txt#crashlyticsoptions_interface) | ***(Public Preview)*** Options for initializing the Crashlytics service using [getCrashlytics()](https://firebase.google.com/docs/reference/js/crashlytics.md.txt#getcrashlytics_a9d22a1). |

## function(app, ...)

### getCrashlytics(app, options)

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Returns the default [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) instance that is associated with the provided [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface). If no instance exists, initializes a new instance with the default settings.

**Signature:**

```typescript
export declare function getCrashlytics(app?: FirebaseApp, options?: CrashlyticsOptions): Crashlytics;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| app | [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface) | The [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface) to use. |
| options | [CrashlyticsOptions](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsoptions.md.txt#crashlyticsoptions_interface) | [CrashlyticsOptions](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsoptions.md.txt#crashlyticsoptions_interface) that configure the Crashlytics instance. |

**Returns:**

[Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface)

The default [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) instance for the given [FirebaseApp](https://firebase.google.com/docs/reference/js/app.firebaseapp.md.txt#firebaseapp_interface).

### Example

```javascript
const crashlytics = getCrashlytics(app);

```

## function()

### breadcrumbs()

**(EXPERIMENTAL)** Enables Crashlytics breadcrumb and trace telemetry collection when passed in [CrashlyticsOptions.features](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsoptions.md.txt#crashlyticsoptionsfeatures).

When enabled, 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.

**Signature:**

```typescript
export declare function breadcrumbs(): CrashlyticsFeature;
```

**Returns:**

[CrashlyticsFeature](https://firebase.google.com/docs/reference/js/crashlytics.crashlyticsfeature.md.txt#crashlyticsfeature_interface)

### Example

```typescript
import { getCrashlytics, breadcrumbs } from 'firebase/crashlytics';

const crashlytics = getCrashlytics(app, {
  features: [breadcrumbs()]
});

```

## function(crashlytics, ...)

### flush(crashlytics)

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Flushes all enqueued Crashlytics data immediately, instead of waiting for default batching.

**Signature:**

```typescript
export declare function flush(crashlytics: Crashlytics): Promise<void>;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| crashlytics | [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) | The [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) instance. |

**Returns:**

Promise\<void\>

a promise which is resolved when all flushes are complete

### log(crashlytics, message, attributes)

**(EXPERIMENTAL)** Queues a log message to be uploaded to the Firebase Crashlytics API.

**Signature:**

```typescript
export declare function log(crashlytics: Crashlytics, message: string, attributes?: Attributes): void;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| crashlytics | [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) | The [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) instance. |
| message | string | The message to log. |
| attributes | Attributes | Optional, arbitrary attributes to attach to the log. |

**Returns:**

void

### recordError(crashlytics, error, attributes)

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.

Queues an error to be uploaded to the Firebase Crashlytics API.

**Signature:**

```typescript
export declare function recordError(crashlytics: Crashlytics, error: unknown, attributes?: Attributes): void;
```

#### Parameters

| Parameter | Type | Description |
|---|---|---|
| crashlytics | [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) | The [Crashlytics](https://firebase.google.com/docs/reference/js/crashlytics.crashlytics.md.txt#crashlytics_interface) instance. |
| error | unknown | The caught exception, typically an Error object |
| attributes | Attributes | Optional, arbitrary attributes to attach to the error log |

**Returns:**

void