HEX
Server: Apache
System: Linux efa57bbe-abb1-400d-2985-3b056fbc2701.secureserver.net 6.1.147-1.el9.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jul 24 12:33:32 EDT 2025 x86_64
User: root (0)
PHP: 8.0.30.4
Disabled: NONE
Upload Files
File: //var/www/wp-content/mu-plugins/vendor/wptool/wp-admin-dash/src/adminDash/clients/ga/GAClient.php
<?php

namespace Wptool\adminDash\clients\ga;

use Wptool\adminDash\utils\Configuration;

class GAClient {

	/** @var string  */
	private $url;

	/** @var string  */
	private $measurement_id;

	/** @var string */
	private $api_secret;

	public function __construct() {

		$this->url            = Configuration::get( 'ga.url' );
		$this->measurement_id = Configuration::get( 'ga.measurement_id' );
		$this->api_secret     = Configuration::get( 'ga.api_secret' );
	}

	/**
	 * Sends request to GA API.
	 *
	 * @param GARequest $request
	 *
	 * @return bool
	 */
	public function send( $request ) {

		$this->url = add_query_arg(
			array(
				'measurement_id' => $this->measurement_id,
				'api_secret'     => $this->api_secret,
			),
			$this->url
		);

		$args = array(
			'body'     => json_encode( $request->get_request_data() ),
			'method'   => 'POST',
			'blocking' => false,
			'headers'  => array(
				'Content-Type' => 'application/json',
			),
		);

		$response = wp_remote_post( $this->url, $args );

		if ( $response instanceof \WP_Error ) {
			return false;
		}

		return true;

	}
}