__webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "Constants": () => (/* binding */ Constants), /* harmony export */ "PageViewTracker": () => (/* binding */ PageViewTracker) /* harmony export */ }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! tslib */ "./node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs"); /* 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 _browser__WEBPACK_IMPORTED_MODULE_1__ = __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_2__ = __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 _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../types */ "./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/types/index.js"); /* harmony import */ var _util_MethodEmbed__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/MethodEmbed */ "./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/MethodEmbed.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 PageViewTracker = /** @class */ (function (_super) { (0,tslib__WEBPACK_IMPORTED_MODULE_6__.__extends)(PageViewTracker, _super); function PageViewTracker() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.isEntrances = false; _this.searchKeywords = _provider__WEBPACK_IMPORTED_MODULE_2__.Event.Constants.KEYWORDS; _this.lastEngageTime = 0; _this.lastScreenStartTimestamp = 0; _this.isFirstTime = true; return _this; } PageViewTracker.prototype.init = function () { PageViewTracker.lastActiveTimestamp = new Date().getTime(); PageViewTracker.idleTimeoutDuration = this.provider.configuration.idleTimeoutDuration; var configuredSearchKeywords = this.provider.configuration.searchKeyWords; Object.assign(this.searchKeywords, configuredSearchKeywords); this.onPageChange = this.onPageChange.bind(this); if (this.isMultiPageApp()) { if (!_browser__WEBPACK_IMPORTED_MODULE_1__.BrowserInfo.isFromReload()) { this.onPageChange(); } } else { this.trackPageViewForSPA(); } this.isFirstTime = false; }; PageViewTracker.prototype.trackPageViewForSPA = function () { _util_MethodEmbed__WEBPACK_IMPORTED_MODULE_4__.MethodEmbed.add(history, 'pushState', this.onPageChange); _util_MethodEmbed__WEBPACK_IMPORTED_MODULE_4__.MethodEmbed.add(history, 'replaceState', this.onPageChange); window.addEventListener('popstate', this.onPageChange); if (!_browser__WEBPACK_IMPORTED_MODULE_1__.BrowserInfo.isFromReload()) { this.onPageChange(); } }; PageViewTracker.prototype.onPageChange = function () { var _a; PageViewTracker.updateIdleDuration(); if (this.context.configuration.isTrackPageViewEvents) { var previousPageUrl = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.getPreviousPageUrl(); var previousPageTitle = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.getPreviousPageTitle(); var currentPageUrl = _browser__WEBPACK_IMPORTED_MODULE_1__.BrowserInfo.getCurrentPageUrl(); var currentPageTitle = _browser__WEBPACK_IMPORTED_MODULE_1__.BrowserInfo.getCurrentPageTitle(); if (this.isFirstTime || this.isMultiPageApp() || previousPageUrl !== currentPageUrl || previousPageTitle !== currentPageTitle) { (_a = this.provider.scrollTracker) === null || _a === void 0 ? void 0 : _a.enterNewPage(); if (!this.isMultiPageApp() && !this.isFirstTime && previousPageUrl !== '') { this.recordUserEngagement(); } this.trackPageView(previousPageUrl, previousPageTitle); this.trackSearchEvents(); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.savePreviousPageUrl(currentPageUrl); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.savePreviousPageTitle(currentPageTitle); } } }; PageViewTracker.prototype.trackPageView = function (previousPageUrl, previousPageTitle) { var _a; var previousPageStartTime = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.getPreviousPageStartTime(); var analyticsEvent = this.provider.createEvent({ name: _provider__WEBPACK_IMPORTED_MODULE_2__.Event.PresetEvent.PAGE_VIEW, }); var currentPageStartTime = analyticsEvent.timestamp; var eventAttributes = (_a = {}, _a[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.PAGE_REFERRER] = previousPageUrl, _a[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.PAGE_REFERRER_TITLE] = previousPageTitle, _a[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.ENTRANCES] = this.isEntrances ? 1 : 0, _a); if (previousPageStartTime > 0) { eventAttributes[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.PREVIOUS_TIMESTAMP] = previousPageStartTime; } if (this.lastEngageTime > 0) { eventAttributes[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.ENGAGEMENT_TIMESTAMP] = this.lastEngageTime; } Object.assign(analyticsEvent.attributes, eventAttributes); this.provider.recordEvent(analyticsEvent); this.isEntrances = false; _util_StorageUtil__WEBPACK_IMPORTED_MODULE_5__.StorageUtil.savePreviousPageStartTime(currentPageStartTime); this.lastScreenStartTimestamp = currentPageStartTime; }; PageViewTracker.prototype.setIsEntrances = function () { this.isEntrances = true; }; PageViewTracker.prototype.updateLastScreenStartTimestamp = function () { this.lastScreenStartTimestamp = new Date().getTime(); PageViewTracker.idleDuration = 0; PageViewTracker.lastActiveTimestamp = this.lastScreenStartTimestamp; }; PageViewTracker.prototype.recordUserEngagement = function (isImmediate) { var _a; if (isImmediate === void 0) { isImmediate = false; } this.lastEngageTime = this.getLastEngageTime(); if (this.provider.configuration.isTrackUserEngagementEvents && this.lastEngageTime > Constants.minEngagementTime) { this.provider.record({ name: _provider__WEBPACK_IMPORTED_MODULE_2__.Event.PresetEvent.USER_ENGAGEMENT, attributes: (_a = {}, _a[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.ENGAGEMENT_TIMESTAMP] = this.lastEngageTime, _a), isImmediate: isImmediate, }); } }; PageViewTracker.prototype.getLastEngageTime = function () { var duration = new Date().getTime() - this.lastScreenStartTimestamp; var engageTime = duration - PageViewTracker.idleDuration; PageViewTracker.idleDuration = 0; return engageTime; }; PageViewTracker.prototype.isMultiPageApp = function () { return this.context.configuration.pageType === _types__WEBPACK_IMPORTED_MODULE_3__.PageType.multiPageApp; }; PageViewTracker.prototype.trackSearchEvents = function () { var e_1, _a, _b; if (!this.context.configuration.isTrackSearchEvents) return; var searchStr = window.location.search; if (!searchStr || searchStr.length === 0) return; var urlParams = new URLSearchParams(searchStr); try { for (var _c = (0,tslib__WEBPACK_IMPORTED_MODULE_6__.__values)(this.searchKeywords), _d = _c.next(); !_d.done; _d = _c.next()) { var keyword = _d.value; if (urlParams.has(keyword)) { var searchTerm = urlParams.get(keyword); this.provider.record({ name: _provider__WEBPACK_IMPORTED_MODULE_2__.Event.PresetEvent.SEARCH, attributes: (_b = {}, _b[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.SEARCH_KEY] = keyword, _b[_provider__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.SEARCH_TERM] = searchTerm, _b), }); break; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_1) throw e_1.error; } } }; PageViewTracker.updateIdleDuration = function () { var currentTimestamp = new Date().getTime(); var idleDuration = currentTimestamp - PageViewTracker.lastActiveTimestamp; if (idleDuration > PageViewTracker.idleTimeoutDuration) { PageViewTracker.idleDuration += idleDuration; } PageViewTracker.lastActiveTimestamp = currentTimestamp; }; PageViewTracker.lastActiveTimestamp = 0; PageViewTracker.idleDuration = 0; PageViewTracker.idleTimeoutDuration = 0; return PageViewTracker; }(_BaseTracker__WEBPACK_IMPORTED_MODULE_0__.BaseTracker)); var Constants; (function (Constants) { Constants[Constants["minEngagementTime"] = 1000] = "minEngagementTime"; })(Constants || (Constants = {})); //# 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/PageViewTracker.js?