Sana Assistant (online)
Table of Contents

Product Collection Viewed event

This article provides reference material about the "Product Collection Viewed" event. The Sana core system emits this event when a product collection is shown. The event is currently emitted on a product list, a search page, and a product set content block. Updating paging, filtering, or sorting counts as a new collection and emits the event.

The custom RxJS operator

The custom RxJS operator that filters an Observable of actions into the product collection viewed Observable.

type ProductCollectionSearchContext = {
  searchRequestId: string | null;
};

type ProductCollectionViewedInfo = {
  searchContext: ProductCollectionSearchContext | null;
};

export function onProductCollectionViewed(): (source$: Observable<Action>) => Observable<ProductCollectionViewedInfo>;
Property Type Description
searchContext ProductCollectionSearchContext | null The search context of the viewed collection. It is taken from the ProductSearchContext of the product search response that produced the collection. Can be null when that response has no search context or the collection was not produced by a search response.

ProductCollectionSearchContext

Property Type Description
searchRequestId string | null The identifier of the search request that produced the collection.

Example:

import { onProductCollectionViewed } from 'sana/events';

const productCollectionViewed$ = action$.pipe(
  onProductCollectionViewed(),
  map(result => notifyProductCollectionViewed(result.searchContext)),
);