# Documentation

Setup, configuration and API reference

## Installation

Add IssueCapture to your site:

### 1. Add & Initialize

Include the script and initialize it with your API key in your HTML, right before the closing `</body>` tag:

```html
<script type="module">
  import IssueCapture from 'https://issuecapture.com/widget.js';
  IssueCapture.init({ apiKey: 'your_api_key_here' });
</script>
```

**That's it!** A floating button appears in the bottom-right corner. It shows a bug icon and expands to "Report Issue" on hover.

Note

You can find your API key in your [dashboard](https://issuecapture.com/dashboard) on your widget's **API Keys** tab. The initial load is about 31KB gzipped.

### 2. Optional: Customize Trigger

Want to use your own button instead of the automatic one? Specify a custom trigger:

```html
<button id="feedback">Report Issue</button>

<script type="module">
  import IssueCapture from 'https://issuecapture.com/widget.js';
  IssueCapture.init({
    apiKey: 'your_api_key_here',
    trigger: '#feedback'  // Use your own button
  });
</script>
```

Success!

Done. The button should now appear bottom-right.

## Configuration

Most settings are configured in your dashboard

Theme, title, components, and features are set once in the dashboard UI. Only runtime options need to be passed in code.

### Required

```js
{
  apiKey: 'string'       // Your IssueCapture API key
}
```

### Optional Runtime Options

```js
{
  // Required
  apiKey: 'string',                    // Your API key (required)

  // Trigger
  trigger: 'string' | 'auto',          // CSS selector or 'auto' for floating button

  // Auto-button (when trigger: 'auto')
  button: {
    position: 'bottom-right',          // bottom-right, bottom-left, top-right, top-left
    text: 'Report Issue',              // Button text
    icon: '🐛',                        // Button icon/emoji
    offset: { x: 20, y: 20 },          // Offset from corner (pixels)
    style: {
      backgroundColor: '#7C3AED',      // Background color
      textColor: '#FFFFFF',            // Text color
      borderRadius: '50px',            // Border radius
      size: 'medium',                  // small, medium, large
      shadow: true                     // Drop shadow
    },
    zIndex: 999999,                    // Z-index
    hidden: false                      // Start hidden (use show() to reveal)
  },

  // Internationalization (16 languages)
  locale: 'en',                        // en, es, de, fr, pt, ja, zh, it, nl, ru, pl, tr, ko, sv, da, no

  // Modal Title Override
  title: 'string',                     // Override dashboard title

  // Current User (dynamic per user)
  user: {
    name: 'string',                    // Pre-fill user name
    email: 'string'                    // Pre-fill user email
  },

  // Default Form Values
  defaultValues: {
    priority: 'string',                // Default priority
    component: 'string',               // Default component/team
    labels: ['string'],                // Pre-select labels
    customFields: {                    // Custom field defaults
      'customfield_10001': 'value'
    }
  },

  // Privacy Options
  enableMetadata: true,                // Collect page URL, user agent
  networkCaptureOptions: {
    excludeDomains: ['stripe.com'],    // Never capture these domains
    excludePatterns: ['/auth/', '/password'] // Exclude sensitive paths
  },

  // Callbacks (for open/close use IssueCapture.on('open' | 'close'))
  onSubmit: function(data) {},         // After the report is accepted
  onError: function(error) {}          // When a submission fails
}
```

### Dashboard Settings (Loaded Automatically)

These are configured once in your dashboard and loaded when the widget opens. For the settings below, the dashboard value **overrides** the same option set in JavaScript. Your snippet always wins for `apiKey`, `trigger` and `title`. `button`, `user`, `defaultValues`, `locale`, `enableMetadata` and `networkCaptureOptions` come only from your snippet.

- Form fields (components, labels, etc.)
- Required fields validation
- Screenshot requirements
- Error capture (console/network)
- File attachments permissions
- Themes & custom CSS
- AI features settings
- Jira project options

**Note:** Dashboard settings are fetched when the widget first opens (not at page load). Settings like `requireScreenshot` and `captureConsoleLogs` from dashboard will override any values set in JavaScript.

### Optional: Errors Before the Widget Loads

From the moment `IssueCapture.init()` runs, the widget keeps recent console errors and warnings and failed network requests in browser memory. They are sent only with a submitted report. Console and network capture are on by default; you can switch either off per widget in the dashboard.

To also keep errors thrown before `init()` runs, while your page is still loading, put this snippet at the top of `<head>`. The widget picks them up when it starts.

```html
<script>
  window.__icErrors = [];
  ['error', 'unhandledrejection', 'securitypolicyviolation'].forEach(function (type) {
    addEventListener(type, function (e) { var q = window.__icErrors; q && q.length < 50 && q.push(e); }, true);
  });
</script>
```

## Runtime Customization

### Pre-fill User Data

Pre-fill the form with the current user's information:

```js
IssueCapture.init({
  apiKey: 'your_api_key',
  user: {
    name: 'John Doe',
    email: 'john@example.com'
  }
});
```

Tip: If you have user authentication, dynamically pass the logged-in user's details.

### Custom Trigger

Use any CSS selector to trigger the widget with your own button:

```html
<!-- Using ID -->
<button id="feedback-btn">Report Issue</button>

IssueCapture.init({
  apiKey: 'your_api_key',
  trigger: '#feedback-btn'  // ID selector
});

<!-- OR using Class -->
<button class="feedback-button">Report Issue</button>

IssueCapture.init({
  apiKey: 'your_api_key',
  trigger: '.feedback-button'  // Class selector
});
```

**CSS Selectors:** Use `#id` for IDs,`.class` for classes, or any valid selector like`button[data-feedback]`

### Set Field Defaults

Programmatically set default values for priority, component, labels, and custom fields:

```js
IssueCapture.init({
  apiKey: 'your_api_key',
  trigger: '#bug-button',
  defaultValues: {
    priority: 'High',              // Set default priority
    component: 'Frontend',         // Set default component
    labels: ['bug', 'ui'],         // Pre-select labels
    customFields: {                // Set custom field values
      'customfield_10001': 'value'
    }
  }
});
```

For example: set priority from the user role, or component based on current page section.

## Custom Fields

Add custom Jira fields to your issue submission form. IssueCapture automatically fetches field options from Jira.

### How It Works

1. **Dashboard Setup** - Go to your widget's Form Configuration page
2. **Click "Add Custom Field"** - Fetches available fields from your Jira project
3. **Select Field** - Choose from dropdown fields, text fields, multi-selects, etc.
4. **Configure** - Set placeholder text, help text, and required status
5. **Save** - Field appears in the widget form with all options from Jira

### Supported Field Types

Text Fields

- Single-line text
- Multi-line textarea
- Number input

Selection Fields

- Single select dropdown
- Multi-select checkboxes
- Radio buttons

Special Fields

- Date picker
- Checkbox (boolean)
- User picker (text input)
- Rating (stars, emoji, numeric or thumbs)

Automatic Features

- Options fetched from Jira
- Required field validation
- Default values support

### Setting Default Values Programmatically

Pre-fill custom field values when initializing the widget:

```js
IssueCapture.init({
  apiKey: 'your_api_key',
  defaultValues: {
    customFields: {
      'customfield_10001': '10023',          // Single select: Jira option ID
      'customfield_10002': 'v2.1.0',         // Text field (Version)
      'customfield_10003': ['10031', '10032'] // Multi-select: Jira option IDs
    }
  }
});
```

**Note:** Field IDs (like `customfield_10001`) must match exactly what Jira uses. The dashboard shows each field's ID when you add it. For select, multi-select and radio fields, pass the Jira option ID (for example `'10023'`); the widget's Form Fields page lists each option's ID. A label is accepted when it matches exactly one option, but only an ID preselects the option in the form, and an ID keeps working if the option is renamed.

Pro Tip

Dropdown fields show their Jira options, so users don't need to know the exact values.

## API Reference

### IssueCapture.init(config)

Initialize the IssueCapture widget with your configuration.

Parameters

- `config` (Object) - Configuration options

Returns

void

```js
IssueCapture.init({
  apiKey: 'your_api_key'
});
```

### IssueCapture.open()

Programmatically open the widget modal.

Returns

Promise\<void>

```js
// Open widget on button click
document.getElementById('custom-button').addEventListener('click', () => {
  IssueCapture.open();
});
```

### IssueCapture.close()

Programmatically close the widget modal.

Returns

void

```js
IssueCapture.close();
```

## Events

Listen to widget events with callbacks and `IssueCapture.on()`:

### onSubmit

Called when IssueCapture accepts the report. The Jira issue is created shortly afterwards, so `data` does not include an issue key. `IssueCapture.on('submit', fn)` receives the same object.

```js
IssueCapture.init({
  apiKey: 'your_api_key',
  onSubmit: function(data) {
    console.log('Report accepted:', data);
    // data: { success: true, queued: true, message,
    //         details: { status: 'queued', queueId, partial, warnings } }
  }
});
```

### open / close

Track when users open or close the widget with `IssueCapture.on()`. There are no `onOpen` or `onClose` config options.

```js
IssueCapture.on('open', function() {
  console.log('Widget opened');
});
IssueCapture.on('close', function() {
  console.log('Widget closed');
});
```

### Errors

There are two error channels, and they report different failures. `onError` is called when a submission fails. `IssueCapture.on('error', fn)` fires when the widget cannot load its configuration (for example an invalid API key, a domain that is not allowed, or a paused widget) or hits an internal error. Use both if you want to hear about every failure.

```js
IssueCapture.init({
  apiKey: 'your_api_key',
  onError: function(error) {
    console.log('Submission failed:', error.message);
  }
});
IssueCapture.on('error', function(error) {
  console.log('Widget could not load:', error.message);
});
```

## Custom Styling

Customize your widget's appearance with CSS. IssueCapture uses Shadow DOM isolation, so your custom CSS won't affect your website.

### Dashboard Theme Editor

The easiest way to customize your widget is through the dashboard:

1. Go to **Widgets → Your Widget → Theme**
2. Choose a preset theme (Material, Glass, Dark, Candy or Contrast)
3. Customize colors, border radius, and font family
4. Add custom CSS for advanced styling
5. Preview changes in real-time

### Available CSS Selectors

Use these CSS selectors to target specific parts of the widget:

```css
/* Main Widget Container */
.issuecapture-modal { }              /* Main modal wrapper */
.issuecapture-backdrop { }           /* Background overlay */

/* Modal Structure */
.issuecapture-header { }             /* Modal header */
.issuecapture-header h2 { }          /* Modal title text */
.issuecapture-close { }              /* Close button */
.issuecapture-content { }            /* Modal body/content */

/* Form Elements */
.issuecapture-form-group { }         /* Form field wrapper */
.issuecapture-label { }              /* Field labels */
.issuecapture-input { }              /* Text inputs */
.issuecapture-textarea { }           /* Text areas */
.issuecapture-select { }             /* Select dropdowns */

/* Buttons */
.issuecapture-btn { }                /* All buttons */
.issuecapture-btn-primary { }        /* Primary action buttons */
.issuecapture-btn-secondary { }      /* Secondary buttons */
.issuecapture-btn-ghost { }          /* Ghost/outline buttons */

/* States */
.issuecapture-success { }            /* Success screen */
.issuecapture-loading-overlay { }    /* Loading overlay */
.issuecapture-spinner { }            /* Loading spinner */

/* Screenshot Capture */
.issuecapture-screenshot-capture { } /* Screenshot step container */
.issuecapture-screenshot-title { }   /* Screenshot step title */
```

Important Notes:

- Use `!important` to override default styles
- CSS is sanitized for security — patterns like scripts are blocked
- Shadow DOM isolation means your CSS won't affect your website

## Content Security Policy

If your site sends a Content-Security-Policy header, add these sources to the matching directives, alongside your own:

```
script-src  https://issuecapture.com;
connect-src https://issuecapture.com https://lbbnlactxysrtpzqobew.supabase.co;
style-src   'unsafe-inline';
img-src     data:;
```

- `script-src` loads `widget.js` and its lazy chunks (screenshot capture and the annotation editor), all served from issuecapture.com.
- `connect-src`: issuecapture.com receives reports and attachment upload requests and serves translations. The Supabase host serves the widget's configuration and stores attachments. If issuecapture.com is blocked, reports cannot be sent; translations still arrive through the Supabase host.
- `style-src` allows the styles the widget injects into its Shadow DOM.
- `img-src` allows the screenshot preview, which is a `data:` URL.

**Inline snippets and a strict script-src.** The install snippets on this page are inline `<script type="module">` blocks. A policy without `'unsafe-inline'` blocks them, even with issuecapture.com allowed. Either add a nonce or hash for that script tag to your `script-src`, or move the import and `init()` call into a file on your own site and load it from there (allowed by `'self'`):

```html
<!-- your page -->
<script type="module" src="/issuecapture-init.js"></script>

// /issuecapture-init.js on your own origin
import IssueCapture from 'https://issuecapture.com/widget.js';
IssueCapture.init({ apiKey: 'your_api_key_here' });
```

**Only set default-src?** Sites whose policy sets only `default-src` must add these as explicit `script-src`, `connect-src`, `style-src` and `img-src` directives.

Need help?

Stuck? Email us and we'll help.

[Contact Support](mailto:support@issuecapture.com)

---

[View this page on issuecapture.com](https://issuecapture.com/docs)
