@elementor/editor-audits 4.4.0-1079 → 4.4.0-1081
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +278 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -175
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/audits/google-consent-mode.ts +68 -0
- package/src/register-audits.ts +2 -0
- package/src/types.ts +2 -0
- package/src/utils/fetch-rendered-html.ts +24 -0
- package/src/utils/scan-consent-signals.ts +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-audits",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-1081",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,19 +39,19 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.4.0-
|
|
43
|
-
"@elementor/editor-mcp": "4.4.0-
|
|
44
|
-
"@elementor/editor-app-bar": "4.4.0-
|
|
45
|
-
"@elementor/editor-elements": "4.4.0-
|
|
46
|
-
"@elementor/editor-floating-panels": "4.4.0-
|
|
47
|
-
"@elementor/editor-notifications": "4.4.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
49
|
-
"@elementor/events": "4.4.0-
|
|
50
|
-
"@elementor/http-client": "4.4.0-
|
|
42
|
+
"@elementor/editor": "4.4.0-1081",
|
|
43
|
+
"@elementor/editor-mcp": "4.4.0-1081",
|
|
44
|
+
"@elementor/editor-app-bar": "4.4.0-1081",
|
|
45
|
+
"@elementor/editor-elements": "4.4.0-1081",
|
|
46
|
+
"@elementor/editor-floating-panels": "4.4.0-1081",
|
|
47
|
+
"@elementor/editor-notifications": "4.4.0-1081",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.4.0-1081",
|
|
49
|
+
"@elementor/events": "4.4.0-1081",
|
|
50
|
+
"@elementor/http-client": "4.4.0-1081",
|
|
51
51
|
"@elementor/icons": "~1.77.0",
|
|
52
|
-
"@elementor/locations": "4.4.0-
|
|
53
|
-
"@elementor/session": "4.4.0-
|
|
54
|
-
"@elementor/store": "4.4.0-
|
|
52
|
+
"@elementor/locations": "4.4.0-1081",
|
|
53
|
+
"@elementor/session": "4.4.0-1081",
|
|
54
|
+
"@elementor/store": "4.4.0-1081",
|
|
55
55
|
"@elementor/ui": "1.37.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { __ } from '@wordpress/i18n';
|
|
2
|
+
|
|
3
|
+
import { type Audit } from '../types';
|
|
4
|
+
import { fetchRenderedHtml } from '../utils/fetch-rendered-html';
|
|
5
|
+
import { hasConsentDefaultCall, hasGoogleTracking } from '../utils/scan-consent-signals';
|
|
6
|
+
|
|
7
|
+
export const audit: Audit = {
|
|
8
|
+
id: 'audits/google-consent-mode',
|
|
9
|
+
title: __( 'Google Consent Mode', 'elementor' ),
|
|
10
|
+
description: __(
|
|
11
|
+
'Google Analytics, Ads, or Tag Manager are running on this site and may not receive a consent signal, which risks losing conversion/analytics data and compliance exposure.',
|
|
12
|
+
'elementor'
|
|
13
|
+
),
|
|
14
|
+
fixHint: __(
|
|
15
|
+
'Turn on Google Consent Mode in your cookie consent plugin so Google tags respect visitor consent choices.',
|
|
16
|
+
'elementor'
|
|
17
|
+
),
|
|
18
|
+
categories: [ 'compliance' ],
|
|
19
|
+
severity: 'warning',
|
|
20
|
+
weight: 1,
|
|
21
|
+
evaluate: async ( ctx ) => {
|
|
22
|
+
if ( ! ctx.pageContext.frontend_url ) {
|
|
23
|
+
return { status: 'skipped', reason: __( 'Page is not published.', 'elementor' ) };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const html = await fetchRenderedHtml( ctx.pageContext.frontend_url );
|
|
27
|
+
|
|
28
|
+
if ( ! html ) {
|
|
29
|
+
return { status: 'skipped', reason: __( 'Could not fetch the published page.', 'elementor' ) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ( ! hasGoogleTracking( html ) ) {
|
|
33
|
+
return { status: 'skipped', reason: __( 'No Google tracking product detected.', 'elementor' ) };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ( hasConsentDefaultCall( html ) ) {
|
|
37
|
+
return { status: 'pass' };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const label = __( 'No Google Consent Mode signal was found on the page.', 'elementor' );
|
|
41
|
+
const isCookiezReady = ctx.pageContext.cookiez_plugin_installed && ctx.pageContext.cookiez_plugin_active;
|
|
42
|
+
|
|
43
|
+
if ( isCookiezReady ) {
|
|
44
|
+
return {
|
|
45
|
+
status: 'fail',
|
|
46
|
+
violations: [
|
|
47
|
+
{
|
|
48
|
+
auditId: audit.id,
|
|
49
|
+
label,
|
|
50
|
+
ctaLabel: __( 'Enable', 'elementor' ),
|
|
51
|
+
externalUrl: ctx.pageContext.cookiez_consent_mode_settings_url,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
status: 'fail',
|
|
59
|
+
violations: [
|
|
60
|
+
{
|
|
61
|
+
auditId: audit.id,
|
|
62
|
+
label,
|
|
63
|
+
externalUrl: ctx.pageContext.cookiez_plugin_action_url,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
package/src/register-audits.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as cookiePolicy from './audits/cookie-policy';
|
|
|
3
3
|
import * as deepNesting from './audits/deep-nesting';
|
|
4
4
|
import * as defaultDesignSystem from './audits/default-design-system';
|
|
5
5
|
import * as deprecatedWidgets from './audits/deprecated-widgets';
|
|
6
|
+
import * as googleConsentMode from './audits/google-consent-mode';
|
|
6
7
|
import * as headingStructure from './audits/heading-structure';
|
|
7
8
|
import * as hiddenElements from './audits/hidden-elements';
|
|
8
9
|
import * as imagesAltText from './audits/images-alt-text';
|
|
@@ -49,6 +50,7 @@ const AUDITS: Audit[] = [
|
|
|
49
50
|
accessibilityPolicy.audit,
|
|
50
51
|
cookiePolicy.audit,
|
|
51
52
|
scanForCookies.audit,
|
|
53
|
+
googleConsentMode.audit,
|
|
52
54
|
];
|
|
53
55
|
|
|
54
56
|
export function registerAllAudits(): void {
|
package/src/types.ts
CHANGED
|
@@ -69,8 +69,10 @@ export type PageContextResponse = {
|
|
|
69
69
|
cookiez_plugin_installed: boolean;
|
|
70
70
|
cookiez_plugin_action_url: string;
|
|
71
71
|
cookiez_scan_url: string;
|
|
72
|
+
cookiez_consent_mode_settings_url: string;
|
|
72
73
|
image_optimization_plugin_active: boolean;
|
|
73
74
|
image_optimization_plugin_url: string;
|
|
75
|
+
frontend_url: string | null;
|
|
74
76
|
site_identity: {
|
|
75
77
|
site_name_set: boolean;
|
|
76
78
|
site_description_set: boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const FETCH_TIMEOUT_MS = 10_000;
|
|
2
|
+
|
|
3
|
+
export async function fetchRenderedHtml( url: string | null ): Promise< string | null > {
|
|
4
|
+
if ( ! url ) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const timeoutController = new AbortController();
|
|
9
|
+
const timeoutId = setTimeout( () => timeoutController.abort(), FETCH_TIMEOUT_MS );
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch( url, { credentials: 'omit', signal: timeoutController.signal } );
|
|
13
|
+
|
|
14
|
+
if ( ! response.ok ) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return await response.text();
|
|
19
|
+
} catch {
|
|
20
|
+
return null;
|
|
21
|
+
} finally {
|
|
22
|
+
clearTimeout( timeoutId );
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const GOOGLE_TRACKING_PATTERNS = [
|
|
2
|
+
/googletagmanager\.com\/gtag\/js\?id=(G|AW)-/,
|
|
3
|
+
/googletagmanager\.com\/gtm\.js/,
|
|
4
|
+
/\bGTM-[A-Z0-9]+\b/,
|
|
5
|
+
/gtag\(\s*['"]config['"]\s*,\s*['"](G|AW)-/,
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
const CONSENT_DEFAULT_PATTERNS = [
|
|
9
|
+
/gtag\(\s*['"]consent['"]\s*,\s*['"]default['"]/,
|
|
10
|
+
/dataLayer\.push\(\s*\[\s*['"]consent['"]\s*,\s*['"]default['"]/,
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export function hasGoogleTracking( html: string ): boolean {
|
|
14
|
+
return GOOGLE_TRACKING_PATTERNS.some( ( pattern ) => pattern.test( html ) );
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function hasConsentDefaultCall( html: string ): boolean {
|
|
18
|
+
return CONSENT_DEFAULT_PATTERNS.some( ( pattern ) => pattern.test( html ) );
|
|
19
|
+
}
|