@elementor/editor-interactions 4.0.0-678 → 4.0.0-679

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-interactions",
3
- "version": "4.0.0-678",
3
+ "version": "4.0.0-679",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,18 +39,19 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor-controls": "4.0.0-678",
43
- "@elementor/editor-elements": "4.0.0-678",
44
- "@elementor/editor-mcp": "4.0.0-678",
45
- "@elementor/editor-props": "4.0.0-678",
46
- "@elementor/editor-responsive": "4.0.0-678",
47
- "@elementor/editor-ui": "4.0.0-678",
48
- "@elementor/editor-v1-adapters": "4.0.0-678",
42
+ "@elementor/editor-controls": "4.0.0-679",
43
+ "@elementor/editor-elements": "4.0.0-679",
44
+ "@elementor/editor-mcp": "4.0.0-679",
45
+ "@elementor/editor-props": "4.0.0-679",
46
+ "@elementor/editor-responsive": "4.0.0-679",
47
+ "@elementor/editor-ui": "4.0.0-679",
48
+ "@elementor/editor-v1-adapters": "4.0.0-679",
49
49
  "@elementor/icons": "^1.68.0",
50
- "@elementor/schema": "4.0.0-678",
51
- "@elementor/session": "4.0.0-678",
50
+ "@elementor/schema": "4.0.0-679",
51
+ "@elementor/session": "4.0.0-679",
52
52
  "@elementor/ui": "1.36.17",
53
- "@elementor/utils": "4.0.0-678",
53
+ "@elementor/utils": "4.0.0-679",
54
+ "@elementor/events": "4.0.0-679",
54
55
  "@wordpress/i18n": "^5.13.0"
55
56
  },
56
57
  "peerDependencies": {
@@ -1,13 +1,15 @@
1
1
  import * as React from 'react';
2
2
  import { useCallback, useEffect, useMemo, useRef } from 'react';
3
- import { Repeater } from '@elementor/editor-controls';
3
+ import { Repeater, type SetRepeaterValuesMeta } from '@elementor/editor-controls';
4
4
  import { InfoCircleFilledIcon, PlayerPlayIcon } from '@elementor/icons';
5
5
  import { Alert, AlertTitle, Box, IconButton, Tooltip } from '@elementor/ui';
6
6
  import { __ } from '@wordpress/i18n';
7
7
 
8
+ import { useInteractionsContext } from '../contexts/interactions-context';
8
9
  import { InteractionItemContextProvider } from '../contexts/interactions-item-context';
9
10
  import type { ElementInteractions, InteractionItemPropValue, InteractionItemValue } from '../types';
10
11
  import { buildDisplayLabel, createDefaultInteractionItem, extractString } from '../utils/prop-value-utils';
12
+ import { trackInteractionCreated } from '../utils/tracking';
11
13
  import { InteractionsListItem } from './interactions-list-item';
12
14
  export const MAX_NUMBER_OF_INTERACTIONS = 5;
13
15
 
@@ -20,6 +22,7 @@ export type InteractionListProps = {
20
22
 
21
23
  export function InteractionsList( props: InteractionListProps ) {
22
24
  const { interactions, onSelectInteractions, onPlayInteraction, triggerCreateOnShowEmpty } = props;
25
+ const { elementId } = useInteractionsContext();
23
26
 
24
27
  const hasInitializedRef = useRef( false );
25
28
 
@@ -62,13 +65,23 @@ export function InteractionsList( props: InteractionListProps ) {
62
65
  ) : undefined;
63
66
 
64
67
  const handleRepeaterChange = useCallback(
65
- ( newItems: ElementInteractions[ 'items' ] ) => {
68
+ (
69
+ newItems: ElementInteractions[ 'items' ],
70
+ _: unknown,
71
+ meta?: SetRepeaterValuesMeta< InteractionItemPropValue >
72
+ ) => {
66
73
  handleUpdateInteractions( {
67
74
  ...interactions,
68
75
  items: newItems,
69
76
  } );
77
+ if ( meta?.action?.type === 'add' ) {
78
+ const addedItem = meta.action.payload[ 0 ]?.item;
79
+ if ( addedItem ) {
80
+ trackInteractionCreated( elementId, addedItem );
81
+ }
82
+ }
70
83
  },
71
- [ interactions, handleUpdateInteractions ]
84
+ [ interactions, handleUpdateInteractions, elementId ]
72
85
  );
73
86
 
74
87
  const handleInteractionChange = useCallback(
@@ -7,6 +7,8 @@ import { InteractionsProvider, useInteractionsContext } from '../contexts/intera
7
7
  import { PopupStateProvider } from '../contexts/popup-state-context';
8
8
  import { useElementInteractions } from '../hooks/use-element-interactions';
9
9
  import type { ElementInteractions } from '../types';
10
+ import { createDefaultInteractionItem } from '../utils/prop-value-utils';
11
+ import { trackInteractionCreated } from '../utils/tracking';
10
12
  import { EmptyState } from './empty-state';
11
13
  import { InteractionsList } from './interactions-list';
12
14
 
@@ -33,6 +35,7 @@ function InteractionsTabContent( { elementId }: { elementId: string } ) {
33
35
  <EmptyState
34
36
  onCreateInteraction={ () => {
35
37
  firstInteractionState[ 1 ]( true );
38
+ trackInteractionCreated( elementId, createDefaultInteractionItem() );
36
39
  } }
37
40
  />
38
41
  ) }
@@ -9,6 +9,7 @@ import {
9
9
  import { useElementInteractions } from '../hooks/use-element-interactions';
10
10
 
11
11
  type InteractionsContextValue = {
12
+ elementId: string;
12
13
  interactions: ElementInteractions;
13
14
  setInteractions: ( value: ElementInteractions | undefined ) => void;
14
15
  playInteractions: ( interactionId: string ) => void;
@@ -45,6 +46,7 @@ export const InteractionsProvider = ( { children, elementId }: { children: React
45
46
  };
46
47
 
47
48
  const contextValue: InteractionsContextValue = {
49
+ elementId,
48
50
  interactions,
49
51
  setInteractions,
50
52
  playInteractions,
@@ -0,0 +1,42 @@
1
+ import { getElementLabel } from '@elementor/editor-elements';
2
+ import { getMixpanel } from '@elementor/events';
3
+
4
+ import type { InteractionItemPropValue } from '../types';
5
+ import { extractString } from './prop-value-utils';
6
+
7
+ const TRIGGER_LABELS: Record< string, string > = {
8
+ load: 'On page load',
9
+ scrollIn: 'Scroll into view',
10
+ scrollOut: 'Scroll out of view',
11
+ scrollOn: 'While scrolling',
12
+ hover: 'Hover',
13
+ click: 'Click',
14
+ };
15
+
16
+ const capitalize = ( s: string ) => s.charAt( 0 ).toUpperCase() + s.slice( 1 );
17
+
18
+ export const trackInteractionCreated = ( elementId: string, item: InteractionItemPropValue ) => {
19
+ const { dispatchEvent, config } = getMixpanel();
20
+ if ( ! config?.names?.interactions?.created ) {
21
+ return;
22
+ }
23
+
24
+ const trigger = extractString( item.value.trigger );
25
+ const effect = extractString( item.value.animation.value.effect );
26
+ const type = extractString( item.value.animation.value.type );
27
+
28
+ dispatchEvent?.( config.names.interactions.created, {
29
+ app_type: config?.appTypes?.editor,
30
+ window_name: config?.appTypes?.editor,
31
+ interaction_type: config?.triggers?.click,
32
+ target_name: getElementLabel( elementId ),
33
+ interaction_result: 'interaction_created',
34
+ target_location: config?.locations?.widgetPanel,
35
+ location_l1: getElementLabel( elementId ),
36
+ location_l2: 'interactions',
37
+ interaction_description: 'interaction_created',
38
+ interaction_trigger: TRIGGER_LABELS[ trigger ] ?? capitalize( trigger ),
39
+ interaction_effect:
40
+ effect === 'custom' ? capitalize( effect ) : `${ capitalize( effect ) } ${ capitalize( type ) }`,
41
+ } );
42
+ };