__webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "SessionTracker": () => (/* binding */ SessionTracker) /* harmony export */ }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! tslib */ "./node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"); /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @aws-amplify/core */ "./node_modules/.pnpm/@aws-amplify+core@5.8.14_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws-amplify/core/lib-esm/Logger/ConsoleLogger.js"); /* harmony import */ var _BaseTracker__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BaseTracker */ "./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/tracker/BaseTracker.js"); /* harmony import */ var _PageViewTracker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PageViewTracker */ "./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/tracker/PageViewTracker.js"); /* harmony import */ var _Session__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Session */ "./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/tracker/Session.js"); /* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../browser */ "./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/browser/index.js"); /* harmony import */ var _provider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../provider */ "./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/provider/index.js"); /* harmony import */ var _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/StorageUtil */ "./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/util/StorageUtil.js"); // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_6__.ConsoleLogger('SessionTracker'); var SessionTracker = /** @class */ (function (_super) { (0,tslib__WEBPACK_IMPORTED_MODULE_7__.__extends)(SessionTracker, _super); function SessionTracker() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.isWindowClosing = false; return _this; } SessionTracker.prototype.init = function () { this.onVisibilityChange = this.onVisibilityChange.bind(this); this.onBeforeUnload = this.onBeforeUnload.bind(this); this.handleInit(); if (!this.checkEnv()) { logger.warn('not supported env'); } else { document.addEventListener(this.visibilityChange, this.onVisibilityChange, false); window.addEventListener('beforeunload', this.onBeforeUnload, false); } }; SessionTracker.prototype.onVisibilityChange = function () { if (document.visibilityState === this.hiddenStr) { this.onPageHide(); } else { this.onPageAppear(); } }; SessionTracker.prototype.handleInit = function () { this.session = _Session__WEBPACK_IMPORTED_MODULE_2__.Session.getCurrentSession(this.context); if (_util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.getIsFirstOpen()) { this.provider.record({ name: _provider__WEBPACK_IMPORTED_MODULE_4__.Event.PresetEvent.FIRST_OPEN, }); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.saveIsFirstOpenToFalse(); } this.onPageAppear(true); }; SessionTracker.prototype.onPageAppear = function (isFirstTime) { var _a; if (isFirstTime === void 0) { isFirstTime = false; } logger.debug('page appear'); var pageViewTracker = this.provider.pageViewTracker; pageViewTracker.updateLastScreenStartTimestamp(); if (!isFirstTime) { this.session = _Session__WEBPACK_IMPORTED_MODULE_2__.Session.getCurrentSession(this.context, this.session); } if (this.session.isNewSession()) { pageViewTracker.setIsEntrances(); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.clearPageInfo(); this.provider.record({ name: _provider__WEBPACK_IMPORTED_MODULE_4__.Event.PresetEvent.SESSION_START }); this.session.isRecorded = true; if (!isFirstTime) { pageViewTracker.onPageChange(); } } if (!this.provider.configuration.isTrackAppStartEvents) return; if (isFirstTime && this.isFromCurrentHost()) return; if (isFirstTime && _browser__WEBPACK_IMPORTED_MODULE_3__.BrowserInfo.isFromReload()) return; this.provider.record({ name: _provider__WEBPACK_IMPORTED_MODULE_4__.Event.PresetEvent.APP_START, attributes: (_a = {}, _a[_provider__WEBPACK_IMPORTED_MODULE_4__.Event.ReservedAttribute.IS_FIRST_TIME] = isFirstTime, _a), }); }; SessionTracker.prototype.isFromCurrentHost = function () { return window.location.host === this.context.browserInfo.latestReferrerHost; }; SessionTracker.prototype.onPageHide = function () { logger.debug('page hide'); this.storeSession(); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.checkClickstreamId(); var isImmediate = !(this.isWindowClosing && _browser__WEBPACK_IMPORTED_MODULE_3__.BrowserInfo.isFirefox()); this.recordUserEngagement(isImmediate); this.recordAppEnd(isImmediate); this.provider.sendEventsInBackground(this.isWindowClosing); }; SessionTracker.prototype.recordUserEngagement = function (isImmediate) { _PageViewTracker__WEBPACK_IMPORTED_MODULE_1__.PageViewTracker.updateIdleDuration(); this.provider.pageViewTracker.recordUserEngagement(isImmediate); }; SessionTracker.prototype.recordAppEnd = function (isImmediate) { if (!this.provider.configuration.isTrackAppEndEvents) return; this.provider.record({ name: _provider__WEBPACK_IMPORTED_MODULE_4__.Event.PresetEvent.APP_END, isImmediate: isImmediate, }); }; SessionTracker.prototype.onBeforeUnload = function () { logger.debug('onBeforeUnload'); this.isWindowClosing = true; }; SessionTracker.prototype.storeSession = function () { this.session.pause(); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.saveSession(this.session); }; SessionTracker.prototype.checkEnv = function () { if (!document || !document.addEventListener) { logger.debug('not in the supported web environment'); return false; } if (typeof document.hidden !== 'undefined') { this.hiddenStr = 'hidden'; this.visibilityChange = 'visibilitychange'; } else if (typeof document.msHidden !== 'undefined') { this.hiddenStr = 'msHidden'; this.visibilityChange = 'msvisibilitychange'; } else if (typeof document.webkitHidden !== 'undefined') { this.hiddenStr = 'webkitHidden'; this.visibilityChange = 'webkitvisibilitychange'; } else { logger.debug('not in the supported web environment'); return false; } return true; }; return SessionTracker; }(_BaseTracker__WEBPACK_IMPORTED_MODULE_0__.BaseTracker)); //# sourceURL=webpack://@pamperedchef/common-analytics/./node_modules/.pnpm/@aws+clickstream-web@0.12.4_react-native@0.79.2_@babel+core@7.27.1_react@19.1.0_/node_modules/@aws/clickstream-web/lib-esm/tracker/SessionTracker.js?