Context

Version:

Type

Class

Import path

@sitecore-cloudsdk/search/browser

Details about the site visitor's search request, such as locale, location, device, and web browser information. Sitecore Search uses this data for personalizing search results.

Constructor

Context(context: ContextData)

Parameters

Name

Type

Description

context

ContextData

Details about the site visitor's search request, such as locale, location, device, and web browser information. Sitecore Search uses this data for personalizing search results.

Properties

Name

Type

Description

_locale

LocaleData

The country and language the webpage is being viewed in.

_page

PageData

The URI the site visitor came to the current webpage from.

_user

UserData

Data about the site visitor.

_store

StoreData

Data about the online store where the site visitor made the search request. Typically used in Buy Online Pickup In Store retail strategies.

_campaign

CampaignData

The UTM parameters in the URL of the webpage.

_geo

GeoData

Geographical data about the search request.

_browser

BrowserData

Data about the site visitor's web browser.

Accessors

The following properties are available to set:

get locale

get locale(): LocaleData | undefined

Returns the locale data of the Context instance.

set locale

set locale(locale: LocaleData)

Sets the locale data of the Context instance.

Parameters

Name

Type

Description

locale

LocaleData

The country and language the webpage is being viewed in.

get page

get page(): PageData | undefined

Returns the page data of the Context instance.

set page

set page(page: PageData)

Sets the page data of the Context instance.

Parameters

Name

Type

Description

page

PageData

The URI the site visitor came to the current webpage from.

get user

get user: UserData | undefined

Returns the user data of the Context instance.

set user

set user(user: UserData | undefined)

Sets the user data of the Context instance.

Parameters

Name

Type

Description

user

UserData

Data about the site visitor.

get store

get store(): StoreData | undefined

Returns the store data of the Context instance.

set store

set store(store: StoreData)

Sets the store data of the Context instance.

Parameters

Name

Type

Description

store

StoreData

Data about the online store where the site visitor made the search request. Typically used in Buy Online Pickup In Store retail strategies.

get campaign

get campaign(): CampaignData | undefined

Returns the campaign data of the Context instance.

set campaign

set campaign(campaign: CampaignData)

Sets the campaign data of the Context instance.

Parameters

Name

Type

Description

campaign

CampaignData

The UTM parameters in the URL of the webpage.

get geo

get geo(): GeoData | undefined

Returns the geo data of the Context instance.

set geo

set geo(geo: GeoData)

Sets the geo data of the Context instance.

Parameters

Name

Type

Description

geo

GeoData

Geographical data about the search request.

get browser

get browser(): BrowserData | undefined

Returns the browser data of the Context instance.

set browser

set browser(browser: BrowserData)

Sets the browser data of the Context instance.

Parameters

Name

Type

Description

browser

BrowserData

Data about the site visitor's web browser.

Methods

_validateContext

Validates the context object.

Signature

private _validateContext(context: ContextData): void

Parameters

Name

Type

Description

context

ContextData

Required.

Details about the site visitor's search request, such as locale, location, device, and web browser information. Sitecore Search uses this data for personalizing search results.

Return value

Returns void.

Errors

_validateContextLocale

Validates the context locale object.

Signature

private _validateContextLocale(locale?: LocaleData): void

Parameters

Name

Type

Description

locale

LocaleData

Optional.

The country and language the webpage is being viewed in.

Return value

Returns void.

Errors

_validateLocation

Validates latitude and longitude.

Signature

private _validateLocation(location: LocationData): void

Parameters

Name

Type

Description

location

LocationData

The geographical coordinates of the location where the site visitor made the search request.

Return value

Returns void.

Errors

_validatePage

Validates the page object.

Signature

private _validatePage(page?: PageData): void

Parameters

Name

Type

Description

page

PageData

The URI the site visitor came to the current webpage from.

Return value

Returns void.

Errors

_validateUser

Validates the user object.

Signature

private _validateUser(user?: UserData): void

Parameters

Name

Type

Description

user

UserData

Optional.

Data about the site visitor.

Return value

Returns void.

Errors

removeLocale

Sets the locale data to undefined.

Signature

removeLocale(): void

Return value

Returns void.

removePage

Sets the page data to undefined.

Signature

removePage(): void

Return value

Returns void.

removeUser

Sets the user data to undefined.

Signature

removeUser(): void

Return value

Returns void.

removeStore

Sets the store data to undefined.

Signature

removeStore(): void

Return value

Returns void.

removeCampaign

Sets the campaign data to undefined.

Signature

removeCampaign(): void

Return value

Returns void.

removeGeo

Sets the geo data to undefined.

Signature

removeGeo(): void

Return value

Returns void.

removeBrowser

Sets the browser data to undefined.

Signature

removeBrowser(): void

Return value

Returns void.

removeIds

Sets the ids data to undefined.

Signature

removeIds(): void

Return value

Returns void.

toDTO

Maps the Context instance to its DTO (data transfer object) format.

Signature

toDTO(): ContextDTO

Return value

Returns the Context instance in a standardized DTO format.

If you have suggestions for improving this article, let us know!