__webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "ClickstreamProvider": () => (/* binding */ ClickstreamProvider) /* harmony export */ }); /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_12__ = __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 _aws_amplify_core_lib_Logger__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @aws-amplify/core/lib/Logger */ "./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/Logger/index.js"); /* harmony import */ var _AnalyticsEventBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./AnalyticsEventBuilder */ "./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/AnalyticsEventBuilder.js"); /* harmony import */ var _ClickstreamContext__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ClickstreamContext */ "./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/ClickstreamContext.js"); /* harmony import */ var _Event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Event */ "./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/Event.js"); /* harmony import */ var _EventChecker__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EventChecker */ "./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/EventChecker.js"); /* harmony import */ var _EventRecorder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./EventRecorder */ "./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/EventRecorder.js"); /* harmony import */ var _browser__WEBPACK_IMPORTED_MODULE_5__ = __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 _tracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../tracker */ "./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/index.js"); /* harmony import */ var _tracker_ClickTracker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../tracker/ClickTracker */ "./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/ClickTracker.js"); /* harmony import */ var _tracker_PageLoadTracker__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../tracker/PageLoadTracker */ "./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/PageLoadTracker.js"); /* harmony import */ var _tracker_ScrollTracker__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../tracker/ScrollTracker */ "./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/ScrollTracker.js"); /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_10__ = __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_StorageUtil__WEBPACK_IMPORTED_MODULE_11__ = __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_12__.ConsoleLogger('ClickstreamProvider'); var ClickstreamProvider = /** @class */ (function () { function ClickstreamProvider() { this.configuration = { appId: '', endpoint: '', sendMode: _types__WEBPACK_IMPORTED_MODULE_10__.SendMode.Immediate, sendEventsInterval: 5000, isTrackPageViewEvents: true, isTrackUserEngagementEvents: true, isTrackClickEvents: true, isTrackSearchEvents: true, isTrackScrollEvents: true, isTrackPageLoadEvents: false, isTrackAppStartEvents: false, isTrackAppEndEvents: false, pageType: _types__WEBPACK_IMPORTED_MODULE_10__.PageType.SPA, isLogEvents: false, sessionTimeoutDuration: 1800000, idleTimeoutDuration: 120000, searchKeyWords: [], domainList: [], globalAttributes: {}, }; } ClickstreamProvider.prototype.configure = function (configuration) { if (configuration.appId === '' || configuration.endpoint === '') { logger.error('Please configure your appId and endpoint'); return configuration; } Object.assign(this.configuration, configuration); this.context = new _ClickstreamContext__WEBPACK_IMPORTED_MODULE_1__.ClickstreamContext(new _browser__WEBPACK_IMPORTED_MODULE_5__.BrowserInfo(), this.configuration); this.eventRecorder = new _EventRecorder__WEBPACK_IMPORTED_MODULE_4__.EventRecorder(this.context); this.globalAttributes = {}; this.setGlobalAttributes(configuration.globalAttributes); this.userAttributes = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.getSimpleUserAttributes(); this.sessionTracker = new _tracker__WEBPACK_IMPORTED_MODULE_6__.SessionTracker(this, this.context); this.pageViewTracker = new _tracker__WEBPACK_IMPORTED_MODULE_6__.PageViewTracker(this, this.context); this.clickTracker = new _tracker_ClickTracker__WEBPACK_IMPORTED_MODULE_7__.ClickTracker(this, this.context); this.scrollTracker = new _tracker_ScrollTracker__WEBPACK_IMPORTED_MODULE_9__.ScrollTracker(this, this.context); this.pageLoadTracker = new _tracker_PageLoadTracker__WEBPACK_IMPORTED_MODULE_8__.PageLoadTracker(this, this.context); this.sessionTracker.setUp(); this.pageViewTracker.setUp(); this.clickTracker.setUp(); this.scrollTracker.setUp(); this.pageLoadTracker.setUp(); if (configuration.sendMode === _types__WEBPACK_IMPORTED_MODULE_10__.SendMode.Batch) { this.startTimer(); } if (this.context.configuration.isLogEvents) { logger.level = _aws_amplify_core_lib_Logger__WEBPACK_IMPORTED_MODULE_13__.LOG_TYPE.DEBUG; } logger.debug('Initialize the SDK successfully, configuration is:\n' + JSON.stringify(this.configuration)); if (this.eventRecorder.getFailedEventsLength() > 0) { this.eventRecorder.haveFailedEvents = true; this.eventRecorder.sendFailedEvents(); } return this.configuration; }; ClickstreamProvider.prototype.updateConfigure = function (configuration) { Object.assign(this.configuration, configuration); }; ClickstreamProvider.prototype.getCategory = function () { return 'Analytics'; }; ClickstreamProvider.prototype.getProviderName = function () { return 'ClickstreamProvider'; }; ClickstreamProvider.prototype.record = function (event) { var result = _EventChecker__WEBPACK_IMPORTED_MODULE_3__.EventChecker.checkEventName(event.name); if (result.error_code > 0) { logger.error(result.error_message); this.recordClickstreamError(result); return; } var resultEvent = this.createEvent(event); this.recordEvent(resultEvent, event.isImmediate); }; ClickstreamProvider.prototype.createEvent = function (event, allUserAttributes) { if (allUserAttributes === void 0) { allUserAttributes = null; } return _AnalyticsEventBuilder__WEBPACK_IMPORTED_MODULE_0__.AnalyticsEventBuilder.createEvent(this.context, event, allUserAttributes === null ? this.userAttributes : allUserAttributes, this.globalAttributes, this.sessionTracker.session); }; ClickstreamProvider.prototype.recordEvent = function (event, isImmediate) { if (isImmediate === void 0) { isImmediate = false; } this.eventRecorder.record(event, isImmediate); }; ClickstreamProvider.prototype.setUserId = function (userId) { var previousUserId = ''; if (_Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.USER_ID in this.userAttributes) { previousUserId = this.userAttributes[_Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.USER_ID].value.toString(); } if (userId === null) { delete this.userAttributes[_Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.USER_ID]; } else if (userId !== previousUserId) { var userInfo = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.getUserInfoFromMapping(userId); var newUserAttribute = {}; newUserAttribute[_Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.USER_ID] = { value: userId, set_timestamp: new Date().getTime(), }; newUserAttribute[_Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP] = userInfo[_Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute.USER_FIRST_TOUCH_TIMESTAMP]; _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.updateUserAttributes(newUserAttribute); this.userAttributes = newUserAttribute; this.context.userUniqueId = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.getCurrentUserUniqueId(); } this.recordProfileSet(this.userAttributes); _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.updateUserAttributes(this.userAttributes); }; ClickstreamProvider.prototype.setUserAttributes = function (attributes) { var timestamp = new Date().getTime(); var allUserAttributes = _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.getAllUserAttributes(); for (var key in attributes) { var value = attributes[key]; if (value === null) { delete allUserAttributes[key]; } else { var currentNumber = Object.keys(allUserAttributes).length; var checkUserAttribute = _EventChecker__WEBPACK_IMPORTED_MODULE_3__.EventChecker.checkUserAttribute; var result = checkUserAttribute(currentNumber, key, value); if (result.error_code > 0) { this.recordClickstreamError(result); } else { allUserAttributes[key] = { value: value, set_timestamp: timestamp, }; } } } _util_StorageUtil__WEBPACK_IMPORTED_MODULE_11__.StorageUtil.updateUserAttributes(allUserAttributes); this.recordProfileSet(allUserAttributes); }; ClickstreamProvider.prototype.setGlobalAttributes = function (attributes) { for (var key in attributes) { var value = attributes[key]; if (value === null) { delete this.globalAttributes[key]; } else { var currentNumber = Object.keys(this.globalAttributes).length; var checkAttributes = _EventChecker__WEBPACK_IMPORTED_MODULE_3__.EventChecker.checkAttributes; var result = checkAttributes(currentNumber, key, value); if (result.error_code > 0) { this.recordClickstreamError(result); } else { this.globalAttributes[key] = value; } } } }; ClickstreamProvider.prototype.recordClickstreamError = function (error) { var _a; var _b = _Event__WEBPACK_IMPORTED_MODULE_2__.Event.ReservedAttribute, ERROR_CODE = _b.ERROR_CODE, ERROR_MESSAGE = _b.ERROR_MESSAGE; var errorEvent = this.createEvent({ name: _Event__WEBPACK_IMPORTED_MODULE_2__.Event.PresetEvent.CLICKSTREAM_ERROR, attributes: (_a = {}, _a[ERROR_CODE] = error.error_code, _a[ERROR_MESSAGE] = error.error_message, _a), }); this.recordEvent(errorEvent); }; ClickstreamProvider.prototype.recordProfileSet = function (allUserAttributes) { var profileSetEvent = this.createEvent({ name: _Event__WEBPACK_IMPORTED_MODULE_2__.Event.PresetEvent.PROFILE_SET }, allUserAttributes); this.recordEvent(profileSetEvent); }; ClickstreamProvider.prototype.startTimer = function () { setInterval(this.flushEvents.bind(this, this.eventRecorder), this.configuration.sendEventsInterval); }; ClickstreamProvider.prototype.flushEvents = function (eventRecorder) { eventRecorder.flushEvents(); }; ClickstreamProvider.prototype.sendEventsInBackground = function (isWindowClosing) { if (!(_browser__WEBPACK_IMPORTED_MODULE_5__.BrowserInfo.isFirefox() && isWindowClosing) && _browser__WEBPACK_IMPORTED_MODULE_5__.BrowserInfo.isNetworkOnLine()) { this.eventRecorder.sendEventsInBackground(isWindowClosing); } }; return ClickstreamProvider; }()); //# 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/provider/ClickstreamProvider.js?