<?php

namespace App\Tracking;

use App\Facades\Settings;
use Illuminate\Contracts\Support\Arrayable;

class XTracker implements Arrayable
{
    public function toArray()
    {
        $pixelId = Settings::get('tracking-x-pixel-id');
        return [
            [
                "body" => '!function(e,t,n,s,u,a){'
                    . 'e.twq||(s=e.twq=function(){s.exe?s.exe.apply(s,arguments):s.queue.push(arguments);},'
                    . 's.version="1.1",s.queue=[],u=t.createElement(n),u.async=!0,u.src="'
                    . 'https://static.ads-twitter.com/uwt.js",'
                    . 'a=t.getElementsByTagName(n)[0],a.parentNode.insertBefore(u,a))}(window,document,"script");'
                    . 'twq("config","' . $pixelId . '");'
                    . 'twq("event","PageView");',
                'data-consent' => 'marketing'
            ]
        ];
    }
}
