crexperium-sdk 1.2.2 → 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);