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

Before </body>
<script src="https://nabd.mokinan.com/sdk/v1/nabd.min.js"></script>
<script src="/js/nabd-init.js"></script>
/js/nabd-init.js
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

bash
npm install nabd-browser
typescript
import { Nabd } from 'nabd-browser';

Nabd.init({ orgToken: 'nb_pub_…', appName: 'My Site', consentRequired: true });

Setup options

OptionDefaultNote
orgTokenRequiredThe public key nb_pub_… only. A secret key stops the SDK.
appNameRequiredThe app name in the dashboard.
environmentproductionstaging or development.
consentRequiredtrueNothing is recorded or sent before setConsent(true).
appVersionunknownSo you can compare the score between releases.
autoScreenstrueTurn it off if you name screens yourself.
ignoreRequestsSignalR and socket.ioPatterns for long-running requests that are not measured. Your list replaces the default.
endpointhttps://api.nabd.mokinan.comFor 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:

html
<body data-nabd-screen="invoice_create">

Or from code in a single-page app, with autoScreens: false so navigation does not change the name:

javascript
Nabd.trackScreen('invoice_create');

Events

javascript
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

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

html
<div data-nabd-ignore><!-- number pad, +/- buttons or copy button --></div>

Privacy and sessions

javascript
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 integration

A 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

TechnologyIntegration
ASP.NET MVC / RazorThe script in _Layout.cshtml.
BlazorThe script in the host page. Calls from C# go through IJSRuntime. .NET errors themselves are not captured.
jQuery / HTMLThe script as it is.
WordPressThe script in the theme footer, after wiring it to your consent plugin.
Ionic / CapacitorThe npm package.
WebView inside a native appDo 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.

javascript
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);

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

http header
Content-Security-Policy:
  script-src 'self' https://nabd.mokinan.com;
  connect-src 'self' https://api.nabd.mokinan.com;