# wpvr/8.5.37/admin/Tracking/AbstractEvent.php

WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress, version 8.5.37. 145 lines.

- Page: https://pluginprobe.com/plugins/wpvr/8.5.37/code/admin/Tracking/AbstractEvent.php
- Raw: https://pluginprobe.com/plugins/wpvr/8.5.37/raw/admin/Tracking/AbstractEvent.php
- Modified: 2025-08-22T09:13:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wpvr/8.5.37/code/admin/Tracking/AbstractEvent.php#L10-L20`.

```php
<?php
/**
 * Abstract class for all event types.
 *
 * @package WpVr\Tracking
 * @since   8.5.37
 */

namespace Wpvr\Admin\Tracking;

// Exit if accessed directly.

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class AbstractEvent
 *
 * Base class for all tracking events.
 *
 * @package WpVr\Tracking
 * @since   8.5.37
 */
abstract class AbstractEvent {

	/**
	 * PostHog client instance.
	 *
	 * @var PosthogClient
	 */
	protected $client;

	/**
	 * Constructor.
	 *
	 * @param PosthogClient $client PostHog client.
	 * @since 8.5.37
	 */
	public function __construct( $client ) {
		$this->client = $client;
		$this->register_hooks();
	}

	/**
	 * Register WordPress hooks for this event.
	 *
	 * Each child class must implement this to define when events are triggered.
	 * @since 8.5.37
	 */
	abstract public function register_hooks();

	/**
	 * Get common properties for all events.
	 *
	 * @return array Common properties.
	 * @since 8.5.37
	 */
	protected function get_common_properties() {
		$properties = array(
			'timestamp' => current_time( 'c' ),
			'plugin' => 'wpvr',
			'version' => defined('WPVR_VERSION') ? WPVR_VERSION : 'unknown',
		);

		return $properties;
	}

	/**
	 * Track signup moment event.
	 *
	 * @param string $action   The specific action that triggered this event.
	 * @param array  $metadata Additional metadata for the event.
	 * @since 8.5.37
	 */
	protected function track_signup_moment( $action, $metadata = array() ) {
		$properties = array_merge(
			$this->get_common_properties(),
			array(
				'funnel_type' => 'signup',
			),
			$metadata
		);

		$this->client->capture( $action, $properties );
	}

	/**
	 * Track setup moment event.
	 *
	 * @param string $action   The specific action that triggered this event.
	 * @param array  $metadata Additional metadata for the event.
	 * @since 8.5.37
	 */
	protected function track_setup_moment( $action, $metadata = array() ) {
		$properties = array_merge(
			$this->get_common_properties(),
			array(
				'funnel_type' => 'setup',
			),
			$metadata
		);

		$this->client->capture( $action, $properties );
	}

	/**
	 * Track aha moment event.
	 *
	 * @param string $action   The specific action that triggered this event.
	 * @param array  $metadata Additional metadata for the event.
	 * @since 8.5.37
	 */
	protected function track_aha_moment( $action, $metadata = array() ) {
		$properties = array_merge(
			$this->get_common_properties(),
			array(
				'funnel_type' => 'aha',
			),
			$metadata
		);

		$this->client->capture( $action, $properties );
	}

    /**
     * Track habit moment event.
     *
     * @param string $action   The specific action that triggered this event.
     * @param array  $metadata Additional metadata for the event.
     * @since 8.5.37
     */
    protected function track_habit_moment( $action, $metadata = array() ) {
        $properties = array_merge(
            $this->get_common_properties(),
            array(
                'funnel_type' => 'habit',
            ),
            $metadata
        );

        $this->client->capture( $action, $properties );
    }
}

```
