# Releasebird JavaScript SDK

Official JavaScript SDK for [Releasebird](https://releasebird.com) - Collect user feedback, bug reports, and feature requests directly from your web application.

## Installation

```bash
npm install releasebird-javascript-sdk
```

or

```bash
yarn add releasebird-javascript-sdk
```

## Quick Start

### Basic Setup

```javascript
import Rbird from 'releasebird-javascript-sdk';

// Initialize with your API key
Rbird.initialize('YOUR_API_KEY');
```

### Initialize without the default widget button

```javascript
Rbird.initialize('YOUR_API_KEY', false);
```

## API Reference

### `Rbird.initialize(apiKey, showButton?)`

Initializes the Releasebird SDK.

**Parameters:**
- `apiKey` (string, required): Your Releasebird API key
- `showButton` (boolean, optional): Show the feedback widget button. Default: `true`

**Example:**
```javascript
Rbird.initialize('YOUR_API_KEY');
// or
Rbird.initialize('YOUR_API_KEY', true);
```

### `Rbird.identify(userId, hash?)`

Identify a user for tracking feedback and session data.

**Parameters:**
- `userId` (string, required): Unique identifier for the user
- `hash` (string, optional): Security hash for user verification

**Example:**
```javascript
Rbird.identify('user@example.com');
// or with hash
Rbird.identify('user@example.com', 'security-hash');
```

### `Rbird.showWidget()`

Programmatically open the feedback widget.

**Example:**
```javascript
Rbird.showWidget();
```

### `Rbird.showButton(visible)`

Show or hide the feedback widget button.

**Parameters:**
- `visible` (boolean, required): `true` to show, `false` to hide

**Example:**
```javascript
Rbird.showButton(true);  // Show button
Rbird.showButton(false); // Hide button
```

### `Rbird.logout()`

Clear the current user session.

**Example:**
```javascript
Rbird.logout();
```

### `Rbird.setStyles(backgroundColor?, textColor?, launcherColor?, launcherPosition?, spaceLeftRight?, spaceBottom?)`

Customize the appearance of the feedback widget.

**Parameters:**
- `backgroundColor` (string, optional): Widget background color. Default: `'blue'`
- `textColor` (string, optional): Widget text color. Default: `'red'`
- `launcherColor` (string, optional): Launcher button color. Default: `'orange'`
- `launcherPosition` (string, optional): Position of the launcher. Default: `'bottom'`
- `spaceLeftRight` (number, optional): Horizontal spacing in pixels. Default: `30`
- `spaceBottom` (number, optional): Bottom spacing in pixels. Default: `30`

**Example:**
```javascript
Rbird.setStyles('#000000', '#FFFFFF', '#FF5722', 'bottom', 20, 20);
```

## Features

- ✅ Automatic session tracking
- ✅ Screenshot capture
- ✅ Video recording
- ✅ Badge notifications
- ✅ User identification
- ✅ Customizable widget appearance
- ✅ Console log tracking
- ✅ Mobile responsive

## TypeScript Support

This package includes TypeScript definitions out of the box.

```typescript
import Rbird from 'releasebird-javascript-sdk';

Rbird.initialize('YOUR_API_KEY');
Rbird.identify('user@example.com');
```

## Requirements

- Modern browser with ES6+ support
- DOM environment (browser, not Node.js)

## License

Commercial - See LICENSE file for details

## Support

- **Issues**: [GitHub Issues](https://github.com/bxt-team/releasebird-javascript-sdk/issues)
- **Website**: [https://releasebird.com](https://releasebird.com)

## Author

buildnext GmbH

---

**Note**: This SDK is designed for browser environments only and requires access to the DOM and browser APIs.
