Options
All
  • Public
  • Public/Protected
  • All
Menu

The store holds the user's consents to the different Features and Campaigns, and their Visit and Event measurements.

If you want to implement your own persistence of the store (e.g. because you want to write it in a database instead of the file system) and your own implementation of the transmission to the Matomo/CIMP backend (e.g. because you want to tunnel the requests through a proxy or add your own encryption layer), then create a subclass of this class and and implement the #constructor, #persist and #send methods.

If you only want to change either one or the other, you can use NodejsStore (found in the backend example) or BrowserStore as a base and work from there.

Hierarchy

Index

Constructors

Properties

Methods

Constructors

constructor

  • new Store(args?: {}, debug?: (message: string) => void): Store
  • Parameters

    • Optional args: {}
      • [p: string]: any
    • Optional debug: (message: string) => void
        • (message: string): void
        • Parameters

          • message: string

          Returns void

    Returns Store

Properties

consents

consents: Consents = ...

events

events: Event[] = []

visits

visits: Visit[] = []

Methods

Abstract load

  • This method gets called from the constructor and will receive the same parameters, as the constructor got.

    Parameters

    • args: {}
       Arguments your implementation might need for loading the store.
      
      • [key: string]: any

    Returns undefined | StoreData

    Deserialized store data.

Abstract persist

  • persist(async: boolean, done: (error?: Error) => void): void
  • This method gets called, when the SDK is of the opinion, that persisting the Store is in order.

    This is partly controlled by the Configuration.persistEveryNTimes configuration option, and by calls to CleanInsights#persist.

    If possible, try to honor the async flag: If it's true, it is set so, because the SDK wants to reduce impact on user responsivity as much as possible. If it's false, the SDK wants to make sure, that the call finishes before the app gets killed.

    Parameters

    • async: boolean
       Indicates, if the persistence should be done asynchronously or synchronously.
       E.g. a persist call during the exit of an app should be done synchronously,
       otherwise the operation might never get finished because the OS kills the
       server too early.
      
    • done: (error?: Error) => void
       Callback, when the operation is finished, either successfully or not.
       If no error is returned, the operation is considered successful and the
       internal counter will be set back again.
      
        • (error?: Error): void
        • Parameters

          • Optional error: Error

          Returns void

    Returns void

Abstract send

  • send(data: string, server: string, timeout: number, done: (error?: Error) => void): void
  • This method gets called, when CleanInsights gathered enough data for a time period and is ready to send the data to a CIMP (CleanInsights Matomo Proxy).

    Parameters

    • data: string
       The serialized JSON for a POST request to a CIMP.
      
    • server: string
       The server URL from `Configuration.server`.
      
    • timeout: number
       The timeout in seconds from `Configuration.timeout`.
      
    • done: (error?: Error) => void
       Callback, when the operation is finished, either successfully or not.
       If no error is returned, the data sent will be removed from the
       store and the store persisted.
      
        • (error?: Error): void
        • Parameters

          • Optional error: Error

          Returns void

    Returns void

Generated using TypeDoc