33namespace AlexWestergaard \PhpGa4 ;
44
55use GuzzleHttp \Client as Guzzle ;
6- use AlexWestergaard \PhpGa4 \Helper \AbstractIO ;
7- use AlexWestergaard \PhpGa4 \Facade \Type \UserProperty ;
8- use AlexWestergaard \PhpGa4 \Facade \Type \Event ;
9- use AlexWestergaard \PhpGa4 \Facade \Type \Analytics as TypeAnalytics ;
6+ use AlexWestergaard \PhpGa4 \Helper ;
7+ use AlexWestergaard \PhpGa4 \Facade ;
108use AlexWestergaard \PhpGa4 \Exception \Ga4Exception ;
119
12- class Analytics extends AbstractIO implements TypeAnalytics
10+ class Analytics extends Helper \IOHelper implements Facade \ Type \AnalyticsType
1311{
1412 protected null |bool $ non_personalized_ads = false ;
1513 protected null |int $ timestamp_micros ;
@@ -85,7 +83,7 @@ public function setTimestampMicros(int|float $microOrUnix)
8583 return $ this ;
8684 }
8785
88- public function addUserProperty (UserProperty ...$ props )
86+ public function addUserProperty (Facade \ Type \ UserPropertyType ...$ props )
8987 {
9088 foreach ($ props as $ prop ) {
9189 $ this ->user_properties = array_replace ($ this ->user_properties , $ prop ->toArray ());
@@ -94,7 +92,7 @@ public function addUserProperty(UserProperty ...$props)
9492 return $ this ;
9593 }
9694
97- public function addEvent (Event ...$ events )
95+ public function addEvent (Facade \ Type \ EventType ...$ events )
9896 {
9997 foreach ($ events as $ event ) {
10098 $ this ->events [] = $ event ->toArray ();
@@ -112,7 +110,7 @@ public function post(): void
112110 throw Ga4Exception::throwMissingApiSecret ();
113111 }
114112
115- $ url = $ this ->debug ? TypeAnalytics ::URL_DEBUG : TypeAnalytics ::URL_LIVE ;
113+ $ url = $ this ->debug ? Facade \ Type \AnalyticsType ::URL_DEBUG : Facade \ Type \AnalyticsType ::URL_LIVE ;
116114 $ url .= '? ' . http_build_query (['measurement_id ' => $ this ->measurement_id , 'api_secret ' => $ this ->api_secret ]);
117115
118116 $ body = $ this ->toArray ();
@@ -141,7 +139,7 @@ public function post(): void
141139 $ guzzle = new Guzzle ();
142140 $ res = $ guzzle ->request ('POST ' , $ url , ['json ' => $ body ]);
143141
144- if (!in_array (($ code = $ res ?->getStatusCode() ?? 0 ), TypeAnalytics ::ACCEPT_RESPONSE_HEADERS )) {
142+ if (!in_array (($ code = $ res ?->getStatusCode() ?? 0 ), Facade \ Type \AnalyticsType ::ACCEPT_RESPONSE_HEADERS )) {
145143 Ga4Exception::throwRequestWrongResponceCode ($ code );
146144 }
147145
0 commit comments