@medianova/sdk
v1.1.50
Published
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.
Downloads
374
Readme
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
Using NPM (TypeScript/JavaScript)
To install the SDK in your project using npm, run the following command:
npm install @medianova/sdk
Using CDN (HTML)
Add the following script tag to the <head>
section of your HTML file:
<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:
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
totrue
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:
<script src="https://botmanagement.mncdn.com/botmanagement-latest.js" type="module" defer></script>
In the <body>
section:
<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:
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 for installation instructions.
Setup
To set up the development environment, run:
deno install
Running the SDK Locally
Start a local server using the following command:
deno task serve
Test
# 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 [email protected].
License
This repository is licensed under the MIT License. Please see the LICENSE file for more information.