UNPKG

@empathyco/x-components

Version:
79 lines (76 loc) 2.7 kB
import { defineComponent, computed, provide } from 'vue'; import '../composables/create-use-device.js'; import { use$x } from '../composables/use-_x.js'; import 'vuex'; import '../plugins/x-bus.js'; import '@empathyco/x-utils'; import '../plugins/x-plugin.js'; import '@vueuse/core'; import 'rxjs'; var _sfc_main = defineComponent({ name: 'DisplayClickProvider', props: { resultFeature: { type: String, required: true, }, ignoreResultClickEvent: { type: Boolean, default: false, }, toolingDisplayTagging: { type: Object, required: false, default: undefined, }, toolingAdd2CartTagging: { type: Object, required: false, default: undefined, }, queryTagging: { type: Object, required: false, default: undefined, }, }, setup(props, { slots }) { const x = use$x(); const displayClickMetadata = computed(() => ({ displayOriginalQuery: x.query.search, feature: props.resultFeature, queryTagging: props.queryTagging, toolingTagging: props.toolingDisplayTagging, toolingAdd2CartTagging: props.toolingAdd2CartTagging, })); const resultAddToCartExtraEventsMap = { related_prompts: 'UserClickedARelatedPromptAdd2Cart', ai_carousel: 'UserClickedAnAiCarouselAdd2Cart', }; const resultClickExtraEventsMap = { related_prompts: 'UserClickedARelatedPromptResult', ai_carousel: 'UserClickedAnAiCarouselResult', }; provide('resultAddToCartExtraEvents', [resultAddToCartExtraEventsMap[props.resultFeature]]); provide('resultAddToCartExtraEventsMetadata', { toolingAdd2CartTagging: props.toolingAdd2CartTagging, }); provide('resultClickExtraEvents', [ resultClickExtraEventsMap[props.resultFeature], 'UserClickedADisplayResult', ]); provide('resultLinkMetadataPerEvent', { UserClickedARelatedPromptResult: displayClickMetadata.value, UserClickedAnAiCarouselResult: displayClickMetadata.value, UserClickedADisplayResult: displayClickMetadata.value, ...(props.ignoreResultClickEvent && { UserClickedAResult: { ignoreInModules: ['tagging'], }, }), }); return () => slots.default?.()[0] ?? ''; }, }); export { _sfc_main as default }; //# sourceMappingURL=display-click-provider.vue.js.map