@koredev/kore-web-sdk 11.18.0-rc.f92a18a → 11.19.0-rc.b432c67

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
@@ -237,7 +235,12 @@ declare class ProactiveWebCampaignPlugin {
237
235
  * @returns true if the recent journey matches the required sequence, false otherwise
238
236
  */
239
237
  isJourneyValid(pageVisitArray: any, websiteArray: any): boolean;
240
- checkEngagementHours(engHours: any): boolean;
238
+ /**
239
+ * Checks if the current time is within the engagement hours specified in engStrategy
240
+ * @param engStrategy - Engagement strategy object with engagement hours settings
241
+ * @returns {boolean} - Returns true if current time is within engagement hours, false otherwise
242
+ */
243
+ checkEngagementHours(engStrategy: any): boolean;
241
244
  createTimeSpentObjs(): void;
242
245
  getLocationDetails(): void;
243
246
  /**
@@ -281,11 +284,48 @@ declare class ProactiveWebCampaignPlugin {
281
284
  * @returns Location name or null if not found
282
285
  */
283
286
  findLocationByType(response: any[], targetType: string): string | null;
284
- 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;
285
325
  /**
286
326
  * Constructs the pwe_data object based on the new campaign structure
287
327
  * Extracts custom column configurations and initializes custom data
288
- * @param campaignData - Campaign data received from socket
328
+ * @param campaignData - Campaign data received from API
289
329
  * @returns Constructed pwe_data object
290
330
  */
291
331
  constructPweData(campaignData: any): any;
@@ -331,7 +371,7 @@ declare class ProactiveWebCampaignPlugin {
331
371
  setupHoverListenerForCondition(condition: any, campInstanceId: string, group: any, groupIndex: number, conditionIndex: number, type: string): void;
332
372
  /**
333
373
  * Constructs rules/exclusions structure with proper grouping and condition tracking
334
- * Reads 'globalType' from socket message but stores as 'groupType' internally
374
+ * Reads 'globalType' from API response but stores as 'groupType' internally
335
375
  * @param rulesConfig - Rules or exclusions configuration
336
376
  * @returns Structured rules object
337
377
  */
@@ -342,6 +382,12 @@ declare class ProactiveWebCampaignPlugin {
342
382
  * @returns Object with conditions grouped by column
343
383
  */
344
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;
345
391
  /**
346
392
  * Checks if a campaign has a specific condition type configured in RULES
347
393
  * @param campaign - Campaign object
@@ -580,11 +626,11 @@ declare class ProactiveWebCampaignPlugin {
580
626
  */
581
627
  updateSatisfactionFlags(campInstanceId: string): void;
582
628
  /**
583
- * Triggers campaign event using existing API logic
629
+ * Triggers campaign event using API and handles response
584
630
  * @param campInstanceId - Campaign instance ID
585
631
  * @param campId - Campaign ID
586
632
  */
587
- triggerCampaignEvent(campInstanceId: string, campId: string): void;
633
+ triggerCampaignEvent(campInstanceId: string, campId: string, campaignData: any): Promise<void>;
588
634
  /**
589
635
  * Checks if any campaign template is active
590
636
  * @returns Boolean indicating if any campaign template is active
@@ -621,22 +667,11 @@ declare class ProactiveWebCampaignPlugin {
621
667
  * Only called during page load/refresh - has error handling fallback
622
668
  */
623
669
  restoreCooldownState(): void;
624
- /**
625
- * Initialize chat session state from sessionStorage
626
- */
627
- initializeChatSessionState(): void;
628
670
  /**
629
671
  * Check if chat window is currently open
630
672
  * Note: When minimize class is present, chat window is actually OPEN
631
673
  * @returns true if chat window is open, false if closed/minimized
632
674
  */
633
675
  isChatWindowOpen(): boolean;
634
- /**
635
- * Update chat session state based on received events
636
- * Handles Session_Start, Session_End, and Bot_Active events
637
- * @param eventType - Type of event received
638
- * @param data - Event data
639
- */
640
- updateChatSessionState(eventType: 'Session_Start' | 'Session_End' | 'Bot_Active', data: any): void;
641
676
  }
642
677
  export default ProactiveWebCampaignPlugin;