Tracker API reference
Definition
This document provides a detailed walkthrough of the tracker API methods and properties
queueEmpty$
This property type is Subject<boolean> and it will emit to its observers true each time the queue becomes empty
Usage in wrappers
- @pulse/browser
- @pulse/react
import { initializeScoped } from '@pulse/browser';
const pulse = initializeScoped({
app: 'your application name'
});
// Now you can subscribe to queueEmpty$ from pulse object
pulse.queueEmpty$.subscribe();
import { PulseContext } from '@pulse/react';
import { useContext, useEffect } from 'react';
const SomeComponent = () => {
const pulse = useContext(PulseContext);
useEffect(() => {
// Now you can subscribe to queueEmpty$ from pulse object
const subscription = pulse.tracker.queueEmpty$.subscribe();
return () => subscription?.unsubscribe()
}, [])
}
getState
This is a function that returns a Promise<Record<string, unknown>> which represents the Pulse SDK state.
- @pulse/browser
- @pulse/react
import { initializeScoped } from '@pulse/browser';
const pulse = initializeScoped({
app: 'your application name'
});
const pulseState = await pulse.getState();
import { usePulseState } from '@pulse/react';
const SomeComponent = () => {
const { state, loading, hasError } = usePulseState();
return (
<>
{hasError && <div>error</div>}
{!loading && state && <div>{JSON.stringify(state)}</div>}
</>
);
}
clearNavigationSource
This is a function that takes an optional label and returns nothing. It cancels the tab's pending declared navigation: the next navigation is no longer attributed to the click on a pulse-navigate element. With a label, it cancels only a declaration with that label. See Declared Navigation Source.
- @pulse/browser
- window.pulse
- dataLayer
import { initializeScoped } from '@pulse/browser';
const pulse = initializeScoped({
app: 'your application name'
});
pulse.clearNavigationSource('checkout cta');
window.pulse.clearNavigationSource('checkout cta');
window.pulse('clearNavigationSource', 'checkout cta');
// Only once the SDK has loaded:
window.pulse.tracker.clearNavigationSource('checkout cta');
window.dataLayer.push(['paa.clearNavigationSource', 'checkout cta']);
Once the SDK is loaded, the call takes effect at once. On the server SDK it does nothing.