This is a preview of unreleased docs from main. View the published docs
Skip to main content

Interface: RecommendationsNamespace

Defined in: types.ts:1283

Recommendation fetching and click reporting methods, available as allegro.recommendations.

Methods​

get()​

get(options?): Promise<RecommendationSet>

Defined in: types.ts:1292

Fetch ranked recommendations for this reader.

Parameters​

ParameterType
options?RecommendationsGetOptions

Returns​

Promise<RecommendationSet>

Example​

const { items } = await allegro.recommendations.get({ limit: 6 });

trackClick()​

trackClick(item, options?): Promise<void>

Defined in: types.ts:1312

Report that the reader clicked one of the items get() returned.

Pass the item object itself — the SDK remembers which request served it, so nothing else is needed. options.position is the only field the caller can override — useful when the item was re-rendered or reordered and the caller knows its displayed position better than the SDK's original index; requestId, device, sourcePath, and strategy always come from the recorded origin, not from options.

Parameters​

ParameterType
itemRecommendationItem
options?{ position?: number; }
options.position?number

Returns​

Promise<void>

Throws​

AllegroApiError when the item cannot be traced to a request, or when its path appears in two different result sets on this page.

Example​

link.addEventListener('click', () => allegro.recommendations.trackClick(item));