@elementor/editor-variables 4.1.0-720 → 4.1.0-721

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-variables",
3
- "version": "4.1.0-720",
3
+ "version": "4.1.0-721",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,22 +39,22 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.1.0-720",
43
- "@elementor/editor-canvas": "4.1.0-720",
44
- "@elementor/editor-controls": "4.1.0-720",
45
- "@elementor/editor-current-user": "4.1.0-720",
46
- "@elementor/editor-mcp": "4.1.0-720",
47
- "@elementor/editor-panels": "4.1.0-720",
48
- "@elementor/editor-props": "4.1.0-720",
49
- "@elementor/editor-ui": "4.1.0-720",
50
- "@elementor/editor-v1-adapters": "4.1.0-720",
51
- "@elementor/menus": "4.1.0-720",
52
- "@elementor/http-client": "4.1.0-720",
42
+ "@elementor/editor": "4.1.0-721",
43
+ "@elementor/editor-canvas": "4.1.0-721",
44
+ "@elementor/editor-controls": "4.1.0-721",
45
+ "@elementor/editor-current-user": "4.1.0-721",
46
+ "@elementor/editor-mcp": "4.1.0-721",
47
+ "@elementor/editor-panels": "4.1.0-721",
48
+ "@elementor/editor-props": "4.1.0-721",
49
+ "@elementor/editor-ui": "4.1.0-721",
50
+ "@elementor/editor-v1-adapters": "4.1.0-721",
51
+ "@elementor/menus": "4.1.0-721",
52
+ "@elementor/http-client": "4.1.0-721",
53
53
  "@elementor/icons": "^1.72.0",
54
- "@elementor/events": "4.1.0-720",
55
- "@elementor/schema": "4.1.0-720",
54
+ "@elementor/events": "4.1.0-721",
55
+ "@elementor/schema": "4.1.0-721",
56
56
  "@elementor/ui": "1.37.2",
57
- "@elementor/utils": "4.1.0-720",
57
+ "@elementor/utils": "4.1.0-721",
58
58
  "@wordpress/i18n": "^5.13.0"
59
59
  },
60
60
  "peerDependencies": {
@@ -25,7 +25,7 @@ import {
25
25
  } from '@elementor/ui';
26
26
  import { __ } from '@wordpress/i18n';
27
27
 
28
- import { trackVariablesManagerEvent } from '../../utils/tracking';
28
+ import { trackVariablesManagerEvent, trackVariableSyncToV3 } from '../../utils/tracking';
29
29
  import { type ErrorResponse, type MappedError, mapServerError } from '../../utils/validations';
30
30
  import { getMenuActionsForVariable, getVariableType } from '../../variables-registry/variable-type-registry';
31
31
  import { DeleteConfirmationDialog } from '../ui/delete-confirmation-dialog';
@@ -76,8 +76,8 @@ export function VariablesManagerPanel() {
76
76
  handleOnChange,
77
77
  createVariable,
78
78
  handleDeleteVariable,
79
- handleStartSync,
80
- handleStopSync,
79
+ handleStartSync: startSyncFromState,
80
+ handleStopSync: stopSyncFromState,
81
81
  handleSave,
82
82
  isSaving,
83
83
  handleSearch,
@@ -151,23 +151,37 @@ export function VariablesManagerPanel() {
151
151
  [ handleDeleteVariable ]
152
152
  );
153
153
 
154
- const handleStopSyncWithConfirmation = useCallback(
154
+ const commitStopSync = useCallback(
155
155
  ( itemId: string ) => {
156
- handleStopSync( itemId );
157
- setStopSyncConfirmation( null );
156
+ stopSyncFromState( itemId );
157
+ const variable = variables[ itemId ];
158
+ if ( variable ) {
159
+ trackVariableSyncToV3( { variableLabel: variable.label, action: 'unsync' } );
160
+ }
158
161
  },
159
- [ handleStopSync ]
162
+ [ stopSyncFromState, variables ]
160
163
  );
161
164
 
162
- const handleShowStopSyncDialog = useCallback(
165
+ const handleStartSync = useCallback(
166
+ ( itemId: string ) => {
167
+ startSyncFromState( itemId );
168
+ const variable = variables[ itemId ];
169
+ if ( variable ) {
170
+ trackVariableSyncToV3( { variableLabel: variable.label, action: 'sync' } );
171
+ }
172
+ },
173
+ [ startSyncFromState, variables ]
174
+ );
175
+
176
+ const handleStopSync = useCallback(
163
177
  ( itemId: string ) => {
164
178
  if ( ! isStopSyncSuppressed ) {
165
179
  setStopSyncConfirmation( itemId );
166
180
  } else {
167
- handleStopSync( itemId );
181
+ commitStopSync( itemId );
168
182
  }
169
183
  },
170
- [ isStopSyncSuppressed, handleStopSync ]
184
+ [ isStopSyncSuppressed, commitStopSync ]
171
185
  );
172
186
 
173
187
  const buildMenuActions = useCallback(
@@ -182,7 +196,7 @@ export function VariablesManagerPanel() {
182
196
  variableId,
183
197
  handlers: {
184
198
  onStartSync: handleStartSync,
185
- onStopSync: handleShowStopSyncDialog,
199
+ onStopSync: handleStopSync,
186
200
  },
187
201
  } );
188
202
 
@@ -203,7 +217,7 @@ export function VariablesManagerPanel() {
203
217
 
204
218
  return [ ...typeActions, deleteAction ];
205
219
  },
206
- [ variables, handleStartSync, handleShowStopSyncDialog ]
220
+ [ variables, handleStartSync, handleStopSync ]
207
221
  );
208
222
 
209
223
  const hasVariables = Object.keys( variables ).length > 0;
@@ -368,7 +382,10 @@ export function VariablesManagerPanel() {
368
382
  <StopSyncConfirmationDialog
369
383
  open
370
384
  onClose={ () => setStopSyncConfirmation( null ) }
371
- onConfirm={ () => handleStopSyncWithConfirmation( stopSyncConfirmation ) }
385
+ onConfirm={ () => {
386
+ commitStopSync( stopSyncConfirmation );
387
+ setStopSyncConfirmation( null );
388
+ } }
372
389
  />
373
390
  ) }
374
391
 
@@ -52,3 +52,32 @@ export const trackVariablesManagerEvent = ( { action, varType, controlPath }: Va
52
52
 
53
53
  dispatchEvent?.( name, eventData );
54
54
  };
55
+
56
+ type VariableSyncToV3Data = {
57
+ variableLabel: string;
58
+ action: 'sync' | 'unsync';
59
+ };
60
+
61
+ export const trackVariableSyncToV3 = ( { variableLabel, action }: VariableSyncToV3Data ) => {
62
+ try {
63
+ const { dispatchEvent, config } = getMixpanel();
64
+ if ( ! config?.names?.variables?.variableSyncToV3 ) {
65
+ return;
66
+ }
67
+
68
+ const name = config.names.variables.variableSyncToV3;
69
+ const isSync = action === 'sync';
70
+
71
+ dispatchEvent?.( name, {
72
+ interaction_type: 'click',
73
+ target_type: variableLabel,
74
+ target_name: isSync ? 'sync_to_v3' : 'unsync_to_v3',
75
+ interaction_result: isSync ? 'var_is_synced_to_V3' : 'var_is_unsynced_from_V3',
76
+ target_location: 'widget_panel',
77
+ location_l1: 'var_manager',
78
+ interaction_description: isSync
79
+ ? `user_synced_${ variableLabel }_to_v3`
80
+ : `user_unsync_${ variableLabel }_from_v3`,
81
+ } );
82
+ } catch {}
83
+ };