Skip to content

Commit 867caca

Browse files
Update all-init-v2 to use DownloadAttribution
1 parent 64910bf commit 867caca

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

media/js/firefox/all/all-init-v2.es6.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
55
*/
66

7-
import StubAttributionConsent from '../../base/stub-attribution/stub-attribution-consent.es6';
7+
import DownloadAttribution from '../../base/download-attribution/download-attribution.es6';
88
import TrackProductDownload from '../../base/datalayer-productdownload.es6';
99
import MzpModal from '@mozilla-protocol/core/protocol/js/modal';
1010

@@ -86,12 +86,14 @@ import MzpModal from '@mozilla-protocol/core/protocol/js/modal';
8686
window.cms.Flare26.initDialogs();
8787
}
8888

89-
// init stub attribution & event tracking for GA4
89+
// Attach existing download attribution to download links
9090
if (downloadButtons && downloadButtons.length > 0) {
91-
if (StubAttributionConsent) {
92-
// We cannot rely on DOM ready as this section is partially fetched
91+
if (DownloadAttribution) {
92+
// download-attribution-init will run on page load and set any allowed download attribution data
93+
// But download links may not be rendered on DOM ready as this section is partially fetched
94+
// So we directly call the function that applies data to links (if no data, does nothing)
9395
// This flow is scheduled for refactoring: https://github.com/mozmeao/springfield/issues/258
94-
StubAttributionConsent.init();
96+
DownloadAttribution.applyAttributionDataToLinks();
9597
}
9698

9799
for (let i = 0; i < downloadButtons.length; ++i) {

media/static-bundles.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@
651651
],
652652
"name": "firefox_all"
653653
},
654+
{
655+
"files": [
656+
"js/firefox/all/all-init-v2.es6.js"
657+
],
658+
"name": "firefox_all-v2"
659+
},
654660
{
655661
"files": [
656662
"js/libs/classlist.js",

springfield/firefox/templates/firefox/all/base.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@
5050
{% endblock %}
5151

5252
{% block js %}
53-
{{ js_bundle('firefox_all') }}
53+
{% if switch('enable-attribution-refactor') %}
54+
{{ js_bundle('firefox_all-v2') }}
55+
{% else %}
56+
{{ js_bundle('firefox_all') }}
57+
{% endif %}
5458
{% endblock %}

0 commit comments

Comments
 (0)