crexperium-sdk 1.2.1 → 1.2.3

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/dist/index.js CHANGED
@@ -451,11 +451,43 @@ class EventsResource extends BaseResource {
451
451
  */
452
452
  class ContactsResource extends BaseResource {
453
453
  /**
454
- * Identify a contact (create or update)
454
+ * Identify a contact (create or update by multiple identifiers)
455
+ *
456
+ * Accepts at least ONE of: externalId, visitorId, email, or phone
457
+ * Priority: externalId > visitorId > email > phone
458
+ *
459
+ * @example
460
+ * // Identify by external ID (after login)
461
+ * await client.contacts.identify({
462
+ * externalId: 'user_123',
463
+ * email: 'user@example.com',
464
+ * firstName: 'John'
465
+ * });
466
+ *
467
+ * @example
468
+ * // Identify by visitor ID (anonymous → known)
469
+ * await client.contacts.identify({
470
+ * visitorId: client.visitorId.getVisitorId(),
471
+ * email: 'user@example.com'
472
+ * });
473
+ *
474
+ * @example
475
+ * // Identify by email only
476
+ * await client.contacts.identify({
477
+ * email: 'user@example.com',
478
+ * firstName: 'John'
479
+ * });
480
+ *
481
+ * @example
482
+ * // Identify by phone only
483
+ * await client.contacts.identify({
484
+ * phone: '+1234567890'
485
+ * });
455
486
  */
456
487
  async identify(options) {
457
- if (!options.externalId) {
458
- throw new Error('externalId is required');
488
+ // Validate that at least one identifier is provided
489
+ if (!options.externalId && !options.visitorId && !options.email && !options.phone) {
490
+ throw new Error('At least one identifier is required: externalId, visitorId, email, or phone');
459
491
  }
460
492
  const data = this.cleanObject(this.toSnakeCase(options));
461
493
  return this.http.post('/api/v1/contacts/identify/', data);
@@ -13195,6 +13227,12 @@ class SessionReplayPlugin {
13195
13227
  console.log('[SessionReplay] Starting rrweb recording...');
13196
13228
  this.startRrwebRecording();
13197
13229
  console.log('[SessionReplay] rrweb recording started');
13230
+ // IMPORTANT: Flush initial events (Type 4 Meta + Type 2 Full Snapshot) immediately
13231
+ // so the session is playable right away, don't wait for the 5s flush interval
13232
+ setTimeout(() => {
13233
+ console.log('[SessionReplay] Performing initial flush of critical events...');
13234
+ this.flush();
13235
+ }, 100); // Small delay to ensure rrweb events are captured
13198
13236
  // Intercept console methods
13199
13237
  if (this.config.telemetry?.captureConsole) {
13200
13238
  this.interceptConsole();