Any website (JavaScript) In development
The nabd-browser core: a ready script or an npm package.
Not available yet. These examples show the planned API; package and function names may change before the first release.
With a script tag
<script src="https://nabd.mokinan.com/sdk/v1/nabd.min.js"></script>
<script src="/js/nabd-init.js"></script>Nabd.init({
orgToken: 'nb_pub_…',
appName: 'My Site',
environment: 'production',
consentRequired: true,
});
// wire it to the accept button of your notice
document.querySelector('#accept-analytics')
.addEventListener('click', () => Nabd.setConsent(true));With npm
npm install nabd-browserimport { Nabd } from 'nabd-browser';
Nabd.init({ orgToken: 'nb_pub_…', appName: 'My Site', consentRequired: true });Setup options
| Option | Default | Note |
|---|---|---|
orgToken | Required | The public key nb_pub_… only. A secret key stops the SDK. |
appName | Required | The app name in the dashboard. |
environment | production | staging or development. |
consentRequired | true | Nothing is recorded or sent before setConsent(true). |
appVersion | unknown | So you can compare the score between releases. |
autoScreens | true | Turn it off if you name screens yourself. |
ignoreRequests | SignalR and socket.io | Patterns for long-running requests that are not measured. Your list replaces the default. |
endpoint | https://api.nabd.mokinan.com | For testing against a local server. |
Screen names
By default the page path with identifiers turned into :id, including #/ links and History API changes. The query after ? is not sent.
Only numbers, UUIDs and long identifiers are replaced. If your paths contain names (/customers/ahmed-ali), turn off autoScreens or name the screen explicitly.
A fixed name for a server-rendered page:
<body data-nabd-screen="invoice_create">Or from code in a single-page app, with autoScreens: false so navigation does not change the name:
Nabd.trackScreen('invoice_create');Events
Nabd.trackEvent('taskCompleted', { screen: 'invoice_create' });
Nabd.trackEvent('errorShown', { screen: 'invoice_create' });
Nabd.startLoading('invoice_create');
Nabd.stopLoading('invoice_create');
Nabd.setUserRef(userRefFromServer);
// an error you caught in try/catch: type and fingerprint only
Nabd.captureError(error);window errors and unhandledrejection are captured automatically, as are fetch and XMLHttpRequest requests: network failures, 5xx errors, and requests longer than 3 seconds (status and duration only). 4xx errors are not counted.
Taps
- Rage tap: three or more on the same spot within a second. Text fields are excluded.
- Disabled element:
disabledoraria-disabled="true". - Dead tap: a button, link or pointer-cursor element where, within a second, there is no page change, network request, navigation, scroll or error.
Detection limits: a button whose work is invisible (copy to clipboard, canvas drawing) may count as dead, so exclude it. A page with a constantly changing element (clock or counter) will miss cases. Keyboard activation is not observed.
With every error, the last 10 steps (screen and element type), kept in sessionStorage so it continues across pages of the same tab. Turn it off with errorTrail: false.
Excluding elements
<div data-nabd-ignore><!-- number pad, +/- buttons or copy button --></div>Privacy and sessions
Nabd.setConsent(false); // stops collection and clears storage
Nabd.requestDataDeletion(); // asks to delete this browser’s data
Nabd.diagnostics(); // { active, queued, lastStatus } to check the integrationA session is per tab and ends after 30 minutes of inactivity. No cookies; storage is localStorage and sessionStorage after consent, plus the consent decision itself.
Notes by technology
| Technology | Integration |
|---|---|
| ASP.NET MVC / Razor | The script in _Layout.cshtml. |
| Blazor | The script in the host page. Calls from C# go through IJSRuntime. .NET errors themselves are not captured. |
| jQuery / HTML | The script as it is. |
| WordPress | The script in the theme footer, after wiring it to your consent plugin. |
| Ionic / Capacitor | The npm package. |
| WebView inside a native app | Do not enable it; use the app SDK. |
Support chat
With messages: true, your team can message a specific user from a ticket in the dashboard, and the user replies from your website. The button appears only when there is a message for them, after consent. You need setUserRef to open a ticket for them.
Nabd.init({ orgToken: 'nb_pub_…', appName: 'My Site', messages: true });
// or with your own UI
Nabd.init({ orgToken: 'nb_pub_…', appName: 'My Site',
messages: true, messagesWidget: false });
const stop = Nabd.onMessages((conversations) => render(conversations));
await Nabd.replyToMessage(conversationId, text);
await Nabd.markMessagesRead(conversationId);- The browser checks for messages every two minutes, every 15 seconds while the conversation is open, and when the page comes back into view.
- The interface is Arabic if the page language (
<html lang>) is Arabic, or, when the page does not set one, if the browser language is Arabic; otherwise it is English. - The conversation is tied to this browser by a random secret stored in it; another browser of the same user does not see it.
- Message text is stored in Nabd for the retention period, so tell your users in your privacy policy.
- Compute
user_refwith HMAC on your server, so a user cannot pretend to be someone else.
Restrict the key to your site
The public key is visible in the page source. In the app’s menu in the dashboard choose “Allowed web domains” and list your domains, so any other site using the same app name is rejected. To block new app names, turn off “Create apps automatically” or use an app-specific key.
Content Security Policy
Content-Security-Policy:
script-src 'self' https://nabd.mokinan.com;
connect-src 'self' https://api.nabd.mokinan.com;