Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Usercentrics

Hierarchy

  • Usercentrics

Constructors

constructor

  • Parameters

    • settingsId: string

      Your unique Usercentrics settingsId

    • Optional options: Options

      Additional options, see interface Options

    Returns Usercentrics

Methods

acceptAllServices

  • acceptAllServices(consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services as "consent given" (e.g. an accept all button was clicked). The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was given (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

acceptAllServicesInCategory

  • acceptAllServicesInCategory(categorySlug: string, consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services in a given category as "consent given". The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    deprecated
    • Will be removed in version 0.5.1. Use updateServices() instead.

    Parameters

    • categorySlug: string

      Category identifier.

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was given (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

changeLanguage

  • changeLanguage(language: string): Promise<void>
  • Change the language. All upcoming SDK calls will return information in this language. Pay attention that the language needs to be set up in your Usercentrics Settings before!

    Parameters

    • language: string

      The language to switch to (ISO 639-1 code)

    Returns Promise<void>

denyAllServices

  • denyAllServices(consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services as "consent denied" (e.g. an deny all button was clicked). Essential services will still be marked as accepted. The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was denied (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

denyAllServicesInCategory

  • denyAllServicesInCategory(categorySlug: string, consentType?: CONSENT_TYPE): Promise<void>
  • Mark all services in a given category as "consent denied". Essential services will still be marked as accepted. The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    deprecated
    • Will be removed in version 0.5.1. Use updateServices() instead.

    Parameters

    • categorySlug: string

      Category identifier.

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was denied (explicit vs. implicit). Default: explicit.

    Returns Promise<void>

fetchIsUserInEU

  • fetchIsUserInEU(): Promise<boolean>
  • Retrieve boolean, that can be used to decide if the user is inside the EU or not.

    Returns Promise<boolean>

fetchUserCountry

  • Retrieve the user's country information.

    Returns Promise<UserCountry>

getCategories

  • Retrieve the categories and their services to display this information in your UI.

    Returns Category[]

getControllerId

  • getControllerId(): string
  • Retrieve the controllerId, that's generated for the user.

    Returns string

getEssentialCategories

  • Retrieve the categories that are marked as essential and their services.

    deprecated
    • Will be removed in version 0.5.1. Use getCategories() instead.

    Returns Category[]

getEssentialServices

  • getEssentialServices(): Service[]
  • Retrieve all services that are considered essential, because they are placed inside an essential category.

    deprecated
    • Will be removed in version 0.5.1. Use getServices() instead.

    Returns Service[]

getNonEssentialCategories

  • getNonEssentialCategories(): Category[]
  • Retrieve the categories that are marked as non-essential and their services.

    deprecated
    • Will be removed in version 0.5.1. Use getCategories() instead.

    Returns Category[]

getNonEssentialServices

  • getNonEssentialServices(): Service[]
  • Retrieve all services that are considered non-essential, because they are placed inside an non-essential category.

    deprecated
    • Will be removed in version 0.5.1. Use getServices() instead.

    Returns Service[]

getServices

  • Retrieve all services.

    Returns Service[]

getSettings

  • Retrieve all settings.

    Returns Settings

init

  • Initializes the Usercentrics framework. This method must be called when loading your website. The return value defines which view you should initially show for your users.

    Returns Promise<INITIAL_VIEW>

restoreUserSession

  • restoreUserSession(controllerId: string): Promise<void>
  • Restore a session for an end user with the given controllerId.

    Parameters

    • controllerId: string

      User's generated controllerId. NOTE: Always use a controllerId provided by the SDK.

    Returns Promise<void>

updateServices

  • Mark given services as "consent given / denied". Essential services will still be marked as accepted. The SDK will store the consent information and trigger events depending on your Usercentrics Settings.

    Parameters

    • decisions: UserDecision[]

      The user's decisions for individual services (see interface definition for details)

    • Default value consentType: CONSENT_TYPE = CONSENT_TYPE.EXPLICIT

      The manner in which the consent was given/denied (explicit vs. implicit). Default: explicit.

    Returns Promise<void>