project-booster-vue 10.5.3 → 10.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "project-booster-vue",
3
- "version": "10.5.3",
3
+ "version": "10.6.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -30,6 +30,14 @@
30
30
  @click="handleShowModal(options)"
31
31
  size="s"
32
32
  theme="bordered-primary-02"
33
+ class="js-cdl"
34
+ data-cdl-click-type="cdl_event"
35
+ :data-cdl-click-data="
36
+ formatEvent(
37
+ { button_name: options.viewModel.button.label, button_location: stepLocation },
38
+ EventTypeEnum.BUTTON,
39
+ )
40
+ "
33
41
  />
34
42
  </template>
35
43
  </m-card>
@@ -46,6 +54,11 @@
46
54
  :iconPosition="button.iconPosition"
47
55
  style="margin-left: 1rem"
48
56
  :data-cerberus="sanitizeCerberusAttribut('MPB-ALERT', button.label)"
57
+ class="js-cdl"
58
+ data-cdl-click-type="cdl_event"
59
+ :data-cdl-click-data="
60
+ formatEvent({ button_name: button.label, button_location: stepLocation }, EventTypeEnum.BUTTON)
61
+ "
49
62
  />
50
63
  </div>
51
64
  </div>
@@ -77,6 +90,7 @@ import { PayloadAction } from '../types/genericPayload';
77
90
  import { sanitizeCerberusAttribut } from '@/services/sanitize';
78
91
  import { ref } from 'vue';
79
92
  import { useStore } from 'vuex';
93
+ import { EventTypeEnum, formatEvent } from '../services/event';
80
94
 
81
95
  const emit = defineEmits(['go-back', 'step-completed']);
82
96
  const showModal = ref(false);
@@ -94,6 +108,10 @@ const props = defineProps({
94
108
  type: Object,
95
109
  default: () => ({}),
96
110
  },
111
+ stepLocation: {
112
+ type: String,
113
+ default: '',
114
+ },
97
115
  });
98
116
 
99
117
  const handleCloseModal = () => {
@@ -228,7 +228,7 @@
228
228
  </div>
229
229
  <div class="pb-question__actions-container__column" v-if="!skippables || hasAnswersSelected">
230
230
  <m-button
231
- class="pb-question__actions-buttons-button"
231
+ class="pb-question__actions-buttons-button js-cdl"
232
232
  size="m"
233
233
  size-from-l="l"
234
234
  icon="ArrowNext48"
@@ -237,6 +237,8 @@
237
237
  @click="nextStepHandler"
238
238
  :disabled="!hasAnswersSelected"
239
239
  :data-cerberus="sanitizeCerberusAttribut('MPB-QUESTION', 'Etape suivante')"
240
+ data-cdl-click-type="cdl_event"
241
+ :data-cdl-click-data="eventData"
240
242
  />
241
243
  </div>
242
244
  <div v-else-if="skippables && !hasAnswersSelected" class="pb-question__actions-container__column">
@@ -388,6 +390,7 @@ import {
388
390
  ScenarioStepAnswerNotification,
389
391
  } from '@/types/pb/Scenario';
390
392
  import { useStore } from 'vuex';
393
+ import { EventTypeEnum, formatEvent } from '../services/event';
391
394
 
392
395
  const BACK_ICON =
393
396
  'https://storage.googleapis.com/project-booster-media/mozaic-icons/svg/Navigation_Arrow_Arrow--Left_16px.svg';
@@ -603,6 +606,7 @@ const selectAnswer = (stepCode: string, answer: ScenarioStepAnswer) => {
603
606
  });
604
607
  selectedAnswers.value.set(answer.code, !selectedAnswers.value.get(answer.code) ?? true);
605
608
  }
609
+ updateCdlValues();
606
610
  };
607
611
 
608
612
  const validMultiSelect = (multiSelectOptions: ScenarioStepMultiSelectAction | undefined) => {
@@ -618,6 +622,7 @@ const validMultiSelect = (multiSelectOptions: ScenarioStepMultiSelectAction | un
618
622
  answers: answers,
619
623
  nextStep: multiSelectOptions?.nextStep,
620
624
  });
625
+ updateCdlValues();
621
626
  };
622
627
 
623
628
  const skipQuestion = (button: ScenarioStepSkippableOptions | undefined) => {
@@ -730,9 +735,10 @@ const handleShowModal = () => {
730
735
  showModal.value = !showModal.value;
731
736
  };
732
737
 
738
+ const eventData: any = ref();
739
+
733
740
  const handleCardClick = (answer: ScenarioStepAnswer, payload: any) => {
734
741
  notification.value = undefined;
735
-
736
742
  if (answer.notification) {
737
743
  notification.value = answer.notification;
738
744
 
@@ -761,6 +767,23 @@ const nextStepHandler = () => {
761
767
  });
762
768
  }
763
769
  };
770
+
771
+ const updateCdlValues = () => {
772
+ const answers: any = [];
773
+
774
+ for (const answerCode in Object.fromEntries(selectedAnswers.value)) {
775
+ answers.push(answerCode);
776
+ }
777
+
778
+ eventData.value = formatEvent(
779
+ {
780
+ field_name: props.payload.viewModel.label,
781
+ funnel_name: props.payload.viewModel.analytics.funnel_name,
782
+ field_value: answers,
783
+ },
784
+ EventTypeEnum.FIELD,
785
+ );
786
+ };
764
787
  </script>
765
788
 
766
789
  <style lang="scss" scoped>
@@ -7,29 +7,54 @@ export enum ButtonType {
7
7
  ACTION = 'action',
8
8
  }
9
9
 
10
- interface EventData {
11
- button_name: string;
12
- button_location: string;
13
- button_type: ButtonType;
10
+ export enum CdlEventEnum {
11
+ CDL = 'cdl_event',
14
12
  }
15
13
 
16
- interface EventField {
17
- field_name: string;
18
- field_value: any;
19
- funnel_name: string;
14
+ export enum EventTypeEnum {
15
+ FIELD = 'field',
16
+ BUTTON = 'button',
17
+ }
18
+
19
+ export interface FormatEventInterface {
20
+ button_name?: string;
21
+ button_location?: string;
22
+ funnel_name?: string;
23
+ field_name?: string;
24
+ field_value?: any;
20
25
  }
21
26
 
22
27
  /**
23
- * Send analytics emit event
24
- * @param event_name
25
- * @param event_data
28
+ * Format event click, field
29
+ * @param param0
30
+ * @param type
31
+ * @returns
26
32
  */
27
- export const sendAnalyticEvent = (store: any, event_name: EventName, event_data: EventData | EventField) => {
28
- store.dispatch('sendEventToBus', {
29
- code: 'EMIT-ANALYTIC-EVENT',
30
- payload: {
31
- event_name,
32
- event_data,
33
- },
33
+ export const formatEvent = (
34
+ { button_name, button_location, funnel_name, field_name, field_value }: FormatEventInterface,
35
+ type: EventTypeEnum,
36
+ ) => {
37
+ let event_data = {};
38
+
39
+ switch (type) {
40
+ case EventTypeEnum.BUTTON:
41
+ event_data = {
42
+ button_name,
43
+ button_location,
44
+ button_type: ButtonType.ACTION,
45
+ };
46
+ break;
47
+ case EventTypeEnum.FIELD:
48
+ event_data = {
49
+ field_name,
50
+ field_value,
51
+ funnel_name,
52
+ };
53
+ break;
54
+ }
55
+
56
+ return JSON.stringify({
57
+ event_name: type === EventTypeEnum.BUTTON ? EventName.CLICK : EventName.FIELD,
58
+ event_data,
34
59
  });
35
60
  };
@@ -64,6 +64,7 @@
64
64
  :sticky-bottom-offset="stickyBottomOffset()"
65
65
  :min-height="minHeight"
66
66
  :is-collaborator="isCollaborator"
67
+ :step-location="state.currentStep?.slots?.beforeContent.label"
67
68
  @step-completed="handleStepCompleted"
68
69
  @update-selected="handleSemiUpdateSelected"
69
70
  @redirection="handleRedirection"
@@ -61,6 +61,9 @@
61
61
  "slots": {
62
62
  "stickyBottom": {
63
63
  "display": false
64
+ },
65
+ "beforeContent": {
66
+ "label": "STEP-1"
64
67
  }
65
68
  },
66
69
  "payload": {