Skip to content

Product Discovery Data & Events

The Product Discovery drop-in uses the event bus to emit and listen to events for communication between drop-ins and external integrations.

Version: 3.0.0
EventDirectionDescription
search/errorEmits and listensTriggered when an error occurs.
search/loadingEmits and listensTriggered when loading state changes.
search/resultEmits and listensTriggered when results are available.

The following sections provide detailed information about each event, including its direction, event payload, and usage examples.

Emitted when an error occurs during search operations such as query execution or facet loading.

string
import { events } from '@dropins/tools/event-bus.js';
events.on('search/error', (payload) => {
console.log('search/error event received:', payload);
// Add your custom logic here
});

Triggered when loading state changes.

boolean
import { events } from '@dropins/tools/event-bus.js';
events.on('search/loading', (payload) => {
console.log('search/loading event received:', payload);
// Add your custom logic here
});

Triggered when results are available.

{
result: ProductSearchResult;
request: SearchVariables;
}

See ProductSearchResult, SearchVariables for full type definitions.

import { events } from '@dropins/tools/event-bus.js';
events.on('search/result', (payload) => {
console.log('search/result event received:', payload);
// Add your custom logic here
});

The following data models are used in event payloads for this drop-in.

Used in: search/result.

interface ProductSearchResult {
facets: SearchFacet[];
items: Product[];
pageInfo: {
currentPage: number;
totalPages: number;
totalItems: number;
pageSize: number;
};
suggestions?: string[];
totalCount: number;
metadata?: {
filterableAttributes: RefineOption[];
sortableAttributes: RefineOption[];
};
}

Used in: search/result.

interface SearchVariables {
scope?: Scope;
phrase?: string;
filter?: SearchFilter[];
sort?: SortOrder[];
currentPage?: number;
pageSize?: number;
context?: SearchContext;
}