web-push-notifications 3.115.0 → 3.117.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,30 @@ 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
+ ## refactor(platform-checker): split browser detection into pure functions
13
+
14
+ - `PlatformChecker` is split into `detectBrowser`, `getFormFactor`, `getPushCapabilities` and `resolvePlatform`; the
15
+ class stays as a facade for sites that read `Pushwoosh.platformChecker`, its remaining getters marked deprecated.
16
+ - The Safari driver choice no longer reads the user agent: the legacy path follows `window.safari.pushNotification`.
17
+ The platform code comes from that path and `unifiedPlatform`; the user agent only tells Firefox (`12`) from the rest.
18
+ - Device type and device model sent with `registerDevice` are unchanged. Legacy EdgeHTML, which no longer exists in
19
+ the wild, is reported as `11` instead of the unrouted `150`.
20
+ - The subscription button shows the Safari help images to every Safari, iOS included; iOS Safari used to get Chrome's.
21
+ - `platformChecker` behaviour changes for sites that read it: `isSafari` now means `window.safari.pushNotification`
22
+ exists, where it used to need only `window.safari` and "Safari" in the user agent; `isEdge` is now true for Chromium
23
+ Edge.
24
+ - Breaking for sites that call them: the `isSafariBrowser`, `isOperaBrowser`, `isEdgeBrowser`, `isFirefoxBrowser`,
25
+ `isChromeBrowser`, `isMacOS`, `canUseServiceWorkers` and `canReceiveNotifications` methods are removed. Use
26
+ `browser.name`, `capabilities` and `isAvailableNotifications` instead; `isMacOS` has no replacement.
27
+
28
+ ## feat(web-popups): count push subscriptions made by a campaign's subscribe button
29
+
30
+ - A `subscribe` button of a web campaign now reports `recordPopupFormEvent` with event `4` (`PUSH_SUBSCRIBE`) when the
31
+ click makes a new subscriber: the permission ends `granted`, the device registers, and it had no push token before —
32
+ the prompt was `default`, or the permission was `granted` but the visitor had unsubscribed. An existing subscriber, a
33
+ refusal, a dismissed prompt or a failed registration sends nothing. A placement or a content opened by its own code
34
+ sends none either.
35
+
12
36
  ## feat(push): report which action button of a web push was tapped
13
37
 
14
38
  - A notification button that carries `id` in the payload now uses it as its action instead of `action-N`, and a tap on
@@ -209,7 +209,6 @@ export declare class Pushwoosh {
209
209
  /** Logged once per init and read by the integrator in the console, so it names the parameter to fix. */
210
210
  private abortInit;
211
211
  private resolvePlatformType;
212
- private detectLegacySafari;
213
212
  private ensureHwid;
214
213
  private readHwid;
215
214
  /** `user_id` is the documented placeholder for "no userId", so it identifies nobody. */
@@ -53,7 +53,7 @@ export declare class Api {
53
53
  registerWhatsappNumber(number: string, isManual?: boolean): Promise<IMapResponse['registerWhatsappNumber']>;
54
54
  getPopupForms(): Promise<Array<WebPopup>>;
55
55
  getPopupFormContent(code: string): Promise<IMapResponse['getPopupFormContent']>;
56
- recordPopupFormEvent(code: string, event: 1 | 2 | 3): Promise<IMapResponse['recordPopupFormEvent']>;
56
+ recordPopupFormEvent(code: string, event: 1 | 2 | 3 | 4): Promise<IMapResponse['recordPopupFormEvent']>;
57
57
  getWebPlacements(): Promise<Array<WebPlacement>>;
58
58
  trackWebPlacement(hash: string, action: WebPlacementAction): Promise<IMapResponse['trackWebPlacement']>;
59
59
  submitPopupForm(code: string, values: WebPopupFormValues): Promise<IMapResponse['submitPopupForm']>;
@@ -57,7 +57,7 @@ interface IRequestGetPopupFormContent extends IRequest {
57
57
  }
58
58
  interface IRequestRecordPopupFormEvent extends IRequest {
59
59
  code: string;
60
- event: 1 | 2 | 3;
60
+ event: 1 | 2 | 3 | 4;
61
61
  clickId?: string;
62
62
  }
63
63
  interface IRequestSubmitPopupForm extends IRequest {
@@ -1 +1,5 @@
1
- export declare const UNIFIED_PLATFORM = 11;
1
+ import { type TPlatformChrome, type TPlatformFirefox, type TPlatformSafari } from './PlatformChecker.types';
2
+ export declare const PLATFORM_SAFARI: TPlatformSafari;
3
+ export declare const PLATFORM_CHROME: TPlatformChrome;
4
+ export declare const PLATFORM_FIREFOX: TPlatformFirefox;
5
+ export declare const UNIFIED_PLATFORM: 11;
@@ -1,54 +1,28 @@
1
- import { type TFormFactor, type TPlatform } from './PlatformChecker.types';
1
+ import { type IBrowserInfo, type IPushCapabilities, type TFormFactor, type TPlatform } from './PlatformChecker.types';
2
2
  export declare class PlatformChecker {
3
- private readonly global;
4
- private readonly _isSafari;
5
- private readonly _isOpera;
6
- private readonly _isEdge;
7
- private readonly _isFirefox;
8
- private readonly _isChrome;
9
- private readonly _isMacOS;
10
- private readonly _isAvailableServiceWorker;
11
- private readonly _isAvailableNotifications;
12
- /**
13
- * Browser name + version
14
- * Example: "Chrome 70"
15
- */
16
- private readonly _browserVersion;
17
- private readonly _platform;
18
- private readonly _formFactor;
3
+ readonly browser: IBrowserInfo;
4
+ readonly capabilities: IPushCapabilities;
5
+ readonly formFactor: TFormFactor;
19
6
  constructor(global: typeof globalThis);
20
- get isEdge(): boolean;
7
+ get isAvailableNotifications(): boolean;
8
+ /** @deprecated use capabilities.webPush */
9
+ get isAvailableServiceWorker(): boolean;
10
+ /** @deprecated use capabilities.safariLegacy */
21
11
  get isSafari(): boolean;
12
+ /** @deprecated use browser.name */
22
13
  get isOpera(): boolean;
23
- get isAvailableServiceWorker(): boolean;
24
- get isAvailableNotifications(): boolean;
25
- get platform(): TPlatform;
14
+ /** @deprecated use browser.name */
15
+ get isEdge(): boolean;
16
+ /** @deprecated use browser.model */
26
17
  get browserVersion(): string;
27
- get formFactor(): TFormFactor;
28
18
  get isMobile(): boolean;
29
19
  get isDesktop(): boolean;
30
- isSafariBrowser(): boolean;
31
- isOperaBrowser(): boolean;
32
- isEdgeBrowser(): boolean;
33
- isFirefoxBrowser(): boolean;
34
- isChromeBrowser(): boolean;
35
- isMacOS(): boolean;
36
- canUseServiceWorkers(): boolean;
37
- /**
38
- * Check availability ServiceWorker or safari browser on macos
39
- */
40
- canReceiveNotifications(): boolean;
41
- /**
42
- * Get Pushwoosh system platform code
43
- */
20
+ /** @deprecated the SDK resolves the platform with its init params */
21
+ get platform(): TPlatform;
22
+ /** @deprecated the SDK resolves the platform with its init params */
44
23
  getPlatformType(): TPlatform;
45
- /**
46
- * Detect whether the current device is mobile or desktop.
47
- * Prefers the modern `navigator.userAgentData` hint and falls back to userAgent parsing.
48
- */
49
- getFormFactor(): TFormFactor;
50
- /**
51
- * Get browser name + version from userAgent
52
- */
24
+ /** @deprecated use browser.model */
53
25
  getBrowserVersion(): string;
26
+ /** @deprecated use formFactor */
27
+ getFormFactor(): TFormFactor;
54
28
  }
@@ -1,6 +1,14 @@
1
1
  export type TPlatformSafari = 10;
2
2
  export type TPlatformChrome = 11;
3
3
  export type TPlatformFirefox = 12;
4
- export type TPlatformEdge = 150;
5
4
  export type TPlatform = TPlatformSafari | TPlatformChrome | TPlatformFirefox;
6
5
  export type TFormFactor = 'MOBILE' | 'DESKTOP';
6
+ export type TBrowserName = 'opera' | 'edge' | 'firefox' | 'chrome' | 'safari' | 'unknown';
7
+ export interface IBrowserInfo {
8
+ name: TBrowserName;
9
+ model: string;
10
+ }
11
+ export interface IPushCapabilities {
12
+ webPush: boolean;
13
+ safariLegacy: boolean;
14
+ }
@@ -0,0 +1,4 @@
1
+ import { type IBrowserInfo } from './PlatformChecker.types';
2
+ type TNavigatorInfo = Pick<Navigator, 'userAgent' | 'appName' | 'appVersion'>;
3
+ export declare function detectBrowser(navigator: TNavigatorInfo): IBrowserInfo;
4
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type TFormFactor } from './PlatformChecker.types';
2
+ type TNavigatorWithHints = Pick<Navigator, 'userAgent'> & {
3
+ userAgentData?: {
4
+ mobile?: boolean;
5
+ };
6
+ };
7
+ export declare function getFormFactor(navigator: TNavigatorWithHints): TFormFactor;
8
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type IPushCapabilities } from './PlatformChecker.types';
2
+ export declare function getPushCapabilities(global: typeof globalThis): IPushCapabilities;
@@ -1 +1,5 @@
1
1
  export { PlatformChecker } from './PlatformChecker';
2
+ export { detectBrowser } from './detectBrowser';
3
+ export { getFormFactor } from './getFormFactor';
4
+ export { getPushCapabilities } from './getPushCapabilities';
5
+ export { isLegacySafariPath, resolvePlatform } from './resolvePlatform';
@@ -0,0 +1,15 @@
1
+ import { type IPushCapabilities, type TBrowserName, type TPlatform } from './PlatformChecker.types';
2
+ interface ILegacySafariInput {
3
+ capabilities: IPushCapabilities;
4
+ hasLegacySubscription: boolean;
5
+ webVapidConfigured: boolean;
6
+ unifiedPlatform: boolean;
7
+ }
8
+ export declare function isLegacySafariPath({ capabilities, hasLegacySubscription, webVapidConfigured, unifiedPlatform }: ILegacySafariInput): boolean;
9
+ interface IPlatformInput {
10
+ legacySafari: boolean;
11
+ unifiedPlatform: boolean;
12
+ browser: TBrowserName;
13
+ }
14
+ export declare function resolvePlatform({ legacySafari, unifiedPlatform, browser }: IPlatformInput): TPlatform;
15
+ export {};