web-push-notifications 3.104.0 → 3.107.0

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/CHANGELOG.md CHANGED
@@ -9,6 +9,49 @@ the same mapping is in the
9
9
  Entries for 3.71.0 through 3.78.0 are grouped under version headings, which is how this file was
10
10
  kept before the version moved to the tag; earlier versions live only in the git history.
11
11
 
12
+ ## feat(web-popups): render products blocks from onsite recommendations
13
+
14
+ - Web popups and Inline blocks draw the `products` slot of `@pushwoosh/websdk-common`: items come from
15
+ the onsite recommendations feed (`recommendations.fetch`, block = the slot key), a card click goes out
16
+ as `PW_RecommendationClick`. The pre-show check and the render share one feed answer (`loadWebPopupProducts` of websdk-common).
17
+ - The slot's `fallbackStrategy` goes to the feed as `fallback` (absent = `none`, never the server's
18
+ default), so the feed serves it when the main strategy is empty.
19
+ - A popup whose `hideWhenEmpty` products block has nothing, fallback included, is not shown (and its
20
+ impression is not spent).
21
+ - `recommendations.fetch` accepts the `cart` strategy: the visitor's latest abandoned cart.
22
+
23
+ ## feat(web-popups): render journey web placements
24
+
25
+ - A journey point can queue a web popup or an inline block for the visitor. The web popups widget pulls
26
+ them with `getWebPlacements` on every page and SPA navigation once `getConfig` reports
27
+ `web_placements.enabled`, and renders the ones a `postEvent` response carries at once; the bundle now
28
+ loads for an application with placements and no campaigns.
29
+ - An inline placement goes into its element ahead of the EMBEDDED campaigns there, one per element (the
30
+ higher priority, the newer on a tie), at its `width`, with a ✕ when it is dismissible; one the server
31
+ stops returning leaves the page. A placement popup takes the display slot ahead of the campaigns. A content
32
+ with a form is refused, as when opened by its content code.
33
+ - Shows (once per page load; an inline block on entering the viewport), clicks and dismisses go to
34
+ `trackWebPlacement`, not to `postEvent`, so they never take the `msgHash` of the last opened push.
35
+ - `webPlacements: { enable: false }` in the init params ignores placements; `webPopups.enable: false` turns
36
+ them off too.
37
+
38
+ ## feat(init): warn about unknown init parameters
39
+
40
+ - `init` writes a `console.warn` for every top-level key the SDK does not know, with the closest known
41
+ key within two edits (`subscribePop` → `subscribePopup`), and for `enabled` on a widget that has no
42
+ `enable` (`subscribeWidget`, `subscribePopup`, `inboxWidget`, `webPopups`). Nothing else changes: the
43
+ key is still ignored, as before.
44
+
45
+ ## fix(events): keep the letter case of the page path in PW_SiteOpened and page rules
46
+
47
+ - `path` in `PW_SiteOpened` keeps the site's letter case (`/Catalog/Shoes/`); a path that does not decode is sent
48
+ as it is. Web campaign page rules (`matching_page_rules`, `matching_pages`, `excluded_pages`) are compared with
49
+ this path case-sensitively, the rule path as stored: `/Catalog` and `/catalog` are different pages.
50
+ - A page rule whose case differs from the site's no longer matches its pages, e.g. `/catalog` saved lowercased on
51
+ `/Catalog`: re-save it in the site's case.
52
+ - A `path` condition in lowercase does not find new events from pages with capitals; events sent by the previous
53
+ release stay lowercased.
54
+
12
55
  ## feat(locale): send the browser locale on application open
13
56
 
14
57
  - `applicationOpen` and `registerDevice` carry a `locale` field (BCP 47, e.g. `pt-BR`): the device language value,
@@ -9,6 +9,7 @@ import { Recommendations } from '../modules/Recommendations/Recommendations';
9
9
  import { type IProductView } from '../modules/Recommendations/Recommendations.types';
10
10
  import { type TPushPermissionStatus } from '../services/PushService/pushPermissionStatus';
11
11
  import { type IPushService } from '../services/PushService/PushService.types';
12
+ import { type WebPlacement } from '../widgets/WebPopups/types';
12
13
  export declare class Pushwoosh {
13
14
  ready: boolean;
14
15
  initParams: IInitParams;
@@ -38,6 +39,13 @@ export declare class Pushwoosh {
38
39
  readonly recommendations: Recommendations;
39
40
  widgetLoader?: (widgetName: string) => Promise<boolean>;
40
41
  constructor();
42
+ /** Placements a postEvent response carried before the web popups widget took over delivery. */
43
+ private pendingWebPlacements;
44
+ /** Set by the web popups widget once it renders placements itself. */
45
+ webPlacementsSink: ((placements: Array<WebPlacement>) => void) | null;
46
+ /** Hands the buffered placements to the widget, emptying the buffer. */
47
+ takeWebPlacements(): Array<WebPlacement>;
48
+ private deliverWebPlacements;
41
49
  private loadWebPopupsWidget;
42
50
  /**
43
51
  * Add Web SDK Event Handler.
@@ -2,7 +2,7 @@ import { type INotificationButton } from '../models/NotificationPayload.types';
2
2
  import { type IRecommendationsConfig } from '../modules/Recommendations/Recommendations.types';
3
3
  import { type ISubscribePopupConfig } from '../widgets/SubscribePopup/types/subscribe-popup';
4
4
  import { type ISubscriptionWidgetParams, type ISubscriptionWidgetPublicApi } from '../widgets/SubscriptionWidget/types';
5
- import { type IWebPopupsConfig, type IWebPopupsPublicApi } from '../widgets/WebPopups/types';
5
+ import { type IWebPlacementsConfig, type IWebPopupsConfig, type IWebPopupsPublicApi } from '../widgets/WebPopups/types';
6
6
  /**
7
7
  * Widgets publish their programmatic interfaces here, keyed by widget name, so
8
8
  * a site can drive them from its own code. Every entry is optional, and when it
@@ -149,6 +149,8 @@ export interface IInitParams {
149
149
  /** The unified subscription widget; while its prompt or bell is on — or whenever the panel saved it — `subscribeWidget`, `subscribePopup` and the Subscription Prompt stay off. */
150
150
  subscriptionWidget?: ISubscriptionWidgetParams;
151
151
  webPopups?: IWebPopupsConfig;
152
+ /** Journey web placements; rendered by the web popups widget, so `webPopups.enable: false` turns them off too. */
153
+ webPlacements?: IWebPlacementsConfig;
152
154
  recommendations?: IRecommendationsConfig;
153
155
  webSDKPath?: string;
154
156
  unifiedPlatform?: boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { type WebPopupHideReason, type WebPopupShowTrigger } from '../widgets/WebPopups/types';
1
+ import { type WebPlacement, type WebPopupHideReason, type WebPopupShowTrigger } from '../widgets/WebPopups/types';
2
2
  export type EventPayload<Parameters extends Record<string, unknown>> = Parameters & Record<'eventId', string>;
3
3
  export type EventHandler<Payload extends EventPayload<Record<string, unknown>>> = (payload: Payload) => void | Promise<void>;
4
4
  export interface EventHandlerMap {
@@ -51,6 +51,9 @@ export interface EventHandlerMap {
51
51
  'receive-in-app-code': EventHandler<EventPayload<{
52
52
  code: string;
53
53
  }>>;
54
+ 'receive-web-placements': EventHandler<EventPayload<{
55
+ placements: Array<WebPlacement>;
56
+ }>>;
54
57
  'subscribe-popup-ready': EventHandler<EventPayload<Record<string, never>>>;
55
58
  'subscribe-popup-show': EventHandler<EventPayload<Record<string, never>>>;
56
59
  'subscribe-popup-hide': EventHandler<EventPayload<Record<string, never>>>;
@@ -0,0 +1,6 @@
1
+ export interface IUnknownInitKey {
2
+ key: string;
3
+ suggestion?: string;
4
+ }
5
+ export declare function findUnknownInitKeys(params: object): IUnknownInitKey[];
6
+ export declare function warnUnknownInitKeys(params: object): void;
@@ -1,2 +1,2 @@
1
- /** The page path events and page rules use: decoded and lowercased, read anew on every call. */
1
+ /** The page path events and page rules use: decoded, in the site's case, read anew on every call. */
2
2
  export declare function getPagePath(): string;
@@ -2,7 +2,7 @@ import { type WebPopupFormValues } from '@pushwoosh/websdk-common/web-popups';
2
2
  import { type MultiRegisterDeviceRequest } from './Api.types';
3
3
  import { type EventBus } from '../../core/modules/EventBus';
4
4
  import { type TPushPermissionStatus } from '../../services/PushService/pushPermissionStatus';
5
- import { type WebPopup } from '../../widgets/WebPopups/types';
5
+ import { type WebPlacement, type WebPlacementAction, type WebPopup } from '../../widgets/WebPopups/types';
6
6
  import { ApiClient, type IRequestInit } from '../ApiClient/ApiClient';
7
7
  import { type IMapResponse } from '../ApiClient/ApiClient.types';
8
8
  import { Data } from '../Data/Data';
@@ -54,6 +54,8 @@ export declare class Api {
54
54
  getPopupForms(): Promise<Array<WebPopup>>;
55
55
  getPopupFormContent(code: string): Promise<IMapResponse['getPopupFormContent']>;
56
56
  recordPopupFormEvent(code: string, event: 1 | 2 | 3): Promise<IMapResponse['recordPopupFormEvent']>;
57
+ getWebPlacements(): Promise<Array<WebPlacement>>;
58
+ trackWebPlacement(hash: string, action: WebPlacementAction): Promise<IMapResponse['trackWebPlacement']>;
57
59
  submitPopupForm(code: string, values: WebPopupFormValues): Promise<IMapResponse['submitPopupForm']>;
58
60
  sdkUsage(report: ISdkUsageReport, init?: IRequestInit): Promise<IMapResponse['sdkUsage']>;
59
61
  postEvent(event: string, attributes: {
@@ -14,6 +14,8 @@ export declare class ApiClient {
14
14
  getPopupFormContent(options: IMapRequest['getPopupFormContent']): Promise<IMapResponse['getPopupFormContent']>;
15
15
  recordPopupFormEvent(options: IMapRequest['recordPopupFormEvent']): Promise<IMapResponse['recordPopupFormEvent']>;
16
16
  submitPopupForm(options: IMapRequest['submitPopupForm']): Promise<IMapResponse['submitPopupForm']>;
17
+ getWebPlacements(options: IMapRequest['getWebPlacements']): Promise<IMapResponse['getWebPlacements']>;
18
+ trackWebPlacement(options: IMapRequest['trackWebPlacement']): Promise<IMapResponse['trackWebPlacement']>;
17
19
  applicationOpen(options: IMapRequest['applicationOpen']): Promise<IMapResponse['applicationOpen']>;
18
20
  registerDevice(options: IMapRequest['registerDevice']): Promise<IMapResponse['registerDevice']>;
19
21
  unregisterDevice(options: IMapRequest['unregisterDevice']): Promise<IMapResponse['unregisterDevice']>;
@@ -1,7 +1,7 @@
1
1
  import { type IServerInitParams, type IServerModules } from '../../core/resolveInitParams';
2
2
  import { type IInboxMessage } from '../../models/InboxMessages.types';
3
3
  import { type TPushPermissionStatus } from '../../services/PushService/pushPermissionStatus';
4
- import { type WebPopup } from '../../widgets/WebPopups/types';
4
+ import { type WebPlacement, type WebPlacementAction, type WebPopup } from '../../widgets/WebPopups/types';
5
5
  import { type MultiRegisterDeviceRequest } from '../Api/Api.types';
6
6
  type TMethodCheckDevice = 'checkDevice';
7
7
  type TMethodGetConfig = 'getConfig';
@@ -28,6 +28,8 @@ type TMethodGetInboxMessages = 'getInboxMessages';
28
28
  type TMethodInboxStatus = 'inboxStatus';
29
29
  type TMethodMultiRegisterDevice = 'multiRegisterDevice';
30
30
  type TMethodSdkUsage = 'sdkUsage';
31
+ type TMethodGetWebPlacements = 'getWebPlacements';
32
+ type TMethodTrackWebPlacement = 'trackWebPlacement';
31
33
  export interface IRequest {
32
34
  application: string;
33
35
  hwid: string;
@@ -177,6 +179,14 @@ interface IRequestSdkUsage extends IRequest {
177
179
  }
178
180
  interface IResponsePostEvent {
179
181
  code?: string;
182
+ web_placements?: Array<WebPlacement>;
183
+ }
184
+ interface IRequestTrackWebPlacement extends IRequest {
185
+ hash: string;
186
+ action: WebPlacementAction;
187
+ }
188
+ interface IResponseGetWebPlacements {
189
+ web_placements?: Array<WebPlacement>;
180
190
  }
181
191
  interface IResponseGetInboxMessages {
182
192
  messages: Array<IInboxMessage>;
@@ -184,7 +194,7 @@ interface IResponseGetInboxMessages {
184
194
  deleted: Array<string>;
185
195
  new_inbox: number;
186
196
  }
187
- export type TMethod = TMethodCheckDevice | TMethodGetConfig | TMethodApplicationOpen | TMethodRegisterDevice | TMethodUnregisterDevice | TMethodDeleteDevice | TMethodMessageDeliveryEvent | TMethodPushStat | TMethodSetTags | TMethodGetTags | TMethodRegisterUser | TMethodRegisterEmail | TMethodRegisterEmailUser | TMethodRegisterSmsNumber | TMethodRegisterWhatsappNumber | TMethodGetPopupForms | TMethodGetPopupFormContent | TMethodRecordPopupFormEvent | TMethodSubmitPopupForm | TMethodSetEmailTags | TMethodPostEvent | TMethodGetInboxMessages | TMethodInboxStatus | TMethodMultiRegisterDevice | TMethodSdkUsage;
197
+ export type TMethod = TMethodCheckDevice | TMethodGetConfig | TMethodApplicationOpen | TMethodRegisterDevice | TMethodUnregisterDevice | TMethodDeleteDevice | TMethodMessageDeliveryEvent | TMethodPushStat | TMethodSetTags | TMethodGetTags | TMethodRegisterUser | TMethodRegisterEmail | TMethodRegisterEmailUser | TMethodRegisterSmsNumber | TMethodRegisterWhatsappNumber | TMethodGetPopupForms | TMethodGetPopupFormContent | TMethodRecordPopupFormEvent | TMethodSubmitPopupForm | TMethodSetEmailTags | TMethodPostEvent | TMethodGetInboxMessages | TMethodInboxStatus | TMethodMultiRegisterDevice | TMethodSdkUsage | TMethodGetWebPlacements | TMethodTrackWebPlacement;
188
198
  export interface IMapRequest {
189
199
  checkDevice: IRequest;
190
200
  getConfig: IRequestGetConfig;
@@ -211,6 +221,8 @@ export interface IMapRequest {
211
221
  inboxStatus: IRequestInboxStatus;
212
222
  multiRegisterDevice: MultiRegisterDeviceRequest;
213
223
  sdkUsage: IRequestSdkUsage;
224
+ getWebPlacements: IRequest;
225
+ trackWebPlacement: IRequestTrackWebPlacement;
214
226
  }
215
227
  export interface IMapResponse {
216
228
  checkDevice: IResponseCheckDevice;
@@ -238,5 +250,7 @@ export interface IMapResponse {
238
250
  inboxStatus: IResponse;
239
251
  multiRegisterDevice: IResponse;
240
252
  sdkUsage: IResponse;
253
+ getWebPlacements: IResponseGetWebPlacements;
254
+ trackWebPlacement: IResponse;
241
255
  }
242
256
  export {};
@@ -1,4 +1,4 @@
1
- export type TRecommendationStrategy = 'viewed' | 'bestsellers_30d' | 'also_bought';
1
+ export type TRecommendationStrategy = 'viewed' | 'bestsellers_30d' | 'also_bought' | 'cart';
2
2
  export interface IRecommendationsConfig {
3
3
  /** Base URL of the onsite feed; the NUE deployment by default. */
4
4
  endpoint?: string;