PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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
elementor / core / common / modules / events-manager / server-events-client.php

server-events-client.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at core/common/modules/events-manager/server-events-client.php

39 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Common\Modules\EventsManager;
4
5 use ElementorDeps\Mixpanel;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 class Server_Events_Client {
12
13 public static function track( string $event_name, array $properties = [] ): bool {
14 // The SDK is bundled via php-scoper (see php-scoper/mixpanel-inc.php), so this is only
15 // a defensive guard in case the prefixed dependency is ever missing from the build.
16 if ( ! class_exists( Mixpanel::class ) ) {
17 return false;
18 }
19
20 try {
21 // The SDK's own instance getter is itself a singleton keyed by token - it returns the
22 // existing instance or creates a new one if it doesn't exist yet.
23 $client = Mixpanel::getInstance( ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN, [
24 'host' => Module::get_mixpanel_api_host(),
25 'consumer' => 'wp',
26 'consumers' => [
27 'wp' => Wp_Http_Consumer::class,
28 ],
29 ] );
30
31 $client->track( $event_name, $properties );
32
33 return true;
34 } catch ( \Throwable $e ) {
35 return false;
36 }
37 }
38 }
39