cap-hydra-web-sdk 1.7.0 → 1.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -42,25 +42,25 @@ npm install cap-hydra-web-sdk@beta
42
42
  **ES6 Modules (TypeScript / JavaScript):**
43
43
 
44
44
  ```javascript
45
- import { WebSDK } from 'cap-hydra-web-sdk';
45
+ import { HydraSDK } from 'cap-hydra-web-sdk';
46
46
  ```
47
47
 
48
48
  **CommonJS:**
49
49
 
50
50
  ```javascript
51
- const { WebSDK } = require('cap-hydra-web-sdk');
51
+ const { HydraSDK } = require('cap-hydra-web-sdk');
52
52
  ```
53
53
 
54
- When using the CDN script tag, `WebSDK` is available as a global on the `window` object.
54
+ When using the CDN script tag, `HydraSDK` is available as a global on the `window` object.
55
55
 
56
56
  ### 3. SDK Initialization
57
57
 
58
- Call `WebSDK.initialize()` once at application startup. The SDK uses Firebase Remote Config to fetch backend configuration (`accountId`, `baseURL`, `debugLevel`, etc.) automatically — you only need to provide Firebase credentials and the Remote Config key.
58
+ Call `HydraSDK.initialize()` once at application startup. The SDK uses Firebase Remote Config to fetch backend configuration (`accountId`, `baseURL`, `debugLevel`, etc.) automatically — you only need to provide Firebase credentials and the Remote Config key.
59
59
 
60
60
  ```javascript
61
- import { WebSDK } from 'cap-hydra-web-sdk';
61
+ import { HydraSDK } from 'cap-hydra-web-sdk';
62
62
 
63
- WebSDK.initialize({
63
+ HydraSDK.initialize({
64
64
  firebaseConfig: {
65
65
  apiKey: 'YOUR_FIREBASE_API_KEY',
66
66
  authDomain: 'your-app.firebaseapp.com',
@@ -75,21 +75,21 @@ WebSDK.initialize({
75
75
  });
76
76
  ```
77
77
 
78
- > **Important:** Initialize the SDK at **module load time** — not inside React `useEffect`, Angular `ngOnInit`, or similar async lifecycle hooks. This ensures the SDK instance exists before any component attempts to use it.
78
+ > **Important:** Initialize the SDK at **module load time** — not inside React `useEffect`, Angular `ngOnInit`, or similar async lifecycle hooks. This ensures the SDK instance exists before any component attempts to use it. In a React app, wrap the call in a small service module (e.g. `services/sdkService.ts`) that calls `HydraSDK.initialize()` at the top level, then import that module wherever you need `HydraSDK`.
79
79
 
80
80
  ### 4. Basic Event Tracking
81
81
 
82
82
  ```javascript
83
83
  // Track a page view (auto-captures URL and title)
84
- WebSDK.pageView();
84
+ HydraSDK.pageView();
85
85
 
86
86
  // Track a custom event
87
- WebSDK.track('page_view', {
87
+ HydraSDK.track('page_view', {
88
88
  page: 'homepage',
89
89
  });
90
90
 
91
91
  // Track with detailed properties
92
- WebSDK.track('add_to_cart', {
92
+ HydraSDK.track('add_to_cart', {
93
93
  product_id: 'shoe-123',
94
94
  product_name: 'Nike Air Max',
95
95
  quantity: 1,
@@ -103,7 +103,7 @@ WebSDK.track('add_to_cart', {
103
103
  When a user logs in, call `identify()` to link their activity to a known identity:
104
104
 
105
105
  ```javascript
106
- WebSDK.identify({
106
+ HydraSDK.identify({
107
107
  identifier: { type: 'email', cuid: 'user@example.com' },
108
108
  actionType: 'USER_REGISTER',
109
109
  traits: {
@@ -118,85 +118,7 @@ Supported identifier types: `'email'`, `'mobile'`, `'externalId'`.
118
118
  When the user logs out, call `reset()` to return to anonymous tracking:
119
119
 
120
120
  ```javascript
121
- WebSDK.reset();
122
- ```
123
-
124
- ---
125
-
126
- ## React Integration Example
127
-
128
- For React applications, wrap the SDK in a service and initialize at module load time:
129
-
130
- ```typescript
131
- // services/sdkService.ts
132
- import { WebSDK } from 'cap-hydra-web-sdk';
133
- import { initializeApp } from 'firebase/app';
134
- import { getMessaging } from 'firebase/messaging';
135
-
136
- class SDKService {
137
- initialize() {
138
- // Push notifications require a Firebase project — you create and own the app and
139
- // Messaging instance; the SDK only calls getToken()/onMessage() against what you give it.
140
- const firebaseApp = initializeApp({
141
- /* your Firebase project config */
142
- });
143
-
144
- WebSDK.initialize({
145
- firebaseConfig: {
146
- /* ... */
147
- },
148
- remoteConfigKey: 'your_app_config_key',
149
- appVersion: '1.0.0',
150
- notifications: {
151
- messaging: getMessaging(firebaseApp),
152
- vapidKey: 'YOUR_VAPID_KEY',
153
- },
154
- });
155
- }
156
-
157
- trackEvent(name: string, properties?: Record<string, unknown>) {
158
- WebSDK.track(name, properties);
159
- }
160
-
161
- trackPageView() {
162
- WebSDK.pageView();
163
- }
164
-
165
- identifyUser(type: 'email' | 'mobile' | 'externalId', cuid: string, traits?: object) {
166
- WebSDK.identify({
167
- identifier: { type, cuid },
168
- actionType: 'USER_REGISTER',
169
- traits,
170
- });
171
- }
172
-
173
- getUser() {
174
- return WebSDK.getUser();
175
- }
176
-
177
- reset() {
178
- WebSDK.reset();
179
- }
180
- }
181
-
182
- export const sdkService = new SDKService();
183
-
184
- // Initialize immediately at module load
185
- sdkService.initialize();
186
- ```
187
-
188
- ```jsx
189
- // App.tsx
190
- import { useEffect } from 'react';
191
- import { sdkService } from './services/sdkService';
192
-
193
- function App() {
194
- useEffect(() => {
195
- sdkService.trackPageView();
196
- }, []);
197
-
198
- return <Dashboard />;
199
- }
121
+ HydraSDK.reset();
200
122
  ```
201
123
 
202
124
  ---
@@ -227,21 +149,23 @@ The SDK supports two bootstrap modes, selected by whether `remoteConfigKey` is p
227
149
 
228
150
  The following fields are fetched from Firebase Remote Config. **Do not set them manually.**
229
151
 
230
- | Field | Required | Default | Description |
231
- | ----------------------- | -------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
232
- | `accountId` | Yes | — | Organization account identifier |
233
- | `baseURL` | Yes | — | API base URL for all SDK requests |
234
- | `orgId` | Yes | — | Organization ID for API authentication |
235
- | `brandId` | No | — | Brand identifier for namespaced database names |
236
- | `applicationId` | No | — | Application identifier for namespaced database names |
237
- | `source` | No | `WEBPUSH` | Source identifier for visitor profiles |
238
- | `channelType` | No | `web` | Communication channel type |
239
- | `sessionTimeoutMinutes` | No | `30` | Session inactivity timeout in minutes |
240
- | `batchSize` | No | `50` | Max events per batch request |
241
- | `debugLevel` | No | `NONE` | Logging level (`NONE` / `ERROR` / `WARN` / `INFO` / `DEBUG`) |
242
- | `gamificationWriteKey` | No | — | CustomerGlu write key; when present, gamification auto-initializes on user signin |
243
- | `gamificationRegion` | No | — | CustomerGlu region code (e.g. `'us'`, `'me'`). Absent = default region (`api.customerglu.com`). Derives both the API base URL and stream URL automatically. |
244
- | `gamificationBaseUrl` | No | — | Explicit override for the gamification API base URL. When present, takes precedence over the `gamificationRegion`-derived URL. Stream URL is still derived from `gamificationRegion`. |
152
+ | Field | Required | Default | Description |
153
+ | ----------------------- | -------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
154
+ | `accountId` | Yes | — | Organization account identifier |
155
+ | `baseURL` | Yes | — | API base URL for all SDK requests |
156
+ | `orgId` | Yes | — | Organization ID for API authentication |
157
+ | `brandId` | No | — | Brand identifier for namespaced database names |
158
+ | `applicationId` | No | — | Application identifier for namespaced database names |
159
+ | `source` | No | `WEBPUSH` | Source identifier for visitor profiles |
160
+ | `channelType` | No | `web` | Communication channel type |
161
+ | `sessionTimeoutMinutes` | No | `30` | Session inactivity timeout in minutes |
162
+ | `batchSize` | No | `50` | Max events per batch request |
163
+ | `debugLevel` | No | `NONE` | Logging level (`NONE` / `ERROR` / `WARN` / `INFO` / `DEBUG` / `VERBOSE`) |
164
+ | `gamificationWriteKey` | Yes\* | — | CustomerGlu write key; when present, gamification auto-initializes on user signin. **Required to enable gamification.** |
165
+ | `gamificationRegion` | Yes\* | — | CustomerGlu region code (e.g. `'us'`, `'me'`). **Required to enable gamification.** Derives the API base URL automatically. |
166
+ | `gamificationBaseUrl` | Yes\* | — | Explicit override for the gamification API base URL. **Required to enable gamification.** Takes precedence over the `gamificationRegion`-derived URL. |
167
+
168
+ > \* `gamificationWriteKey`, `gamificationRegion`, and `gamificationBaseUrl` are all required together to enable gamification. Omit all three if gamification is not being used.
245
169
 
246
170
  **Example Remote Config JSON** (stored as the value of your `remoteConfigKey` in Firebase Console):
247
171
 
@@ -258,39 +182,24 @@ The following fields are fetched from Firebase Remote Config. **Do not set them
258
182
  "batchSize": 50,
259
183
  "debugLevel": "NONE",
260
184
  "gamificationWriteKey": "wk_live_xxxxxxxxxx",
261
- "gamificationRegion": "us"
185
+ "gamificationRegion": "us",
186
+ "gamificationBaseUrl": "https://api-us.customerglu.com"
262
187
  }
263
188
  ```
264
189
 
265
- > **Gamification is opt-in.** If `gamificationWriteKey` is absent from Remote Config, the gamification module is silently skipped. When present, campaigns and entry points are fetched and rendered automatically after `identify()`.
266
- >
267
- > **Containers** — six display types are supported:
268
- >
269
- > | Container | Behavior | Host HTML needed? |
270
- > | ------------- | ---------------------------------------------------- | ------------------------------------- |
271
- > | ICON_BUTTON | Fixed button (bottom-left) that opens a CHAT_BOX | No |
272
- > | CHAT_BOX | Fixed panel above the icon button | No |
273
- > | POP_UP | Centered full-page modal | No |
274
- > | BOTTOM_SHEET | Sheet that slides up from the bottom | No |
275
- > | EMBEDDED | Full-width inline block injected into a hook element | **Yes** — `<div id="{hookId}"></div>` |
276
- > | NATIVE_BANNER | Block-level inline injection into a hook element | **Yes** — `<div id="{hookId}"></div>` |
277
- >
278
- > For EMBEDDED and NATIVE_BANNER, place a `<div id="{hookId}"></div>` at the desired position in your HTML. The `hookId` value is configured in the CustomerGlu dashboard.
279
- >
280
- > **Content types** — eleven types control what renders inside a container: `CAMPAIGN`, `WALLET`, `NUDGE`, `PROGRAM`, `REWARD` (all iframe-based), `STATIC` (image), `DYNAMIC`, `DYNAMIC_MULTISTEP_1`, `DYNAMIC_MULTISTEP_2`, `DYNAMIC_MULTISTEP_3` (native DOM progress widgets), and `ACCEPT_GUARD` (streak enrollment modal). All are configured from the CustomerGlu backend — no host-app code required.
281
- >
282
- > `gamificationRegion` is optional; omit it to use the default CustomerGlu region. See [DEVELOPER_GUIDE.md §14](DEVELOPER_GUIDE.md#14-gamification-customerglu) for the full container and content type reference.
190
+ > **Gamification is opt-in.** With the three fields above configured, campaigns and entry points are fetched and rendered automatically after `identify()` — no other host-app code is required beyond placing a `<div id="{hookId}"></div>` for EMBEDDED/NATIVE_BANNER container types. Once a user explicitly closes a campaign, it won't reopen again until a new session starts, by default — no configuration needed. See [DEVELOPER_GUIDE.md §14](DEVELOPER_GUIDE.md#14-gamification-customerglu) for the full container/content-type reference, the session-dismissal rules, and the 7 engagement-tracking events sent automatically alongside `track()`/`pageView()`.
283
191
 
284
192
  ### Direct-Config Bootstrap (No Firebase)
285
193
 
286
194
  If you don't want to depend on Firebase at all, omit `firebaseConfig` and `remoteConfigKey` from `initialize()` and pass the config directly instead:
287
195
 
288
196
  ```typescript
289
- WebSDK.initialize({
197
+ HydraSDK.initialize({
290
198
  accountId: '100458',
291
199
  baseURL: 'https://api.example.capillarytech.com',
292
200
  orgId: '100458',
293
- // Everything below is optional — same fields, same defaults as Remote Config bootstrap.
201
+ // Everything below is optional (same fields, same defaults as Remote Config bootstrap) —
202
+ // except the gamification trio, which is required together only if you want gamification.
294
203
  brandId: '1',
295
204
  applicationId: '2',
296
205
  sessionTimeoutMinutes: 30,
@@ -298,35 +207,34 @@ WebSDK.initialize({
298
207
  debugLevel: 'NONE',
299
208
  gamificationWriteKey: 'wk_live_xxxxxxxxxx',
300
209
  gamificationRegion: 'us',
210
+ gamificationBaseUrl: 'https://api-us.customerglu.com',
301
211
  });
302
212
  ```
303
213
 
304
- | Field | Required? | Notes |
305
- | --------------- | --------- | ---------------------------------------------------------------------------- |
306
- | `accountId` | **Yes** | Same field as the Remote Config JSON's `accountId` |
307
- | `baseURL` | **Yes** | Same field as the Remote Config JSON's `baseURL` |
308
- | `orgId` | **Yes** | Same field as the Remote Config JSON's `orgId` |
309
- | Everything else | No | Same optional fields and defaults as the "Auto-populated Fields" table above |
214
+ | Field | Required? | Notes |
215
+ | --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
216
+ | `accountId` | **Yes** | Same field as the Remote Config JSON's `accountId` |
217
+ | `baseURL` | **Yes** | Same field as the Remote Config JSON's `baseURL` |
218
+ | `orgId` | **Yes** | Same field as the Remote Config JSON's `orgId` |
219
+ | Everything else | No | Same fields and requirements as the "Auto-populated Fields" table above (gamification's 3 fields are still required together if enabling gamification) |
310
220
 
311
- No Firebase project is required in this mode. The one exception is push notifications, which always require Firebase regardless of bootstrap mode — see [Push Notifications](#push-notifications) below for how to create and pass a Messaging instance via `notifications.messaging`.
221
+ No Firebase project is required in this mode, except for push notifications — see [Push Notifications](#push-notifications) below.
312
222
 
313
- This is also how to use a different config source than this SDK's built-in Remote Config fetch — including Firebase Remote Config used elsewhere in your own app. Fetch your config however you like and pass the values in directly; there's nothing Firebase-specific about this mode.
223
+ This is also how to use a different config source than this SDK's built-in Remote Config fetch. Fetch your config however you like and pass the values in directly; there's nothing Firebase-specific about this mode.
314
224
 
315
225
  ---
316
226
 
317
227
  ## Public API Reference
318
228
 
319
- All 8 public methods are static and accessed via `WebSDK.*`. All methods (except `initialize`) internally wait for SDK initialization to complete before executing.
229
+ All 15 public methods are static and accessed via `HydraSDK.*`. All methods (except `initialize`) internally wait for SDK initialization to complete before executing.
320
230
 
321
231
  ### 1. `initialize(config)`
322
232
 
323
233
  Creates and initializes the SDK singleton. Must be called once before any other method. Safe to call multiple times — subsequent calls return the existing instance.
324
234
 
325
235
  ```javascript
326
- const sdk = WebSDK.initialize({
327
- firebaseConfig: {
328
- /* ... */
329
- },
236
+ const sdk = HydraSDK.initialize({
237
+ firebaseConfig: {/* ... */},
330
238
  remoteConfigKey: 'your_app_config_key',
331
239
  appVersion: '1.0.0',
332
240
  });
@@ -343,7 +251,7 @@ const sdk = WebSDK.initialize({
343
251
  Tracks a custom behavioral event.
344
252
 
345
253
  ```javascript
346
- WebSDK.track('button_click', {
254
+ HydraSDK.track('button_click', {
347
255
  button_id: 'checkout',
348
256
  page: 'cart',
349
257
  value: 99.99,
@@ -355,6 +263,10 @@ WebSDK.track('button_click', {
355
263
  | `eventName` | `string` | Yes | Name of the event |
356
264
  | `properties` | `Record<string, unknown>` | No | Custom event properties |
357
265
 
266
+ If gamification is configured and a CustomerGlu entry point is set up with `triggerType: "ACTION_EVENT"` for this `eventName`, this same `track()` call also evaluates and, if its display conditions pass, opens that entry point — no separate call is needed. Unlike screen-triggered campaigns, an `ACTION_EVENT` entry point isn't rationed by a frequency cap and isn't blocked once its campaign is marked completed — it keeps responding to every occurrence of its event.
267
+
268
+ > **Overlay campaigns queue, they don't stack.** If a matching entry point is a pop-up, bottom sheet, or chat box and another overlay campaign is already open, it waits in a priority-ordered queue and shows automatically once the current one closes — you never see two overlay campaigns on screen at once. Icon buttons, banners, and embeds are unaffected and open immediately. See [DEVELOPER_GUIDE.md's Campaign Queue section](DEVELOPER_GUIDE.md#campaign-queue) for the full ordering/persistence rules.
269
+
358
270
  ---
359
271
 
360
272
  ### 3. `pageView(options?)`
@@ -363,13 +275,13 @@ Tracks a page view event. If called with no arguments, automatically captures th
363
275
 
364
276
  ```javascript
365
277
  // Automatic capture
366
- WebSDK.pageView();
278
+ HydraSDK.pageView();
367
279
 
368
280
  // With custom options
369
- WebSDK.pageView({
370
- url: 'https://example.com/products/123',
371
- title: 'Product Detail',
372
- category: 'product',
281
+ HydraSDK.pageView({
282
+ page_url: 'https://example.com/products/123',
283
+ page_title: 'Product Detail',
284
+ page_category: 'product',
373
285
  properties: { productId: 'SKU-123' },
374
286
  });
375
287
  ```
@@ -380,12 +292,18 @@ WebSDK.pageView({
380
292
 
381
293
  **`PageViewOptions` fields:**
382
294
 
383
- | Field | Type | Description |
384
- | ------------ | ------------------------- | --------------------------------------------------------- |
385
- | `url` | `string` | Override the current page URL |
386
- | `title` | `string` | Override the current page title |
387
- | `category` | `string` | Page category (e.g., `'blog'`, `'product'`, `'checkout'`) |
388
- | `properties` | `Record<string, unknown>` | Custom properties |
295
+ | Field | Type | Description |
296
+ | --------------- | ------------------------- | --------------------------------------------------------- |
297
+ | `page_url` | `string` | Override the current page URL |
298
+ | `page_title` | `string` | Override the current page title |
299
+ | `referrer` | `string` | Override the page referrer |
300
+ | `page_category` | `string` | Page category (e.g., `'blog'`, `'product'`, `'checkout'`) |
301
+ | `properties` | `Record<string, unknown>` | Custom properties |
302
+
303
+ These same keys (`page_url`, `page_title`, `referrer`, `page_category`) are what's sent as the
304
+ `page_view` event's attributes. See
305
+ [DEVELOPER_GUIDE.md § Automatic Event Attributes](DEVELOPER_GUIDE.md#automatic-event-attributes)
306
+ for the full schema, including the automatic `scroll_depth` event.
389
307
 
390
308
  ---
391
309
 
@@ -395,7 +313,7 @@ Identifies a user (login/signup) or updates user profile attributes. This is the
395
313
 
396
314
  ```javascript
397
315
  // User login / signup
398
- WebSDK.identify({
316
+ HydraSDK.identify({
399
317
  identifier: { type: 'email', cuid: 'user@example.com' },
400
318
  actionType: 'USER_REGISTER',
401
319
  traits: {
@@ -407,7 +325,7 @@ WebSDK.identify({
407
325
  });
408
326
 
409
327
  // User profile update
410
- WebSDK.identify({
328
+ HydraSDK.identify({
411
329
  identifier: { type: 'mobile', cuid: '+1234567890' },
412
330
  actionType: 'USER_UPDATE',
413
331
  traits: {
@@ -433,16 +351,19 @@ WebSDK.identify({
433
351
 
434
352
  **`IdentifyTraits` fields:**
435
353
 
436
- | Field | Type | Description |
437
- | ----------- | ------------------------- | ----------------------------------------------- |
438
- | `firstName` | `string` | First name |
439
- | `lastName` | `string` | Last name |
440
- | `gender` | `string` | Gender |
441
- | `birthday` | `string` | Birthday |
442
- | `city` | `string` | City |
443
- | `country` | `string` | Country |
444
- | `timezone` | `string` | Timezone |
445
- | `custom` | `Record<string, unknown>` | Additional custom attributes merged into events |
354
+ | Field | Type | Description |
355
+ | ------------ | ------------------------- | ----------------------------------------------------------------------------- |
356
+ | `firstName` | `string` | First name |
357
+ | `lastName` | `string` | Last name |
358
+ | `gender` | `string` | Gender |
359
+ | `birthday` | `string` | Birthday |
360
+ | `city` | `string` | City |
361
+ | `country` | `string` | Country |
362
+ | `timezone` | `string` | Timezone |
363
+ | `email` | `string` | Secondary identifier — ignored if it duplicates the primary `identifier.type` |
364
+ | `mobile` | `string` | Secondary identifier — ignored if it duplicates the primary `identifier.type` |
365
+ | `externalId` | `string` | Secondary identifier — ignored if it duplicates the primary `identifier.type` |
366
+ | `custom` | `Record<string, unknown>` | Additional custom attributes merged into events |
446
367
 
447
368
  ---
448
369
 
@@ -451,7 +372,7 @@ WebSDK.identify({
451
372
  Returns a snapshot of the current user's identity, session, and engagement status. Only available when the user is **anonymous** — throws an error after `identify()` has been called, to prevent exposure of identified-user data.
452
373
 
453
374
  ```javascript
454
- const userInfo = WebSDK.getUser();
375
+ const userInfo = HydraSDK.getUser();
455
376
 
456
377
  console.log(userInfo.visitorId); // "visitor-abc-123"
457
378
  console.log(userInfo.isAnonymous); // true
@@ -483,7 +404,7 @@ console.log(userInfo.isFirstSession); // true
483
404
  Returns the backend-assigned anonymous visitor ID, or `null` if visitor tracking is disabled or not yet resolved. Available regardless of whether the user is identified or anonymous.
484
405
 
485
406
  ```javascript
486
- const visitorId = WebSDK.getAnonymousId();
407
+ const visitorId = HydraSDK.getAnonymousId();
487
408
  // "b3f1a2c4-..." or null
488
409
  ```
489
410
 
@@ -496,17 +417,19 @@ const visitorId = WebSDK.getAnonymousId();
496
417
  Re-enables event tracking after it was disabled. Pending events in the queue are processed.
497
418
 
498
419
  ```javascript
499
- WebSDK.enableSDK();
420
+ HydraSDK.enableSDK();
500
421
  ```
501
422
 
502
423
  ---
503
424
 
504
425
  ### 8. `disableSDK()`
505
426
 
506
- Disables event tracking. New events are dropped. Existing queued events are preserved in IndexedDB and will be sent when the SDK is re-enabled.
427
+ Disables event tracking (e.g. when tracking consent is declined). New `track()`/`pageView()` events and scroll-depth auto-tracking are dropped. Existing queued events are preserved in IndexedDB and will be sent when the SDK is re-enabled.
428
+
429
+ User identity events (`identify()`, `reset()`, `pushUserSignin`/`pushUserSignup`/`pushUserUpdate`/`pushUserSignOut`) and gamification events continue to be tracked regardless of `disableSDK()` — they are not behavioral analytics and must keep flowing even when tracking consent is not given.
507
430
 
508
431
  ```javascript
509
- WebSDK.disableSDK();
432
+ HydraSDK.disableSDK();
510
433
  ```
511
434
 
512
435
  ---
@@ -516,7 +439,7 @@ WebSDK.disableSDK();
516
439
  Signs out the current user and returns the SDK to anonymous tracking mode.
517
440
 
518
441
  ```javascript
519
- WebSDK.reset();
442
+ HydraSDK.reset();
520
443
  ```
521
444
 
522
445
  ---
@@ -526,7 +449,7 @@ WebSDK.reset();
526
449
  Stores a Capillary short-lived token and appends it as `?capToken=<value>` (or `&capToken=<value>` if the URL already has query params) to all loyalty embed URLs rendered by the SDK.
527
450
 
528
451
  ```javascript
529
- WebSDK.setCapToken('your-capillary-token');
452
+ HydraSDK.setCapToken('your-capillary-token');
530
453
  ```
531
454
 
532
455
  Call this whenever the token is refreshed. The token is persisted in the SDK's internal storage and survives page reloads. It is cleared on `reset()` / sign-out — call `setCapToken()` again after the user signs back in.
@@ -538,9 +461,109 @@ Call this whenever the token is refreshed. The token is persisted in the SDK's i
538
461
  Returns the currently stored Capillary token, or `null` if none has been set.
539
462
 
540
463
  ```javascript
541
- const token = WebSDK.getCapToken();
464
+ const token = HydraSDK.getCapToken();
465
+ ```
466
+
467
+ ---
468
+
469
+ ### 12. `setGamificationSuppressed(value)`
470
+
471
+ Suppresses (`true`) or resumes (`false`) overlay-style gamification campaigns (pop-ups, bottom sheets, chat widgets, floating icons). While suppressed, none of these open — not on a screen/path match, not from an event trigger, and not from a click inside a banner or embed. Only an explicit `openEntryPoint()` call is unaffected. Default is `false`, so existing integrations that never call this see no behavior change.
472
+
473
+ ```javascript
474
+ HydraSDK.setGamificationSuppressed(true);
475
+ // Automatic campaign rendering is suppressed.
476
+
477
+ HydraSDK.setGamificationSuppressed(false);
478
+ // Automatic campaign rendering resumes.
479
+ ```
480
+
481
+ Enabling suppression closes any overlay that's already open. Resuming re-evaluates immediately, so a campaign that became eligible while suppressed (including one closed by suppression) shows right away instead of waiting for the next page navigation. The suppression state is persisted and survives a page reload — call it once and it stays in effect until you call it again with the opposite value.
482
+
483
+ This does not apply to embed, banner, or loyalty campaigns — those target a specific element on your page by id, so they keep rendering normally regardless of this setting. Clicking one still won't open a pop-up or bottom sheet while suppressed.
484
+
485
+ ---
486
+
487
+ ### 13. `isGamificationSuppressed()`
488
+
489
+ Returns the current suppression state.
490
+
491
+ ```javascript
492
+ const suppressed = HydraSDK.isGamificationSuppressed();
493
+ console.log(suppressed); // false, unless setGamificationSuppressed(true) was called
494
+ ```
495
+
496
+ ---
497
+
498
+ ### 14. `enablePagePathTracking(enabled)`
499
+
500
+ Toggles gamification's screen/path detection between automatic (default) and manual. When automatic, the SDK detects the current path itself from `window.location.href` on every SPA navigation. When disabled, call [`onScreenChanged()`](#15-onscreenchangedscreenname) yourself on every navigation instead — useful for apps whose routing doesn't produce a real URL change (e.g. native-shell webviews, custom router state). Switching modes immediately re-evaluates gamification display rules against whichever "current path" is now appropriate. The mode is persisted and survives page reloads.
501
+
502
+ ```javascript
503
+ HydraSDK.enablePagePathTracking(false); // switch to manual mode
504
+ ```
505
+
506
+ | Parameter | Type | Required | Description |
507
+ | --------- | --------- | -------- | -------------------------------------------------- |
508
+ | `enabled` | `boolean` | Yes | `true` for automatic detection, `false` for manual |
509
+
510
+ ---
511
+
512
+ ### 15. `onScreenChanged(screenName)`
513
+
514
+ Reports the current screen when path tracking is in manual mode (see above). `screenName` is matched against entry points' path rules exactly like an auto-detected URL would be. No-op for gamification rule evaluation while automatic mode is still active.
515
+
516
+ ```javascript
517
+ HydraSDK.onScreenChanged('checkout');
542
518
  ```
543
519
 
520
+ | Parameter | Type | Required | Description |
521
+ | ------------ | -------- | -------- | ----------------------------- |
522
+ | `screenName` | `string` | Yes | The current screen/route name |
523
+
524
+ ---
525
+
526
+ ### 16. `setTheme(theme)`
527
+
528
+ Sets the gamification theme. Appends a `darkMode=true`/`darkMode=false` query param to every campaign/loyalty embed URL the SDK loads from this point on (so the CustomerGlu-hosted content can theme itself), and switches the color scheme of the SDK's own container chrome and hand-built widgets.
529
+
530
+ ```javascript
531
+ HydraSDK.setTheme('DARK');
532
+ ```
533
+
534
+ | Value | Behavior |
535
+ | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
536
+ | `NONE` | Default. No theme-specific behavior — the `darkMode` param is omitted entirely and everything renders exactly as it did before `setTheme()` existed. |
537
+ | `LIGHT` | Forces light mode (`darkMode=false`). |
538
+ | `DARK` | Forces dark mode (`darkMode=true`). |
539
+ | `AUTO` | Follows the browser's `prefers-color-scheme`, re-checked fresh every time something is rendered — no listener is registered, so a system preference change takes effect the next time a campaign opens rather than live on one already open. |
540
+
541
+ Only campaigns/loyalty embeds loaded after the call are affected — anything already on screen is left as-is. An unrecognized value is logged and ignored. The theme is persisted and survives a page reload, same as `setGamificationSuppressed()`.
542
+
543
+ | Parameter | Type | Required | Description |
544
+ | --------- | --------------------------------------- | -------- | ----------------- |
545
+ | `theme` | `'NONE' \| 'AUTO' \| 'DARK' \| 'LIGHT'` | Yes | The desired theme |
546
+
547
+ ---
548
+
549
+ ### 17. `setGamificationCallback(callback)`
550
+
551
+ Registers host-facing hooks for gamification lifecycle and content events: init success/failure, entry points loaded, campaign opened/closed, inbound analytics, deep links, and event triggers with no matching campaign. All hooks are optional; pass `null` to unregister.
552
+
553
+ ```javascript
554
+ HydraSDK.setGamificationCallback({
555
+ onInitSuccess: () => console.log('gamification ready'),
556
+ onCampaignOpened: campaignId => console.log('opened', campaignId),
557
+ onDeepLinkEvent: data => router.push(data.deepLink),
558
+ });
559
+ ```
560
+
561
+ | Parameter | Type | Required | Description |
562
+ | ---------- | ------------------------------ | -------- | ----------------------------------------- |
563
+ | `callback` | `GamificationCallback \| null` | Yes | The hooks to register, or `null` to clear |
564
+
565
+ See [DEVELOPER_GUIDE.md §6.17](DEVELOPER_GUIDE.md#617-setgamificationcallbackcallback) for the full hook reference.
566
+
544
567
  ---
545
568
 
546
569
  ## Push Notifications
@@ -562,11 +585,9 @@ push notifications; the SDK no-ops safely with no compile-time or runtime error.
562
585
  import { initializeApp } from 'firebase/app';
563
586
  import { getMessaging } from 'firebase/messaging';
564
587
 
565
- const firebaseApp = initializeApp({
566
- /* your Firebase project config */
567
- });
588
+ const firebaseApp = initializeApp({/* your Firebase project config */});
568
589
 
569
- WebSDK.initialize({
590
+ HydraSDK.initialize({
570
591
  accountId: '100458',
571
592
  baseURL: 'https://api.example.capillarytech.com',
572
593
  orgId: '100458',
@@ -594,12 +615,55 @@ If not provided, it defaults to `/firebase-messaging-sw.js`.
594
615
 
595
616
  ---
596
617
 
618
+ ## Content Security Policy (CSP)
619
+
620
+ If your application enforces a Content Security Policy (CSP), allowlist the following domains so the SDK functions correctly. Add these to your existing directives rather than replacing them — the exact set needed depends on which features you use.
621
+
622
+ **`connect-src`**
623
+
624
+ - `https://*.capillarytech.com` — core API, gamification, and loyalty traffic (always required)
625
+ - `https://*.googleapis.com`, `https://*.firebaseio.com`, `https://*.firebaseapp.com` — only if using Remote Config bootstrap and/or push notifications
626
+
627
+ **`script-src`**
628
+
629
+ - `'self'`
630
+ - `https://*.gstatic.com` — push notifications only (loads the Firebase Messaging scripts inside the service worker)
631
+
632
+ **`frame-src`**
633
+
634
+ - `https://*.capillarytech.com` — loyalty embeds and gamification iframe content types (CAMPAIGN, WALLET, NUDGE, PROGRAM, REWARD)
635
+
636
+ **`img-src`**
637
+
638
+ - `https://*.capillarytech.com` — loyalty embeds and the gamification STATIC content type
639
+
640
+ **`worker-src`**
641
+
642
+ - `'self'`, `blob:`, `data:` — required for push notifications (service worker support)
643
+
644
+ **Example:**
645
+
646
+ ```text
647
+ connect-src 'self' https://*.capillarytech.com https://*.googleapis.com https://*.firebaseio.com https://*.firebaseapp.com https://*.posthog.com;
648
+ script-src 'self' https://*.gstatic.com https://*.posthog.com;
649
+ frame-src 'self' https://*.capillarytech.com;
650
+ img-src 'self' https://*.capillarytech.com;
651
+ worker-src 'self' blob: data:;
652
+ ```
653
+
654
+ > If you're not using Remote Config bootstrap, push notifications, or gamification/loyalty, only the `capillarytech.com` and `posthog.com` entries are needed.
655
+
656
+ ---
657
+
597
658
  ## Minimum Browser Requirements
598
659
 
599
- | Browser | Minimum Version | Notes |
600
- | ------- | --------------- | ----------------------------------------------------- |
601
- | Chrome | 49+ | Full support |
602
- | Firefox | 52+ (ESR) | Full support |
603
- | Safari | 10+ | Service Worker requires 11.1+ |
604
- | Edge | 79+ (Chromium) | Full support |
605
- | IE | 11 | Limited: no Service Worker, no Push API, no Web Locks |
660
+ **Internet Explorer is not supported.** The SDK targets modern evergreen browsers only, driven by the `browserslist` field in `package.json` (`> 0.5%, last 2 versions, Firefox ESR, not dead`) — the same query used for the Babel build.
661
+
662
+ | Browser | Minimum Version | Notes |
663
+ | ------- | --------------- | ------------ |
664
+ | Chrome | 109+ | Full support |
665
+ | Firefox | 140+ (ESR) | Full support |
666
+ | Safari | 26.3+ | Full support |
667
+ | Edge | 149+ (Chromium) | Full support |
668
+
669
+ These are the versions the query above currently resolves to (`npx browserslist`), not a fixed promise — because the query includes `> 0.5%` (global usage share), the effective floor rises automatically as old versions fall out of use. Run `npx browserslist` in the repo for the current resolved list rather than trusting this table once it's been a while since it was last regenerated.