Syncing Project Settings

Syncing Project Settings

Why this matters  

The PageSense SDK works off a local copy of your project settings. When you update an experiment — change a variation, adjust traffic, modify targeting rules — the SDK needs to pick up those changes.
getAndUpdateProjectSettings does exactly that: it pulls the latest settings from PageSense and refreshes the SDK's internal state. You can trigger this via webhooks (real-time) or polling (scheduled).
Changes that trigger a sync:
  • New or updated experiments
  • Variation or traffic allocation changes
  • Updated audience targeting rules
  • Goal configuration changes
  • Experiment status updates
Webhooks give you real-time updates. When you modify a FullStack experiment in PageSense, the flow looks like this:
  1. Pause the experiment.
  2. Apply the changes.
  3. Relaunch the experiment.
If a webhook URL is set in your Environment Settings, PageSense sends a POST notification to that URL on relaunch. Your server should handle that event and call getAndUpdateProjectSettings immediately.
Retry behaviour if the webhook fails:
  • PageSense retries every 30 seconds.
  • Retries run for up to 15 minutes.
  • After that window, retries stop.
  • A new relaunch triggers a fresh notification.

Option 2 — Polling-based Sync  

No webhook setup? Use polling instead. The SDK runs a background loop at a configured interval, calls the settings API, and updates the configuration if anything has changed. Nothing to manage manually — it just runs.

getAndUpdateProjectSettings API  

Method  
  1. await pageSenseClient.getAndUpdateProjectSettings(
  2.   accountId,
  3.   sdkKey,
  4.   projectName
  5. );

Parameters  

Parameter
Type
Required
Description
accountId
String
Yes
Your PageSense account identifier.
sdkKey
String
Yes
Secure SDK key for your environment.
projectName
String
Yes
The PageSense project to sync.

Return Value  
  • true — settings fetched and updated successfully.
  • false — update failed (invalid params, network issue, or server error).
Usage Example  
  1. await pageSenseClient.getAndUpdateProjectSettings(
  2.   "ZylkerUser1",
  3.   "xyz123abdscd",
  4.   "ZylkerFullStackProject"
  5. );
After this runs, all subsequent experiment evaluations use the refreshed configuration.

Polling Lifecycle Methods  

Method
What it does
startPolling()
Kicks off the polling loop.
runPollingCycle()
Runs one sync cycle manually.
stopPolling()
Stops the loop and frees resources.
registerShutdownHooks()
Ensures polling stops cleanly when the Node.js process exits.

Quick comparison  

Approach
Best for
Webhook
Real-time updates, minimal latency.
Polling
Environments where webhook setup isn't possible.