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