Skip to main content

LocalStorage

Definition

This document offers a comprehensive guide on how the Pulse SDK utilizes localStorage, detailing the types of data stored and the services that interact with this storage.

The list and porpose of each key in localStorage

  • paa_unpublished
  • paa_traffic_source
  • paa_la
  • paa_ss
  • paa_did
  • paa_sid
  • paa_config_override
  • paa_debug
  • paa_debug-exp
  • paa_log_level
  • paa_tab_activity_{tab_id}
  • paa_tab_info_{tab_id}
  • paa_pulse_bc_{channel_name}
  • paa_locks
  • paa_ur
  • paa_experiments
  • paa_segments-{did first 5 letters}
  • paa_attr

paa_unpublished

The paa_unpublished record contains data of unpublished batches, which will be sent to the server at the earliest possible opportunity. After the SDK delivers the stored batches to the server, the record will be removed from localStorage.

The paa_unpublished record can only be set by the Pulse Tracker SDK. The SDK sets this record in two scenarios:

  • the tab becomes invisible and there are unsent events in the message queue or the batch queue
  • or the client closes it. In these cases, the Pulse SDK checks if any ongoing fetch call is in progress and if the batch in the queue fits within the size limit for the keepalive flag (64kb). If it meets the requirements, the SDK sends the batch and stores the remaining batches in localStorage under the paa_unpublished key. Otherwise, the SDK stores all batches in localStorage. For more details on how the "batch queue" works, refer to the relevant section here.

The paa_unpublished data is used exclusively in the BatchQueue.

paa_traffic_source

The paa_traffic_source record can contain the following fields:

  • utmParams (optional)
  • clickId (optional)
  • referrer (optional)
  • landingPageURL (required)

The paa_traffic_source record can only be set by the Pulse Tracker SDK. The SDK sets this record in three scenarios:

  • The click ID has been updated
  • The referrer has been updated
  • The utmParams have been updated

The paa_traffic_source data is used exclusively in the TrafficSourceService.

paa_la

The paa_la record contains the timestamp of the user's last activity on the page where the Pulse SDK was initialized.

The paa_la record can only be set by the Pulse Tracker SDK. The SDK updates this record whenever the user interacts with the page.

The paa_la data is used exclusively in the SessionService.

paa_ss

The paa_ss record contains data regarding the session state, such as:

{
"app": string,
"debug": boolean,
"device_id": string,
"experiments": Experiment[],
"infected": Infected[],
"language_code": string,
"market": "web",
"platform": "web",
"pulse": "state",
"segments": string[],
"session_id": string,
"user_id": string | null,
"v": string,
"version": string | null
}

The paa_ss record can only be set by the Pulse Tracker SDK. The SDK sets this record in several scenarios, including:

  • When the client calls the tracker.state function and passes a new state
  • When the client initializes the SDK and passes the application name
  • When a new experiments list is received from the server
  • When the user participates in a new experiment
  • When a new segments list is received from the server
  • When a new session is generated

The paa_ss data is set and used exclusively in two services: SettingsService and SessionService.

paa_did

The paa_did record contains the device id of the browser where the Pulse SDK was initialized.

The paa_did record can be set either by the Pulse SDK itself or by the ID provided by the receiver. The receiver will send the device ID of the browser if the user has opened another application where the Pulse SDK is initialized and the pulse SDK will set it as new device ID.

The paa_did data is set and used exclusively in two services: DeviceIdService and SessionService.

paa_sid

The paa_sid record contains the device ID of the browser where the Pulse SDK was initialized, concatenated with a timestamp into a single string.

The paa_sid record can only be set by the Pulse Tracker SDK. The SDK sets this record in three scenarios:

  • There is no session ID record immediately after SDK initialization.
  • The user did not interact with the page for more than 30 minutes and then performs an action again.
  • The user is in one of the GDPR countries and accepts the cookie consent in the application.

The paa_sid data is set and used exclusively in two services: ExperimentsService and SessionService.

paa_config_override

The paa_config_override record should contain a JSON object with key-value pairs. During initialization, the Pulse SDK will retrieve the configurations from localStorage. If a configuration in localStorage has a different value than the nested configurations in the script, the SDK will prioritize the configuration from the paa_config_override record.

The paa_config_override record should be set by the client if they want to debug or test something in their application.

The paa_config_override data is used exclusively in one module: PulseModule.

paa_debug

The paa_debug record should contain an array of strings with values like: 'all', 'receiver', and 'debugger'. During initialization and if a storage change event happens, the Pulse SDK will retrieve the debug modules from localStorage. In the Pulse SDK, there are two services that use the value provided in the record: AnalyticsTransport, and StatePlugin.

The Pulse SDK has a DebugService to work with the storage record and provide a wide range of functions for handling the provided modules.

paa_debug-exp

The paa_debug-exp record should contain a JSON object with key-value pairs like: {app, id, name, variant, url}. During initialization, the Pulse SDK will retrieve the configurations from the landing page URL's query parameters or from localStorage. If the landing page URL contains the mentioned query parameters, the SDK will take and set the data in localStorage under the paa_debug-exp key.

The paa_debug-exp data is set and used exclusively ExperimentDebugService.

paa_log_level

The paa_log_level record can contain a numerical value from 0 to 4, inclusive.

The paa_log_level record can only be set by the Pulse Tracker SDK. The SDK sets this record if the client calls LoggerService.setLevel function and passes the log level.

The paa_log_level data is used exclusively in the LoggerService.

paa_tab_activity_{tab_id}

The next record is paa_tab_activity_{tab_id}. The SDK keeps user activities in localStorage and sets a unique tab ID in the key to separate records per tab. The only service that uses and sets these records in storage is ActivitySynchronizer. The SDK adds a record to localStorage when a user performs an activity on the page. Upon initialization, the SDK removes closed tab records from storage. Additionally, if no events occur on a page, the SDK will remove the activity record for that tab.

Key: paa_tab_activity_{tab_id} Data: User activity data Who can put a record: Pulse Tracker SDK When records are set: When a user performs an activity on the page Who is using the records: ActivitySynchronizer

paa_tab_info_{tab_id}

The next record is paa_tab_info_{tab_id}. The SDK writes and updates tab information in localStorage, setting a unique tab ID in the key to separate records per tab. There are two services that use and set these records in storage: ActivitySynchronizer and TabInfoService. The SDK adds a record to localStorage when initialized on a page, and updates the data if one of the following actions occurs:

  • The page becomes invisible
  • New activity happens on the page
  • The tab is closed
  • Additionally, the SDK will remove the tab info record for the tab if the tab is closed.

Key: paa_tab_info_{tab_id} Data: Tab information like: { id, lastActivity, persisted, unloaded, visible } Who can put a record: Pulse Tracker SDK (through ActivitySynchronizer and TabInfoService) When records are set: Initialization on the page Page becomes invisible New activity on the page Tab closure Who is using the records: ActivitySynchronizer, TabInfoService

paa_locks

The paa_locks record contains an array of strings and is updated exclusively by the Pulse Tracker SDK when attempting to unsafely lock any key. This data is utilized solely within the UnsafeLockManager.

paa_ur

The paa_ur record contains a string value.

The paa_ur record can be set by the Pulse Tracker SDK or by the client. It can be included in the prefetch script or directly set in localStorage under the paa_ur key. The SDK updates this record during initialization when it detects a ur query parameter in the URLs of prefetch scripts.

The paa_ur data is used in the following services:

  • UserRoleService
  • PulseSettings
  • CacheService

paa_experiments

The paa_experiments record contains an array of string values (the experiment IDs).

The paa_experiments record can be set by the Pulse Settings SDK. The Settings SDK puts and updates the paa_experiments record when it receives the experiments list from the server, which may differ from the list stored in localStorage.

The paa_experiments data is used in the following services:

  • ExperimentsService (Settings SDK)
  • ExperimentsService (Tracker SDK)

paa_segments-{did first 5 letters}

The paa_segments-{did first 5 letters} record contains a JSON object with segments, which is an array of string values representing the segments, along with a ts (timestamp) field.

The paa_segments-{did first 5 letters} record can be set by the Pulse Settings SDK. The Settings SDK puts and updates the paa_segments-{did first 5 letters} record when it receives the segments list from the server.

The paa_segments-{did first 5 letters} data is used in the following service:

  • SegmentsResolverService

paa_attr

The paa_attr record contains a timestamp of the last attribute request.

The paa_attr record can be set by the Pulse Tracker SDK. The tracker SDK puts and updates the paa_attr record each time when the SDK fires an "attribute" request.

The paa_attr data is used in the following service:

  • DeviceAttributesService