# Web SDK Reference

## .initialize

Request the notification permission and register a subscribed device.

{% tabs %}
{% tab title="JavaScript" %}
<pre class="language-javascript"><code class="lang-javascript"><strong>/*
</strong>Params
- options: InitializeOptions
  - projectId
  - serviceWorkerPath
<strong>*/
</strong><strong>
</strong><strong>FlareLane.initialize({ projectId: "&#x3C;PROJECT_ID>" });
</strong></code></pre>
{% endtab %}
{% endtabs %}

## .setLogLevel

{% tabs %}
{% tab title="JavaScript" %}
```javascript
/*
Params
- logLevel: 'none' | 'error' | 'verbose'(default)
*/

FlareLane.setLogLevel('verbose');
```
{% endtab %}
{% endtabs %}

***

## Subscription

### .getIsSubscribed

{% tabs %}
{% tab title="JavaScript" %}
<pre class="language-javascript"><code class="lang-javascript"><strong>/*
</strong>Params
- callback: (Boolean) => {}
<strong>*/
</strong><strong>
</strong><strong>FlareLane.getIsSubscribed((isSubscribed) => {
</strong>    // Do something...
    console.log(isSubscribed);
});
</code></pre>
{% endtab %}
{% endtabs %}

### .setIsSubscribed

Use if you want to manage subscriptions directly within your app.

{% tabs %}
{% tab title="JavaScript" %}
```javascript
/*
Params
- isSubscribed: Boolean
- callback: (Boolean) => {}
*/

const callback = (isSubscribed) => {
    // Do something...
    console.log(isSubscribed);
};

// SUBSCRIBE
FlareLane.setIsSubscribed(true, callback);
// UNSUBSCRIBE
FlareLane.setIsSubscribed(false, callback);
```
{% endtab %}
{% endtabs %}

***

## Data Management

### .setUserId

When logging in, specify the user ID.

{% tabs %}
{% tab title="JavaScript" %}
```javascript
/*
Params
- userId: string | null
*/

// SET
FlareLane.setUserId("USER_ID");
// REMOVE
FlareLane.setUserId(null);
```
{% endtab %}
{% endtabs %}

### .trackEvent

{% tabs %}
{% tab title="JavaScript" %}
```javascript
/*
Params
- type: string
- data?: Record<string, string | number>
*/

FlareLane.trackEvent('test_event');
// OR
FlareLane.trackEvent('test_event', { "dataKey": "dataValue" });
```
{% endtab %}
{% endtabs %}

### .setTags

{% tabs %}
{% tab title="JavaScript" %}
```javascript
/*
Params
- tags: Record<string, string | number>
*/

// SET
FlareLane.setTags({ gender: "men", age: 24 });
```
{% endtab %}
{% endtabs %}

### .getDeviceId

{% tabs %}
{% tab title="JavaScript" %}
<pre class="language-javascript"><code class="lang-javascript">/*
Params
- callback: (string | null) => {}
*/

FlareLane.getDeviceId((deviceId)) => {
  // Do something...
  console.log(deviceId);
<strong>});
</strong></code></pre>
{% endtab %}
{% endtabs %}

***

## Notifications Handler

### .setConvertedHandler

Register a callback handler to be executed when the app enters after clicking on the notification.

{% tabs %}
{% tab title="JavaScript" %}
```javascript
/*
Params
- callback: (Notification) => {}
*/

FlareLane.setConvertedHandler((notification) => {
    // Do something...
    console.log(notification);
 });
```
{% endtab %}
{% endtabs %}

***

## In-App Message

### .displayInApp

Displays the highest priority in-app message that can be shown in the group.

{% tabs %}
{% tab title="JavaScript" %}
```javascript
FlareLane.displayInApp("home");
```
{% endtab %}
{% endtabs %}

### .setInAppMessageActionHandler

Implement a handler for custom actions in the in-app message.

{% tabs %}
{% tab title="JavaScript" %}
```javascript
FlareLane.setInAppMessageActionHandler((iam, actionId) => {
  // Do Something...
});
```
{% endtab %}
{% endtabs %}

