@selwise/widget 0.0.2 → 1.0.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/README.md +2 -1
- package/dist/npm/cjs/index.cjs +2 -0
- package/dist/npm/cjs/index.cjs.LICENSE.txt +1 -0
- package/dist/npm/cjs/index.d.ts +59 -0
- package/dist/npm/esm/index.d.ts +59 -4
- package/dist/npm/esm/index.mjs +2 -0
- package/dist/npm/esm/index.mjs.LICENSE.txt +1 -0
- package/package.json +14 -16
- package/dist/npm/cjs/constants.js +0 -167
- package/dist/npm/cjs/constants.js.map +0 -1
- package/dist/npm/cjs/core/conflict-resolver.js +0 -203
- package/dist/npm/cjs/core/conflict-resolver.js.map +0 -1
- package/dist/npm/cjs/core/event-batcher.js +0 -977
- package/dist/npm/cjs/core/event-batcher.js.map +0 -1
- package/dist/npm/cjs/core/experiment-overrides.js +0 -178
- package/dist/npm/cjs/core/experiment-overrides.js.map +0 -1
- package/dist/npm/cjs/core/experiments.js +0 -317
- package/dist/npm/cjs/core/experiments.js.map +0 -1
- package/dist/npm/cjs/core/frequency-caps.js +0 -297
- package/dist/npm/cjs/core/frequency-caps.js.map +0 -1
- package/dist/npm/cjs/core/index.js +0 -27
- package/dist/npm/cjs/core/index.js.map +0 -1
- package/dist/npm/cjs/core/indexeddb-queue.js +0 -333
- package/dist/npm/cjs/core/indexeddb-queue.js.map +0 -1
- package/dist/npm/cjs/core/journey-tracker.js +0 -243
- package/dist/npm/cjs/core/journey-tracker.js.map +0 -1
- package/dist/npm/cjs/core/page-targeting/index.js +0 -72
- package/dist/npm/cjs/core/page-targeting/index.js.map +0 -1
- package/dist/npm/cjs/core/script-executor.js +0 -80
- package/dist/npm/cjs/core/script-executor.js.map +0 -1
- package/dist/npm/cjs/core/segments.js +0 -172
- package/dist/npm/cjs/core/segments.js.map +0 -1
- package/dist/npm/cjs/core/tracker.js +0 -798
- package/dist/npm/cjs/core/tracker.js.map +0 -1
- package/dist/npm/cjs/datalayer/basket.js +0 -385
- package/dist/npm/cjs/datalayer/basket.js.map +0 -1
- package/dist/npm/cjs/datalayer/cart-association.js +0 -226
- package/dist/npm/cjs/datalayer/cart-association.js.map +0 -1
- package/dist/npm/cjs/datalayer/checkout.js +0 -382
- package/dist/npm/cjs/datalayer/checkout.js.map +0 -1
- package/dist/npm/cjs/datalayer/constants.js +0 -163
- package/dist/npm/cjs/datalayer/constants.js.map +0 -1
- package/dist/npm/cjs/datalayer/index.js +0 -1010
- package/dist/npm/cjs/datalayer/index.js.map +0 -1
- package/dist/npm/cjs/datalayer/listener.js +0 -416
- package/dist/npm/cjs/datalayer/listener.js.map +0 -1
- package/dist/npm/cjs/datalayer/page.js +0 -343
- package/dist/npm/cjs/datalayer/page.js.map +0 -1
- package/dist/npm/cjs/datalayer/product.js +0 -517
- package/dist/npm/cjs/datalayer/product.js.map +0 -1
- package/dist/npm/cjs/datalayer/reverse-mappings.js +0 -139
- package/dist/npm/cjs/datalayer/reverse-mappings.js.map +0 -1
- package/dist/npm/cjs/datalayer/search.js +0 -363
- package/dist/npm/cjs/datalayer/search.js.map +0 -1
- package/dist/npm/cjs/datalayer/types.js +0 -134
- package/dist/npm/cjs/datalayer/types.js.map +0 -1
- package/dist/npm/cjs/datalayer/user.js +0 -372
- package/dist/npm/cjs/datalayer/user.js.map +0 -1
- package/dist/npm/cjs/debug/index.js +0 -679
- package/dist/npm/cjs/debug/index.js.map +0 -1
- package/dist/npm/cjs/entries/cdn.js +0 -72
- package/dist/npm/cjs/entries/cdn.js.map +0 -1
- package/dist/npm/cjs/index.js +0 -10
- package/dist/npm/cjs/index.js.map +0 -1
- package/dist/npm/cjs/modules/contract/recommendation-contract.js +0 -119
- package/dist/npm/cjs/modules/contract/recommendation-contract.js.map +0 -1
- package/dist/npm/cjs/modules/contract/search-contract.js +0 -18
- package/dist/npm/cjs/modules/contract/search-contract.js.map +0 -1
- package/dist/npm/cjs/modules/contract/tracking-contract.js +0 -16
- package/dist/npm/cjs/modules/contract/tracking-contract.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/configs.js +0 -164
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/configs.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/index.js +0 -21
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/index.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/types.js +0 -3
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/types.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/validators.js +0 -107
- package/dist/npm/cjs/modules/contract/vendor/recommendation-contract/validators.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/search-contract/configs.js +0 -404
- package/dist/npm/cjs/modules/contract/vendor/search-contract/configs.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/search-contract/index.js +0 -21
- package/dist/npm/cjs/modules/contract/vendor/search-contract/index.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/search-contract/types.js +0 -8
- package/dist/npm/cjs/modules/contract/vendor/search-contract/types.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/search-contract/validators.js +0 -126
- package/dist/npm/cjs/modules/contract/vendor/search-contract/validators.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/configs.js +0 -133
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/configs.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/index.js +0 -21
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/index.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/types.js +0 -3
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/types.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/validators.js +0 -154
- package/dist/npm/cjs/modules/contract/vendor/tracking-contract/validators.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/configs.js +0 -1481
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/configs.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/index.js +0 -22
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/index.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/layout.js +0 -21
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/layout.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/types.js +0 -8
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/types.js.map +0 -1
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/validators.js +0 -139
- package/dist/npm/cjs/modules/contract/vendor/widget-contract/validators.js.map +0 -1
- package/dist/npm/cjs/modules/contract/widget-contract.js +0 -10
- package/dist/npm/cjs/modules/contract/widget-contract.js.map +0 -1
- package/dist/npm/cjs/modules/products/tracking.js +0 -214
- package/dist/npm/cjs/modules/products/tracking.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/cart-handlers.js +0 -52
- package/dist/npm/cjs/modules/recommendation/cart-handlers.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/components/product-card-renderer.js +0 -287
- package/dist/npm/cjs/modules/recommendation/components/product-card-renderer.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/index.js +0 -678
- package/dist/npm/cjs/modules/recommendation/index.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/renderers/grid.js +0 -21
- package/dist/npm/cjs/modules/recommendation/renderers/grid.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/renderers/list.js +0 -22
- package/dist/npm/cjs/modules/recommendation/renderers/list.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/renderers/masonry.js +0 -22
- package/dist/npm/cjs/modules/recommendation/renderers/masonry.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/renderers/slider-renderer.js +0 -145
- package/dist/npm/cjs/modules/recommendation/renderers/slider-renderer.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/slider-controls.js +0 -201
- package/dist/npm/cjs/modules/recommendation/slider-controls.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/tracking.js +0 -247
- package/dist/npm/cjs/modules/recommendation/tracking.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/utils/dom.js +0 -70
- package/dist/npm/cjs/modules/recommendation/utils/dom.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/utils/format.js +0 -13
- package/dist/npm/cjs/modules/recommendation/utils/format.js.map +0 -1
- package/dist/npm/cjs/modules/recommendation/utils/index.js +0 -22
- package/dist/npm/cjs/modules/recommendation/utils/index.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/helpers.js +0 -16
- package/dist/npm/cjs/modules/renderer/helpers.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/index.js +0 -52
- package/dist/npm/cjs/modules/renderer/index.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/style-resolver.js +0 -11
- package/dist/npm/cjs/modules/renderer/style-resolver.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/styles/index.js +0 -254
- package/dist/npm/cjs/modules/renderer/styles/index.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/styles.js +0 -7
- package/dist/npm/cjs/modules/renderer/styles.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/utils/helpers.js +0 -243
- package/dist/npm/cjs/modules/renderer/utils/helpers.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/utils/image-renderer.js +0 -65
- package/dist/npm/cjs/modules/renderer/utils/image-renderer.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/utils/placement.js +0 -34
- package/dist/npm/cjs/modules/renderer/utils/placement.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/utils.js +0 -61
- package/dist/npm/cjs/modules/renderer/utils.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/announcement-bar.js +0 -84
- package/dist/npm/cjs/modules/renderer/widgets/announcement-bar.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/cart-count.js +0 -211
- package/dist/npm/cjs/modules/renderer/widgets/cart-count.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/cookie-consent.js +0 -459
- package/dist/npm/cjs/modules/renderer/widgets/cookie-consent.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/countdown-timer.js +0 -132
- package/dist/npm/cjs/modules/renderer/widgets/countdown-timer.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/custom.js +0 -58
- package/dist/npm/cjs/modules/renderer/widgets/custom.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/embedded-card.js +0 -97
- package/dist/npm/cjs/modules/renderer/widgets/embedded-card.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/exit-intent-popup.js +0 -151
- package/dist/npm/cjs/modules/renderer/widgets/exit-intent-popup.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/floating-button.js +0 -70
- package/dist/npm/cjs/modules/renderer/widgets/floating-button.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/helpers.js +0 -87
- package/dist/npm/cjs/modules/renderer/widgets/helpers.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/index.js +0 -39
- package/dist/npm/cjs/modules/renderer/widgets/index.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/inline-banner.js +0 -124
- package/dist/npm/cjs/modules/renderer/widgets/inline-banner.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/newsletter.js +0 -280
- package/dist/npm/cjs/modules/renderer/widgets/newsletter.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/product-view-count.js +0 -197
- package/dist/npm/cjs/modules/renderer/widgets/product-view-count.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/slide-in.js +0 -105
- package/dist/npm/cjs/modules/renderer/widgets/slide-in.js.map +0 -1
- package/dist/npm/cjs/modules/renderer/widgets/sticky-footer.js +0 -47
- package/dist/npm/cjs/modules/renderer/widgets/sticky-footer.js.map +0 -1
- package/dist/npm/cjs/modules/search/cart/index.js +0 -42
- package/dist/npm/cjs/modules/search/cart/index.js.map +0 -1
- package/dist/npm/cjs/modules/search/components/index.js +0 -13
- package/dist/npm/cjs/modules/search/components/index.js.map +0 -1
- package/dist/npm/cjs/modules/search/components/search-box.js +0 -28
- package/dist/npm/cjs/modules/search/components/search-box.js.map +0 -1
- package/dist/npm/cjs/modules/search/components/search-item.js +0 -197
- package/dist/npm/cjs/modules/search/components/search-item.js.map +0 -1
- package/dist/npm/cjs/modules/search/components/suggestions.js +0 -132
- package/dist/npm/cjs/modules/search/components/suggestions.js.map +0 -1
- package/dist/npm/cjs/modules/search/index.js +0 -646
- package/dist/npm/cjs/modules/search/index.js.map +0 -1
- package/dist/npm/cjs/modules/search/renderers/position-renderers.js +0 -229
- package/dist/npm/cjs/modules/search/renderers/position-renderers.js.map +0 -1
- package/dist/npm/cjs/modules/search/renderers/results-renderer.js +0 -180
- package/dist/npm/cjs/modules/search/renderers/results-renderer.js.map +0 -1
- package/dist/npm/cjs/modules/search/services/api-service.js +0 -121
- package/dist/npm/cjs/modules/search/services/api-service.js.map +0 -1
- package/dist/npm/cjs/modules/search/services/tracking-service.js +0 -263
- package/dist/npm/cjs/modules/search/services/tracking-service.js.map +0 -1
- package/dist/npm/cjs/modules/search/styles.js +0 -864
- package/dist/npm/cjs/modules/search/styles.js.map +0 -1
- package/dist/npm/cjs/modules/search/utils/helpers.js +0 -100
- package/dist/npm/cjs/modules/search/utils/helpers.js.map +0 -1
- package/dist/npm/cjs/modules/search/utils/icons.js +0 -41
- package/dist/npm/cjs/modules/search/utils/icons.js.map +0 -1
- package/dist/npm/cjs/modules/search/utils/index.js +0 -22
- package/dist/npm/cjs/modules/search/utils/index.js.map +0 -1
- package/dist/npm/cjs/modules/search/utils/storage.js +0 -58
- package/dist/npm/cjs/modules/search/utils/storage.js.map +0 -1
- package/dist/npm/cjs/selwise.js +0 -1160
- package/dist/npm/cjs/selwise.js.map +0 -1
- package/dist/npm/cjs/sentry-test.js +0 -118
- package/dist/npm/cjs/sentry-test.js.map +0 -1
- package/dist/npm/cjs/sentry.js +0 -451
- package/dist/npm/cjs/sentry.js.map +0 -1
- package/dist/npm/cjs/shared/cart/handlers.js +0 -259
- package/dist/npm/cjs/shared/cart/handlers.js.map +0 -1
- package/dist/npm/cjs/shared/cart/index.js +0 -23
- package/dist/npm/cjs/shared/cart/index.js.map +0 -1
- package/dist/npm/cjs/shared/cart/types.js +0 -7
- package/dist/npm/cjs/shared/cart/types.js.map +0 -1
- package/dist/npm/cjs/shared/product-card/index.js +0 -24
- package/dist/npm/cjs/shared/product-card/index.js.map +0 -1
- package/dist/npm/cjs/shared/product-card/renderer.js +0 -341
- package/dist/npm/cjs/shared/product-card/renderer.js.map +0 -1
- package/dist/npm/cjs/shared/product-card/styles.js +0 -195
- package/dist/npm/cjs/shared/product-card/styles.js.map +0 -1
- package/dist/npm/cjs/shared/product-card/types.js +0 -67
- package/dist/npm/cjs/shared/product-card/types.js.map +0 -1
- package/dist/npm/cjs/types/config.js +0 -6
- package/dist/npm/cjs/types/config.js.map +0 -1
- package/dist/npm/cjs/types/experiments.js +0 -17
- package/dist/npm/cjs/types/experiments.js.map +0 -1
- package/dist/npm/cjs/types/global-api.js +0 -3
- package/dist/npm/cjs/types/global-api.js.map +0 -1
- package/dist/npm/cjs/types/index.js +0 -27
- package/dist/npm/cjs/types/index.js.map +0 -1
- package/dist/npm/cjs/types/recommendation.js +0 -6
- package/dist/npm/cjs/types/recommendation.js.map +0 -1
- package/dist/npm/cjs/types/renderer.js +0 -6
- package/dist/npm/cjs/types/renderer.js.map +0 -1
- package/dist/npm/cjs/types/search.js +0 -6
- package/dist/npm/cjs/types/search.js.map +0 -1
- package/dist/npm/cjs/utils/api-url.js +0 -35
- package/dist/npm/cjs/utils/api-url.js.map +0 -1
- package/dist/npm/cjs/utils/debounce.js +0 -74
- package/dist/npm/cjs/utils/debounce.js.map +0 -1
- package/dist/npm/cjs/utils/event-id.js +0 -23
- package/dist/npm/cjs/utils/event-id.js.map +0 -1
- package/dist/npm/cjs/utils/index.js +0 -28
- package/dist/npm/cjs/utils/index.js.map +0 -1
- package/dist/npm/cjs/utils/logger.js +0 -74
- package/dist/npm/cjs/utils/logger.js.map +0 -1
- package/dist/npm/cjs/utils/sanitize.js +0 -159
- package/dist/npm/cjs/utils/sanitize.js.map +0 -1
- package/dist/npm/cjs/utils/storage.js +0 -285
- package/dist/npm/cjs/utils/storage.js.map +0 -1
- package/dist/npm/cjs/utils/tracking-metadata.js +0 -18
- package/dist/npm/cjs/utils/tracking-metadata.js.map +0 -1
- package/dist/npm/cjs/utils/url-matcher.js +0 -11
- package/dist/npm/cjs/utils/url-matcher.js.map +0 -1
- package/dist/npm/esm/constants.d.ts +0 -130
- package/dist/npm/esm/constants.js +0 -164
- package/dist/npm/esm/constants.js.map +0 -1
- package/dist/npm/esm/core/conflict-resolver.d.ts +0 -96
- package/dist/npm/esm/core/conflict-resolver.js +0 -198
- package/dist/npm/esm/core/conflict-resolver.js.map +0 -1
- package/dist/npm/esm/core/event-batcher.d.ts +0 -253
- package/dist/npm/esm/core/event-batcher.js +0 -973
- package/dist/npm/esm/core/event-batcher.js.map +0 -1
- package/dist/npm/esm/core/experiment-overrides.d.ts +0 -7
- package/dist/npm/esm/core/experiment-overrides.js +0 -172
- package/dist/npm/esm/core/experiment-overrides.js.map +0 -1
- package/dist/npm/esm/core/experiments.d.ts +0 -90
- package/dist/npm/esm/core/experiments.js +0 -313
- package/dist/npm/esm/core/experiments.js.map +0 -1
- package/dist/npm/esm/core/frequency-caps.d.ts +0 -124
- package/dist/npm/esm/core/frequency-caps.js +0 -292
- package/dist/npm/esm/core/frequency-caps.js.map +0 -1
- package/dist/npm/esm/core/index.d.ts +0 -10
- package/dist/npm/esm/core/index.js +0 -11
- package/dist/npm/esm/core/index.js.map +0 -1
- package/dist/npm/esm/core/indexeddb-queue.d.ts +0 -83
- package/dist/npm/esm/core/indexeddb-queue.js +0 -328
- package/dist/npm/esm/core/indexeddb-queue.js.map +0 -1
- package/dist/npm/esm/core/journey-tracker.d.ts +0 -102
- package/dist/npm/esm/core/journey-tracker.js +0 -237
- package/dist/npm/esm/core/journey-tracker.js.map +0 -1
- package/dist/npm/esm/core/page-targeting/index.d.ts +0 -8
- package/dist/npm/esm/core/page-targeting/index.js +0 -67
- package/dist/npm/esm/core/page-targeting/index.js.map +0 -1
- package/dist/npm/esm/core/script-executor.d.ts +0 -31
- package/dist/npm/esm/core/script-executor.js +0 -76
- package/dist/npm/esm/core/script-executor.js.map +0 -1
- package/dist/npm/esm/core/segments.d.ts +0 -39
- package/dist/npm/esm/core/segments.js +0 -168
- package/dist/npm/esm/core/segments.js.map +0 -1
- package/dist/npm/esm/core/tracker.d.ts +0 -182
- package/dist/npm/esm/core/tracker.js +0 -794
- package/dist/npm/esm/core/tracker.js.map +0 -1
- package/dist/npm/esm/datalayer/basket.d.ts +0 -104
- package/dist/npm/esm/datalayer/basket.js +0 -381
- package/dist/npm/esm/datalayer/basket.js.map +0 -1
- package/dist/npm/esm/datalayer/cart-association.d.ts +0 -65
- package/dist/npm/esm/datalayer/cart-association.js +0 -222
- package/dist/npm/esm/datalayer/cart-association.js.map +0 -1
- package/dist/npm/esm/datalayer/checkout.d.ts +0 -96
- package/dist/npm/esm/datalayer/checkout.js +0 -378
- package/dist/npm/esm/datalayer/checkout.js.map +0 -1
- package/dist/npm/esm/datalayer/constants.d.ts +0 -77
- package/dist/npm/esm/datalayer/constants.js +0 -160
- package/dist/npm/esm/datalayer/constants.js.map +0 -1
- package/dist/npm/esm/datalayer/index.d.ts +0 -212
- package/dist/npm/esm/datalayer/index.js +0 -991
- package/dist/npm/esm/datalayer/index.js.map +0 -1
- package/dist/npm/esm/datalayer/listener.d.ts +0 -108
- package/dist/npm/esm/datalayer/listener.js +0 -411
- package/dist/npm/esm/datalayer/listener.js.map +0 -1
- package/dist/npm/esm/datalayer/page.d.ts +0 -94
- package/dist/npm/esm/datalayer/page.js +0 -339
- package/dist/npm/esm/datalayer/page.js.map +0 -1
- package/dist/npm/esm/datalayer/product.d.ts +0 -133
- package/dist/npm/esm/datalayer/product.js +0 -513
- package/dist/npm/esm/datalayer/product.js.map +0 -1
- package/dist/npm/esm/datalayer/reverse-mappings.d.ts +0 -62
- package/dist/npm/esm/datalayer/reverse-mappings.js +0 -135
- package/dist/npm/esm/datalayer/reverse-mappings.js.map +0 -1
- package/dist/npm/esm/datalayer/search.d.ts +0 -108
- package/dist/npm/esm/datalayer/search.js +0 -359
- package/dist/npm/esm/datalayer/search.js.map +0 -1
- package/dist/npm/esm/datalayer/types.d.ts +0 -292
- package/dist/npm/esm/datalayer/types.js +0 -131
- package/dist/npm/esm/datalayer/types.js.map +0 -1
- package/dist/npm/esm/datalayer/user.d.ts +0 -104
- package/dist/npm/esm/datalayer/user.js +0 -368
- package/dist/npm/esm/datalayer/user.js.map +0 -1
- package/dist/npm/esm/debug/index.d.ts +0 -173
- package/dist/npm/esm/debug/index.js +0 -673
- package/dist/npm/esm/debug/index.js.map +0 -1
- package/dist/npm/esm/entries/cdn.d.ts +0 -1
- package/dist/npm/esm/entries/cdn.js +0 -35
- package/dist/npm/esm/entries/cdn.js.map +0 -1
- package/dist/npm/esm/index.js +0 -4
- package/dist/npm/esm/index.js.map +0 -1
- package/dist/npm/esm/modules/contract/recommendation-contract.d.ts +0 -5
- package/dist/npm/esm/modules/contract/recommendation-contract.js +0 -107
- package/dist/npm/esm/modules/contract/recommendation-contract.js.map +0 -1
- package/dist/npm/esm/modules/contract/search-contract.d.ts +0 -1
- package/dist/npm/esm/modules/contract/search-contract.js +0 -2
- package/dist/npm/esm/modules/contract/search-contract.js.map +0 -1
- package/dist/npm/esm/modules/contract/tracking-contract.d.ts +0 -1
- package/dist/npm/esm/modules/contract/tracking-contract.js +0 -2
- package/dist/npm/esm/modules/contract/tracking-contract.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/configs.d.ts +0 -8
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/configs.js +0 -160
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/configs.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/index.d.ts +0 -3
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/index.js +0 -5
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/index.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/types.d.ts +0 -56
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/types.js +0 -2
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/types.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/validators.d.ts +0 -3
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/validators.js +0 -103
- package/dist/npm/esm/modules/contract/vendor/recommendation-contract/validators.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/search-contract/configs.d.ts +0 -35
- package/dist/npm/esm/modules/contract/vendor/search-contract/configs.js +0 -396
- package/dist/npm/esm/modules/contract/vendor/search-contract/configs.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/search-contract/index.d.ts +0 -3
- package/dist/npm/esm/modules/contract/vendor/search-contract/index.js +0 -5
- package/dist/npm/esm/modules/contract/vendor/search-contract/index.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/search-contract/types.d.ts +0 -119
- package/dist/npm/esm/modules/contract/vendor/search-contract/types.js +0 -7
- package/dist/npm/esm/modules/contract/vendor/search-contract/types.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/search-contract/validators.d.ts +0 -22
- package/dist/npm/esm/modules/contract/vendor/search-contract/validators.js +0 -118
- package/dist/npm/esm/modules/contract/vendor/search-contract/validators.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/configs.d.ts +0 -7
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/configs.js +0 -130
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/configs.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/index.d.ts +0 -3
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/index.js +0 -5
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/index.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/types.d.ts +0 -37
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/types.js +0 -2
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/types.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/validators.d.ts +0 -6
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/validators.js +0 -147
- package/dist/npm/esm/modules/contract/vendor/tracking-contract/validators.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/widget-contract/configs.d.ts +0 -22
- package/dist/npm/esm/modules/contract/vendor/widget-contract/configs.js +0 -1472
- package/dist/npm/esm/modules/contract/vendor/widget-contract/configs.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/widget-contract/index.d.ts +0 -4
- package/dist/npm/esm/modules/contract/vendor/widget-contract/index.js +0 -6
- package/dist/npm/esm/modules/contract/vendor/widget-contract/index.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/widget-contract/layout.d.ts +0 -14
- package/dist/npm/esm/modules/contract/vendor/widget-contract/layout.js +0 -18
- package/dist/npm/esm/modules/contract/vendor/widget-contract/layout.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/widget-contract/types.d.ts +0 -128
- package/dist/npm/esm/modules/contract/vendor/widget-contract/types.js +0 -7
- package/dist/npm/esm/modules/contract/vendor/widget-contract/types.js.map +0 -1
- package/dist/npm/esm/modules/contract/vendor/widget-contract/validators.d.ts +0 -11
- package/dist/npm/esm/modules/contract/vendor/widget-contract/validators.js +0 -132
- package/dist/npm/esm/modules/contract/vendor/widget-contract/validators.js.map +0 -1
- package/dist/npm/esm/modules/contract/widget-contract.d.ts +0 -1
- package/dist/npm/esm/modules/contract/widget-contract.js +0 -2
- package/dist/npm/esm/modules/contract/widget-contract.js.map +0 -1
- package/dist/npm/esm/modules/products/tracking.d.ts +0 -122
- package/dist/npm/esm/modules/products/tracking.js +0 -203
- package/dist/npm/esm/modules/products/tracking.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/cart-handlers.d.ts +0 -10
- package/dist/npm/esm/modules/recommendation/cart-handlers.js +0 -49
- package/dist/npm/esm/modules/recommendation/cart-handlers.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/components/product-card-renderer.d.ts +0 -37
- package/dist/npm/esm/modules/recommendation/components/product-card-renderer.js +0 -281
- package/dist/npm/esm/modules/recommendation/components/product-card-renderer.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/index.d.ts +0 -11
- package/dist/npm/esm/modules/recommendation/index.js +0 -674
- package/dist/npm/esm/modules/recommendation/index.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/renderers/grid.d.ts +0 -5
- package/dist/npm/esm/modules/recommendation/renderers/grid.js +0 -18
- package/dist/npm/esm/modules/recommendation/renderers/grid.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/renderers/list.d.ts +0 -5
- package/dist/npm/esm/modules/recommendation/renderers/list.js +0 -19
- package/dist/npm/esm/modules/recommendation/renderers/list.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/renderers/masonry.d.ts +0 -5
- package/dist/npm/esm/modules/recommendation/renderers/masonry.js +0 -19
- package/dist/npm/esm/modules/recommendation/renderers/masonry.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/renderers/slider-renderer.d.ts +0 -10
- package/dist/npm/esm/modules/recommendation/renderers/slider-renderer.js +0 -140
- package/dist/npm/esm/modules/recommendation/renderers/slider-renderer.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/slider-controls.d.ts +0 -17
- package/dist/npm/esm/modules/recommendation/slider-controls.js +0 -187
- package/dist/npm/esm/modules/recommendation/slider-controls.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/tracking.d.ts +0 -28
- package/dist/npm/esm/modules/recommendation/tracking.js +0 -237
- package/dist/npm/esm/modules/recommendation/tracking.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/utils/dom.d.ts +0 -10
- package/dist/npm/esm/modules/recommendation/utils/dom.js +0 -63
- package/dist/npm/esm/modules/recommendation/utils/dom.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/utils/format.d.ts +0 -4
- package/dist/npm/esm/modules/recommendation/utils/format.js +0 -10
- package/dist/npm/esm/modules/recommendation/utils/format.js.map +0 -1
- package/dist/npm/esm/modules/recommendation/utils/index.d.ts +0 -5
- package/dist/npm/esm/modules/recommendation/utils/index.js +0 -6
- package/dist/npm/esm/modules/recommendation/utils/index.js.map +0 -1
- package/dist/npm/esm/modules/renderer/helpers.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/helpers.js +0 -6
- package/dist/npm/esm/modules/renderer/helpers.js.map +0 -1
- package/dist/npm/esm/modules/renderer/index.d.ts +0 -8
- package/dist/npm/esm/modules/renderer/index.js +0 -48
- package/dist/npm/esm/modules/renderer/index.js.map +0 -1
- package/dist/npm/esm/modules/renderer/style-resolver.d.ts +0 -1
- package/dist/npm/esm/modules/renderer/style-resolver.js +0 -8
- package/dist/npm/esm/modules/renderer/style-resolver.js.map +0 -1
- package/dist/npm/esm/modules/renderer/styles/index.d.ts +0 -12
- package/dist/npm/esm/modules/renderer/styles/index.js +0 -250
- package/dist/npm/esm/modules/renderer/styles/index.js.map +0 -1
- package/dist/npm/esm/modules/renderer/styles.d.ts +0 -1
- package/dist/npm/esm/modules/renderer/styles.js +0 -2
- package/dist/npm/esm/modules/renderer/styles.js.map +0 -1
- package/dist/npm/esm/modules/renderer/utils/helpers.d.ts +0 -58
- package/dist/npm/esm/modules/renderer/utils/helpers.js +0 -225
- package/dist/npm/esm/modules/renderer/utils/helpers.js.map +0 -1
- package/dist/npm/esm/modules/renderer/utils/image-renderer.d.ts +0 -17
- package/dist/npm/esm/modules/renderer/utils/image-renderer.js +0 -60
- package/dist/npm/esm/modules/renderer/utils/image-renderer.js.map +0 -1
- package/dist/npm/esm/modules/renderer/utils/placement.d.ts +0 -6
- package/dist/npm/esm/modules/renderer/utils/placement.js +0 -31
- package/dist/npm/esm/modules/renderer/utils/placement.js.map +0 -1
- package/dist/npm/esm/modules/renderer/utils.d.ts +0 -11
- package/dist/npm/esm/modules/renderer/utils.js +0 -44
- package/dist/npm/esm/modules/renderer/utils.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/announcement-bar.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/announcement-bar.js +0 -81
- package/dist/npm/esm/modules/renderer/widgets/announcement-bar.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/cart-count.d.ts +0 -6
- package/dist/npm/esm/modules/renderer/widgets/cart-count.js +0 -208
- package/dist/npm/esm/modules/renderer/widgets/cart-count.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/cookie-consent.d.ts +0 -18
- package/dist/npm/esm/modules/renderer/widgets/cookie-consent.js +0 -454
- package/dist/npm/esm/modules/renderer/widgets/cookie-consent.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/countdown-timer.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/countdown-timer.js +0 -129
- package/dist/npm/esm/modules/renderer/widgets/countdown-timer.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/custom.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/custom.js +0 -55
- package/dist/npm/esm/modules/renderer/widgets/custom.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/embedded-card.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/embedded-card.js +0 -94
- package/dist/npm/esm/modules/renderer/widgets/embedded-card.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/exit-intent-popup.d.ts +0 -6
- package/dist/npm/esm/modules/renderer/widgets/exit-intent-popup.js +0 -147
- package/dist/npm/esm/modules/renderer/widgets/exit-intent-popup.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/floating-button.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/floating-button.js +0 -67
- package/dist/npm/esm/modules/renderer/widgets/floating-button.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/helpers.d.ts +0 -29
- package/dist/npm/esm/modules/renderer/widgets/helpers.js +0 -82
- package/dist/npm/esm/modules/renderer/widgets/helpers.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/index.d.ts +0 -17
- package/dist/npm/esm/modules/renderer/widgets/index.js +0 -19
- package/dist/npm/esm/modules/renderer/widgets/index.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/inline-banner.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/inline-banner.js +0 -121
- package/dist/npm/esm/modules/renderer/widgets/inline-banner.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/newsletter.d.ts +0 -6
- package/dist/npm/esm/modules/renderer/widgets/newsletter.js +0 -277
- package/dist/npm/esm/modules/renderer/widgets/newsletter.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/product-view-count.d.ts +0 -6
- package/dist/npm/esm/modules/renderer/widgets/product-view-count.js +0 -194
- package/dist/npm/esm/modules/renderer/widgets/product-view-count.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/slide-in.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/slide-in.js +0 -102
- package/dist/npm/esm/modules/renderer/widgets/slide-in.js.map +0 -1
- package/dist/npm/esm/modules/renderer/widgets/sticky-footer.d.ts +0 -5
- package/dist/npm/esm/modules/renderer/widgets/sticky-footer.js +0 -44
- package/dist/npm/esm/modules/renderer/widgets/sticky-footer.js.map +0 -1
- package/dist/npm/esm/modules/search/cart/index.d.ts +0 -26
- package/dist/npm/esm/modules/search/cart/index.js +0 -39
- package/dist/npm/esm/modules/search/cart/index.js.map +0 -1
- package/dist/npm/esm/modules/search/components/index.d.ts +0 -6
- package/dist/npm/esm/modules/search/components/index.js +0 -7
- package/dist/npm/esm/modules/search/components/index.js.map +0 -1
- package/dist/npm/esm/modules/search/components/search-box.d.ts +0 -11
- package/dist/npm/esm/modules/search/components/search-box.js +0 -25
- package/dist/npm/esm/modules/search/components/search-box.js.map +0 -1
- package/dist/npm/esm/modules/search/components/search-item.d.ts +0 -20
- package/dist/npm/esm/modules/search/components/search-item.js +0 -193
- package/dist/npm/esm/modules/search/components/search-item.js.map +0 -1
- package/dist/npm/esm/modules/search/components/suggestions.d.ts +0 -10
- package/dist/npm/esm/modules/search/components/suggestions.js +0 -129
- package/dist/npm/esm/modules/search/components/suggestions.js.map +0 -1
- package/dist/npm/esm/modules/search/index.d.ts +0 -67
- package/dist/npm/esm/modules/search/index.js +0 -642
- package/dist/npm/esm/modules/search/index.js.map +0 -1
- package/dist/npm/esm/modules/search/renderers/position-renderers.d.ts +0 -23
- package/dist/npm/esm/modules/search/renderers/position-renderers.js +0 -221
- package/dist/npm/esm/modules/search/renderers/position-renderers.js.map +0 -1
- package/dist/npm/esm/modules/search/renderers/results-renderer.d.ts +0 -20
- package/dist/npm/esm/modules/search/renderers/results-renderer.js +0 -176
- package/dist/npm/esm/modules/search/renderers/results-renderer.js.map +0 -1
- package/dist/npm/esm/modules/search/services/api-service.d.ts +0 -18
- package/dist/npm/esm/modules/search/services/api-service.js +0 -115
- package/dist/npm/esm/modules/search/services/api-service.js.map +0 -1
- package/dist/npm/esm/modules/search/services/tracking-service.d.ts +0 -16
- package/dist/npm/esm/modules/search/services/tracking-service.js +0 -250
- package/dist/npm/esm/modules/search/services/tracking-service.js.map +0 -1
- package/dist/npm/esm/modules/search/styles.d.ts +0 -13
- package/dist/npm/esm/modules/search/styles.js +0 -860
- package/dist/npm/esm/modules/search/styles.js.map +0 -1
- package/dist/npm/esm/modules/search/utils/helpers.d.ts +0 -24
- package/dist/npm/esm/modules/search/utils/helpers.js +0 -93
- package/dist/npm/esm/modules/search/utils/helpers.js.map +0 -1
- package/dist/npm/esm/modules/search/utils/icons.d.ts +0 -16
- package/dist/npm/esm/modules/search/utils/icons.js +0 -36
- package/dist/npm/esm/modules/search/utils/icons.js.map +0 -1
- package/dist/npm/esm/modules/search/utils/index.d.ts +0 -6
- package/dist/npm/esm/modules/search/utils/index.js +0 -7
- package/dist/npm/esm/modules/search/utils/index.js.map +0 -1
- package/dist/npm/esm/modules/search/utils/storage.d.ts +0 -7
- package/dist/npm/esm/modules/search/utils/storage.js +0 -52
- package/dist/npm/esm/modules/search/utils/storage.js.map +0 -1
- package/dist/npm/esm/package.json +0 -1
- package/dist/npm/esm/selwise.d.ts +0 -209
- package/dist/npm/esm/selwise.js +0 -1123
- package/dist/npm/esm/selwise.js.map +0 -1
- package/dist/npm/esm/sentry-test.d.ts +0 -45
- package/dist/npm/esm/sentry-test.js +0 -109
- package/dist/npm/esm/sentry-test.js.map +0 -1
- package/dist/npm/esm/sentry.d.ts +0 -86
- package/dist/npm/esm/sentry.js +0 -441
- package/dist/npm/esm/sentry.js.map +0 -1
- package/dist/npm/esm/shared/cart/handlers.d.ts +0 -46
- package/dist/npm/esm/shared/cart/handlers.js +0 -249
- package/dist/npm/esm/shared/cart/handlers.js.map +0 -1
- package/dist/npm/esm/shared/cart/index.d.ts +0 -6
- package/dist/npm/esm/shared/cart/index.js +0 -7
- package/dist/npm/esm/shared/cart/index.js.map +0 -1
- package/dist/npm/esm/shared/cart/types.d.ts +0 -30
- package/dist/npm/esm/shared/cart/types.js +0 -6
- package/dist/npm/esm/shared/cart/types.js.map +0 -1
- package/dist/npm/esm/shared/product-card/index.d.ts +0 -7
- package/dist/npm/esm/shared/product-card/index.js +0 -8
- package/dist/npm/esm/shared/product-card/index.js.map +0 -1
- package/dist/npm/esm/shared/product-card/renderer.d.ts +0 -35
- package/dist/npm/esm/shared/product-card/renderer.js +0 -334
- package/dist/npm/esm/shared/product-card/renderer.js.map +0 -1
- package/dist/npm/esm/shared/product-card/styles.d.ts +0 -17
- package/dist/npm/esm/shared/product-card/styles.js +0 -190
- package/dist/npm/esm/shared/product-card/styles.js.map +0 -1
- package/dist/npm/esm/shared/product-card/types.d.ts +0 -84
- package/dist/npm/esm/shared/product-card/types.js +0 -63
- package/dist/npm/esm/shared/product-card/types.js.map +0 -1
- package/dist/npm/esm/types/config.d.ts +0 -26
- package/dist/npm/esm/types/config.js +0 -5
- package/dist/npm/esm/types/config.js.map +0 -1
- package/dist/npm/esm/types/experiments.d.ts +0 -47
- package/dist/npm/esm/types/experiments.js +0 -14
- package/dist/npm/esm/types/experiments.js.map +0 -1
- package/dist/npm/esm/types/global-api.d.ts +0 -40
- package/dist/npm/esm/types/global-api.js +0 -2
- package/dist/npm/esm/types/global-api.js.map +0 -1
- package/dist/npm/esm/types/index.d.ts +0 -9
- package/dist/npm/esm/types/index.js +0 -11
- package/dist/npm/esm/types/index.js.map +0 -1
- package/dist/npm/esm/types/recommendation.d.ts +0 -186
- package/dist/npm/esm/types/recommendation.js +0 -5
- package/dist/npm/esm/types/recommendation.js.map +0 -1
- package/dist/npm/esm/types/renderer.d.ts +0 -99
- package/dist/npm/esm/types/renderer.js +0 -5
- package/dist/npm/esm/types/renderer.js.map +0 -1
- package/dist/npm/esm/types/search.d.ts +0 -186
- package/dist/npm/esm/types/search.js +0 -5
- package/dist/npm/esm/types/search.js.map +0 -1
- package/dist/npm/esm/utils/api-url.d.ts +0 -1
- package/dist/npm/esm/utils/api-url.js +0 -32
- package/dist/npm/esm/utils/api-url.js.map +0 -1
- package/dist/npm/esm/utils/debounce.d.ts +0 -27
- package/dist/npm/esm/utils/debounce.js +0 -70
- package/dist/npm/esm/utils/debounce.js.map +0 -1
- package/dist/npm/esm/utils/event-id.d.ts +0 -5
- package/dist/npm/esm/utils/event-id.js +0 -20
- package/dist/npm/esm/utils/event-id.js.map +0 -1
- package/dist/npm/esm/utils/index.d.ts +0 -11
- package/dist/npm/esm/utils/index.js +0 -12
- package/dist/npm/esm/utils/index.js.map +0 -1
- package/dist/npm/esm/utils/logger.d.ts +0 -31
- package/dist/npm/esm/utils/logger.js +0 -66
- package/dist/npm/esm/utils/logger.js.map +0 -1
- package/dist/npm/esm/utils/sanitize.d.ts +0 -38
- package/dist/npm/esm/utils/sanitize.js +0 -148
- package/dist/npm/esm/utils/sanitize.js.map +0 -1
- package/dist/npm/esm/utils/storage.d.ts +0 -72
- package/dist/npm/esm/utils/storage.js +0 -271
- package/dist/npm/esm/utils/storage.js.map +0 -1
- package/dist/npm/esm/utils/tracking-metadata.d.ts +0 -1
- package/dist/npm/esm/utils/tracking-metadata.js +0 -15
- package/dist/npm/esm/utils/tracking-metadata.js.map +0 -1
- package/dist/npm/esm/utils/url-matcher.d.ts +0 -4
- package/dist/npm/esm/utils/url-matcher.js +0 -8
- package/dist/npm/esm/utils/url-matcher.js.map +0 -1
package/dist/npm/esm/selwise.js
DELETED
|
@@ -1,1123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Selwise - Lightweight Embed Script
|
|
3
|
-
* Campaign-Centric Architecture
|
|
4
|
-
* Target: < 15KB gzipped
|
|
5
|
-
*/
|
|
6
|
-
import { WidgetRenderer } from './modules/renderer/index.js';
|
|
7
|
-
import { Tracker, ExperimentManager, getConflictResolver, getFrequencyCapManager, evaluatePageTargeting, } from './core/index.js';
|
|
8
|
-
import { deepMergeExperimentConfig, getEffectiveConfig, normalizeContentFields, } from './core/experiment-overrides.js';
|
|
9
|
-
import { SegmentManager } from './core/segments.js';
|
|
10
|
-
import { isTestModeEnabled, resolveApiUrl } from './utils/index.js';
|
|
11
|
-
import { testModeLog, testModeDebug, testModeWarn, testModeError, setDebugMode, } from './utils/logger.js';
|
|
12
|
-
import { initSentryFromConfig, captureException } from './sentry.js';
|
|
13
|
-
import { DataLayerManager } from './datalayer/index.js';
|
|
14
|
-
import { cleanupDeferredRenderers, removeEntityRootsFromDOM, removeEntityRootsById, } from './modules/renderer/utils/helpers.js';
|
|
15
|
-
export class Selwise {
|
|
16
|
-
constructor() {
|
|
17
|
-
this.experiments = null;
|
|
18
|
-
this.segments = null;
|
|
19
|
-
this.dataLayerManager = null; // Data layer for GTM-style tracking
|
|
20
|
-
this.searchModule = null; // Dynamically loaded module
|
|
21
|
-
this.recommendationsCleanup = null; // Cleanup function for recommendations
|
|
22
|
-
this.recommendationsInitialized = false;
|
|
23
|
-
this.campaigns = [];
|
|
24
|
-
this.widgets = [];
|
|
25
|
-
this.recommendationWidgets = [];
|
|
26
|
-
this.isDestroyed = false;
|
|
27
|
-
this.renderedEntities = new Set(); // Track rendered entities to prevent duplicates
|
|
28
|
-
this.frequencyCapManager = getFrequencyCapManager();
|
|
29
|
-
this.conflictResolver = getConflictResolver();
|
|
30
|
-
// Store original History API methods for cleanup
|
|
31
|
-
this.originalPushState = null;
|
|
32
|
-
this.originalReplaceState = null;
|
|
33
|
-
this.popStateListener = null;
|
|
34
|
-
// Track pending timeouts for cleanup
|
|
35
|
-
this.pendingTimeouts = new Set();
|
|
36
|
-
this.spaCleanupSetup = false;
|
|
37
|
-
this.config = {
|
|
38
|
-
siteKey: '',
|
|
39
|
-
apiUrl: resolveApiUrl(),
|
|
40
|
-
};
|
|
41
|
-
this.renderer = new WidgetRenderer();
|
|
42
|
-
this.tracker = new Tracker(this.config.apiUrl, this.config.siteKey);
|
|
43
|
-
}
|
|
44
|
-
isBrowserEnvironment() {
|
|
45
|
-
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
46
|
-
}
|
|
47
|
-
bindGlobalInstance() {
|
|
48
|
-
if (!this.isBrowserEnvironment())
|
|
49
|
-
return;
|
|
50
|
-
try {
|
|
51
|
-
window.Selwise = this;
|
|
52
|
-
}
|
|
53
|
-
catch {
|
|
54
|
-
// ignore
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
clearGlobalInstanceBinding() {
|
|
58
|
-
if (!this.isBrowserEnvironment())
|
|
59
|
-
return;
|
|
60
|
-
try {
|
|
61
|
-
const globalWindow = window;
|
|
62
|
-
if (globalWindow.Selwise !== this)
|
|
63
|
-
return;
|
|
64
|
-
delete globalWindow.Selwise;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
try {
|
|
68
|
-
if (window.Selwise === this) {
|
|
69
|
-
window.Selwise = undefined;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
// ignore
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Public getters for external access
|
|
78
|
-
get siteKey() {
|
|
79
|
-
return this.config.siteKey || '';
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Detect missing browser features
|
|
83
|
-
* Returns array of missing feature names for graceful degradation
|
|
84
|
-
*/
|
|
85
|
-
detectMissingFeatures() {
|
|
86
|
-
const missing = [];
|
|
87
|
-
// Check for fetch API
|
|
88
|
-
if (typeof fetch === 'undefined') {
|
|
89
|
-
missing.push('fetch');
|
|
90
|
-
}
|
|
91
|
-
// Check for Promise support
|
|
92
|
-
if (typeof Promise === 'undefined') {
|
|
93
|
-
missing.push('Promise');
|
|
94
|
-
}
|
|
95
|
-
// Check for IntersectionObserver (used in view tracking)
|
|
96
|
-
if (typeof IntersectionObserver === 'undefined') {
|
|
97
|
-
missing.push('IntersectionObserver');
|
|
98
|
-
}
|
|
99
|
-
// Check for Map/Set (used for caching)
|
|
100
|
-
if (typeof Map === 'undefined' || typeof Set === 'undefined') {
|
|
101
|
-
missing.push('Map/Set');
|
|
102
|
-
}
|
|
103
|
-
// Check for MutationObserver (used for SPA navigation)
|
|
104
|
-
if (typeof MutationObserver === 'undefined') {
|
|
105
|
-
missing.push('MutationObserver');
|
|
106
|
-
}
|
|
107
|
-
// Check for URL/URLSearchParams (used in search)
|
|
108
|
-
if (typeof URL === 'undefined' || typeof URLSearchParams === 'undefined') {
|
|
109
|
-
missing.push('URL/URLSearchParams');
|
|
110
|
-
}
|
|
111
|
-
return missing;
|
|
112
|
-
}
|
|
113
|
-
get apiUrl() {
|
|
114
|
-
return this.config.apiUrl || '';
|
|
115
|
-
}
|
|
116
|
-
get trackingConfig() {
|
|
117
|
-
return this._trackingConfig || null;
|
|
118
|
-
}
|
|
119
|
-
cleanupRenderedEntityRoots() {
|
|
120
|
-
this.renderedEntities.clear();
|
|
121
|
-
cleanupDeferredRenderers();
|
|
122
|
-
removeEntityRootsFromDOM();
|
|
123
|
-
document.querySelectorAll('[data-widget-id]').forEach((element) => {
|
|
124
|
-
const htmlElement = element;
|
|
125
|
-
if (htmlElement.getAttribute('data-selwise-recommendation') === 'true')
|
|
126
|
-
return;
|
|
127
|
-
htmlElement.remove();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
cleanupRenderedEntityById(entityId, entityType) {
|
|
131
|
-
removeEntityRootsById(entityId, entityType);
|
|
132
|
-
document.querySelectorAll('[data-widget-id]').forEach((element) => {
|
|
133
|
-
const htmlElement = element;
|
|
134
|
-
if (htmlElement.dataset.widgetId !== entityId)
|
|
135
|
-
return;
|
|
136
|
-
if (htmlElement.getAttribute('data-selwise-recommendation') === 'true')
|
|
137
|
-
return;
|
|
138
|
-
htmlElement.remove();
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Setup SPA navigation detection for cleanup
|
|
143
|
-
* Listens for popstate and detects URL changes
|
|
144
|
-
*
|
|
145
|
-
* FIXED: Race condition by reading location.href directly instead of caching
|
|
146
|
-
*/
|
|
147
|
-
setupSPACleanup() {
|
|
148
|
-
// Store original History API methods for restoration on destroy
|
|
149
|
-
this.originalPushState = history.pushState.bind(history);
|
|
150
|
-
this.originalReplaceState = history.replaceState.bind(history);
|
|
151
|
-
// Listen for back/forward navigation - store listener for cleanup
|
|
152
|
-
this.popStateListener = () => {
|
|
153
|
-
this.onNavigate();
|
|
154
|
-
};
|
|
155
|
-
window.addEventListener('popstate', this.popStateListener);
|
|
156
|
-
// Intercept pushState and replaceState for modern SPAs
|
|
157
|
-
// Capture URL before and after to detect actual changes
|
|
158
|
-
history.pushState = (...args) => {
|
|
159
|
-
const previousUrl = window.location.href;
|
|
160
|
-
this.originalPushState(...args);
|
|
161
|
-
const currentUrl = window.location.href;
|
|
162
|
-
if (previousUrl !== currentUrl) {
|
|
163
|
-
this.onNavigate();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
history.replaceState = (...args) => {
|
|
167
|
-
const previousUrl = window.location.href;
|
|
168
|
-
this.originalReplaceState(...args);
|
|
169
|
-
const currentUrl = window.location.href;
|
|
170
|
-
if (previousUrl !== currentUrl) {
|
|
171
|
-
this.onNavigate();
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Called when SPA navigation is detected
|
|
177
|
-
* Cleans up current page resources and re-initializes for new page
|
|
178
|
-
*/
|
|
179
|
-
onNavigate() {
|
|
180
|
-
const currentUrl = window.location.href;
|
|
181
|
-
testModeDebug('Selwise', 'SPA navigation detected:', currentUrl, '- cleaning up...');
|
|
182
|
-
// Clear any pending timeouts from previous navigation
|
|
183
|
-
this.pendingTimeouts.forEach((id) => clearTimeout(id));
|
|
184
|
-
this.pendingTimeouts.clear();
|
|
185
|
-
// Cleanup search module
|
|
186
|
-
if (this.searchModule?.destroy) {
|
|
187
|
-
this.searchModule.destroy();
|
|
188
|
-
this.searchModule = null;
|
|
189
|
-
}
|
|
190
|
-
// Cleanup recommendations module
|
|
191
|
-
if (this.recommendationsCleanup) {
|
|
192
|
-
this.recommendationsCleanup();
|
|
193
|
-
this.recommendationsCleanup = null;
|
|
194
|
-
}
|
|
195
|
-
this.recommendationsInitialized = false;
|
|
196
|
-
// Cleanup rendered campaign/widget roots and pending deferred observers
|
|
197
|
-
this.cleanupRenderedEntityRoots();
|
|
198
|
-
// Cleanup tracker state (IntersectionObservers, caches)
|
|
199
|
-
this.tracker.cleanup();
|
|
200
|
-
// Cleanup and reinitialize data layer for new page
|
|
201
|
-
if (this.dataLayerManager) {
|
|
202
|
-
this.dataLayerManager.destroy();
|
|
203
|
-
this.dataLayerManager = null;
|
|
204
|
-
}
|
|
205
|
-
const dataLayerTimeout = window.setTimeout(() => {
|
|
206
|
-
this.pendingTimeouts.delete(dataLayerTimeout);
|
|
207
|
-
this.initDataLayer();
|
|
208
|
-
}, 50);
|
|
209
|
-
this.pendingTimeouts.add(dataLayerTimeout);
|
|
210
|
-
// Cleanup custom scripts
|
|
211
|
-
document.querySelectorAll('script[data-selwise-script]').forEach((el) => el.remove());
|
|
212
|
-
document.querySelectorAll('style[data-selwise-script-css]').forEach((el) => el.remove());
|
|
213
|
-
// Cleanup custom widget JS/CSS
|
|
214
|
-
document.querySelectorAll('script[data-selwise-custom-js]').forEach((el) => el.remove());
|
|
215
|
-
document.querySelectorAll('style[data-selwise-custom-css]').forEach((el) => el.remove());
|
|
216
|
-
// Cleanup product card JS
|
|
217
|
-
document.querySelectorAll('script[data-selwise-card-js]').forEach((el) => el.remove());
|
|
218
|
-
// Re-initialize for new page (after a small delay to let DOM settle)
|
|
219
|
-
const initTimeout = window.setTimeout(() => {
|
|
220
|
-
this.pendingTimeouts.delete(initTimeout);
|
|
221
|
-
this.initSearch();
|
|
222
|
-
this.initRecommendations();
|
|
223
|
-
this.renderEntitiesWithPolicies().catch((error) => {
|
|
224
|
-
testModeDebug('Selwise', 'Failed to render entities after navigation:', error);
|
|
225
|
-
});
|
|
226
|
-
}, 100);
|
|
227
|
-
this.pendingTimeouts.add(initTimeout);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Destroy the entire Selwise instance
|
|
231
|
-
* Call this when completely removing the widget from the page
|
|
232
|
-
*/
|
|
233
|
-
destroy() {
|
|
234
|
-
if (this.isDestroyed)
|
|
235
|
-
return;
|
|
236
|
-
this.isDestroyed = true;
|
|
237
|
-
// Clear all pending timeouts
|
|
238
|
-
this.pendingTimeouts.forEach((id) => clearTimeout(id));
|
|
239
|
-
this.pendingTimeouts.clear();
|
|
240
|
-
// Restore original History API methods to prevent memory leaks
|
|
241
|
-
if (this.originalPushState) {
|
|
242
|
-
history.pushState = this.originalPushState;
|
|
243
|
-
this.originalPushState = null;
|
|
244
|
-
}
|
|
245
|
-
if (this.originalReplaceState) {
|
|
246
|
-
history.replaceState = this.originalReplaceState;
|
|
247
|
-
this.originalReplaceState = null;
|
|
248
|
-
}
|
|
249
|
-
if (this.popStateListener) {
|
|
250
|
-
window.removeEventListener('popstate', this.popStateListener);
|
|
251
|
-
this.popStateListener = null;
|
|
252
|
-
}
|
|
253
|
-
this.spaCleanupSetup = false;
|
|
254
|
-
// Cleanup search module
|
|
255
|
-
if (this.searchModule?.destroy) {
|
|
256
|
-
this.searchModule.destroy();
|
|
257
|
-
}
|
|
258
|
-
// Cleanup recommendations module
|
|
259
|
-
if (this.recommendationsCleanup) {
|
|
260
|
-
this.recommendationsCleanup();
|
|
261
|
-
}
|
|
262
|
-
// Cleanup data layer manager
|
|
263
|
-
if (this.dataLayerManager) {
|
|
264
|
-
this.dataLayerManager.destroy();
|
|
265
|
-
}
|
|
266
|
-
// Cleanup tracker
|
|
267
|
-
this.tracker.flush();
|
|
268
|
-
this.tracker.cleanup();
|
|
269
|
-
if (this.isBrowserEnvironment()) {
|
|
270
|
-
this.cleanupRenderedEntityRoots();
|
|
271
|
-
}
|
|
272
|
-
this.clearGlobalInstanceBinding();
|
|
273
|
-
testModeDebug('Selwise', 'Instance destroyed');
|
|
274
|
-
}
|
|
275
|
-
async init(config) {
|
|
276
|
-
if (!this.isBrowserEnvironment()) {
|
|
277
|
-
testModeWarn('Selwise', 'init() must be called in a browser environment');
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
this.isDestroyed = false;
|
|
281
|
-
// Feature detection - check for required browser APIs
|
|
282
|
-
const missingFeatures = this.detectMissingFeatures();
|
|
283
|
-
if (missingFeatures.length > 0) {
|
|
284
|
-
testModeWarn('Selwise', 'Browser missing required features:', missingFeatures.join(', '), '- Widget may not function correctly');
|
|
285
|
-
// Don't completely fail - allow partial functionality
|
|
286
|
-
}
|
|
287
|
-
this.config = { ...this.config, ...config };
|
|
288
|
-
this.tracker = new Tracker(this.config.apiUrl, this.config.siteKey);
|
|
289
|
-
this.bindGlobalInstance();
|
|
290
|
-
this.tracker.setupConsentCallback();
|
|
291
|
-
if (!this.spaCleanupSetup) {
|
|
292
|
-
this.setupSPACleanup();
|
|
293
|
-
this.spaCleanupSetup = true;
|
|
294
|
-
}
|
|
295
|
-
if (!this.config.siteKey) {
|
|
296
|
-
testModeWarn('Selwise', 'No site key provided');
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
// Initialize Sentry early - only if explicitly configured
|
|
300
|
-
// This loads asynchronously from CDN to avoid bundle size impact
|
|
301
|
-
initSentryFromConfig().catch(() => {
|
|
302
|
-
// Silently fail - Sentry issues shouldn't block widget initialization
|
|
303
|
-
});
|
|
304
|
-
try {
|
|
305
|
-
// Initialize experiments first to get variants
|
|
306
|
-
this.experiments = new ExperimentManager(this.config.siteKey, this.tracker.getVisitorId(), this.config.apiUrl);
|
|
307
|
-
await this.experiments.init();
|
|
308
|
-
// Initialize segment manager
|
|
309
|
-
this.segments = new SegmentManager(this.config.apiUrl, this.config.siteKey, this.tracker.getVisitorId(), this.tracker.getSessionId(), this.tracker.getSiteUserId(), this.tracker.getSiteUserProfileId());
|
|
310
|
-
// PERFORMANCE: Use batch config endpoint for campaigns, widgets, recommendations, and tracking config
|
|
311
|
-
// This replaces 4 separate requests with 1
|
|
312
|
-
const [configResult, scriptsResult, integrationsResult] = await Promise.allSettled([
|
|
313
|
-
this.loadSiteConfig().catch((e) => {
|
|
314
|
-
testModeError('Selwise', 'Failed to load site config:', e);
|
|
315
|
-
return null;
|
|
316
|
-
}),
|
|
317
|
-
this.loadScripts().catch((e) => {
|
|
318
|
-
testModeError('Selwise', 'Failed to load scripts:', e);
|
|
319
|
-
return null;
|
|
320
|
-
}),
|
|
321
|
-
fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/integrations`).catch(() => null),
|
|
322
|
-
]);
|
|
323
|
-
// Process integration configs for reverse event mapping
|
|
324
|
-
if (integrationsResult.status === 'fulfilled' &&
|
|
325
|
-
integrationsResult.value &&
|
|
326
|
-
integrationsResult.value.ok) {
|
|
327
|
-
const integrations = await integrationsResult.value.json();
|
|
328
|
-
const reverseMapping = {};
|
|
329
|
-
// Collect all reverse mappings from enabled integrations
|
|
330
|
-
for (const integration of integrations.integrations || []) {
|
|
331
|
-
const reverseEventMapping = integration.reverseEventMapping || {};
|
|
332
|
-
if (integration.enabled && reverseEventMapping) {
|
|
333
|
-
Object.assign(reverseMapping, reverseEventMapping);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
if (Object.keys(reverseMapping).length > 0) {
|
|
337
|
-
this.config.reverseEventMapping = reverseMapping;
|
|
338
|
-
testModeLog('Selwise', 'Reverse event mapping loaded:', reverseMapping);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
// Process batch config result
|
|
342
|
-
if (configResult.status === 'fulfilled' && configResult.value) {
|
|
343
|
-
const { campaigns, widgets, recommendations, tracking } = configResult.value;
|
|
344
|
-
this.campaigns = campaigns || [];
|
|
345
|
-
this.widgets = widgets || [];
|
|
346
|
-
this.recommendationWidgets = recommendations || [];
|
|
347
|
-
// Apply tracking config from batch endpoint
|
|
348
|
-
if (tracking) {
|
|
349
|
-
this._trackingConfig = tracking;
|
|
350
|
-
// Check for subscription requirement
|
|
351
|
-
if (tracking.subscriptionRequired) {
|
|
352
|
-
testModeWarn('Selwise', 'Subscription required:', tracking.subscriptionMessage);
|
|
353
|
-
this.handleSubscriptionInactive(tracking.subscriptionMessage);
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
// Convert flush interval from seconds to milliseconds
|
|
357
|
-
const flushIntervalMs = tracking.flushInterval
|
|
358
|
-
? tracking.flushInterval * 1000
|
|
359
|
-
: undefined;
|
|
360
|
-
// Apply configuration to tracker's batcher
|
|
361
|
-
this.tracker.setBatcherConfig({
|
|
362
|
-
enabled: tracking.batchingEnabled,
|
|
363
|
-
batchSize: tracking.batchSize,
|
|
364
|
-
flushInterval: flushIntervalMs,
|
|
365
|
-
enablePersistence: tracking.offlinePersistence,
|
|
366
|
-
enableSendBeacon: tracking.sendBeaconOnUnload,
|
|
367
|
-
maxRetries: tracking.maxRetries,
|
|
368
|
-
maxQueueSize: tracking.maxQueueSize,
|
|
369
|
-
maxStorageEvents: tracking.maxStorageEvents,
|
|
370
|
-
debugMode: tracking.debugMode,
|
|
371
|
-
});
|
|
372
|
-
// Set global debug mode for logger
|
|
373
|
-
setDebugMode(tracking.debugMode || false);
|
|
374
|
-
// Initialize the batcher (loads overflow events and flushes them)
|
|
375
|
-
await this.tracker.initialize();
|
|
376
|
-
// Store data layer config for initialization
|
|
377
|
-
this.config.dataLayerConfig = tracking.dataLayerConfig;
|
|
378
|
-
if (tracking.debugMode) {
|
|
379
|
-
testModeLog('Selwise', 'Tracking config loaded from batch endpoint:', tracking);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
testModeLog('Selwise', 'Loaded site config from batch endpoint:', {
|
|
383
|
-
campaigns: this.campaigns.length,
|
|
384
|
-
widgets: this.widgets.length,
|
|
385
|
-
recommendations: this.recommendationWidgets.length,
|
|
386
|
-
});
|
|
387
|
-
// Initialize data layer (after tracking config is loaded)
|
|
388
|
-
this.initDataLayer();
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
// Fallback to individual endpoints if batch fails
|
|
392
|
-
testModeWarn('Selwise', 'Batch endpoint failed, falling back to individual endpoints');
|
|
393
|
-
this.recommendationWidgets = [];
|
|
394
|
-
// Fall back to loading tracking config separately
|
|
395
|
-
await this.loadTrackingConfig();
|
|
396
|
-
// Initialize data layer (after tracking config is loaded)
|
|
397
|
-
this.initDataLayer();
|
|
398
|
-
// Load campaigns and widgets
|
|
399
|
-
await this.loadCampaignsAndWidgets();
|
|
400
|
-
}
|
|
401
|
-
// Render campaigns and widgets immediately using requestIdleCallback for non-blocking execution
|
|
402
|
-
if ('requestIdleCallback' in window) {
|
|
403
|
-
requestIdleCallback(() => {
|
|
404
|
-
this.renderEntitiesWithPolicies();
|
|
405
|
-
}, { timeout: 100 }); // Force rendering after 100ms even if idle doesn't fire
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
// Fallback for browsers without requestIdleCallback
|
|
409
|
-
setTimeout(() => {
|
|
410
|
-
this.renderEntitiesWithPolicies();
|
|
411
|
-
}, 0);
|
|
412
|
-
}
|
|
413
|
-
// Initialize search module (lazy loaded) - run in background
|
|
414
|
-
if ('requestIdleCallback' in window) {
|
|
415
|
-
requestIdleCallback(() => this.initSearch(), { timeout: 200 });
|
|
416
|
-
}
|
|
417
|
-
else {
|
|
418
|
-
setTimeout(() => this.initSearch(), 50);
|
|
419
|
-
}
|
|
420
|
-
// Initialize recommendations module (lazy loaded) - run in background after critical path
|
|
421
|
-
if ('requestIdleCallback' in window) {
|
|
422
|
-
requestIdleCallback(() => this.initRecommendations(), { timeout: 300 });
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
setTimeout(() => this.initRecommendations(), 100);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
catch (error) {
|
|
429
|
-
testModeDebug('Selwise', 'Failed to load data', error);
|
|
430
|
-
// Send to Sentry if initialized
|
|
431
|
-
if (error instanceof Error) {
|
|
432
|
-
captureException(error, { context: 'init' });
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Fetch and apply tracking configuration from server
|
|
438
|
-
* This allows dashboard settings to control client-side batching behavior
|
|
439
|
-
* and data layer configuration
|
|
440
|
-
*/
|
|
441
|
-
async loadTrackingConfig() {
|
|
442
|
-
if (!this.config.siteKey || !this.config.apiUrl)
|
|
443
|
-
return;
|
|
444
|
-
try {
|
|
445
|
-
const [trackingResponse, integrationsResponse] = await Promise.allSettled([
|
|
446
|
-
fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/tracking-config`),
|
|
447
|
-
fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/integrations`),
|
|
448
|
-
]);
|
|
449
|
-
// Process tracking config
|
|
450
|
-
if (trackingResponse.status === 'fulfilled' && trackingResponse.value.ok) {
|
|
451
|
-
const config = await trackingResponse.value.json();
|
|
452
|
-
// Store full config for external access (e.g., cookie consent widget)
|
|
453
|
-
this._trackingConfig = config;
|
|
454
|
-
// Check for subscription requirement
|
|
455
|
-
if (config.subscriptionRequired) {
|
|
456
|
-
testModeWarn('Selwise', 'Subscription required:', config.subscriptionMessage);
|
|
457
|
-
this.handleSubscriptionInactive(config.subscriptionMessage);
|
|
458
|
-
return; // Stop initialization
|
|
459
|
-
}
|
|
460
|
-
// Convert flush interval from seconds to milliseconds
|
|
461
|
-
const flushIntervalMs = config.flushInterval ? config.flushInterval * 1000 : undefined;
|
|
462
|
-
// Apply configuration to tracker's batcher
|
|
463
|
-
this.tracker.setBatcherConfig({
|
|
464
|
-
enabled: config.batchingEnabled,
|
|
465
|
-
batchSize: config.batchSize,
|
|
466
|
-
flushInterval: flushIntervalMs,
|
|
467
|
-
enablePersistence: config.offlinePersistence,
|
|
468
|
-
enableSendBeacon: config.sendBeaconOnUnload,
|
|
469
|
-
maxRetries: config.maxRetries,
|
|
470
|
-
maxQueueSize: config.maxQueueSize,
|
|
471
|
-
maxStorageEvents: config.maxStorageEvents,
|
|
472
|
-
debugMode: config.debugMode,
|
|
473
|
-
});
|
|
474
|
-
// Set global debug mode for logger
|
|
475
|
-
setDebugMode(config.debugMode || false);
|
|
476
|
-
// Initialize the batcher (loads overflow events and flushes them)
|
|
477
|
-
await this.tracker.initialize();
|
|
478
|
-
if (config.debugMode) {
|
|
479
|
-
testModeLog('Selwise', 'Tracking config loaded:', config);
|
|
480
|
-
}
|
|
481
|
-
// Store data layer config for initialization
|
|
482
|
-
this.config.dataLayerConfig = config.dataLayerConfig;
|
|
483
|
-
}
|
|
484
|
-
else if (trackingResponse.status === 'fulfilled' && trackingResponse.value.status === 403) {
|
|
485
|
-
// Subscription check failed at HTTP level
|
|
486
|
-
const error = await trackingResponse.value.json().catch(() => ({}));
|
|
487
|
-
testModeWarn('Selwise', 'Subscription required (HTTP 403):', error.message || 'Subscription inactive');
|
|
488
|
-
this.handleSubscriptionInactive(error.message || 'Subscription required');
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
// Process integration configs for reverse event mapping
|
|
492
|
-
if (integrationsResponse.status === 'fulfilled' && integrationsResponse.value.ok) {
|
|
493
|
-
const integrations = await integrationsResponse.value.json();
|
|
494
|
-
const reverseMapping = {};
|
|
495
|
-
// Collect all reverse mappings from enabled integrations
|
|
496
|
-
for (const integration of integrations.integrations || []) {
|
|
497
|
-
const reverseEventMapping = integration.reverseEventMapping || {};
|
|
498
|
-
if (integration.enabled && reverseEventMapping) {
|
|
499
|
-
Object.assign(reverseMapping, reverseEventMapping);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
if (Object.keys(reverseMapping).length > 0) {
|
|
503
|
-
this.config.reverseEventMapping = reverseMapping;
|
|
504
|
-
testModeLog('Selwise', 'Reverse event mapping loaded:', reverseMapping);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
catch (error) {
|
|
509
|
-
// Silently fail, use defaults
|
|
510
|
-
testModeDebug('Selwise', 'Failed to load tracking config, using defaults');
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
/**
|
|
514
|
-
* Load campaigns, widgets, and recommendations using the batch config endpoint
|
|
515
|
-
* PERFORMANCE: Single request instead of 3 separate requests
|
|
516
|
-
* Falls back to individual endpoints if batch endpoint fails
|
|
517
|
-
*/
|
|
518
|
-
async loadSiteConfig() {
|
|
519
|
-
if (!this.config.siteKey || !this.config.apiUrl)
|
|
520
|
-
return null;
|
|
521
|
-
try {
|
|
522
|
-
const response = await fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/config`, {
|
|
523
|
-
method: 'GET',
|
|
524
|
-
});
|
|
525
|
-
if (!response.ok) {
|
|
526
|
-
if (response.status === 403) {
|
|
527
|
-
const error = await response.json().catch(() => ({}));
|
|
528
|
-
testModeWarn('Selwise', 'Subscription required:', error.message || 'Subscription inactive');
|
|
529
|
-
this.handleSubscriptionInactive(error.message || 'Subscription required');
|
|
530
|
-
}
|
|
531
|
-
return null;
|
|
532
|
-
}
|
|
533
|
-
const data = await response.json();
|
|
534
|
-
return data;
|
|
535
|
-
}
|
|
536
|
-
catch (error) {
|
|
537
|
-
testModeDebug('Selwise', 'Failed to load batch config, falling back to individual endpoints');
|
|
538
|
-
return null;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Fallback path: load campaigns and widgets individually
|
|
543
|
-
* Used only if batch endpoint fails
|
|
544
|
-
*/
|
|
545
|
-
async loadCampaignsAndWidgets() {
|
|
546
|
-
const campaignsPromise = this.loadCampaigns().catch((e) => {
|
|
547
|
-
testModeError('Selwise', 'Failed to load campaigns:', e);
|
|
548
|
-
return null;
|
|
549
|
-
});
|
|
550
|
-
const widgetsPromise = this.loadWidgets().catch((e) => {
|
|
551
|
-
testModeError('Selwise', 'Failed to load widgets:', e);
|
|
552
|
-
return null;
|
|
553
|
-
});
|
|
554
|
-
await Promise.allSettled([campaignsPromise, widgetsPromise]);
|
|
555
|
-
}
|
|
556
|
-
/**
|
|
557
|
-
* Initialize the data layer manager
|
|
558
|
-
* Called after tracking config is loaded to respect server-side settings
|
|
559
|
-
*/
|
|
560
|
-
initDataLayer() {
|
|
561
|
-
if (!this.config.siteKey)
|
|
562
|
-
return;
|
|
563
|
-
const dlConfig = this.config.dataLayerConfig || {};
|
|
564
|
-
const reverseMapping = this.config.reverseEventMapping || {};
|
|
565
|
-
this.dataLayerManager = new DataLayerManager(this.tracker, this.config.siteKey, resolveApiUrl(this.config.apiUrl), {
|
|
566
|
-
enabled: dlConfig.enabled ?? true, // Enabled by default for comprehensive event tracking
|
|
567
|
-
variableName: dlConfig.variableName ?? 'selwiseLayer',
|
|
568
|
-
pageDetection: dlConfig.pageDetection ?? 'auto',
|
|
569
|
-
autoPageTracking: dlConfig.autoPageTracking ?? true,
|
|
570
|
-
cartAbandonmentTimeout: dlConfig.cartAbandonmentTimeout ?? 30,
|
|
571
|
-
pageTypePatterns: dlConfig.pageTypePatterns ?? undefined,
|
|
572
|
-
debugMode: dlConfig.debugMode ?? false,
|
|
573
|
-
cookieConsent: dlConfig.cookieConsent,
|
|
574
|
-
trackingModules: dlConfig.trackingModules,
|
|
575
|
-
bufferSize: dlConfig.bufferSize,
|
|
576
|
-
flushInterval: dlConfig.flushInterval,
|
|
577
|
-
reverseEventMapping: Object.keys(reverseMapping).length > 0 ? reverseMapping : undefined,
|
|
578
|
-
externalDataLayerName: 'dataLayer',
|
|
579
|
-
});
|
|
580
|
-
// Initialize if enabled (enabled by default)
|
|
581
|
-
if (dlConfig.enabled ?? true) {
|
|
582
|
-
this.dataLayerManager.init();
|
|
583
|
-
testModeLog('Selwise', 'Data layer manager initialized and started');
|
|
584
|
-
}
|
|
585
|
-
else {
|
|
586
|
-
testModeLog('Selwise', 'Data layer manager created but NOT enabled (disabled in dashboard settings)');
|
|
587
|
-
}
|
|
588
|
-
if (dlConfig.debugMode) {
|
|
589
|
-
testModeLog('Selwise', 'Data layer initialized with config:', dlConfig);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Public helper for experiment variant access
|
|
594
|
-
* Returns the full variant assignment for an experiment
|
|
595
|
-
*/
|
|
596
|
-
getVariant(experimentId) {
|
|
597
|
-
return this.experiments?.getVariant(experimentId);
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Public helper for getting the assigned variant ID
|
|
601
|
-
* Returns just the variant ID (e.g., 'variant_a', 'control')
|
|
602
|
-
*/
|
|
603
|
-
getExperimentVariant(experimentId) {
|
|
604
|
-
if (!this.experiments)
|
|
605
|
-
return null;
|
|
606
|
-
return this.experiments.getAssignedVariant(experimentId);
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Public helper for getting all active experiment assignments
|
|
610
|
-
* Returns an array of all experiment assignments for the current visitor
|
|
611
|
-
*/
|
|
612
|
-
getActiveExperiments() {
|
|
613
|
-
if (!this.experiments)
|
|
614
|
-
return [];
|
|
615
|
-
return this.experiments.getAllAssignments();
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* Public helper for purchase/order tracking.
|
|
619
|
-
* Merchants can call: window.Selwise.trackOrder({...})
|
|
620
|
-
*/
|
|
621
|
-
async trackOrder(order) {
|
|
622
|
-
return this.tracker.trackOrder(order);
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Identify a user.
|
|
626
|
-
* Call this when a user logs in or is identified.
|
|
627
|
-
* @param userId Unique user ID from your system
|
|
628
|
-
* @param metadata Optional metadata about the user
|
|
629
|
-
* @returns Promise with success status and merge indicator
|
|
630
|
-
*/
|
|
631
|
-
async identify(userId, metadata) {
|
|
632
|
-
if (!userId)
|
|
633
|
-
return { success: false, merged: false };
|
|
634
|
-
const result = await this.tracker.identify(userId, metadata);
|
|
635
|
-
// Update segment manager with new user identifiers for accurate evaluation
|
|
636
|
-
if (this.segments) {
|
|
637
|
-
this.segments.updateUserIdentifiers(this.tracker.getSiteUserId(), this.tracker.getSiteUserProfileId());
|
|
638
|
-
}
|
|
639
|
-
return result;
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* Set user traits without changing identity.
|
|
643
|
-
* Call this to update user attributes like name, email, plan, etc.
|
|
644
|
-
* @param traits Key-value pairs of user attributes
|
|
645
|
-
* @returns Promise with success status
|
|
646
|
-
*/
|
|
647
|
-
async setTraits(traits) {
|
|
648
|
-
return this.tracker.setTraits(traits);
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* Track a custom event.
|
|
652
|
-
* Call this to track custom events like 'button_clicked', 'form_submitted', etc.
|
|
653
|
-
* @param name Event name (e.g., 'product_viewed', 'button_clicked')
|
|
654
|
-
* @param args Optional event data including entityType, entityId, and metadata
|
|
655
|
-
*
|
|
656
|
-
* @example
|
|
657
|
-
* window.Selwise.track('product_viewed', {
|
|
658
|
-
* entityType: 'product',
|
|
659
|
-
* entityId: 'prod_123',
|
|
660
|
-
* metadata: { price: 99.99, category: 'electronics' }
|
|
661
|
-
* })
|
|
662
|
-
*/
|
|
663
|
-
track(name, args) {
|
|
664
|
-
return this.tracker.track(name, args);
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* Get current site user ID (if user has been identified)
|
|
668
|
-
* @returns The site user ID or undefined
|
|
669
|
-
*/
|
|
670
|
-
getSiteUserId() {
|
|
671
|
-
return this.tracker.getSiteUserId();
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Get current visitor ID
|
|
675
|
-
* @returns The visitor ID
|
|
676
|
-
*/
|
|
677
|
-
getVisitorId() {
|
|
678
|
-
return this.tracker.getVisitorId();
|
|
679
|
-
}
|
|
680
|
-
/**
|
|
681
|
-
* Get current session ID
|
|
682
|
-
* @returns The session ID
|
|
683
|
-
*/
|
|
684
|
-
getSessionId() {
|
|
685
|
-
return this.tracker.getSessionId();
|
|
686
|
-
}
|
|
687
|
-
/**
|
|
688
|
-
* Get current journey ID
|
|
689
|
-
* @returns The journey ID or null if no active journey
|
|
690
|
-
*/
|
|
691
|
-
getJourneyId() {
|
|
692
|
-
return this.tracker.getJourneyId();
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Get current journey state for debugging
|
|
696
|
-
* @returns Journey state including ID, age, and validity
|
|
697
|
-
*/
|
|
698
|
-
getJourneyState() {
|
|
699
|
-
return this.tracker.getJourneyState();
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* End the current journey
|
|
703
|
-
* Clears the journey ID and starts a new one on the next event
|
|
704
|
-
*/
|
|
705
|
-
endJourney() {
|
|
706
|
-
this.tracker.endJourney();
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Search module - dynamically imported for code splitting
|
|
710
|
-
*/
|
|
711
|
-
async initSearch() {
|
|
712
|
-
try {
|
|
713
|
-
// Dynamic import - creates separate chunk (selwise-search.js)
|
|
714
|
-
const { SearchModule } = await import(
|
|
715
|
-
/* webpackChunkName: "selwise-search" */
|
|
716
|
-
'./modules/search/index.js');
|
|
717
|
-
this.searchModule = new SearchModule(this.config.apiUrl, this.config.siteKey, this.experiments ?? undefined, this.segments ?? undefined);
|
|
718
|
-
await this.searchModule.init();
|
|
719
|
-
}
|
|
720
|
-
catch (error) {
|
|
721
|
-
testModeDebug('Selwise', 'Search module initialization failed', error);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
/**
|
|
725
|
-
* Recommendations module - dynamically imported for code splitting
|
|
726
|
-
*/
|
|
727
|
-
async initRecommendations() {
|
|
728
|
-
if (this.recommendationsInitialized)
|
|
729
|
-
return;
|
|
730
|
-
try {
|
|
731
|
-
// Dynamic import - creates separate chunk (selwise-reco.js)
|
|
732
|
-
const { initRecommendations, cleanup } = await import(
|
|
733
|
-
/* webpackChunkName: "selwise-reco" */
|
|
734
|
-
'./modules/recommendation/index.js');
|
|
735
|
-
await initRecommendations({
|
|
736
|
-
siteKey: this.config.siteKey,
|
|
737
|
-
apiEndpoint: this.config.apiUrl,
|
|
738
|
-
experimentManager: this.experiments ?? undefined,
|
|
739
|
-
segmentManager: this.segments ?? undefined,
|
|
740
|
-
widgets: this.recommendationWidgets,
|
|
741
|
-
});
|
|
742
|
-
this.recommendationsInitialized = true;
|
|
743
|
-
this.recommendationsCleanup = cleanup; // Store cleanup function
|
|
744
|
-
testModeLog('Selwise', 'Recommendations module initialized');
|
|
745
|
-
}
|
|
746
|
-
catch (error) {
|
|
747
|
-
testModeDebug('Selwise', 'Recommendations module initialization failed', error);
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
async loadCampaigns() {
|
|
751
|
-
const response = await fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/campaigns`, {
|
|
752
|
-
method: 'GET',
|
|
753
|
-
});
|
|
754
|
-
if (!response.ok) {
|
|
755
|
-
if (response.status === 403) {
|
|
756
|
-
const error = await response.json().catch(() => ({}));
|
|
757
|
-
testModeWarn('Selwise', 'Subscription required for campaigns:', error.message || 'Subscription inactive');
|
|
758
|
-
this.handleSubscriptionInactive(error.message || 'Subscription required');
|
|
759
|
-
}
|
|
760
|
-
throw new Error('Failed to fetch campaigns');
|
|
761
|
-
}
|
|
762
|
-
const data = await response.json();
|
|
763
|
-
this.campaigns = data.campaigns || [];
|
|
764
|
-
}
|
|
765
|
-
async loadWidgets() {
|
|
766
|
-
const response = await fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/widgets`, {
|
|
767
|
-
method: 'GET',
|
|
768
|
-
});
|
|
769
|
-
if (!response.ok) {
|
|
770
|
-
if (response.status === 403) {
|
|
771
|
-
const error = await response.json().catch(() => ({}));
|
|
772
|
-
testModeWarn('Selwise', 'Subscription required for widgets:', error.message || 'Subscription inactive');
|
|
773
|
-
this.handleSubscriptionInactive(error.message || 'Subscription required');
|
|
774
|
-
}
|
|
775
|
-
// Silently fail when endpoint is unavailable
|
|
776
|
-
return;
|
|
777
|
-
}
|
|
778
|
-
const data = await response.json();
|
|
779
|
-
this.widgets = data.widgets || [];
|
|
780
|
-
}
|
|
781
|
-
async loadScripts() {
|
|
782
|
-
const currentPath = window.location.pathname;
|
|
783
|
-
try {
|
|
784
|
-
const response = await fetch(`${this.config.apiUrl}/public/sites/${this.config.siteKey}/scripts?path=${encodeURIComponent(currentPath)}`, {
|
|
785
|
-
method: 'GET',
|
|
786
|
-
});
|
|
787
|
-
if (!response.ok) {
|
|
788
|
-
testModeDebug('Selwise', 'Failed to fetch scripts');
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
const data = await response.json();
|
|
792
|
-
const scripts = data.scripts || [];
|
|
793
|
-
testModeLog('Selwise', 'Loading custom scripts:', scripts.length);
|
|
794
|
-
scripts.forEach((script) => {
|
|
795
|
-
try {
|
|
796
|
-
// Inject CSS first if provided
|
|
797
|
-
if (script.css) {
|
|
798
|
-
const styleElement = document.createElement('style');
|
|
799
|
-
styleElement.setAttribute('data-selwise-script-css', script.id);
|
|
800
|
-
styleElement.textContent = script.css;
|
|
801
|
-
document.head.appendChild(styleElement);
|
|
802
|
-
testModeLog('Selwise', `Injected script CSS: ${script.name}`);
|
|
803
|
-
}
|
|
804
|
-
// Create and execute the script
|
|
805
|
-
const scriptElement = document.createElement('script');
|
|
806
|
-
scriptElement.setAttribute('data-selwise-script', script.id);
|
|
807
|
-
scriptElement.textContent = script.code;
|
|
808
|
-
document.body.appendChild(scriptElement);
|
|
809
|
-
testModeLog('Selwise', `Injected script: ${script.name}`);
|
|
810
|
-
this.tracker.track('script_injected', {
|
|
811
|
-
entityType: 'script',
|
|
812
|
-
entityId: script.id,
|
|
813
|
-
metadata: { name: script.name },
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
catch (error) {
|
|
817
|
-
testModeError('Selwise', `Failed to execute script: ${script.name}`);
|
|
818
|
-
testModeDebug('Selwise', 'Script execution error details:', error);
|
|
819
|
-
if (error instanceof SyntaxError) {
|
|
820
|
-
testModeWarn('Selwise', 'Script syntax error. Please check for invalid characters or escapes.');
|
|
821
|
-
}
|
|
822
|
-
try {
|
|
823
|
-
this.tracker.track('script_error', {
|
|
824
|
-
entityType: 'script',
|
|
825
|
-
entityId: script.id,
|
|
826
|
-
metadata: {
|
|
827
|
-
name: script.name,
|
|
828
|
-
message: error?.message,
|
|
829
|
-
},
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
catch {
|
|
833
|
-
// ignore
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
catch (error) {
|
|
839
|
-
testModeDebug('Selwise', 'Failed to load scripts', error);
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
shouldRenderForCurrentPage(entity, type) {
|
|
843
|
-
const shouldRender = evaluatePageTargeting(entity.pageTargetingJson, window.location.href);
|
|
844
|
-
if (!shouldRender) {
|
|
845
|
-
testModeLog('Selwise', `Skipping ${type} due to page targeting: ${entity.id}`);
|
|
846
|
-
}
|
|
847
|
-
return shouldRender;
|
|
848
|
-
}
|
|
849
|
-
buildDisplayCandidates() {
|
|
850
|
-
const allEntities = [
|
|
851
|
-
...this.campaigns.map((campaign) => ({ entity: campaign, type: 'campaign' })),
|
|
852
|
-
...this.widgets.map((widget) => ({ entity: widget, type: 'widget' })),
|
|
853
|
-
];
|
|
854
|
-
return allEntities
|
|
855
|
-
.filter(({ entity, type }) => this.shouldRenderForCurrentPage(entity, type))
|
|
856
|
-
.map(({ entity, type }) => {
|
|
857
|
-
const placementConfig = (entity.placementConfigJson || {});
|
|
858
|
-
const selector = placementConfig.selector;
|
|
859
|
-
const placementPosition = placementConfig.position || placementConfig.insertPosition;
|
|
860
|
-
const conflictResolution = placementConfig.conflictResolution || {};
|
|
861
|
-
const candidate = this.conflictResolver.applyConfig({
|
|
862
|
-
id: `${type}:${entity.id}`,
|
|
863
|
-
type,
|
|
864
|
-
selector,
|
|
865
|
-
placementPosition,
|
|
866
|
-
priority: entity.priority ?? conflictResolution.priority,
|
|
867
|
-
conflictBehavior: conflictResolution.behavior,
|
|
868
|
-
placementConfigJson: placementConfig,
|
|
869
|
-
});
|
|
870
|
-
return {
|
|
871
|
-
id: candidate.id,
|
|
872
|
-
type,
|
|
873
|
-
priority: candidate.priority,
|
|
874
|
-
conflictBehavior: candidate.conflictBehavior,
|
|
875
|
-
selector: candidate.selector,
|
|
876
|
-
placementPosition: candidate.placementPosition,
|
|
877
|
-
placementConfigJson: placementConfig,
|
|
878
|
-
sourceId: entity.id,
|
|
879
|
-
sourceEntity: entity,
|
|
880
|
-
frequencyCapConfig: placementConfig.frequencyCap,
|
|
881
|
-
};
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
async renderEntitiesWithPolicies() {
|
|
885
|
-
const candidates = this.buildDisplayCandidates();
|
|
886
|
-
testModeLog('Selwise', 'Rendering entities with policies:', candidates.length);
|
|
887
|
-
this.renderedEntities.clear();
|
|
888
|
-
this.frequencyCapManager.cleanup();
|
|
889
|
-
if (candidates.length === 0)
|
|
890
|
-
return;
|
|
891
|
-
const resolutionResults = this.conflictResolver.resolveAll(candidates);
|
|
892
|
-
const selectedIds = new Set(resolutionResults.flatMap((result) => result.selected.map((candidate) => candidate.id)));
|
|
893
|
-
for (const candidate of candidates) {
|
|
894
|
-
if (!selectedIds.has(candidate.id)) {
|
|
895
|
-
continue;
|
|
896
|
-
}
|
|
897
|
-
const frequencyKey = `display:${candidate.id}`;
|
|
898
|
-
if (candidate.frequencyCapConfig) {
|
|
899
|
-
const check = this.frequencyCapManager.canShow(frequencyKey, candidate.frequencyCapConfig);
|
|
900
|
-
if (!check.allowed) {
|
|
901
|
-
testModeLog('Selwise', `Skipping ${candidate.type} due to frequency cap (${check.reason || 'limit'}):`, candidate.sourceId);
|
|
902
|
-
continue;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
const rendered = await this.renderEntity(candidate.sourceEntity, candidate.type);
|
|
906
|
-
if (rendered && candidate.frequencyCapConfig) {
|
|
907
|
-
this.frequencyCapManager.recordShown(frequencyKey);
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Unified entity rendering for campaigns and widgets
|
|
913
|
-
* @param skipVariantCheck - Skip variant module lookup (used when rendering variant modules to prevent infinite loops)
|
|
914
|
-
*/
|
|
915
|
-
async renderEntity(entity, type, skipVariantCheck = false) {
|
|
916
|
-
const testModeEnabled = isTestModeEnabled();
|
|
917
|
-
const entityName = type === 'campaign' ? 'campaign' : 'widget';
|
|
918
|
-
// Skip if already rendered (prevents duplicate rendering when both control and variant are in the list)
|
|
919
|
-
if (this.renderedEntities.has(entity.id)) {
|
|
920
|
-
testModeLog('Selwise', `Skipping already rendered ${entityName}: ${entity.id}`);
|
|
921
|
-
return false;
|
|
922
|
-
}
|
|
923
|
-
// Skip test mode entities if test mode is not enabled
|
|
924
|
-
if (entity.isTestMode && !testModeEnabled) {
|
|
925
|
-
testModeWarn('Selwise', `Skipping test mode ${entityName}: ${entity.id}${type === 'campaign' ? " (Run localStorage.setItem('selwise_test_mode', 'true') to view)" : ''}`);
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
// Re-check page targeting at render time to avoid stale route races.
|
|
929
|
-
if (!this.shouldRenderForCurrentPage(entity, type)) {
|
|
930
|
-
return false;
|
|
931
|
-
}
|
|
932
|
-
// Check for different_module mode experiment FIRST (before shouldRenderTarget check)
|
|
933
|
-
// If this entity has a variant module, render it instead and skip the original
|
|
934
|
-
// Skip this check if we're already rendering a variant module (to prevent infinite loops)
|
|
935
|
-
const variantAssignment = skipVariantCheck
|
|
936
|
-
? null
|
|
937
|
-
: this.experiments?.getVariantModuleForTarget(entity.id);
|
|
938
|
-
if (variantAssignment && variantAssignment.moduleData) {
|
|
939
|
-
testModeLog('Selwise', `Rendering variant module for ${entityName}: ${entity.id} -> variant: ${variantAssignment.moduleData.id}`);
|
|
940
|
-
// This entity has a variant module that should be rendered instead
|
|
941
|
-
await this.renderVariantModule(variantAssignment.moduleData, variantAssignment.experimentId, variantAssignment.variantId, variantAssignment.targetType || type // Use assignment's targetType or current entity type
|
|
942
|
-
);
|
|
943
|
-
// Don't render the original entity
|
|
944
|
-
return false;
|
|
945
|
-
}
|
|
946
|
-
// Check if this entity should be rendered (e.g. not replaced by an experiment)
|
|
947
|
-
if (this.experiments && !this.experiments.shouldRenderTarget(entity.id)) {
|
|
948
|
-
testModeLog('Selwise', `Skipping ${entityName} (excluded by experiment): ${entity.id}`);
|
|
949
|
-
return false;
|
|
950
|
-
}
|
|
951
|
-
// Check segment targeting
|
|
952
|
-
if (this.segments && entity.segmentTargetingMode && entity.segmentIds) {
|
|
953
|
-
const shouldShow = await this.segments.shouldShow(entity.segmentTargetingMode, entity.segmentIds);
|
|
954
|
-
if (!shouldShow) {
|
|
955
|
-
testModeLog('Selwise', `Skipping ${entityName} due to segment targeting: ${entity.id}`);
|
|
956
|
-
return false;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
// Skip if no content
|
|
960
|
-
if (!entity.contentJson || Object.keys(entity.contentJson).length === 0) {
|
|
961
|
-
testModeWarn('Selwise', `Skipping empty ${entityName}: ${entity.id}`);
|
|
962
|
-
return false;
|
|
963
|
-
}
|
|
964
|
-
// Check for experiment variant override (config_override mode)
|
|
965
|
-
let variantContent = normalizeContentFields(entity.contentJson || {});
|
|
966
|
-
let variantStyles = entity.stylesJson || {};
|
|
967
|
-
let variantPlacement = entity.placementConfigJson || {};
|
|
968
|
-
const assignment = this.experiments?.getVariant(entity.id) ||
|
|
969
|
-
this.experiments?.getAssignmentByTargetId(entity.id);
|
|
970
|
-
if (assignment) {
|
|
971
|
-
const config = getEffectiveConfig(assignment);
|
|
972
|
-
if (config?.content && typeof config.content === 'object') {
|
|
973
|
-
variantContent = deepMergeExperimentConfig(variantContent, normalizeContentFields(config.content));
|
|
974
|
-
}
|
|
975
|
-
if (config?.styles && typeof config.styles === 'object') {
|
|
976
|
-
variantStyles = deepMergeExperimentConfig(variantStyles, config.styles);
|
|
977
|
-
}
|
|
978
|
-
if (config?.placement && typeof config.placement === 'object') {
|
|
979
|
-
variantPlacement = deepMergeExperimentConfig(variantPlacement, config.placement);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
// Create renderer objects
|
|
983
|
-
const widgetForRenderer = {
|
|
984
|
-
id: entity.id,
|
|
985
|
-
type: entity.type,
|
|
986
|
-
placementConfigJson: variantPlacement,
|
|
987
|
-
__entityType: type,
|
|
988
|
-
};
|
|
989
|
-
const campaignForRenderer = {
|
|
990
|
-
id: entity.id,
|
|
991
|
-
contentJson: variantContent,
|
|
992
|
-
stylesJson: variantStyles,
|
|
993
|
-
};
|
|
994
|
-
// Idempotency guard for SPA re-renders.
|
|
995
|
-
this.cleanupRenderedEntityById(entity.id, type);
|
|
996
|
-
const element = this.renderer.render(widgetForRenderer, campaignForRenderer);
|
|
997
|
-
if (element) {
|
|
998
|
-
// Mark as rendered to prevent duplicates
|
|
999
|
-
this.renderedEntities.add(entity.id);
|
|
1000
|
-
// Track impression
|
|
1001
|
-
this.tracker.track('impression', {
|
|
1002
|
-
entityType: type === 'campaign' ? 'campaign' : 'widget',
|
|
1003
|
-
entityId: entity.id,
|
|
1004
|
-
});
|
|
1005
|
-
// Track experiment impression if applicable
|
|
1006
|
-
if (assignment) {
|
|
1007
|
-
this.experiments?.trackImpression(assignment.experimentId);
|
|
1008
|
-
}
|
|
1009
|
-
// Setup click tracking
|
|
1010
|
-
element.addEventListener('click', (e) => {
|
|
1011
|
-
const target = e.target;
|
|
1012
|
-
if (target.tagName === 'A' || target.tagName === 'BUTTON') {
|
|
1013
|
-
const buttonText = target.textContent?.toLowerCase() || '';
|
|
1014
|
-
const isAddToCart = /add to cart|buy now|purchase|add to bag|sepete ekle|satın al|buy now/i.test(buttonText);
|
|
1015
|
-
this.tracker.track('click', {
|
|
1016
|
-
entityType: type === 'campaign' ? 'campaign' : 'widget',
|
|
1017
|
-
entityId: entity.id,
|
|
1018
|
-
});
|
|
1019
|
-
if (type === 'campaign') {
|
|
1020
|
-
// Track add_to_cart for campaign buttons that are clearly purchase-related
|
|
1021
|
-
if (isAddToCart) {
|
|
1022
|
-
this.tracker.track('add_to_cart', {
|
|
1023
|
-
entityType: 'campaign',
|
|
1024
|
-
entityId: entity.id,
|
|
1025
|
-
metadata: {
|
|
1026
|
-
buttonText: target.textContent,
|
|
1027
|
-
},
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
// Track experiment conversion
|
|
1032
|
-
if (assignment) {
|
|
1033
|
-
this.experiments?.trackConversion(assignment.experimentId);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
return true;
|
|
1038
|
-
}
|
|
1039
|
-
return false;
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
|
-
* Render a variant module from different_module mode experiment
|
|
1043
|
-
* @param moduleData The module data containing target type and full entity data
|
|
1044
|
-
* @param experimentId The experiment ID
|
|
1045
|
-
* @param variantId The variant ID
|
|
1046
|
-
* @param targetType The target type (widget, campaign, recommendation, etc.)
|
|
1047
|
-
*/
|
|
1048
|
-
async renderVariantModule(moduleData, experimentId, variantId, targetType) {
|
|
1049
|
-
// Handle both wrapped and direct moduleData formats
|
|
1050
|
-
// Wrapped: { targetType, data }
|
|
1051
|
-
// Direct: moduleData IS the entity, targetType comes from parameter
|
|
1052
|
-
let data;
|
|
1053
|
-
let effectiveTargetType;
|
|
1054
|
-
if (moduleData.data) {
|
|
1055
|
-
// Wrapped format
|
|
1056
|
-
data = moduleData.data;
|
|
1057
|
-
effectiveTargetType = moduleData.targetType || targetType || 'widget';
|
|
1058
|
-
}
|
|
1059
|
-
else {
|
|
1060
|
-
// Direct format - moduleData IS the entity
|
|
1061
|
-
data = moduleData;
|
|
1062
|
-
effectiveTargetType = targetType || 'widget';
|
|
1063
|
-
}
|
|
1064
|
-
// Track experiment impression
|
|
1065
|
-
if (this.experiments) {
|
|
1066
|
-
this.experiments.trackImpression(experimentId);
|
|
1067
|
-
}
|
|
1068
|
-
// Track impression for the variant
|
|
1069
|
-
this.tracker.track('impression', {
|
|
1070
|
-
entityType: effectiveTargetType,
|
|
1071
|
-
entityId: data.id,
|
|
1072
|
-
metadata: {
|
|
1073
|
-
experimentId,
|
|
1074
|
-
variantId,
|
|
1075
|
-
isVariantModule: true,
|
|
1076
|
-
},
|
|
1077
|
-
});
|
|
1078
|
-
// Render based on target type
|
|
1079
|
-
// Pass skipVariantCheck=true to prevent infinite loops when rendering variant modules
|
|
1080
|
-
switch (effectiveTargetType) {
|
|
1081
|
-
case 'widget':
|
|
1082
|
-
await this.renderEntity(data, 'widget', true);
|
|
1083
|
-
break;
|
|
1084
|
-
case 'campaign':
|
|
1085
|
-
await this.renderEntity(data, 'campaign', true);
|
|
1086
|
-
break;
|
|
1087
|
-
case 'recommendation':
|
|
1088
|
-
// Recommendations are handled by the recommendations module
|
|
1089
|
-
// The module will pick up the variant from the experiment manager
|
|
1090
|
-
testModeLog('Selwise', 'Variant recommendation module will be rendered by recommendations module');
|
|
1091
|
-
break;
|
|
1092
|
-
case 'search_config':
|
|
1093
|
-
// Search is handled by the search module
|
|
1094
|
-
testModeLog('Selwise', 'Variant search config will be applied by search module');
|
|
1095
|
-
break;
|
|
1096
|
-
default:
|
|
1097
|
-
testModeWarn('Selwise', `Unknown target type for variant module: ${effectiveTargetType}`);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Handle inactive subscription
|
|
1102
|
-
* Disables widget and emits event for parent application to handle
|
|
1103
|
-
*
|
|
1104
|
-
* @param message Error message from server
|
|
1105
|
-
*/
|
|
1106
|
-
handleSubscriptionInactive(message) {
|
|
1107
|
-
// Mark widget as disabled
|
|
1108
|
-
this.enabled = false;
|
|
1109
|
-
this.subscriptionInactive = true;
|
|
1110
|
-
this.subscriptionMessage = message;
|
|
1111
|
-
// Emit event for parent to handle
|
|
1112
|
-
if (typeof window !== 'undefined') {
|
|
1113
|
-
const event = new CustomEvent('selwise:subscription-inactive', {
|
|
1114
|
-
detail: { message },
|
|
1115
|
-
});
|
|
1116
|
-
window.dispatchEvent(event);
|
|
1117
|
-
}
|
|
1118
|
-
// Optionally show a subtle console warning for developers
|
|
1119
|
-
testModeWarn('Selwise', 'Subscription inactive. Widget will not display. ' + 'Message: ' + message);
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
export default Selwise;
|
|
1123
|
-
//# sourceMappingURL=selwise.js.map
|