mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
better?
This commit is contained in:
parent
f1b5b66813
commit
543b5df52b
1 changed files with 7 additions and 0 deletions
|
@ -12,6 +12,12 @@ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
||||||
import globalData from '@generated/globalData';
|
import globalData from '@generated/globalData';
|
||||||
import type {PluginOptions} from '@docusaurus/plugin-google-gtag';
|
import type {PluginOptions} from '@docusaurus/plugin-google-gtag';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
'ga-disable-MEASUREMENT_ID': boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default (function () {
|
export default (function () {
|
||||||
if (!ExecutionEnvironment.canUseDOM) {
|
if (!ExecutionEnvironment.canUseDOM) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -40,6 +46,7 @@ export default (function () {
|
||||||
localStorage.getItem('docusaurus.cookieConsent') ?? 'null',
|
localStorage.getItem('docusaurus.cookieConsent') ?? 'null',
|
||||||
) as boolean | null;
|
) as boolean | null;
|
||||||
if (!cookieConsentResponse) {
|
if (!cookieConsentResponse) {
|
||||||
|
window['ga-disable-MEASUREMENT_ID'] = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Always refer to the variable on window in-case it gets overridden elsewhere.
|
// Always refer to the variable on window in-case it gets overridden elsewhere.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue