@elementor/editor-audits 4.4.0-beta3 → 4.4.0
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +265 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -15
- package/src/audits/accessibility-statement.ts +1 -0
- package/src/audits/accessibility-widget.ts +1 -0
- package/src/audits/cookie-policy.ts +1 -0
- package/src/audits/google-consent-mode.ts +1 -0
- package/src/audits/images-alt-text.ts +1 -0
- package/src/audits/images-inefficient-format.ts +1 -0
- package/src/audits/images-too-large.ts +1 -0
- package/src/audits/scan-for-cookies.ts +1 -0
- package/src/components/audit-panel.tsx +6 -1
- package/src/components/fix-violation-with-angie.tsx +15 -15
- package/src/components/promotions.tsx +9 -2
- package/src/components/violation-cta-button.tsx +9 -1
- package/src/components/violation-row.tsx +28 -4
- package/src/constants.ts +13 -4
- package/src/hooks/focus-violation.ts +9 -5
- package/src/hooks/use-audit-report.ts +6 -1
- package/src/hooks/use-track-panel-viewed.ts +31 -0
- package/src/types.ts +1 -0
- package/src/utils/build-run-summary.ts +45 -0
- package/src/utils/tracking-names.ts +12 -0
- package/src/utils/tracking.ts +130 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { getMixpanel } from '@elementor/events';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
FINDING_CLICKED_EVENT,
|
|
5
|
+
PANEL_CLOSED_EVENT,
|
|
6
|
+
PANEL_VIEWED_EVENT,
|
|
7
|
+
RUN_COMPLETED_EVENT,
|
|
8
|
+
RUN_STARTED_EVENT,
|
|
9
|
+
TRACKING_LOCATION_L1,
|
|
10
|
+
TRACKING_TARGET_LOCATION,
|
|
11
|
+
TRACKING_WINDOW_NAME,
|
|
12
|
+
} from '../constants';
|
|
13
|
+
import { type AuditMeta, type AuditViolation, type PageAuditReport } from '../types';
|
|
14
|
+
import { buildRunSummary } from './build-run-summary';
|
|
15
|
+
import { toCheckName, toTrackingSeverity } from './tracking-names';
|
|
16
|
+
|
|
17
|
+
export type RunTrigger = 'run_audit' | 'rescan';
|
|
18
|
+
|
|
19
|
+
export type ViewIssueResult =
|
|
20
|
+
| 'element_focused'
|
|
21
|
+
| 'page_settings_opened'
|
|
22
|
+
| 'site_settings_opened'
|
|
23
|
+
| 'external_url_opened';
|
|
24
|
+
|
|
25
|
+
export type FindingLocation = 'overview' | 'issues';
|
|
26
|
+
|
|
27
|
+
type FindingAction =
|
|
28
|
+
| { actionType: 'view_issue'; interactionResult: ViewIssueResult }
|
|
29
|
+
| { actionType: 'fix_with_angie'; interactionResult: 'angie_prompt_sent' }
|
|
30
|
+
| { actionType: 'fix_with_app'; interactionResult: 'app_opened'; appInstalled?: boolean };
|
|
31
|
+
|
|
32
|
+
type FindingClick = FindingAction & {
|
|
33
|
+
audit: AuditMeta;
|
|
34
|
+
locationL2: FindingLocation;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const dispatch = ( eventName: string, payload: Record< string, unknown > ) => {
|
|
38
|
+
getMixpanel().dispatchEvent?.( eventName, {
|
|
39
|
+
window_name: TRACKING_WINDOW_NAME,
|
|
40
|
+
target_location: TRACKING_TARGET_LOCATION,
|
|
41
|
+
location_l1: TRACKING_LOCATION_L1,
|
|
42
|
+
...payload,
|
|
43
|
+
} );
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const trackPanelViewed = ( {
|
|
47
|
+
hasPriorReport,
|
|
48
|
+
isFirstOpen,
|
|
49
|
+
}: {
|
|
50
|
+
hasPriorReport: boolean;
|
|
51
|
+
isFirstOpen: boolean;
|
|
52
|
+
} ) => {
|
|
53
|
+
dispatch( PANEL_VIEWED_EVENT, {
|
|
54
|
+
interaction_type: 'view',
|
|
55
|
+
target_type: 'panel',
|
|
56
|
+
target_name: 'page_audit_panel',
|
|
57
|
+
interaction_result: 'panel_viewed',
|
|
58
|
+
metadata: { has_prior_report: hasPriorReport, is_first_open: isFirstOpen },
|
|
59
|
+
} );
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const trackPanelClosed = () => {
|
|
63
|
+
dispatch( PANEL_CLOSED_EVENT, {
|
|
64
|
+
interaction_type: 'click',
|
|
65
|
+
target_type: 'button',
|
|
66
|
+
target_name: 'close',
|
|
67
|
+
interaction_result: 'panel_closed',
|
|
68
|
+
} );
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const trackRunStarted = ( trigger: RunTrigger ) => {
|
|
72
|
+
dispatch( RUN_STARTED_EVENT, {
|
|
73
|
+
interaction_type: 'click',
|
|
74
|
+
target_type: 'button',
|
|
75
|
+
target_name: trigger,
|
|
76
|
+
interaction_result: 'run_initiated',
|
|
77
|
+
} );
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const trackRunOutcome = ( interactionResult: 'run_completed' | 'run_failed', details: Record< string, unknown > ) => {
|
|
81
|
+
dispatch( RUN_COMPLETED_EVENT, {
|
|
82
|
+
interaction_type: 'view',
|
|
83
|
+
target_type: 'report',
|
|
84
|
+
target_name: 'audit_report',
|
|
85
|
+
interaction_result: interactionResult,
|
|
86
|
+
...details,
|
|
87
|
+
} );
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const trackRunCompleted = ( report: PageAuditReport ) => {
|
|
91
|
+
const { state, metadata } = buildRunSummary( report );
|
|
92
|
+
|
|
93
|
+
trackRunOutcome( 'run_completed', { state, metadata } );
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const trackRunFailed = () => {
|
|
97
|
+
trackRunOutcome( 'run_failed', {} );
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const trackFixWithApp = ( audit: AuditMeta, violation: AuditViolation, locationL2: FindingLocation ) => {
|
|
101
|
+
if ( violation.appInstalled === undefined ) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
trackFindingClicked( {
|
|
106
|
+
audit,
|
|
107
|
+
locationL2,
|
|
108
|
+
actionType: 'fix_with_app',
|
|
109
|
+
interactionResult: 'app_opened',
|
|
110
|
+
appInstalled: violation.appInstalled,
|
|
111
|
+
} );
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const trackFindingClicked = ( click: FindingClick ) => {
|
|
115
|
+
const { audit, locationL2, actionType, interactionResult } = click;
|
|
116
|
+
|
|
117
|
+
dispatch( FINDING_CLICKED_EVENT, {
|
|
118
|
+
interaction_type: 'click',
|
|
119
|
+
target_type: 'row',
|
|
120
|
+
target_name: 'finding_row',
|
|
121
|
+
action_type: actionType,
|
|
122
|
+
target_value: toCheckName( audit.id ),
|
|
123
|
+
interaction_result: interactionResult,
|
|
124
|
+
state: toTrackingSeverity( audit.severity ),
|
|
125
|
+
location_l2: locationL2,
|
|
126
|
+
...( click.actionType === 'fix_with_app' && {
|
|
127
|
+
app_status: click.appInstalled ? 'installed' : 'not_installed',
|
|
128
|
+
} ),
|
|
129
|
+
} );
|
|
130
|
+
};
|