PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.0-dev2
Elementor Website Builder – more than just a page builder v3.35.0-dev2
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | core/common/modules/events-manager/module.php +18 -90 4.3.0-beta33.35.0-dev2 View file →
@@ -3,12 +3,9 @@
3 3 namespace Elementor\Core\Common\Modules\EventsManager;
4 4
5 5 use Elementor\Core\Base\Module as BaseModule;
6 6 use Elementor\Core\Common\Modules\Connect\Apps\Base_App;
7 -use Elementor\Core\Common\Modules\Connect\Apps\Common_App;
8 -use Elementor\Core\Common\Modules\EventsManager\RestApi\Events_Proxy_REST_API;
9 7 use Elementor\Core\Experiments\Manager as Experiments_Manager;
10 -use Elementor\Includes\EditorAssetsAPI;
11 8 use Elementor\Utils;
12 9 use Elementor\Plugin;
13 10 use Elementor\Tracker;
14 11
@@ -18,46 +15,27 @@
18 15
19 16 class Module extends BaseModule {
20 17
21 18 const EXPERIMENT_NAME = 'editor_events';
22 - const DEFAULT_SESSION_RECORDING_PERCENT = 0;
19 +
23 20 const REMOTE_MIXPANEL_CONFIG_URL = 'https://assets.elementor.com/mixpanel/v1/mixpanel.json';
24 21
25 - const API_UPSTREAM_HOST = 'https://api-eu.mixpanel.com';
26 - const LIBS_UPSTREAM_HOST = 'https://cdn.mxpnl.com/libs';
27 -
28 - public function __construct() {
29 - parent::__construct();
30 -
31 - ( new Events_Proxy_REST_API() )->register_hooks();
32 - }
33 -
34 22 public function get_name() {
35 23 return 'events-manager';
36 24 }
37 25
38 26 public static function get_editor_events_config() {
39 - $can_send_events = self::can_send_events();
27 + $can_send_events = ! empty( ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN ) &&
28 + Tracker::is_allow_track() &&
29 + ! Tracker::has_terms_changed( '2025-07-07' ) &&
30 + Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME );
40 31
41 - $is_flags_enabled = false;
42 - $session_recording_percent = self::DEFAULT_SESSION_RECORDING_PERCENT;
43 - $debug = ( defined( 'ELEMENTOR_EDITOR_EVENTS_DEBUG' ) && ELEMENTOR_EDITOR_EVENTS_DEBUG ) ?? false;
32 + $mixpanel_config = self::get_remote_mixpanel_config();
33 + $session_replays = $mixpanel_config[0]['sessionReplays'] ?? [];
34 + $is_flags_enabled = $mixpanel_config[0]['flags'] ?? false;
44 35
45 - if ( $can_send_events ) {
46 - $mixpanel_config = self::get_remote_mixpanel_config();
47 - $has_config = EditorAssetsAPI::has_valid_nested_array( $mixpanel_config, [ 0 ] );
48 -
49 - if ( $has_config ) {
50 - $is_flags_enabled = (bool) ( $mixpanel_config[0]['flags'] ?? false );
51 -
52 - $session_replays = $mixpanel_config[0]['sessionReplays'] ?? [];
53 - $session_recording_percent = $session_replays['recordSessionsPercent'] ?? null;
54 - }
55 - }
56 -
57 36 $settings = [
58 37 'can_send_events' => $can_send_events,
59 - 'debug' => $debug,
60 38 'elementor_version' => ELEMENTOR_VERSION,
61 39 'site_url' => hash( 'sha256', get_site_url() ),
62 40 'wp_version' => get_bloginfo( 'version' ),
63 41 'user_agent' => esc_html( Utils::get_super_global_value( $_SERVER, 'HTTP_USER_AGENT' ) ),
@@ -65,43 +43,16 @@
65 43 'site_key' => get_option( Base_App::OPTION_CONNECT_SITE_KEY ),
66 44 'subscription_id' => self::get_subscription_id(),
67 45 'subscription' => self::get_subscription(),
68 46 'token' => ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN,
69 - 'proxy_api_host' => rest_url( Events_Proxy_REST_API::API_NAMESPACE . '/' . Events_Proxy_REST_API::API_BASE . '/api' ),
70 - 'proxy_lib_base_path' => rest_url( Events_Proxy_REST_API::API_NAMESPACE . '/' . Events_Proxy_REST_API::API_BASE . '/libs/' ),
47 + 'session_replays' => $session_replays,
71 48 'flags_enabled' => $is_flags_enabled,
72 - 'user_id' => self::get_user_id(),
73 - 'session_recording_percent' => $session_recording_percent,
49 + 'isEditorOneActive' => Plugin::$instance->experiments->is_feature_active( 'e_editor_one' ),
74 50 ];
75 51
76 52 return $settings;
77 53 }
78 54
79 - public static function dispatch_event( string $event_name, array $properties = [] ): void {
80 - if ( ! self::can_send_events() ) {
81 - return;
82 - }
83 -
84 - try {
85 - $user_id = self::get_user_id();
86 -
87 - $context = [
88 - 'user_id' => $user_id,
89 - 'distinct_id' => $user_id,
90 - 'subscription_id' => self::get_subscription_id(),
91 - 'site_key' => get_option( Base_App::OPTION_CONNECT_SITE_KEY ),
92 - 'app_version' => ELEMENTOR_VERSION,
93 - 'wp_version' => get_bloginfo( 'version' ),
94 - 'site_language' => get_locale(),
95 - 'source' => 'server',
96 - ];
97 -
98 - Server_Events_Client::track( $event_name, array_merge( $properties, $context ) );
99 - } catch ( \Throwable $e ) {
100 - return;
101 - }
102 - }
103 -
104 55 public static function get_experimental_data(): array {
105 56 return [
106 57 'name' => static::EXPERIMENT_NAME,
107 58 'title' => esc_html__( 'Elementor Editor Events', 'elementor' ),
@@ -115,15 +66,8 @@
115 66 ],
116 67 ];
117 68 }
118 69
119 - private static function can_send_events(): bool {
120 - return ! empty( ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN ) &&
121 - Tracker::is_allow_track() &&
122 - ! Tracker::has_terms_changed() &&
123 - Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME );
124 - }
125 -
126 70 private static function get_subscription_id() {
127 71 $subscription = self::get_subscription();
128 72
129 73 return $subscription['subscription_id'] ?? null;
@@ -142,35 +86,19 @@
142 86 return json_decode( $license_data['value'], true );
143 87 }
144 88
145 89 private static function get_remote_mixpanel_config() {
146 - $editor_assets_api = new EditorAssetsAPI( [
147 - EditorAssetsAPI::ASSETS_DATA_URL => static::REMOTE_MIXPANEL_CONFIG_URL,
148 - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_mixpanel_config',
149 - EditorAssetsAPI::ASSETS_DATA_KEY => 'mixpanel',
150 - ] );
90 + $data = wp_remote_get( static::REMOTE_MIXPANEL_CONFIG_URL );
151 91
152 - return $editor_assets_api->get_assets_data();
153 - }
92 + if ( is_wp_error( $data ) ) {
93 + return [];
94 + }
154 95
155 - public static function get_mixpanel_api_host() {
156 - $mixpanel_config = self::get_remote_mixpanel_config();
96 + $data = json_decode( wp_remote_retrieve_body( $data ), true );
157 97
158 - return wp_http_validate_url( $mixpanel_config[0]['apiHost'] ?? static::API_UPSTREAM_HOST );
159 - }
160 -
161 - public static function get_mixpanel_lib_host() {
162 - $mixpanel_config = self::get_remote_mixpanel_config();
163 -
164 - return wp_http_validate_url( $mixpanel_config[0]['libHost'] ?? static::LIBS_UPSTREAM_HOST );
165 - }
166 -
167 - private static function get_user_id() {
168 - $user_common_data = get_user_option( Common_App::OPTION_CONNECT_COMMON_DATA_KEY );
169 -
170 - if ( ! is_array( $user_common_data ) ) {
171 - return null;
98 + if ( empty( $data['mixpanel'] ) || ! is_array( $data['mixpanel'] ) ) {
99 + return [];
172 100 }
173 101
174 - return Common_App::get_connect_user_id_from_access_token( $user_common_data['access_token'] ?? null );
102 + return $data['mixpanel'];
175 103 }
176 104 }