npm package: @medianova/sdk
Description: The Bot Management SDK provides bot detection and analytics functionality for web applications running in browsers. This SDK helps protect your application from malicious bots, collect analytics data, and enhance overall security.
Latest version: 1.1.57

# Bot Management SDK
The Bot Management SDK provides bot detection and analytics functionality for web applications running in browsers. This SDK helps protect your application from malicious bots, collect analytics data, and enhance overall security.

## Table of Contents
- [Installation](#installation)
  - [Using NPM (TypeScript/JavaScript)](#using-npm-typescriptjavascript)
  - [Using CDN (HTML)](#using-cdn-html)
- [Usage](#usage)
  - [TypeScript/JavaScript](#typescriptjavascript)
  - [HTML](#html)
- [Configuration Options](#configuration-options)
- [Development](#development)
  - [Requirements](#requirements)
  - [Setup](#setup)
  - [Running the SDK Locally](#running-the-sdk-locally)
- [Support](#support)
- [License](#license)

# Installation
## Using NPM (TypeScript/JavaScript)
To install the SDK in your project using npm, run the following command:

```sh
npm install @medianova/sdk
```
## Using CDN (HTML)
Add the following script tag to the `<head>` section of your HTML file:

```html
<script src="https://botmanagement.mncdn.com/botmanagement-latest.js" type="module" defer></script>
```

# Usage

## TypeScript/JavaScript
To initialize and run the SDK in a TypeScript or JavaScript environment, follow these steps:

```ts
import { init } from '@medianova/sdk';

async function runSDK() {
const clientKey = "your-client-key-here";
const monitoringMode = false; // If you set the variable as true, the SDK will only collect the visit data but not apply the bot prevention.
try {
await init(clientKey, { monitoringMode });
console.log('Medianova Client SDK initialized successfully.');
} catch (error) {
console.error('SDK initialization or operation failed:', error);
}
}

runSDK();
```

### Notes:

- Replace `"your-client-key-here"` with the client key provided to you by Medianova.
- Setting `monitoringMode` to `true` the SDK will only collect the visit data but not apply the bot prevention.

## HTML
To use the SDK directly in an HTML file, add the following script tags to your `<head>` and `<body>` sections:

### In the `<head>` section:

```html
<script src="https://botmanagement.mncdn.com/botmanagement-latest.js" type="module" defer></script>
```

### In the `<body>` section:

```html

<script type="module">
  import { init } from 'https://botmanagement.mncdn.com/botmanagement-latest.js';

  async function runSDK() {
    const clientKey = "your-client-key-here";
    const monitoringMode = false; // Set to true if you want to use monitoring only
    try {
      await init(clientKey, { monitoringMode });
      console.log('Medianova Client SDK initialized successfully.');
    } catch (error) {
      console.error('SDK initialization or operation failed:', error);
    }
  }

  runSDK();
</script>
```

### Notes:

- Replace `"your-client-key-here"` with the client key provided to you by Medianova.
- Setting `monitoringMode` to `true the SDK will only collect the visit data but not apply the bot prevention.

## Configuration Options
The `init` function accepts the following parameters:

- `clientKey` (string): **Required**. Your unique client key provided by Medianova.
- `options` (object): **Optional**. Configuration options for the SDK.
  - `monitoringMode` (boolean): When set to `true, the SDK runs in monitoring mode only, without applying bot mitigation.

### Example:

```ts
await init('your-client-key-here', { monitoringMode: true });
```

## Development
If you want to contribute to the SDK or run it locally, follow these steps:

## Requirements
- Deno: Ensure that Deno is installed on your machine. Visit [deno docs](https://docs.deno.com/) for installation instructions.

## Setup
To set up the development environment, run:

```sh
deno install
```

## Running the SDK Locally
Start a local server using the following command:

```sh
deno task serve
```

### Test

```sh
# this will be needed to initialize a page with the SDK running within.
deno task test

# then, to check if the splash image appears, run the command below:
deno task test:bot

# to simulate the visit as a normal visit, run the command below:
deno task test:human
```

## Support
If you encounter any issues or have questions, please reach out to our support team at [support@medianova.com](mailto:support@medianova.com).

## License

This repository is licensed under the [MIT License](LICENSE). Please see the LICENSE file for more information.