cap-hydra-web-sdk 1.0.6 → 1.0.8-beta.20260325123739
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 +71 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -145,6 +145,10 @@ class SDKService {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
getUser() {
|
|
149
|
+
return WebSDK.getUser();
|
|
150
|
+
}
|
|
151
|
+
|
|
148
152
|
reset() {
|
|
149
153
|
WebSDK.reset();
|
|
150
154
|
}
|
|
@@ -193,15 +197,43 @@ SDK configuration values like `accountId`, `baseURL`, `debugLevel`, etc. are aut
|
|
|
193
197
|
|
|
194
198
|
### Auto-populated Fields (from Remote Config)
|
|
195
199
|
|
|
196
|
-
The following fields are fetched from Firebase Remote Config. **Do not set them manually
|
|
197
|
-
|
|
198
|
-
|
|
200
|
+
The following fields are fetched from Firebase Remote Config. **Do not set them manually.**
|
|
201
|
+
|
|
202
|
+
| Field | Required | Default | Description |
|
|
203
|
+
| ----------------------- | -------- | --------- | ------------------------------------------------------------ |
|
|
204
|
+
| `accountId` | Yes | — | Organization account identifier |
|
|
205
|
+
| `baseURL` | Yes | — | API base URL for all SDK requests |
|
|
206
|
+
| `orgId` | Yes | — | Organization ID for API authentication |
|
|
207
|
+
| `brandId` | No | — | Brand identifier for namespaced database names |
|
|
208
|
+
| `applicationId` | No | — | Application identifier for namespaced database names |
|
|
209
|
+
| `source` | No | `WEBPUSH` | Source identifier for visitor profiles |
|
|
210
|
+
| `channelType` | No | `web` | Communication channel type |
|
|
211
|
+
| `sessionTimeoutMinutes` | No | `30` | Session inactivity timeout in minutes |
|
|
212
|
+
| `batchSize` | No | `50` | Max events per batch request |
|
|
213
|
+
| `debugLevel` | No | `NONE` | Logging level (`NONE` / `ERROR` / `WARN` / `INFO` / `DEBUG`) |
|
|
214
|
+
|
|
215
|
+
**Example Remote Config JSON** (stored as the value of your `remoteConfigKey` in Firebase Console):
|
|
216
|
+
|
|
217
|
+
```json
|
|
218
|
+
{
|
|
219
|
+
"accountId": "100458",
|
|
220
|
+
"baseURL": "https://api.example.capillarytech.com",
|
|
221
|
+
"orgId": "100458",
|
|
222
|
+
"brandId": "1",
|
|
223
|
+
"applicationId": "2",
|
|
224
|
+
"source": "WEBPUSH",
|
|
225
|
+
"channelType": "web",
|
|
226
|
+
"sessionTimeoutMinutes": 30,
|
|
227
|
+
"batchSize": 50,
|
|
228
|
+
"debugLevel": "NONE"
|
|
229
|
+
}
|
|
230
|
+
```
|
|
199
231
|
|
|
200
232
|
---
|
|
201
233
|
|
|
202
234
|
## Public API Reference
|
|
203
235
|
|
|
204
|
-
All
|
|
236
|
+
All 8 public methods are static and accessed via `WebSDK.*`. All methods (except `initialize`) internally wait for SDK initialization to complete before executing.
|
|
205
237
|
|
|
206
238
|
### 1. `initialize(config)`
|
|
207
239
|
|
|
@@ -318,7 +350,39 @@ WebSDK.identify({
|
|
|
318
350
|
|
|
319
351
|
---
|
|
320
352
|
|
|
321
|
-
### 5. `
|
|
353
|
+
### 5. `getUser()`
|
|
354
|
+
|
|
355
|
+
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.
|
|
356
|
+
|
|
357
|
+
```javascript
|
|
358
|
+
const userInfo = WebSDK.getUser();
|
|
359
|
+
|
|
360
|
+
console.log(userInfo.visitorId); // "visitor-abc-123"
|
|
361
|
+
console.log(userInfo.isAnonymous); // true
|
|
362
|
+
console.log(userInfo.sessionNumber); // 1
|
|
363
|
+
console.log(userInfo.isFirstSession); // true
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Returns:** `UserInfo`
|
|
367
|
+
|
|
368
|
+
| Field | Type | Description |
|
|
369
|
+
| ------------------- | --------------------------------- | ------------------------------------- |
|
|
370
|
+
| `visitorId` | `string` | The anonymous visitor ID |
|
|
371
|
+
| `userId` | `string \| null` | Always `null` for anonymous users |
|
|
372
|
+
| `sessionId` | `string` | The current session ID |
|
|
373
|
+
| `isIdentified` | `boolean` | Always `false` for anonymous users |
|
|
374
|
+
| `isAnonymous` | `boolean` | Always `true` for anonymous users |
|
|
375
|
+
| `profileTier` | `'anonymous' \| 'known'` | Always `'anonymous'` for anonymous users |
|
|
376
|
+
| `attributes` | `Record<string, unknown> \| null` | Always `null` for anonymous users |
|
|
377
|
+
| `sessionNumber` | `number` | Number of sessions for this visitor |
|
|
378
|
+
| `isFirstSession` | `boolean` | `true` when `sessionNumber === 1` |
|
|
379
|
+
| `isReturningVisitor`| `boolean` | `true` when `sessionNumber > 1` |
|
|
380
|
+
|
|
381
|
+
**Throws:** `Error` if the user is identified (i.e., after `identify()` has been called).
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
### 6. `enableSDK()`
|
|
322
386
|
|
|
323
387
|
Re-enables event tracking after it was disabled. Pending events in the queue are processed.
|
|
324
388
|
|
|
@@ -328,7 +392,7 @@ WebSDK.enableSDK();
|
|
|
328
392
|
|
|
329
393
|
---
|
|
330
394
|
|
|
331
|
-
###
|
|
395
|
+
### 7. `disableSDK()`
|
|
332
396
|
|
|
333
397
|
Disables event tracking. New events are dropped. Existing queued events are preserved in IndexedDB and will be sent when the SDK is re-enabled.
|
|
334
398
|
|
|
@@ -338,7 +402,7 @@ WebSDK.disableSDK();
|
|
|
338
402
|
|
|
339
403
|
---
|
|
340
404
|
|
|
341
|
-
###
|
|
405
|
+
### 8. `reset()`
|
|
342
406
|
|
|
343
407
|
Signs out the current user and returns the SDK to anonymous tracking mode.
|
|
344
408
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { WebSDK as default } from '@/core/init';
|
|
2
|
-
export { DebugLevel, FirebaseConfig, Identifier, IdentifierType, IdentifyActionType, IdentifyParams, IdentifyTraits, NotificationConfig, NotificationPayload, NotificationState, PageViewOptions, UserAttributes, WebSDKConfig } from '@/shared/types';
|
|
2
|
+
export { DebugLevel, FirebaseConfig, Identifier, IdentifierType, IdentifyActionType, IdentifyParams, IdentifyTraits, NotificationConfig, NotificationPayload, NotificationState, PageViewOptions, UserAttributes, UserInfo, WebSDKConfig } from '@/shared/types';
|