Browser SDK quickstart
Install the browser SDK, configure your collector, and send your first event.
@askdepth/corev0.3.0On this page
The browser SDK detects interaction problems and sends bounded telemetry batches to your Askdepth collector. Add explicit events for actions that matter in your application.
Install
$ npm install @askdepth/coreThese examples describe @askdepth/core@0.3.0. React and Next.js applications can use the provider instead.
Initialize in the browser
Copy the browser write key and full telemetry endpoint supplied for your analytics project. Replace both placeholders below. The endpoint must include /v1/telemetry; the SDK posts to the exact URL you supply.
import { Askdepth } from '@askdepth/core';
Askdepth.init({
writeKey: 'YOUR_BROWSER_WRITE_KEY',
endpoint: 'https://YOUR_COLLECTOR/v1/telemetry',
environment: 'production',
consent: 'unknown',
});Call init from your browser entry point, after browser APIs are available. On the server it returns the API object without starting collection. Repeating an identical configuration is idempotent; changing configuration replaces the singleton runtime.
Grant consent and send an event
Wire the consent methods to your application's actual consent choice. With unknown or denied, collection and explicit events remain inactive.
import { Askdepth } from '@askdepth/core';
// Run after the visitor accepts the relevant collection purposes.
Askdepth.setConsent('granted');
Askdepth.track('checkout_started', {
item_count: 2,
checkout_variant: 'compact',
});Use fixed event names and non-sensitive properties. Events sent before collection becomes active are discarded. See consent and event limits.
Check the integration
import { Askdepth } from '@askdepth/core';
console.log(Askdepth.isInitialized());
console.log(Askdepth.getSessionId());With valid configuration, granted consent, and a sampled-in runtime, isInitialized() returns true. In the browser Network panel, look for a POST to your telemetry endpoint after about two seconds. The request carries x-askdepth-write-key and protocol metadata.
A successful request means the collector accepted the batch; it does not prove that all downstream processing has finished. Delivery is best effort, especially when a page closes or a device loses connectivity.
If there is no request, check the write key, complete endpoint, consent, sampling, Content Security Policy connect-src, and browser console. The SDK has no public flush, reset, or shutdown method in this release.
Enable replay separately
Install @askdepth/replay before enabling replay: true. The recorder is dynamically imported and is not a runtime dependency installed by core automatically. See session replay for setup and masking.
