Skip to content

Commit 800bf7a

Browse files
[email protected] - Add support for tracking contexts (#2543)
* [email protected] - Add support for tracking contexts * [email protected] - Use mixin to provide prop * Add storybook controls and update READMEs * Use latest f-trak
1 parent bb8a18c commit 800bf7a

25 files changed

+278
-88
lines changed

packages/components/organisms/f-footer/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
44
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
55

6+
## v8.9.0
7+
8+
_June 24, 2024_
9+
10+
### Added
11+
12+
- New prop `globalTrackingContexts` which are passed through to f-trak for analytics events.
13+
- Use `f-trak` v1+
14+
615
## v8.8.0
716

817
_May 21, 2024_

packages/components/organisms/f-footer/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ The props that can be defined are as follows (if any):
9090
| `showCourierLinks` | `Bool` | `true` | Controls whether to show courier links in footer. |
9191
| `showCountrySelector` | `Bool` | `true` | Controls whether to show country selector in footer. |
9292
| `content` | `Object` | `{}` | Content to be displayed in the footer (sections, links, etc.) |
93+
| `globalTrackingContexts` | `Array` | `[]` | Array containing the global tracking contexts to be passed through to f-trak. |
9394

9495
### CSS Classes
9596

packages/components/organisms/f-footer/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@justeat/f-footer",
3-
"version": "8.8.0",
3+
"version": "8.9.0",
44
"main": "dist/f-footer.umd.min.js",
55
"maxBundleSize": "80kB",
66
"files": [
@@ -54,7 +54,7 @@
5454
"v-click-outside": "3.1.2"
5555
},
5656
"peerDependencies": {
57-
"@justeat/f-trak": ">=0.6.0"
57+
"@justeat/f-trak": "1.x"
5858
},
5959
"devDependencies": {
6060
"@justeat/f-wdio-utils": "1.x"

packages/components/organisms/f-footer/src/components/ButtonList.vue

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
v-for="(button, i) in buttonList.buttons"
1010
:key="`${i}_Button`"
1111
:href="button.url"
12-
:data-trak='`{
13-
"trakEvent": "click",
14-
"category": "engagement",
15-
"action": "footer",
16-
"label": "${button.gtm}"
17-
}`'
12+
:data-trak='JSON.stringify({
13+
trakEvent: "click",
14+
category: "engagement",
15+
action: "footer",
16+
label: button.gtm,
17+
...(globalTrackingContexts.length ? {
18+
context: globalTrackingContexts
19+
} : {})
20+
})'
1821
:class="$style['c-buttonList-button']"
1922
target="_blank"
2023
rel="noopener noreferrer">
@@ -25,7 +28,11 @@
2528
</template>
2629

2730
<script>
31+
import analyticsMixin from '../mixins/analytics.mixin';
32+
2833
export default {
34+
mixins: [analyticsMixin],
35+
2936
props: {
3037
buttonList: {
3138
type: Object,

packages/components/organisms/f-footer/src/components/CountrySelector.vue

+13-6
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,15 @@
5555
:key="`${i}_Country`"
5656
:data-test-id="[`countrySelector-country-${country.dataTestKey}`]">
5757
<a
58-
:data-trak='`{
59-
"trakEvent": "click",
60-
"category": "engagement",
61-
"action": "footer",
62-
"label": "${country.gtm}"
63-
}`'
58+
:data-trak='JSON.stringify({
59+
trakEvent: "click",
60+
category: "engagement",
61+
action: "footer",
62+
label: country.gtm,
63+
...(globalTrackingContexts.length ? {
64+
context: globalTrackingContexts
65+
} : {})
66+
})'
6467
:href="country.siteUrl"
6568
:class="$style['c-countrySelector-link']"
6669
data-test-id="countrySelector-countryLink">
@@ -85,7 +88,9 @@ import {
8588
CrossIcon
8689
} from '@justeat/f-vue-icons';
8790
import vClickOutside from 'v-click-outside';
91+
8892
import FlagIcon from './FlagIcon.vue';
93+
import analyticsMixin from '../mixins/analytics.mixin';
8994
9095
export default {
9196
components: {
@@ -98,6 +103,8 @@ export default {
98103
clickOutside: vClickOutside.directive
99104
},
100105
106+
mixins: [analyticsMixin],
107+
101108
props: {
102109
currentCountryName: {
103110
type: String,

packages/components/organisms/f-footer/src/components/FeedbackBlock.vue

+13-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
$style['is-invisible']
77
]"
88
data-gtm-feedback
9-
data-trak='{
10-
"trakEvent": "click",
11-
"category": "engagement",
12-
"action": "footer",
13-
"label": "click_feedback"
14-
}'>
9+
:data-trak='JSON.stringify({
10+
trakEvent: "click",
11+
category: "engagement",
12+
action: "footer",
13+
label: "click_feedback",
14+
...(globalTrackingContexts.length ? {
15+
context: globalTrackingContexts
16+
} : {})
17+
})'>
1518
<h2
1619
:class="[
1720
$style['c-footer-heading'],
@@ -34,7 +37,11 @@
3437
</template>
3538

3639
<script>
40+
import analyticsMixin from '../mixins/analytics.mixin';
41+
3742
export default {
43+
mixins: [analyticsMixin],
44+
3845
props: {
3946
title: {
4047
type: String,

packages/components/organisms/f-footer/src/components/Footer.vue

+25-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<link-list
1515
v-for="(section, i) in content.sections"
1616
:key="`${i}_LinkList`"
17-
:link-list="section" />
17+
:link-list="section"
18+
:global-tracking-contexts="globalTrackingContexts" />
1819
</div>
1920

2021
<div :class="$style['c-footer-light']">
@@ -30,7 +31,8 @@
3031
<button-list
3132
v-for="(buttonList, i) in copy.linkButtonList"
3233
:key="`${i}_ButtonList`"
33-
:button-list="buttonList" />
34+
:button-list="buttonList"
35+
:global-tracking-contexts="globalTrackingContexts" />
3436
</div>
3537

3638
<div
@@ -42,18 +44,21 @@
4244
:title="copy.downloadOurApps"
4345
:icons="copy.appStoreIcons"
4446
:locale="copy.locale"
45-
list-type="apps" />
47+
list-type="apps"
48+
:global-tracking-contexts="globalTrackingContexts" />
4649

4750
<feedback-block
4851
:title="copy.feedback"
4952
:text="copy.improveOurWebsite"
5053
:button-text="copy.sendFeedback"
51-
data-test-id="feedback-block" />
54+
data-test-id="feedback-block"
55+
:global-tracking-contexts="globalTrackingContexts" />
5256

5357
<icon-list
5458
:icons="copy.socialIcons"
5559
:title="copy.followUs"
56-
list-type="social" />
60+
list-type="social"
61+
:global-tracking-contexts="globalTrackingContexts" />
5762
</div>
5863
</div>
5964
</div>
@@ -73,7 +78,8 @@
7378
:current-country-name="copy.currentCountryName"
7479
:current-country-key="copy.currentCountryKey"
7580
:countries="countryList"
76-
:change-country-text="copy.changeCurrentCountry" />
81+
:change-country-text="copy.changeCurrentCountry"
82+
:global-tracking-contexts="globalTrackingContexts" />
7783

7884
<legal-field
7985
v-if="metaLegalFieldEnabled"
@@ -82,23 +88,27 @@
8288

8389
<icon-list
8490
:icons="copy.paymentIcons"
85-
list-type="payments" />
91+
list-type="payments"
92+
:global-tracking-contexts="globalTrackingContexts" />
8693
</div>
8794
</footer>
8895
</template>
8996

9097
<script>
9198
import { globalisationServices } from '@justeat/f-services';
99+
92100
import ButtonList from './ButtonList.vue';
93101
import CountrySelector from './CountrySelector.vue';
94102
import FeedbackBlock from './FeedbackBlock.vue';
95103
import IconList from './IconList.vue';
96104
import LegalField from './LegalField.vue';
97105
import LinkList from './LinkList.vue';
98106
import { tenantConfigs, countries } from '../tenants';
107+
import analyticsMixin from '../mixins/analytics.mixin';
99108
100109
export default {
101110
name: 'PageFooter',
111+
102112
components: {
103113
ButtonList,
104114
CountrySelector,
@@ -107,6 +117,9 @@ export default {
107117
LegalField,
108118
LinkList
109119
},
120+
121+
mixins: [analyticsMixin],
122+
110123
props: {
111124
locale: {
112125
type: String,
@@ -125,20 +138,25 @@ export default {
125138
default: () => {}
126139
}
127140
},
141+
128142
computed: {
129143
footerLocale () {
130144
return globalisationServices.getLocale(tenantConfigs, this.locale, this.$i18n);
131145
},
146+
132147
copy () {
133148
const localeConfig = tenantConfigs[this.footerLocale];
134149
return localeConfig;
135150
},
151+
136152
theme () {
137153
return globalisationServices.getTheme(this.footerLocale);
138154
},
155+
139156
metaLegalFieldEnabled () {
140157
return Object.keys(this.copy.metaLegalField).length > 0;
141158
},
159+
142160
countryList () {
143161
return countries.filter(country => country.key !== this.copy.currentCountryKey);
144162
}

packages/components/organisms/f-footer/src/components/IconList.vue

+12-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@
3131
:href="icon.url"
3232
:title="icon.alt"
3333
:class="$style['c-iconList-listLink']"
34-
:data-trak='`{
35-
"trakEvent": "click",
36-
"category": "engagement",
37-
"action": "footer",
38-
"label": "${icon.gtm}"
39-
}`'
34+
:data-trak='JSON.stringify({
35+
trakEvent: "click",
36+
category: "engagement",
37+
action: "footer",
38+
label: icon.gtm,
39+
...(globalTrackingContexts.length ? {
40+
context: globalTrackingContexts
41+
} : {})
42+
})'
4043
:data-test-id="`footerIcon ${icon.name}`">
4144
<component
4245
:is="iconChoice"
@@ -58,13 +61,16 @@
5861
<script>
5962
import BaseProviderIcon from './BaseProviderIcon.vue';
6063
import AppStoreIcon from './AppStoreIcon.vue';
64+
import analyticsMixin from '../mixins/analytics.mixin';
6165
6266
export default {
6367
components: {
6468
AppStoreIcon,
6569
BaseProviderIcon
6670
},
6771
72+
mixins: [analyticsMixin],
73+
6874
props: {
6975
icons: {
7076
type: Array,

packages/components/organisms/f-footer/src/components/LinkList.vue

+21-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,15 @@
5252
:rel="link.rel"
5353
:target="link.target"
5454
:class="$style['c-footer-list-link']"
55-
:data-trak='`{
56-
"trakEvent": "click",
57-
"category": "engagement",
58-
"action": "footer",
59-
"label": "${link.gtmLabel}"
60-
}`'>
55+
:data-trak='JSON.stringify({
56+
trakEvent: "click",
57+
category: "engagement",
58+
action: "footer",
59+
label: link.gtmLabel,
60+
...(globalTrackingContexts.length ? {
61+
context: globalTrackingContexts
62+
} : {})
63+
})'>
6164
{{ link.text }}
6265
</a>
6366
</li>
@@ -69,23 +72,30 @@
6972
import { ChevronIcon } from '@justeat/f-vue-icons';
7073
import { windowServices } from '@justeat/f-services';
7174
75+
import analyticsMixin from '../mixins/analytics.mixin';
76+
7277
export default {
7378
components: {
7479
ChevronIcon
7580
},
81+
82+
mixins: [analyticsMixin],
83+
7684
props: {
7785
linkList: {
7886
type: Object,
7987
default: () => ({})
8088
}
8189
},
90+
8291
data () {
8392
return {
8493
currentScreenWidth: 0,
8594
interactedState: null,
8695
panelCollapsed: false
8796
};
8897
},
98+
8999
computed: {
90100
listId () {
91101
return `footer-${this.linkList.name.toLowerCase().split(' ').join('-')}`;
@@ -103,15 +113,18 @@ export default {
103113
return this.panelCollapsed ? 'linkList-wrapper-collapsed' : 'linkList-wrapper';
104114
}
105115
},
116+
106117
mounted () {
107118
this.currentScreenWidth = windowServices.getWindowWidth();
108119
windowServices.addEvent('resize', this.onResize, 100);
109120
110121
this.setPanelCollapsed();
111122
},
123+
112124
destroyed () {
113125
windowServices.removeEvent('resize', this.onResize);
114126
},
127+
115128
methods: {
116129
/**
117130
* Sets Links List panel collapsed state.
@@ -126,6 +139,7 @@ export default {
126139
this.panelCollapsed = false;
127140
}
128141
},
142+
129143
/**
130144
* Handle click events on Link List visibility toggle.
131145
* Only applied to below `wide` screen width (ref. Fozzie UI breakpoints).
@@ -136,6 +150,7 @@ export default {
136150
this.setPanelCollapsed();
137151
}
138152
},
153+
139154
/**
140155
* Handles `resize` window events.
141156
* Screen width is the only factor that affects Links List presentation.

0 commit comments

Comments
 (0)