Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Signal

Class representing all exposed Signal methods

Hierarchy

  • Signal

Implements

Index

Properties

currencyCode

currencyCode: string = 'USD'

Readonly version

version: string = 'v1'

Library version, this also is the same as our API version

Static DEFAULT_BASE_URL

DEFAULT_BASE_URL: string = 'https://track.coherentpath.com'

Methods

browser

  • browser(callback?: Callback<undefined | string>): void
  • This method checks if there's a browser id assigned to the user, creates a new browser id if no id found or assigned id is expired. This method is called automatically within Signal.init

    signal.browser()
    

    Usage with callback

    signal.browser(browserId => {
     console.log('Browser ID', browserId)
    })
    
    throws

    SignalError when init method has not been called

    Parameters

    • Optional callback: Callback<undefined | string>

    Returns void

debug

  • debug(value?: boolean): void
  • Calling the debug method turns on debug mode, which logs helpful messages to the console.

    signal.debug() // set to true
    signal.debug(false) // set to false
    signal.debug(true) // set to true
    

    Parameters

    • value: boolean = true

      next debug value (default: true)

    Returns void

event

forget

  • forget(): void
  • This method clears identityId from storage if one exist

    signal.forget()
    

    Returns void

getFetchInstance

  • getFetchInstance(): Fetch
  • Returns Fetch

identity

  • This method creates new IIdentity. Takes an optional callback that either takes an @{link IIdentity} when an identity is created or undefined when no identity created, means there's already one in our storage

    signal.identity({
     referenceId: 'CUSTOMER-123',
     email: 'test@email.com',
     source: 'login',
     attributes: {
     name: 'test'
      }
    }, identity => console.log('identity created',identity))
    
    throws

    SignalError when init method has not been called

    Parameters

    Returns void

init

  • The init method lets you initialise signal before any usage within the page

    signal.init('CLIENT_TOKEN')
    

    Usage with custom base URL

    signal.init('CLIENT_TOKEN', {baseUrl: 'https://custom-url'})
    
    throws

    SignalTypeError when a token, options.baseUrl or options.currencyCode is not a string or an empty string and options.currencyCode is not 3 characters

    Parameters

    • token: string

      account CLIENT_TOKEN

    • options: IInitOptions = ...

      configuration object

    Returns void

ping

  • ping(callback?: Callback<boolean>): void
  • This method checks if the provided IInitOptions.baseUrl is valid or not.

    signal.ping()
    

    Usage with callback

    signal.ping(isAlive => {
     console.log('Base URL alive', isAlive)
    })
    
    throws

    SignalError when init method has not been called

    Parameters

    • Optional callback: Callback<boolean>

      takes isAlive boolean parameter which is true if the url is alive or false if not

    Returns void

session

  • session(callback?: Callback<undefined | string>): void
  • This method checks if there's a session id assigned to the user, creates a new session id if no id found or assigned id is expired. This method is called automatically within Signal.init

    signal.session()
    

    Usage with callback

    signal.session(sessionId => {
     console.log('Session ID', sessionId)
    })
    
    throws

    SignalError when init method has not been called

    Parameters

    • Optional callback: Callback<undefined | string>

    Returns void

updateBatchCallsConfiguration

updateStorageDriversOrder

whoami

  • This method fetches the information about the current user access token

    signal.whoami()
    

    Usage with callback

    signal.whoami(user => {
     console.log('User information', user)
    })
    
    throws

    SignalError when init method has not been called

    Parameters

    Returns void

Generated using TypeDoc