> For the complete documentation index, see [llms.txt](https://bugpilot.gitbook.io/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bugpilot.gitbook.io/api-docs/sdk-js/getting-started/saving-bug-reports.md).

# Saving Bug Reports

## `saveReport`

{% hint style="warning" %}
**Deprecation notice:** this method will be removed in the coming weeks.
{% endhint %}

You can use the saveReport method to generate a bug report and save it programmatically. The bug report will include the usual information, such as screen recording, console, and user info.

You could call this method when the user clicks a button or a link to submit a bug report or build your own custom integratinos to generate reports automatically when a specific error has happened during critical flows.

#### Example

{% code lineNumbers="true" %}

```javascript
window.Bugpilot.saveReport({
  source: "string", // Optional
  userProvidedDescription: "string", // Optional
});
```

{% endcode %}

The method takes an optional parameter with the following properties:

<table><thead><tr><th width="246">Key</th><th width="311.3333333333333">Description</th><th>Required</th></tr></thead><tbody><tr><td>source</td><td><p>A string that describe how or why this report has been generated. For example, "widget", "feedback-widget", or "home-page-widget".</p><p></p><p>This string will be shown on the Bug report page.</p></td><td>Optional</td></tr><tr><td>userProvidedDescription</td><td>A description of the problem, for example, a description provided by the user after a bug has happened. This string will be the description of the bug and will be shown on the report page and sent to the configured integrations.</td><td>Optional</td></tr></tbody></table>

{% hint style="warning" %}
Reports can take a few seconds to be saved and uploaded to Bugpilot. Calling saveReport during `unload` or `onbeforeunload` will not work.
{% endhint %}
