/
githubmirror
/
angular
Обзор
Документация
Войти
/
githubmirror
/
angular
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
adev/shared-docs/utils/analytics.utils.ts
46 строк
1 KB
Alan Agius
refactor: ensure modules with 'declare global' are correctly handled by Rollup
13 мар 2026, 22:07
13 мар 2026, 22:07
e8cfa44
Код
Авторство
О чём код?
/*! * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ declare global { interface Window { gtag?(...args: any[]): void; } } export const setCookieConsent = (state: 'denied' | 'granted'): void => { try { if (window.gtag) { const consentOptions = { ad_user_data: state, ad_personalization: state, ad_storage: state, analytics_storage: state, }; if (state === 'denied') { window.gtag('consent', 'default', { ...consentOptions, wait_for_update: 500, }); } else if (state === 'granted') { window.gtag('consent', 'update', { ...consentOptions, }); } } } catch { if (state === 'denied') { console.error('Unable to set default cookie consent.'); } else if (state === 'granted') { console.error('Unable to grant cookie consent.'); } } }; // This fixes the RollupError: Exported variable "global" is not defined. export {};