Skip to content
Draft
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ede47dc
Copy existing Stub Attribution folder and rename to Download Attribution
maureenlholland Apr 15, 2026
5a79ad6
Convert JS file to ES6
maureenlholland Apr 15, 2026
05601ac
Refactor download attribution to clarify split between essential and …
maureenlholland Apr 15, 2026
2901242
Add refactored JS bundle and apply behind switch
maureenlholland Apr 23, 2026
e4ac493
Update download as default to simpler attribution flow
maureenlholland Apr 23, 2026
b0a7bbc
Move GTM event listener into GTM analytics storage util
maureenlholland Apr 23, 2026
5434feb
Add auto-download JS
maureenlholland Apr 28, 2026
8efb354
Duplicate all-init JS for use with new Download Attribution JS
maureenlholland Apr 29, 2026
dfb55e6
Update all-init-v2 to use DownloadAttribution
maureenlholland Apr 29, 2026
1c92946
Ensure stale essential data is refreshed
maureenlholland Apr 29, 2026
8630374
Add E2E download attribution tests
maureenlholland May 5, 2026
fb3e452
Auto-download should apply any existing download attribution to download
maureenlholland May 12, 2026
1e871de
Add check for valid essential campaigns and fix download as default c…
maureenlholland May 13, 2026
00cb6ab
Rename marketing to analytics for consistency
maureenlholland May 13, 2026
b7b3b92
All download attribution values default to (not set)
maureenlholland May 13, 2026
2cdfea0
Reorg and update comment for default download attribution init JS
maureenlholland May 13, 2026
1293142
Fix edge case with cookie policy page consent status update
maureenlholland May 13, 2026
f5ba0a8
Restore commented out code (was used for local testing)
maureenlholland May 13, 2026
48bb9c9
Fix invalid use of waffle switch
maureenlholland May 13, 2026
326f6be
Add removeDownloadAsDefault setup to playwright tests for more contro…
maureenlholland May 13, 2026
62c6b39
Update thanks prefix comment
maureenlholland May 13, 2026
de6963a
Fix source key typo
maureenlholland May 18, 2026
f886354
Gate JS download attribution call behind check for HTML data switch a…
maureenlholland May 18, 2026
6cbf61b
Guard against undefined Mozilla namespace
maureenlholland May 18, 2026
f7c2cb9
Ensure download as default also has timeout callback to avoid trappin…
maureenlholland May 18, 2026
3c7d5c0
Add guard against undefined Mozilla.DownloadAttribution
maureenlholland May 18, 2026
608d4d8
Ensure extended template inherits /thanks html attrs
maureenlholland May 18, 2026
0cbcb05
Fix playwright test typo and potential race conditions
maureenlholland May 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions media/js/base/consent/utils.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import MozAllowList from './allow-list.es6';
import DownloadAttribution from '../download-attribution/download-attribution.es6';

const COOKIE_ID = 'moz-consent-pref'; // Cookie name
const COOKIE_EXPIRY_DAYS = 182; // 6 months expiry
Expand Down Expand Up @@ -44,6 +45,16 @@ function setGtagAdsConsentMode(hasConsent, type = 'update') {
* @returns {Boolean}
*/
function setGtagAnalyticsConsentMode(hasConsent, type = 'update') {
// This is a failsafe to ensure we always remove analytics download attribution
// when consent status is denied (regardless of whether or not we are on page with
// a consent banner, i.e. the cookie policy page)
//
// This failsafe is only necessary as long as GTM is conditionally loaded
// Once it is always loaded, we can rely on GTM consent mode status
if (!hasConsent) {
DownloadAttribution.initAnalytics(false);
}

// bail out if GTAG has not been created with GTMSnippet.loadSnippet
// this needs to run before GTM snippet loads to set proper defaults
if (typeof window.gtag === 'undefined') {
Expand All @@ -53,6 +64,9 @@ function setGtagAnalyticsConsentMode(hasConsent, type = 'update') {
window.gtag('consent', type, {
analytics_storage: 'granted'
});

// We only apply analytics information if GTAG is available
DownloadAttribution.initAnalytics(true);
} else {
Comment thread
maureenlholland marked this conversation as resolved.
window.gtag('consent', type, {
analytics_storage: 'denied'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import DownloadAttribution from './download-attribution.es6';

// Refresh the essential data to avoid an outdated download experience
// - If there's new essential data, update
// - If there's no essential data, remove
DownloadAttribution.initEssential();

DownloadAttribution.applyAttributionDataToLinks();
Loading
Loading