@elementor/editor-audits 4.4.0-beta2 → 4.4.0-beta3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-audits",
3
- "version": "4.4.0-beta2",
3
+ "version": "4.4.0-beta3",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,21 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.4.0-beta2",
43
- "@elementor/editor-mcp": "4.4.0-beta2",
44
- "@elementor/editor-app-bar": "4.4.0-beta2",
45
- "@elementor/editor-current-user": "4.4.0-beta2",
46
- "@elementor/editor-elements": "4.4.0-beta2",
47
- "@elementor/editor-floating-panels": "4.4.0-beta2",
48
- "@elementor/editor-notifications": "4.4.0-beta2",
49
- "@elementor/editor-props": "4.4.0-beta2",
50
- "@elementor/editor-styles": "4.4.0-beta2",
51
- "@elementor/editor-v1-adapters": "4.4.0-beta2",
52
- "@elementor/events": "4.4.0-beta2",
53
- "@elementor/http-client": "4.4.0-beta2",
42
+ "@elementor/editor": "4.4.0-beta3",
43
+ "@elementor/editor-mcp": "4.4.0-beta3",
44
+ "@elementor/editor-app-bar": "4.4.0-beta3",
45
+ "@elementor/editor-elements": "4.4.0-beta3",
46
+ "@elementor/editor-floating-panels": "4.4.0-beta3",
47
+ "@elementor/editor-notifications": "4.4.0-beta3",
48
+ "@elementor/editor-props": "4.4.0-beta3",
49
+ "@elementor/editor-styles": "4.4.0-beta3",
50
+ "@elementor/editor-v1-adapters": "4.4.0-beta3",
51
+ "@elementor/events": "4.4.0-beta3",
52
+ "@elementor/http-client": "4.4.0-beta3",
54
53
  "@elementor/icons": "~1.78.1",
55
- "@elementor/locations": "4.4.0-beta2",
56
- "@elementor/session": "4.4.0-beta2",
57
- "@elementor/store": "4.4.0-beta2",
54
+ "@elementor/locations": "4.4.0-beta3",
55
+ "@elementor/session": "4.4.0-beta3",
56
+ "@elementor/store": "4.4.0-beta3",
58
57
  "@elementor/ui": "1.41.4"
59
58
  },
60
59
  "peerDependencies": {
@@ -32,7 +32,6 @@ export const audit: Audit = {
32
32
  ctaLabel: __( 'Create', 'elementor' ),
33
33
  secondaryCtaLabel: __( 'Learn more', 'elementor' ),
34
34
  secondaryCtaUrl: 'https://elementor.com/help/start-using-ally/#statement',
35
- appInstalled: isReady,
36
35
  },
37
36
  ],
38
37
  };
@@ -34,7 +34,6 @@ export const audit: Audit = {
34
34
  label: __( 'No accessibility widget is active on this site.', 'elementor' ),
35
35
  externalUrl: isReady ? ctx.pageContext.ally_widget_settings_url : ctx.pageContext.ally_plugin_url,
36
36
  ctaLabel: __( 'Activate', 'elementor' ),
37
- appInstalled: isReady,
38
37
  },
39
38
  ],
40
39
  };
@@ -26,7 +26,6 @@ export const audit: Audit = {
26
26
  label: __( 'Cookiez plugin is not installed or active.', 'elementor' ),
27
27
  externalUrl: ctx.pageContext.cookiez_plugin_url,
28
28
  ctaLabel: __( 'Set up cookie consent', 'elementor' ),
29
- appInstalled: ctx.pageContext.cookiez_plugin_active,
30
29
  },
31
30
  ],
32
31
  };
@@ -45,7 +45,6 @@ export const audit: Audit = {
45
45
  auditId: audit.id,
46
46
  label,
47
47
  ctaLabel: __( 'Enable', 'elementor' ),
48
- appInstalled: true,
49
48
  externalUrl: ctx.pageContext.cookiez_consent_mode_settings_url,
50
49
  },
51
50
  ],
@@ -38,7 +38,6 @@ export const audit: Audit = {
38
38
  label: __( 'Image is missing alt text.', 'elementor' ),
39
39
  externalUrl: isReady ? ctx.pageContext.ally_scan_url : ctx.pageContext.ally_plugin_url,
40
40
  ctaLabel: __( 'Fix with Ally', 'elementor' ),
41
- appInstalled: isReady,
42
41
  } );
43
42
  }
44
43
  } );
@@ -57,7 +57,6 @@ export const audit: Audit = {
57
57
  ? ctx.pageContext.image_optimization_settings_url
58
58
  : ctx.pageContext.image_optimization_plugin_url,
59
59
  ctaLabel: __( 'Optimize all', 'elementor' ),
60
- appInstalled: isReady,
61
60
  } ) );
62
61
 
63
62
  return violations.length === 0
@@ -65,7 +65,6 @@ export const audit: Audit = {
65
65
  ? ctx.pageContext.image_optimization_settings_url
66
66
  : ctx.pageContext.image_optimization_plugin_url,
67
67
  ctaLabel: __( 'Optimize all', 'elementor' ),
68
- appInstalled: isReady,
69
68
  } ) );
70
69
 
71
70
  return violations.length === 0
@@ -23,7 +23,6 @@ export const audit: Audit = {
23
23
  auditId: audit.id,
24
24
  label: __( 'This page has not been scanned for cookies yet.', 'elementor' ),
25
25
  externalUrl: isReady ? ctx.pageContext.cookiez_scan_url : ctx.pageContext.cookiez_plugin_action_url,
26
- appInstalled: isReady,
27
26
  },
28
27
  ],
29
28
  };
@@ -6,8 +6,6 @@ import { __ } from '@wordpress/i18n';
6
6
 
7
7
  import { AUDIT_PANEL_ID } from '../constants';
8
8
  import { useAuditReport } from '../hooks/use-audit-report';
9
- import { useTrackPanelViewed } from '../hooks/use-track-panel-viewed';
10
- import { trackPanelClosed } from '../utils/tracking';
11
9
  import AuditFeedback from './audit-feedback';
12
10
  import ErrorPage from './pages/error-page';
13
11
  import LoadingPage from './pages/loading-page';
@@ -18,10 +16,8 @@ import RescanButton from './rescan-button';
18
16
  export default function AuditPanel() {
19
17
  const { status, report, error, isStale, run } = useAuditReport();
20
18
 
21
- useTrackPanelViewed();
22
-
23
19
  const hostDocumentId = getHostDocumentId() ?? 0;
24
- const onRun = () => run( hostDocumentId, report ? 'rescan' : 'run_audit' );
20
+ const onRun = () => run( hostDocumentId );
25
21
  const lastScanLabel = report ? new Date( report.runAt ).toLocaleTimeString() : null;
26
22
 
27
23
  return (
@@ -31,7 +27,6 @@ export default function AuditPanel() {
31
27
  title={ __( 'Page Audit', 'elementor' ) }
32
28
  badge={ __( 'Beta', 'elementor' ) }
33
29
  titleVariant="subtitle2"
34
- onClose={ trackPanelClosed }
35
30
  />
36
31
  <FloatingPanelBody
37
32
  sx={
@@ -5,17 +5,14 @@ import { Button, IconButton, Tooltip } from '@elementor/ui';
5
5
  import { __ } from '@wordpress/i18n';
6
6
 
7
7
  import { ANGIE_FIX_ENTRY_POINT, CREATE_WIDGET_EVENT } from '../constants';
8
- import { type AuditMeta } from '../types';
9
- import { trackFindingClicked } from '../utils/tracking';
10
8
 
11
9
  type Props = {
12
- audit: AuditMeta;
13
10
  prompt: string;
14
11
  panelZIndex: number;
15
12
  variant?: 'icon' | 'button';
16
13
  };
17
14
 
18
- export default function FixViolationWithAngie( { audit, prompt, panelZIndex, variant = 'icon' }: Props ) {
15
+ export default function FixViolationWithAngie( { prompt, panelZIndex, variant = 'icon' }: Props ) {
19
16
  const label = __( 'Fix with Angie', 'elementor' );
20
17
  const href = `#angie-prompt=${ encodeURIComponent( prompt ) }`;
21
18
 
@@ -25,12 +22,6 @@ export default function FixViolationWithAngie( { audit, prompt, panelZIndex, var
25
22
 
26
23
  if ( isAngieAvailable() ) {
27
24
  sendPromptToAngie( prompt );
28
- trackFindingClicked( {
29
- audit,
30
- locationL2: 'issues',
31
- actionType: 'fix_with_angie',
32
- interactionResult: 'angie_prompt_sent',
33
- } );
34
25
  return;
35
26
  }
36
27
 
@@ -5,7 +5,6 @@ import { __ } from '@wordpress/i18n';
5
5
  import { PROMOTIONS } from '../register-promotions';
6
6
  import { type PageAuditReport } from '../types';
7
7
  import { findAuditRun } from '../utils/find-audit-run';
8
- import { trackFixWithApp } from '../utils/tracking';
9
8
  import PromotionCard from './promotion-card';
10
9
 
11
10
  type Props = {
@@ -59,14 +58,8 @@ export default function Promotions( { report }: Props ) {
59
58
  ctaLabel={ config.ctaLabel }
60
59
  ctaDisabled={ ! ctaUrl }
61
60
  onCtaClick={ () => {
62
- if ( ! ctaUrl ) {
63
- return;
64
- }
65
-
66
- window.open( ctaUrl, '_blank', 'noopener' );
67
-
68
- if ( run.result.status === 'fail' ) {
69
- trackFixWithApp( run.audit, run.result.violations[ 0 ], 'overview' );
61
+ if ( ctaUrl ) {
62
+ window.open( ctaUrl, '_blank' );
70
63
  }
71
64
  } }
72
65
  />
@@ -7,22 +7,14 @@ type Props = {
7
7
  externalUrl: string;
8
8
  variant?: 'outlined' | 'text';
9
9
  withIcon?: boolean;
10
- onOpen?: () => void;
11
10
  };
12
11
 
13
- export default function ViolationCtaButton( {
14
- ctaLabel,
15
- externalUrl,
16
- variant = 'outlined',
17
- withIcon = false,
18
- onOpen,
19
- }: Props ) {
12
+ export default function ViolationCtaButton( { ctaLabel, externalUrl, variant = 'outlined', withIcon = false }: Props ) {
20
13
  const handleClick = ( event: React.MouseEvent< HTMLButtonElement > ) => {
21
14
  event.stopPropagation();
22
15
  event.preventDefault();
23
16
 
24
17
  window.open( externalUrl, '_blank', 'noopener' );
25
- onOpen?.();
26
18
  };
27
19
 
28
20
  return (
@@ -11,7 +11,6 @@ import { type AuditMeta, type AuditViolation } from '../types';
11
11
  import { buildAngiePrompt } from '../utils/build-angie-prompt';
12
12
  import { isScoredAudit } from '../utils/is-scored-audit';
13
13
  import { onKeyboardClick } from '../utils/keyboard-click';
14
- import { trackFindingClicked, trackFixWithApp } from '../utils/tracking';
15
14
  import FixViolationWithAngie from './fix-violation-with-angie';
16
15
  import SeverityIcon from './severity-icons';
17
16
  import ViolationCtaButton from './violation-cta-button';
@@ -53,12 +52,10 @@ function StatusIndicator( { audit, violations }: Pick< Props, 'audit' | 'violati
53
52
  }
54
53
 
55
54
  function GuidanceAction( {
56
- audit,
57
55
  violation,
58
56
  sharedAngiePrompt,
59
57
  panelZIndex,
60
58
  }: {
61
- audit: AuditMeta;
62
59
  violation: AuditViolation;
63
60
  sharedAngiePrompt?: string;
64
61
  panelZIndex: number;
@@ -76,7 +73,6 @@ function GuidanceAction( {
76
73
  ctaLabel={ violation.ctaLabel as string }
77
74
  externalUrl={ violation.externalUrl as string }
78
75
  withIcon
79
- onOpen={ () => trackFixWithApp( audit, violation, 'issues' ) }
80
76
  />
81
77
  ) }
82
78
  { hasPrimaryCta && violation.secondaryCtaLabel && violation.secondaryCtaUrl && (
@@ -87,12 +83,7 @@ function GuidanceAction( {
87
83
  />
88
84
  ) }
89
85
  { sharedAngiePrompt && (
90
- <FixViolationWithAngie
91
- audit={ audit }
92
- prompt={ sharedAngiePrompt }
93
- panelZIndex={ panelZIndex }
94
- variant="button"
95
- />
86
+ <FixViolationWithAngie prompt={ sharedAngiePrompt } panelZIndex={ panelZIndex } variant="button" />
96
87
  ) }
97
88
  </Box>
98
89
  );
@@ -122,22 +113,9 @@ export default function ViolationRow( { audit, expanded, onToggleExpand, skipRea
122
113
  const panelZIndex = useFloatingPanelZIndex( AUDIT_PANEL_ID );
123
114
  const sharedAngiePrompt = getSharedAngiePrompt( violations );
124
115
 
125
- const viewIssue = ( violation: AuditViolation ) => {
126
- const interactionResult = focusViolation( violation );
127
-
128
- if ( interactionResult ) {
129
- trackFindingClicked( {
130
- audit,
131
- locationL2: 'issues',
132
- actionType: 'view_issue',
133
- interactionResult,
134
- } );
135
- }
136
- };
137
-
138
116
  const handleGuidanceClick = () => {
139
117
  if ( isGuidanceFocusable && primaryViolation ) {
140
- viewIssue( primaryViolation );
118
+ focusViolation( primaryViolation );
141
119
  }
142
120
  };
143
121
 
@@ -192,7 +170,6 @@ export default function ViolationRow( { audit, expanded, onToggleExpand, skipRea
192
170
  </Typography>
193
171
  { primaryViolation && (
194
172
  <GuidanceAction
195
- audit={ audit }
196
173
  violation={ primaryViolation }
197
174
  sharedAngiePrompt={ sharedAngiePrompt }
198
175
  panelZIndex={ panelZIndex }
@@ -217,8 +194,8 @@ export default function ViolationRow( { audit, expanded, onToggleExpand, skipRea
217
194
  key={ idx }
218
195
  role="button"
219
196
  tabIndex={ 0 }
220
- onClick={ () => viewIssue( violation ) }
221
- onKeyDown={ onKeyboardClick( () => viewIssue( violation ) ) }
197
+ onClick={ () => focusViolation( violation ) }
198
+ onKeyDown={ onKeyboardClick( () => focusViolation( violation ) ) }
222
199
  sx={ {
223
200
  display: 'flex',
224
201
  alignItems: 'center',
@@ -249,7 +226,6 @@ export default function ViolationRow( { audit, expanded, onToggleExpand, skipRea
249
226
  sx={ { opacity: 0, transition: 'opacity .15s' } }
250
227
  >
251
228
  <FixViolationWithAngie
252
- audit={ audit }
253
229
  prompt={
254
230
  violation.angiePrompt ?? buildAngiePrompt( angiePromptContext )
255
231
  }
package/src/constants.ts CHANGED
@@ -18,19 +18,6 @@ export const FEEDBACK_SENT_EVENT = 'audit_feedback_sent';
18
18
  export const FEEDBACK_CANCELLED_EVENT = 'audit_feedback_cancelled';
19
19
  export const FEEDBACK_CLOSED_EVENT = 'audit_feedback_closed';
20
20
 
21
- export const PANEL_VIEWED_EVENT = 'page_audit_panel_viewed';
22
- export const PANEL_CLOSED_EVENT = 'page_audit_panel_closed';
23
- export const RUN_STARTED_EVENT = 'page_audit_run_started';
24
- export const RUN_COMPLETED_EVENT = 'page_audit_run_completed';
25
- export const FINDING_CLICKED_EVENT = 'page_audit_finding_clicked';
26
-
27
- export const TRACKING_WINDOW_NAME = 'page_audit';
28
- export const TRACKING_TARGET_LOCATION = 'panel';
29
- export const TRACKING_LOCATION_L1 = 'audit_panel';
30
-
31
- export const FIRST_OPEN_MESSAGE_KEY = 'page-audit-panel-opened';
32
- export const AUDIT_ID_PREFIX = 'audits/';
33
-
34
21
  export const ALL_CATEGORIES: AuditCategory[] = [
35
22
  'best-practices',
36
23
  'seo',
@@ -2,11 +2,10 @@ import { getContainer, selectElement } from '@elementor/editor-elements';
2
2
  import { __privateOpenRoute as openRoute, __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
3
3
 
4
4
  import { type AuditViolation } from '../types';
5
- import { type ViewIssueResult } from '../utils/tracking';
6
5
 
7
6
  const SCROLL_TO_VIEW_DELAY_MS = 200;
8
7
 
9
- export function focusViolation( violation: AuditViolation ): ViewIssueResult | null {
8
+ export function focusViolation( violation: AuditViolation ): void {
10
9
  if ( violation.elementId ) {
11
10
  const container = getContainer( violation.elementId );
12
11
 
@@ -28,30 +27,27 @@ export function focusViolation( violation: AuditViolation ): ViewIssueResult | n
28
27
  runCommand( 'panel/editor/open' );
29
28
  }
30
29
 
31
- return container ? 'element_focused' : null;
30
+ return;
32
31
  }
33
32
 
34
33
  if ( violation.externalUrl ) {
35
34
  window.open( violation.externalUrl, '_blank' );
36
- return 'external_url_opened';
35
+ return;
37
36
  }
38
37
 
39
38
  if ( violation.targetHint === 'page-settings' ) {
40
39
  openRoute( 'panel/page-settings/settings' );
41
- return 'page_settings_opened';
40
+ return;
42
41
  }
43
42
 
44
43
  if ( violation.targetHint === 'site-settings' ) {
45
44
  runCommand( 'panel/global/open' );
46
- return 'site_settings_opened';
45
+ return;
47
46
  }
48
47
 
49
48
  if ( violation.targetHint === 'site-identity-settings' ) {
50
49
  void runCommand( 'panel/global/open' ).then( () => {
51
50
  openRoute( 'panel/global/settings-site-identity' );
52
51
  } );
53
- return 'site_settings_opened';
54
52
  }
55
-
56
- return null;
57
53
  }
@@ -6,7 +6,6 @@ import { runPageAudit } from '../runner';
6
6
  import { type GlobalState, selectError, selectIsStale, selectReport, selectStatus, slice } from '../store';
7
7
  import { getPersistedReport, persistReport } from '../utils/report-storage';
8
8
  import { SessionExpiredError } from '../utils/session-expiration';
9
- import { type RunTrigger, trackRunCompleted, trackRunFailed, trackRunStarted } from '../utils/tracking';
10
9
 
11
10
  export function useAuditReport() {
12
11
  const status = useSelector( ( state: GlobalState ) => selectStatus( state ) );
@@ -30,24 +29,20 @@ export function useAuditReport() {
30
29
  }
31
30
  }, [ documentId, report, dispatch ] );
32
31
 
33
- const run = async ( documentIdToRun: number, trigger: RunTrigger ) => {
32
+ const run = async ( documentIdToRun: number ) => {
34
33
  dispatch( slice.actions.runStarted() );
35
- trackRunStarted( trigger );
36
34
 
37
35
  try {
38
36
  const nextReport = await runPageAudit( documentIdToRun );
39
37
  dispatch( slice.actions.runSucceeded( nextReport ) );
40
38
  persistReport( documentIdToRun, nextReport );
41
- trackRunCompleted( nextReport );
42
39
  } catch ( e ) {
43
40
  if ( e instanceof SessionExpiredError ) {
44
41
  dispatch( slice.actions.runAborted() );
45
- trackRunFailed();
46
42
  return;
47
43
  }
48
44
 
49
45
  dispatch( slice.actions.runFailed( e instanceof Error ? e.message : 'Unknown error' ) );
50
- trackRunFailed();
51
46
  }
52
47
  };
53
48
 
package/src/types.ts CHANGED
@@ -43,7 +43,6 @@ export type AuditViolation = {
43
43
  ctaLabel?: string;
44
44
  secondaryCtaLabel?: string;
45
45
  secondaryCtaUrl?: string;
46
- appInstalled?: boolean;
47
46
  };
48
47
 
49
48
  export type PageContextResponse = {
@@ -1,31 +0,0 @@
1
- import { useEffect, useRef, useState } from 'react';
2
- import { useCurrentUser, useSuppressedMessage } from '@elementor/editor-current-user';
3
- import { getHostDocumentId } from '@elementor/editor-elements';
4
- import { __useSelector as useSelector } from '@elementor/store';
5
-
6
- import { FIRST_OPEN_MESSAGE_KEY } from '../constants';
7
- import { type GlobalState, selectReport } from '../store';
8
- import { getPersistedReport } from '../utils/report-storage';
9
- import { trackPanelViewed } from '../utils/tracking';
10
-
11
- export function useTrackPanelViewed() {
12
- const { data: currentUser } = useCurrentUser();
13
- const [ isFirstOpenMessageSuppressed, suppressFirstOpenMessage ] = useSuppressedMessage( FIRST_OPEN_MESSAGE_KEY );
14
- const report = useSelector( ( state: GlobalState ) => selectReport( state ) );
15
- const [ hasPriorReport ] = useState( () => {
16
- const documentId = getHostDocumentId() ?? 0;
17
-
18
- return Boolean( report ) || Boolean( documentId && getPersistedReport( documentId ) );
19
- } );
20
- const hasTracked = useRef( false );
21
-
22
- useEffect( () => {
23
- if ( ! currentUser || hasTracked.current ) {
24
- return;
25
- }
26
-
27
- hasTracked.current = true;
28
- trackPanelViewed( { hasPriorReport, isFirstOpen: ! isFirstOpenMessageSuppressed } );
29
- suppressFirstOpenMessage();
30
- }, [ currentUser, hasPriorReport, isFirstOpenMessageSuppressed, suppressFirstOpenMessage ] );
31
- }
@@ -1,45 +0,0 @@
1
- import { type PageAuditReport } from '../types';
2
- import { isScoredAudit } from './is-scored-audit';
3
- import { toCheckName, toTrackingSeverity, type TrackingSeverity } from './tracking-names';
4
-
5
- type RequiredFix = {
6
- check: string;
7
- severity: TrackingSeverity;
8
- };
9
-
10
- export type RunSummary = {
11
- state: TrackingSeverity | 'success';
12
- metadata: {
13
- score: number;
14
- fix_count: number;
15
- error_count: number;
16
- warning_count: number;
17
- suggestion_count: number;
18
- required_fixes: RequiredFix[];
19
- };
20
- };
21
-
22
- const SEVERITY_PRIORITY: TrackingSeverity[] = [ 'error', 'warning', 'suggestion' ];
23
-
24
- export function buildRunSummary( report: PageAuditReport ): RunSummary {
25
- const requiredFixes: RequiredFix[] = report.auditResults
26
- .filter( ( { audit, result } ) => result.status === 'fail' && isScoredAudit( audit ) )
27
- .map( ( { audit } ) => ( { check: toCheckName( audit.id ), severity: toTrackingSeverity( audit.severity ) } ) );
28
-
29
- const countBySeverity = ( severity: TrackingSeverity ) =>
30
- requiredFixes.filter( ( fix ) => fix.severity === severity ).length;
31
-
32
- const highestSeverity = SEVERITY_PRIORITY.find( ( severity ) => countBySeverity( severity ) > 0 );
33
-
34
- return {
35
- state: highestSeverity ?? 'success',
36
- metadata: {
37
- score: report.overall,
38
- fix_count: requiredFixes.length,
39
- error_count: countBySeverity( 'error' ),
40
- warning_count: countBySeverity( 'warning' ),
41
- suggestion_count: countBySeverity( 'suggestion' ),
42
- required_fixes: requiredFixes,
43
- },
44
- };
45
- }
@@ -1,12 +0,0 @@
1
- import { AUDIT_ID_PREFIX } from '../constants';
2
- import { type AuditSeverity } from '../types';
3
-
4
- export type TrackingSeverity = 'error' | 'warning' | 'suggestion';
5
-
6
- export function toTrackingSeverity( severity: AuditSeverity ): TrackingSeverity {
7
- return severity === 'info' ? 'suggestion' : severity;
8
- }
9
-
10
- export function toCheckName( auditId: string ): string {
11
- return auditId.replace( AUDIT_ID_PREFIX, '' ).replace( /-/g, '_' );
12
- }
@@ -1,130 +0,0 @@
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
- };