@koredev/kore-web-sdk 11.18.0-rc.fbcaa35 → 11.19.0-rc.bb3daf8

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.
@@ -24,6 +24,8 @@ declare class ProactiveWebCampaignPlugin {
24
24
  static readonly MAX_FLATTEN_DEPTH = 10;
25
25
  private static readonly ACTIVE_CAMPAIGN_SELECTOR;
26
26
  private static readonly CHAT_CONTAINER_SELECTOR;
27
+ private static readonly MAX_API_RETRIES;
28
+ private static readonly RETRY_DELAY_MS;
27
29
  isPendingSendAPIEvent: boolean;
28
30
  coolDownTime: number;
29
31
  cooldownState: {
@@ -31,9 +33,6 @@ declare class ProactiveWebCampaignPlugin {
31
33
  startTime: number;
32
34
  expiryTime: number;
33
35
  };
34
- isVisitorAlreadyChatting: boolean;
35
- private chatSessionInfo;
36
- private static readonly CHAT_SESSION_STORAGE_KEY;
37
36
  constructor(config: any);
38
37
  /**
39
38
  * Generates a unique browser session ID for the campaign trigger session
@@ -132,7 +131,6 @@ declare class ProactiveWebCampaignPlugin {
132
131
  * @param campaigns - Array of campaign data
133
132
  */
134
133
  extractCustomColumns(campaigns: any[]): void;
135
- sendPWCStartEvent(): void;
136
134
  installPWCTemplates(): void;
137
135
  /**
138
136
  * Creates targeted timers for timeSpent conditions instead of polling every second
@@ -286,11 +284,48 @@ declare class ProactiveWebCampaignPlugin {
286
284
  * @returns Location name or null if not found
287
285
  */
288
286
  findLocationByType(response: any[], targetType: string): string | null;
289
- sendApiEvent(payload: string, route: string, campInstanceId?: string): Promise<void>;
287
+ /**
288
+ * Sends API event with retry logic
289
+ * @param payload - Event payload
290
+ * @param route - API route
291
+ * @param retryCount - Number of retries remaining (default: MAX_API_RETRIES)
292
+ * @returns Promise with API response
293
+ */
294
+ sendApiEvent(payload: any, route: string, retryCount?: number): Promise<any>;
295
+ /**
296
+ * Determines if an HTTP status code should trigger a retry
297
+ * Retries: 429 (Rate Limit), 5xx (Server Errors)
298
+ * Does NOT retry: 4xx (Client Errors, except 429)
299
+ * @param statusCode - HTTP status code
300
+ * @returns Boolean indicating if retry should happen
301
+ */
302
+ private shouldRetryStatusCode;
303
+ /**
304
+ * Initializes PWC campaigns by calling the pwe_verify API
305
+ */
306
+ initializePWCCampaigns(): Promise<void>;
307
+ /**
308
+ * Restores PWC state from sessionStorage for multi-page apps
309
+ * Called when pwe_data exists but in-memory state is lost (page navigation)
310
+ * Reconstructs campInfo from stored data to avoid redundant API calls
311
+ * @returns Boolean indicating if restoration was successful
312
+ */
313
+ restorePWCStateFromStorage(): boolean;
314
+ /**
315
+ * Handles the pwe_verify API response
316
+ * Processes campaign configuration and initializes PWC system
317
+ * @param responseData - API response data
318
+ */
319
+ handlePweVerifyResponse(responseData: any): Promise<void>;
320
+ /**
321
+ * Handles the pwe_event API response and renders campaign templates
322
+ * @param responseData - API response data
323
+ */
324
+ handlePweEventResponse(responseData: any): void;
290
325
  /**
291
326
  * Constructs the pwe_data object based on the new campaign structure
292
327
  * Extracts custom column configurations and initializes custom data
293
- * @param campaignData - Campaign data received from socket
328
+ * @param campaignData - Campaign data received from API
294
329
  * @returns Constructed pwe_data object
295
330
  */
296
331
  constructPweData(campaignData: any): any;
@@ -336,7 +371,7 @@ declare class ProactiveWebCampaignPlugin {
336
371
  setupHoverListenerForCondition(condition: any, campInstanceId: string, group: any, groupIndex: number, conditionIndex: number, type: string): void;
337
372
  /**
338
373
  * Constructs rules/exclusions structure with proper grouping and condition tracking
339
- * Reads 'globalType' from socket message but stores as 'groupType' internally
374
+ * Reads 'globalType' from API response but stores as 'groupType' internally
340
375
  * @param rulesConfig - Rules or exclusions configuration
341
376
  * @returns Structured rules object
342
377
  */
@@ -347,6 +382,12 @@ declare class ProactiveWebCampaignPlugin {
347
382
  * @returns Object with conditions grouped by column
348
383
  */
349
384
  groupConditionsByColumn(conditions: any[]): any;
385
+ /**
386
+ * Reconstructs RAW rules format from PROCESSED format stored in pwe_data
387
+ * @param processedRules - Processed rules structure from pwe_data.expected
388
+ * @returns RAW rules structure matching original API format
389
+ */
390
+ reconstructRawRulesFromProcessed(processedRules: any): any;
350
391
  /**
351
392
  * Checks if a campaign has a specific condition type configured in RULES
352
393
  * @param campaign - Campaign object
@@ -585,11 +626,11 @@ declare class ProactiveWebCampaignPlugin {
585
626
  */
586
627
  updateSatisfactionFlags(campInstanceId: string): void;
587
628
  /**
588
- * Triggers campaign event using existing API logic
629
+ * Triggers campaign event using API and handles response
589
630
  * @param campInstanceId - Campaign instance ID
590
631
  * @param campId - Campaign ID
591
632
  */
592
- triggerCampaignEvent(campInstanceId: string, campId: string): void;
633
+ triggerCampaignEvent(campInstanceId: string, campId: string, campaignData: any): Promise<void>;
593
634
  /**
594
635
  * Checks if any campaign template is active
595
636
  * @returns Boolean indicating if any campaign template is active
@@ -626,22 +667,11 @@ declare class ProactiveWebCampaignPlugin {
626
667
  * Only called during page load/refresh - has error handling fallback
627
668
  */
628
669
  restoreCooldownState(): void;
629
- /**
630
- * Initialize chat session state from sessionStorage
631
- */
632
- initializeChatSessionState(): void;
633
670
  /**
634
671
  * Check if chat window is currently open
635
672
  * Note: When minimize class is present, chat window is actually OPEN
636
673
  * @returns true if chat window is open, false if closed/minimized
637
674
  */
638
675
  isChatWindowOpen(): boolean;
639
- /**
640
- * Update chat session state based on received events
641
- * Handles Session_Start, Session_End, and Bot_Active events
642
- * @param eventType - Type of event received
643
- * @param data - Event data
644
- */
645
- updateChatSessionState(eventType: 'Session_Start' | 'Session_End' | 'Bot_Active', data: any): void;
646
676
  }
647
677
  export default ProactiveWebCampaignPlugin;