@joryio/web-sdk 1.3.2-beta.1 → 1.3.3-beta.1
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 +12 -0
- package/README.md +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/inapp.d.ts +15 -0
- package/dist/core/inapp.d.ts.map +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/joryio-sw.js +1 -1
- package/dist/joryio.cjs.js +230 -22
- package/dist/joryio.min.js +2 -2
- package/dist/joryio.min.js.map +1 -1
- package/dist/joryio.mjs +230 -23
- package/dist/joryio.umd.js +249 -28
- package/package.json +1 -1
- package/src/core/config.ts +1 -1
- package/src/core/inapp.ts +297 -40
- package/src/index.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.3.3 - 2026-11-03
|
|
4
|
+
|
|
5
|
+
Fixed: an in-app message counts as displayed only once someone could have seen it. It used to be counted - `in_app.displayed` reported and the campaign's frequency cap spent - the moment it was put on the page, so a message that appeared during a sign-in redirect, or just as someone clicked a logout link, used up the cap while it was visible for a flash at most. Now:
|
|
6
|
+
|
|
7
|
+
- a message appears only once the page has finished loading and gone idle, and never while the page is unloading (`beforeunload` / `pagehide`);
|
|
8
|
+
- it counts as displayed after it has been on screen for `IN_APP_DISPLAY_DWELL_MS` (1000 ms) with the tab visible. If the tab is hidden first the timer starts again when it is visible; if the page unloads first, nothing is reported, the frequency cap is untouched, and the message is eligible again on the next page;
|
|
9
|
+
- a click or a close by the person before then counts as seen: `displayed` is reported first, then the click or dismissal. Removal by the SDK or by your code (`dismissInAppMessage`, `reset()`) before then reports nothing.
|
|
10
|
+
|
|
11
|
+
Changed: `inApp.displayOptions.onDisplay` fires when the message counts as displayed, together with the `displayed` report, rather than when it is put on screen - the same timing as `onMessageDisplay` on iOS. `IN_APP_DISPLAY_DWELL_MS` is exported. No wire changes.
|
|
12
|
+
|
|
13
|
+
Fixed: the script-tag file (`joryio.min.js`, `joryio.umd.js`) is safe on a page with an AMD loader such as RequireJS (every Magento Luma store). Loaded by a plain `<script>`, the old UMD wrapper called an anonymous `define()`, which RequireJS attached to another module that was loading or reported as "Mismatched anonymous define() module" - and the SDK did not start. The SDK now always starts and sets `window.Joryio`; on an AMD page it defines an anonymous module only when RequireJS itself requested the file, and otherwise the named module `joryio-web-sdk`. Loading it with `require()` under any module id, as a CommonJS module or from npm (`import` / `require`) is unchanged.
|
|
14
|
+
|
|
3
15
|
## 1.3.2 - 2026-10-25
|
|
4
16
|
|
|
5
17
|
No change from the in-app hold added to the other four SDKs in this version (`holdInAppMessagesForHandler`): the web SDK always draws its own in-app messages and has no handler that takes drawing over after `init()` - its `inApp` hooks are passed in the init config, before the first sync - so the window that option closes does not exist here.
|
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ The SDK files are served from one global host, `https://sdk.joryio.com`:
|
|
|
81
81
|
| Path | What you get |
|
|
82
82
|
|------|--------------|
|
|
83
83
|
| `/web/1/<file>` | The newest 1.x release - recommended. Picks up fixes, never a breaking change |
|
|
84
|
-
| `/web/<version>/<file>` | One exact version, e.g. `/web/1.3.
|
|
84
|
+
| `/web/<version>/<file>` | One exact version, e.g. `/web/1.3.2/joryio.min.js`. Its contents never change |
|
|
85
85
|
|
|
86
86
|
Files: `joryio.min.js` (the SDK), `joryio-sw.js` (the web push service worker) and `joryio.umd.js` (unminified UMD build).
|
|
87
87
|
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.3.
|
|
1
|
+
export declare const SDK_VERSION = "1.3.3";
|
|
2
2
|
export declare const DEFAULT_API_ENDPOINT = "https://api-eu1.joryio.com/api";
|
|
3
3
|
export declare function normalizeApiEndpoint(raw: string | undefined | null): string;
|
|
4
4
|
export declare const DEFAULT_BATCH_SIZE = 50;
|
package/dist/core/inapp.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export declare const IN_APP_DEFAULT_MAX_WIDTH: {
|
|
|
104
104
|
export declare const IN_APP_VIEWPORT_MARGIN = 16;
|
|
105
105
|
export declare function inAppMaxWidth(campaign: Pick<InAppCampaign, 'type' | 'content'>): number | null;
|
|
106
106
|
export declare function inAppFrameWidth(maxWidth: number, viewportWidth: number, margin?: number): number;
|
|
107
|
+
export declare const IN_APP_DISPLAY_DWELL_MS = 1000;
|
|
107
108
|
export declare function scopeCssRules(rules: ArrayLike<unknown>, scope: string): string;
|
|
108
109
|
export declare function normalizedElementId(raw: unknown): string | undefined;
|
|
109
110
|
export declare function cssValue(raw: unknown): string | null;
|
|
@@ -130,6 +131,10 @@ export declare class InAppMessagingManager {
|
|
|
130
131
|
private syncAgain;
|
|
131
132
|
private syncAgainChanges;
|
|
132
133
|
private claimed;
|
|
134
|
+
private awaitingDwell;
|
|
135
|
+
private pageLeaving;
|
|
136
|
+
private settleWaiters;
|
|
137
|
+
private pageListeners;
|
|
133
138
|
private iframes;
|
|
134
139
|
private frameMaxWidths;
|
|
135
140
|
private viewportListener?;
|
|
@@ -142,6 +147,16 @@ export declare class InAppMessagingManager {
|
|
|
142
147
|
private bridge;
|
|
143
148
|
private auth;
|
|
144
149
|
constructor(apiEndpoint: string, sdkKey: string, identity: IdentityManager, session: SessionManager, logger: Logger, storage?: StorageManager | null, options?: DisplayOptions, bridge?: InAppBridge, auth?: InAppAuthProvider | null, runtime?: InAppRuntimeOptions);
|
|
150
|
+
private pageHidden;
|
|
151
|
+
private installPageLifecycle;
|
|
152
|
+
private removePageLifecycle;
|
|
153
|
+
private whenPageSettled;
|
|
154
|
+
private isMounted;
|
|
155
|
+
private scheduleDwell;
|
|
156
|
+
private pauseDwells;
|
|
157
|
+
private resumeDwells;
|
|
158
|
+
private dropDwell;
|
|
159
|
+
private confirmDisplay;
|
|
145
160
|
private loadImpressionTimestamps;
|
|
146
161
|
private persistImpressionTimestamps;
|
|
147
162
|
private installHostBridge;
|
package/dist/core/inapp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inapp.d.ts","sourceRoot":"","sources":["../../src/core/inapp.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAQ/C,MAAM,WAAW,iBAAiB;IAEhC,iBAAiB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzE,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC;IACnD,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAE3E,gBAAgB,CAAC,IAAI,MAAM,GAAG,IAAI,CAAC;CACpC;AAMD,MAAM,WAAW,mBAAmB;IAKlC,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IAExB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,cAAc,CAAC,EAAE,mBAAmB,GAAG,oBAAoB,CAAC;IAE5D,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAClD;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;I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326
|
}
|
|
327
327
|
|
|
328
|
-
declare const SDK_VERSION = "1.3.
|
|
328
|
+
declare const SDK_VERSION = "1.3.3";
|
|
329
329
|
interface InAppDisplayOptions {
|
|
330
330
|
defaultPosition?: 'top' | 'center' | 'bottom';
|
|
331
331
|
defaultAnimation?: 'fade' | 'slide' | 'none';
|
|
@@ -438,6 +438,7 @@ interface InAppMessage {
|
|
|
438
438
|
renderedHtml: string;
|
|
439
439
|
displayedAt?: Date;
|
|
440
440
|
}
|
|
441
|
+
declare const IN_APP_DISPLAY_DWELL_MS = 1000;
|
|
441
442
|
|
|
442
443
|
interface EcommerceProduct {
|
|
443
444
|
productId: string;
|
|
@@ -708,5 +709,5 @@ declare class JoryioSDK {
|
|
|
708
709
|
|
|
709
710
|
declare function installSnippetQueue(win: any): void;
|
|
710
711
|
|
|
711
|
-
export { EcommerceTracker, JoryioSDK, PushManager, SDK_VERSION, SubscriptionStatus, User, createEcommerceTracker, JoryioSDK as default, installSnippetQueue };
|
|
712
|
+
export { EcommerceTracker, IN_APP_DISPLAY_DWELL_MS, JoryioSDK, PushManager, SDK_VERSION, SubscriptionStatus, User, createEcommerceTracker, JoryioSDK as default, installSnippetQueue };
|
|
712
713
|
export type { EcommerceCartItem, EcommerceConfig, EcommerceOrder, EcommerceProduct, InAppCampaign, InAppDisplayOptions, InAppMessage, InAppOptions, InAppTrigger, InitConfig, Plugin, PushPermissionState, PushSubscribeOptions, SdkAuthFailureCallback, SdkAuthFailureInfo, SdkAuthFailureReason, SubscriptionChannel, SubscriptionPreferences, TrackingConsent, UTMData, UTMParameters };
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { PushManager };
|
|
|
16
16
|
export { EcommerceTracker, createEcommerceTracker };
|
|
17
17
|
export type { InitConfig, Plugin, InAppOptions, InAppDisplayOptions, InAppCampaign, InAppMessage, InAppTrigger, UTMParameters, UTMData, SubscriptionChannel, SubscriptionPreferences, PushSubscribeOptions, PushPermissionState, TrackingConsent, EcommerceProduct, EcommerceCartItem, EcommerceOrder, EcommerceConfig, SdkAuthFailureInfo, SdkAuthFailureReason, SdkAuthFailureCallback, };
|
|
18
18
|
export { SDK_VERSION } from './core/config';
|
|
19
|
+
export { IN_APP_DISPLAY_DWELL_MS } from './core/inapp';
|
|
19
20
|
export default JoryioSDK;
|
|
20
21
|
export declare function installSnippetQueue(win: any): void;
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAA8D,MAAM,YAAY,CAAC;AACnG,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EAChB,MAAM,kBAAkB,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AAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,CAAC;AAGvB,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,CAAC;AAGpD,YAAY,EACV,UAAU,EACV,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,OAAO,EACP,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,GACvB,CAAC;AAGF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGvD,eAAe,SAAS,CAAC;AA6GzB,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAwHlD"}
|
package/dist/joryio-sw.js
CHANGED
package/dist/joryio.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Joryio Web SDK v1.3.
|
|
2
|
+
* Joryio Web SDK v1.3.3-beta.1
|
|
3
3
|
* (c) 2026 Joryio. All rights reserved.
|
|
4
4
|
* @license Commercial - see https://github.com/joryio/joryio-web-sdk/blob/main/LICENSE
|
|
5
5
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
|
-
const SDK_VERSION = '1.3.
|
|
10
|
+
const SDK_VERSION = '1.3.3';
|
|
11
11
|
const DEFAULT_API_ENDPOINT = 'https://api-eu1.joryio.com/api';
|
|
12
12
|
function normalizeApiEndpoint(raw) {
|
|
13
13
|
const trimmed = (raw || '').trim();
|
|
@@ -2285,6 +2285,11 @@ const IMPRESSIONS_STORAGE_KEY = 'inapp_impressions';
|
|
|
2285
2285
|
const MAX_DISPLAYED_MESSAGES = 500;
|
|
2286
2286
|
const MAX_IMPRESSION_TIMESTAMPS = 500;
|
|
2287
2287
|
const MAX_WATCHED_ATTRIBUTES = 200;
|
|
2288
|
+
const IN_APP_DISPLAY_DWELL_MS = 1000;
|
|
2289
|
+
const PAGE_SETTLE_FALLBACK_MS = 50;
|
|
2290
|
+
const PAGE_SETTLE_IDLE_TIMEOUT_MS = 500;
|
|
2291
|
+
const PAGE_LOAD_MAX_WAIT_MS = 10000;
|
|
2292
|
+
const USER_DISMISS_ACTIONS = new Set(['close_button', 'backdrop', 'button', 'bridge_close']);
|
|
2288
2293
|
function scopeCssRules(rules, scope) {
|
|
2289
2294
|
var _a, _b;
|
|
2290
2295
|
const scopeSelector = (selectorText) => selectorText
|
|
@@ -2394,6 +2399,10 @@ class InAppMessagingManager {
|
|
|
2394
2399
|
this.generation = 0;
|
|
2395
2400
|
this.syncAgain = false;
|
|
2396
2401
|
this.claimed = new Set();
|
|
2402
|
+
this.awaitingDwell = new Map();
|
|
2403
|
+
this.pageLeaving = false;
|
|
2404
|
+
this.settleWaiters = new Set();
|
|
2405
|
+
this.pageListeners = [];
|
|
2397
2406
|
this.iframes = new Map();
|
|
2398
2407
|
this.frameMaxWidths = new Map();
|
|
2399
2408
|
this.allowHtmlJsInAppMessages = false;
|
|
@@ -2417,6 +2426,176 @@ class InAppMessagingManager {
|
|
|
2417
2426
|
this.auth = auth || null;
|
|
2418
2427
|
this.loadImpressionTimestamps();
|
|
2419
2428
|
this.installHostBridge();
|
|
2429
|
+
this.installPageLifecycle();
|
|
2430
|
+
}
|
|
2431
|
+
pageHidden() {
|
|
2432
|
+
if (typeof document === 'undefined')
|
|
2433
|
+
return false;
|
|
2434
|
+
return document.visibilityState === 'hidden' || document.hidden === true;
|
|
2435
|
+
}
|
|
2436
|
+
installPageLifecycle() {
|
|
2437
|
+
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function')
|
|
2438
|
+
return;
|
|
2439
|
+
const on = (target, type, fn) => {
|
|
2440
|
+
if (!target || typeof target.addEventListener !== 'function')
|
|
2441
|
+
return;
|
|
2442
|
+
target.addEventListener(type, fn);
|
|
2443
|
+
this.pageListeners.push([target, type, fn]);
|
|
2444
|
+
};
|
|
2445
|
+
const leaving = () => {
|
|
2446
|
+
this.pageLeaving = true;
|
|
2447
|
+
this.pauseDwells();
|
|
2448
|
+
this.settleWaiters.forEach((cancel) => cancel());
|
|
2449
|
+
};
|
|
2450
|
+
const stayed = () => {
|
|
2451
|
+
if (!this.pageLeaving)
|
|
2452
|
+
return;
|
|
2453
|
+
this.pageLeaving = false;
|
|
2454
|
+
this.resumeDwells();
|
|
2455
|
+
};
|
|
2456
|
+
on(window, 'beforeunload', leaving);
|
|
2457
|
+
on(window, 'pagehide', leaving);
|
|
2458
|
+
on(window, 'pageshow', () => {
|
|
2459
|
+
this.pageLeaving = false;
|
|
2460
|
+
this.resumeDwells();
|
|
2461
|
+
});
|
|
2462
|
+
on(window, 'pointerdown', stayed);
|
|
2463
|
+
on(window, 'keydown', stayed);
|
|
2464
|
+
if (typeof document !== 'undefined') {
|
|
2465
|
+
on(document, 'visibilitychange', () => {
|
|
2466
|
+
if (this.pageHidden()) {
|
|
2467
|
+
this.pauseDwells();
|
|
2468
|
+
}
|
|
2469
|
+
else {
|
|
2470
|
+
this.pageLeaving = false;
|
|
2471
|
+
this.resumeDwells();
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
removePageLifecycle() {
|
|
2477
|
+
var _a;
|
|
2478
|
+
for (const [target, type, fn] of this.pageListeners) {
|
|
2479
|
+
try {
|
|
2480
|
+
(_a = target.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(target, type, fn);
|
|
2481
|
+
}
|
|
2482
|
+
catch (_b) {
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
this.pageListeners = [];
|
|
2486
|
+
}
|
|
2487
|
+
whenPageSettled() {
|
|
2488
|
+
if (typeof window === 'undefined' || typeof document === 'undefined')
|
|
2489
|
+
return Promise.resolve(true);
|
|
2490
|
+
if (this.pageLeaving)
|
|
2491
|
+
return Promise.resolve(false);
|
|
2492
|
+
return new Promise((resolve) => {
|
|
2493
|
+
let done = false;
|
|
2494
|
+
let loadTimer;
|
|
2495
|
+
let idleTimer;
|
|
2496
|
+
const w = window;
|
|
2497
|
+
const finish = (ok) => {
|
|
2498
|
+
if (done)
|
|
2499
|
+
return;
|
|
2500
|
+
done = true;
|
|
2501
|
+
this.settleWaiters.delete(cancel);
|
|
2502
|
+
if (loadTimer)
|
|
2503
|
+
clearTimeout(loadTimer);
|
|
2504
|
+
if (idleTimer)
|
|
2505
|
+
clearTimeout(idleTimer);
|
|
2506
|
+
if (typeof w.removeEventListener === 'function')
|
|
2507
|
+
w.removeEventListener('load', onLoad);
|
|
2508
|
+
resolve(ok && !this.pageLeaving);
|
|
2509
|
+
};
|
|
2510
|
+
const cancel = () => finish(false);
|
|
2511
|
+
const idle = () => {
|
|
2512
|
+
if (done)
|
|
2513
|
+
return;
|
|
2514
|
+
if (typeof w.requestIdleCallback === 'function') {
|
|
2515
|
+
w.requestIdleCallback(() => finish(true), { timeout: PAGE_SETTLE_IDLE_TIMEOUT_MS });
|
|
2516
|
+
}
|
|
2517
|
+
else {
|
|
2518
|
+
idleTimer = setTimeout(() => finish(true), PAGE_SETTLE_FALLBACK_MS);
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2521
|
+
const onLoad = () => {
|
|
2522
|
+
if (loadTimer)
|
|
2523
|
+
clearTimeout(loadTimer);
|
|
2524
|
+
loadTimer = undefined;
|
|
2525
|
+
idle();
|
|
2526
|
+
};
|
|
2527
|
+
this.settleWaiters.add(cancel);
|
|
2528
|
+
const state = document.readyState;
|
|
2529
|
+
if (!state || state === 'complete' || typeof w.addEventListener !== 'function') {
|
|
2530
|
+
idle();
|
|
2531
|
+
}
|
|
2532
|
+
else {
|
|
2533
|
+
w.addEventListener('load', onLoad, { once: true });
|
|
2534
|
+
loadTimer = setTimeout(onLoad, PAGE_LOAD_MAX_WAIT_MS);
|
|
2535
|
+
}
|
|
2536
|
+
});
|
|
2537
|
+
}
|
|
2538
|
+
isMounted(campaignId) {
|
|
2539
|
+
if (!this.displayedMessages.has(campaignId) || typeof document === 'undefined')
|
|
2540
|
+
return false;
|
|
2541
|
+
const el = document.getElementById(`joryio-inapp-${campaignId}`);
|
|
2542
|
+
return !!el && el.isConnected !== false;
|
|
2543
|
+
}
|
|
2544
|
+
scheduleDwell(campaignId, generation) {
|
|
2545
|
+
const existing = this.awaitingDwell.get(campaignId);
|
|
2546
|
+
if (existing === null || existing === void 0 ? void 0 : existing.timer)
|
|
2547
|
+
clearTimeout(existing.timer);
|
|
2548
|
+
if (this.pageLeaving || this.pageHidden()) {
|
|
2549
|
+
this.awaitingDwell.set(campaignId, { timer: null, generation });
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
2552
|
+
const timer = setTimeout(() => {
|
|
2553
|
+
const entry = this.awaitingDwell.get(campaignId);
|
|
2554
|
+
if (!entry || entry.timer !== timer)
|
|
2555
|
+
return;
|
|
2556
|
+
entry.timer = null;
|
|
2557
|
+
if (this.pageLeaving || this.pageHidden() || !this.isMounted(campaignId))
|
|
2558
|
+
return;
|
|
2559
|
+
if (entry.generation !== this.generation)
|
|
2560
|
+
return;
|
|
2561
|
+
this.confirmDisplay(campaignId).catch(() => undefined);
|
|
2562
|
+
}, IN_APP_DISPLAY_DWELL_MS);
|
|
2563
|
+
this.awaitingDwell.set(campaignId, { timer, generation });
|
|
2564
|
+
}
|
|
2565
|
+
pauseDwells() {
|
|
2566
|
+
this.awaitingDwell.forEach((entry) => {
|
|
2567
|
+
if (entry.timer)
|
|
2568
|
+
clearTimeout(entry.timer);
|
|
2569
|
+
entry.timer = null;
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
resumeDwells() {
|
|
2573
|
+
if (this.pageLeaving || this.pageHidden())
|
|
2574
|
+
return;
|
|
2575
|
+
this.awaitingDwell.forEach((entry, campaignId) => {
|
|
2576
|
+
if (!entry.timer && this.isMounted(campaignId))
|
|
2577
|
+
this.scheduleDwell(campaignId, entry.generation);
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2580
|
+
dropDwell(campaignId) {
|
|
2581
|
+
const entry = this.awaitingDwell.get(campaignId);
|
|
2582
|
+
if (entry === null || entry === void 0 ? void 0 : entry.timer)
|
|
2583
|
+
clearTimeout(entry.timer);
|
|
2584
|
+
this.awaitingDwell.delete(campaignId);
|
|
2585
|
+
}
|
|
2586
|
+
confirmDisplay(campaignId) {
|
|
2587
|
+
if (!this.awaitingDwell.has(campaignId))
|
|
2588
|
+
return Promise.resolve();
|
|
2589
|
+
this.dropDwell(campaignId);
|
|
2590
|
+
const timestamps = this.impressionTimestamps.get(campaignId) || [];
|
|
2591
|
+
timestamps.push(Date.now());
|
|
2592
|
+
this.boundedMapSet(this.impressionTimestamps, campaignId, timestamps, MAX_IMPRESSION_TIMESTAMPS);
|
|
2593
|
+
this.persistImpressionTimestamps();
|
|
2594
|
+
const reported = this.trackImpression(campaignId, 'displayed');
|
|
2595
|
+
const message = this.displayedMessages.get(campaignId);
|
|
2596
|
+
if (message)
|
|
2597
|
+
this.callHost('onMessageDisplay', () => { var _a, _b; return (_b = (_a = this.displayOptions).onDisplay) === null || _b === void 0 ? void 0 : _b.call(_a, message); });
|
|
2598
|
+
return reported;
|
|
2420
2599
|
}
|
|
2421
2600
|
loadImpressionTimestamps() {
|
|
2422
2601
|
if (!this.storage)
|
|
@@ -2552,6 +2731,7 @@ class InAppMessagingManager {
|
|
|
2552
2731
|
this.syncRetried = false;
|
|
2553
2732
|
this.pendingDelays.forEach((timer) => clearTimeout(timer));
|
|
2554
2733
|
this.pendingDelays.clear();
|
|
2734
|
+
this.settleWaiters.forEach((cancel) => cancel());
|
|
2555
2735
|
}
|
|
2556
2736
|
startPeriodicSync() {
|
|
2557
2737
|
if (this.periodicSyncTimer) {
|
|
@@ -2805,37 +2985,44 @@ class InAppMessagingManager {
|
|
|
2805
2985
|
`(permission not 'default'); suppressing.`);
|
|
2806
2986
|
return;
|
|
2807
2987
|
}
|
|
2808
|
-
const message = {
|
|
2809
|
-
campaign,
|
|
2810
|
-
renderedHtml,
|
|
2811
|
-
displayedAt: new Date(),
|
|
2812
|
-
};
|
|
2813
2988
|
const commitDisplay = () => {
|
|
2989
|
+
const message = {
|
|
2990
|
+
campaign,
|
|
2991
|
+
renderedHtml,
|
|
2992
|
+
displayedAt: new Date(),
|
|
2993
|
+
};
|
|
2814
2994
|
this.boundedMapSet(this.displayedMessages, campaign.id, message, MAX_DISPLAYED_MESSAGES);
|
|
2815
|
-
const timestamps = this.impressionTimestamps.get(campaign.id) || [];
|
|
2816
|
-
timestamps.push(Date.now());
|
|
2817
|
-
this.boundedMapSet(this.impressionTimestamps, campaign.id, timestamps, MAX_IMPRESSION_TIMESTAMPS);
|
|
2818
|
-
this.persistImpressionTimestamps();
|
|
2819
2995
|
this.display(message);
|
|
2996
|
+
this.scheduleDwell(campaign.id, generation);
|
|
2997
|
+
};
|
|
2998
|
+
const show = async () => {
|
|
2999
|
+
if (!(await this.whenPageSettled())) {
|
|
3000
|
+
this.logger.debug(`Campaign ${campaign.id} not displayed: the page is unloading. It stays eligible.`);
|
|
3001
|
+
return;
|
|
3002
|
+
}
|
|
3003
|
+
if (generation !== this.generation || !this.runtime.canSend()) {
|
|
3004
|
+
this.logger.debug(`Campaign ${campaign.id} not displayed: the visitor or consent changed`);
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
if (this.displayedMessages.has(campaign.id) || !this.checkFrequencyCap(campaign))
|
|
3008
|
+
return;
|
|
3009
|
+
commitDisplay();
|
|
2820
3010
|
};
|
|
2821
3011
|
const delayMs = Math.max(0, Number(campaign.delay) || 0) * 1000;
|
|
2822
3012
|
if (delayMs > 0) {
|
|
2823
3013
|
const timer = setTimeout(() => {
|
|
2824
3014
|
this.pendingDelays.delete(campaign.id);
|
|
2825
|
-
if (
|
|
2826
|
-
this.logger.debug(`Campaign ${campaign.id} not displayed after its delay: the visitor or consent changed`);
|
|
3015
|
+
if (this.claimed.has(id) || this.displayedMessages.has(id))
|
|
2827
3016
|
return;
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
this.trackImpression(campaign.id, 'displayed').catch(() => undefined);
|
|
3017
|
+
this.claimed.add(id);
|
|
3018
|
+
show()
|
|
3019
|
+
.catch((error) => this.logger.error('In-app display failed:', error))
|
|
3020
|
+
.finally(() => this.claimed.delete(id));
|
|
2833
3021
|
}, delayMs);
|
|
2834
3022
|
this.pendingDelays.set(campaign.id, timer);
|
|
2835
3023
|
return;
|
|
2836
3024
|
}
|
|
2837
|
-
|
|
2838
|
-
await this.trackImpression(campaign.id, 'displayed');
|
|
3025
|
+
await show();
|
|
2839
3026
|
}
|
|
2840
3027
|
finally {
|
|
2841
3028
|
this.claimed.delete(id);
|
|
@@ -3276,7 +3463,6 @@ class InAppMessagingManager {
|
|
|
3276
3463
|
}
|
|
3277
3464
|
}
|
|
3278
3465
|
targetContainer.appendChild(container);
|
|
3279
|
-
this.callHost('onMessageDisplay', () => { var _a, _b; return (_b = (_a = this.displayOptions).onDisplay) === null || _b === void 0 ? void 0 : _b.call(_a, message); });
|
|
3280
3466
|
this.logger.info(`Displayed campaign: ${campaign.name} (${campaign.id})`);
|
|
3281
3467
|
}
|
|
3282
3468
|
hostViewportWidth() {
|
|
@@ -3428,6 +3614,17 @@ class InAppMessagingManager {
|
|
|
3428
3614
|
clearTimeout(pending);
|
|
3429
3615
|
this.pendingDelays.delete(campaignId);
|
|
3430
3616
|
}
|
|
3617
|
+
let report = true;
|
|
3618
|
+
const dwell = this.awaitingDwell.get(campaignId);
|
|
3619
|
+
if (dwell) {
|
|
3620
|
+
if (USER_DISMISS_ACTIONS.has(action) && dwell.generation === this.generation) {
|
|
3621
|
+
this.confirmDisplay(campaignId).catch(() => undefined);
|
|
3622
|
+
}
|
|
3623
|
+
else {
|
|
3624
|
+
this.dropDwell(campaignId);
|
|
3625
|
+
report = false;
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3431
3628
|
const container = document.getElementById(`joryio-inapp-${campaignId}`);
|
|
3432
3629
|
const backdrop = document.getElementById(`joryio-backdrop-${campaignId}`);
|
|
3433
3630
|
const style = document.getElementById(`joryio-style-${campaignId}`);
|
|
@@ -3449,7 +3646,8 @@ class InAppMessagingManager {
|
|
|
3449
3646
|
}
|
|
3450
3647
|
const message = this.displayedMessages.get(campaignId);
|
|
3451
3648
|
if (message) {
|
|
3452
|
-
|
|
3649
|
+
if (report)
|
|
3650
|
+
await this.trackImpression(campaignId, 'dismissed').catch(() => undefined);
|
|
3453
3651
|
this.callHost('onMessageDismiss', () => { var _a, _b; return (_b = (_a = this.displayOptions).onDismiss) === null || _b === void 0 ? void 0 : _b.call(_a, message, action); });
|
|
3454
3652
|
this.displayedMessages.delete(campaignId);
|
|
3455
3653
|
}
|
|
@@ -3502,6 +3700,12 @@ class InAppMessagingManager {
|
|
|
3502
3700
|
return;
|
|
3503
3701
|
if (!this.runtime.canSend())
|
|
3504
3702
|
return;
|
|
3703
|
+
const dwell = type !== 'displayed' ? this.awaitingDwell.get(campaignId) : undefined;
|
|
3704
|
+
if (dwell) {
|
|
3705
|
+
if (dwell.generation !== this.generation)
|
|
3706
|
+
return;
|
|
3707
|
+
this.confirmDisplay(campaignId).catch(() => undefined);
|
|
3708
|
+
}
|
|
3505
3709
|
const sessionId = this.session.getSessionId();
|
|
3506
3710
|
const data = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ campaignId, variantId: campaign.variantId }, this.subject()), { sessionId, deviceType: 'web', locale: navigator.language, userAgent: navigator.userAgent }), (campaign.pendingId ? { pendingId: campaign.pendingId } : {})), (campaign.deliveryToken ? { deliveryToken: campaign.deliveryToken } : {})), extra);
|
|
3507
3711
|
if (type === 'displayed') {
|
|
@@ -3663,6 +3867,7 @@ class InAppMessagingManager {
|
|
|
3663
3867
|
}
|
|
3664
3868
|
this.campaigns.clear();
|
|
3665
3869
|
this.displayedMessages.clear();
|
|
3870
|
+
this.awaitingDwell.forEach((_entry, campaignId) => this.dropDwell(campaignId));
|
|
3666
3871
|
this.watchedAttributes.clear();
|
|
3667
3872
|
this.iframes.clear();
|
|
3668
3873
|
this.frameMaxWidths.clear();
|
|
@@ -3704,6 +3909,8 @@ class InAppMessagingManager {
|
|
|
3704
3909
|
}
|
|
3705
3910
|
this.campaigns.clear();
|
|
3706
3911
|
this.displayedMessages.clear();
|
|
3912
|
+
this.awaitingDwell.forEach((_entry, campaignId) => this.dropDwell(campaignId));
|
|
3913
|
+
this.removePageLifecycle();
|
|
3707
3914
|
this.impressionTimestamps.clear();
|
|
3708
3915
|
this.watchedAttributes.clear();
|
|
3709
3916
|
this.iframes.clear();
|
|
@@ -7322,6 +7529,7 @@ if (typeof window !== 'undefined') {
|
|
|
7322
7529
|
}
|
|
7323
7530
|
|
|
7324
7531
|
exports.EcommerceTracker = EcommerceTracker;
|
|
7532
|
+
exports.IN_APP_DISPLAY_DWELL_MS = IN_APP_DISPLAY_DWELL_MS;
|
|
7325
7533
|
exports.JoryioSDK = JoryioSDK;
|
|
7326
7534
|
exports.PushManager = PushManager;
|
|
7327
7535
|
exports.SDK_VERSION = SDK_VERSION;
|