Class TecsafeWidgetManager

The main entry point for the TECSAFE Widget SDK

Hierarchy (view full)

Constructors

  • The main entry point for the TECSAFE Widget SDK. This class should only be instantiated after the user has consented to the terms, conditions, and privacy policy. The SDK will not ensure GDPR compliance itself - this task is left for the implementor to integrate into existing tools and flows.

    Parameters

    • customerTokenCallback: CustomerTokenCallback

      A function that returns the customer token as a string inside a promise. It is expected that you implement a route in your backend, using your own auth method to secure API communication, and request a token from the TECSAFE API /jwt/saleschannel-customer. This function handles initial as well as consecutive token creation. If a previous token exists it must be handed in for proper session upgrading.

    • addToCartCallback: AddToCartHandler

      A function that adds product(s) to the cart. It is left tpo the implementor to chose a single or bulk processing given their frameworks prerequisites. The function will return a success status.

    • widgetManagerConfig: WidgetManagerConfig

      The SDK configuration containing tracking and regional settings for customer specific app optimization.

    Returns TecsafeWidgetManager

    An error if the configuration is invalid.

Properties

listeners: Map<string, MessageEventHandler<any>[]> = ...

Methods

  • Creates a custom page widget.

    Parameters

    • el: HTMLElement

      The element to attach the widget to

    • OptionalcontextId: string

      A custom contextID which needs to be references in TECSAFE's cockpit to provide the necessary layout context.

    Returns CustomPageWidget

    The custom page widget

  • Creates a product detail widget.

    Parameters

    • el: HTMLElement

      The element to attach the widget to

    • articleNumber: string

      The articleNumber of the respectively promoted article on the PDP. Make sure to configure that article in TECSAFE's cockkpit to provide the necessary layout context.

    Returns ProductDetailWidget

    The product detail widget

  • Destroys all widgets, and resets the SDK to its initial state

    Returns Promise<void>

  • Emits a message to all widgets

    Type Parameters

    • P

    Parameters

    Returns this

    this

  • Gets the full screen data. It is not recommended to use this method directly.

    Returns any

    The full screen data

  • Gets the token, refreshing it if necessary. Utilizes a cache to prevent multiple requests, and only refreshes the token if it is expired (or refresh is true).

    Parameters

    • refresh: boolean = false

    Returns Promise<string>

    The token as a string inside a promise

  • Gets the timestamp (in milliseconds) when the token will expire

    Returns number

    The timestamp when the token will expire

  • Opens the AppWidget in full screen mode on the provided url

    Parameters

    • url: string

      The url to open in full screen

    Returns void

    An error if the url is not in the allowedOrigins list

    AppWidget

  • Refreshes the token and propagates it to all widget instances. If a customer's login status changes you have to notify TECSAFE about that change. The customer token API will ensure that guest assets will be transferred to registered accounts on login and that restigered customer sessions will be cleaned appropriately for a new guest session.

    Parameters

    • Optionaltoken: string

      If provided, the token to use instead of fetching a new one with the tokenFN

    Returns Promise<void>

  • Sets the full screen data. It is not recommended to use this method directly.

    Parameters

    • data: any

      The full screen data

    Returns void

  • Triggers all listeners for a given message type

    Parameters

    • type: string

      The message type

    • envelope: MessageEnvelope<any>

      The message envelope containing the payload

    • sdk: ISDK

      The SDK instance

    • widget: IWidget

      The widget instance

    Returns void