# wpvr/8.5.72/vendor/linno/telemetry/src/Drivers/PostHogDriver.php

WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress, version 8.5.72. 53 lines.

- Page: https://pluginprobe.com/plugins/wpvr/8.5.72/code/vendor/linno/telemetry/src/Drivers/PostHogDriver.php
- Raw: https://pluginprobe.com/plugins/wpvr/8.5.72/raw/vendor/linno/telemetry/src/Drivers/PostHogDriver.php
- Modified: 2026-04-02T11:52: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.72/code/vendor/linno/telemetry/src/Drivers/PostHogDriver.php#L10-L20`.

```php
<?php

namespace LinnoSDK\Telemetry\Drivers;

use LinnoSDK\Telemetry\Helpers\Utils;
use PostHog\PostHog;

class PostHogDriver implements DriverInterface
{
    protected $host;
    protected $apiKey;
    protected $lastError;

    public function __construct(string $host)
    {
        $this->host = $host;
    }

    public function send(string $event, array $properties): bool
    {
        try {
            PostHog::init($this->apiKey, ['host' => $this->host]);

            $identify = $properties['__identify'] ?? [];
            unset($properties['__identify']);

            PostHog::capture([
                'distinctId' => Utils::getUniqueSiteId(),
                'event' => $event,
                'properties' => $properties,
                '$set' => $identify,
            ]);

            PostHog::flush();

            return true;
        } catch (\Exception $e) {
            $this->lastError = $e->getMessage();
            return false;
        }
    }

    public function setApiKey(string $apiKey): void
    {
        $this->apiKey = $apiKey;
    }

    public function getLastError(): ?string
    {
        return $this->lastError;
    }
}

```
