@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $urlParts = parse_url($url); |
| 71 | 71 | $url = $urlParts['path'] ?? '/'; |
| 72 | 72 | if (isset($urlParts['query'])) { |
| 73 | - $url .= '?' . $urlParts['query']; |
|
| 73 | + $url .= '?'.$urlParts['query']; |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $path = parse_url($url, PHP_URL_PATH); |
| 112 | 112 | $pathFragments = explode('/', rtrim($path, '/')); |
| 113 | 113 | $fileName = end($pathFragments); |
| 114 | - $trackingUrl = UrlHelper::siteUrl('instantanalytics/pageViewTrack/' . $fileName, $urlParams); |
|
| 114 | + $trackingUrl = UrlHelper::siteUrl('instantanalytics/pageViewTrack/'.$fileName, $urlParams); |
|
| 115 | 115 | |
| 116 | 116 | InstantAnalytics::$plugin->logAnalyticsEvent( |
| 117 | 117 | 'Created pageViewTrackingUrl for: {trackingUrl}', |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | $urlParams = compact('url', 'eventName', 'params'); |
| 143 | 143 | |
| 144 | 144 | $fileName = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_BASENAME); |
| 145 | - $trackingUrl = UrlHelper::siteUrl('instantanalytics/eventTrack/' . $fileName, $urlParams); |
|
| 145 | + $trackingUrl = UrlHelper::siteUrl('instantanalytics/eventTrack/'.$fileName, $urlParams); |
|
| 146 | 146 | |
| 147 | 147 | InstantAnalytics::$plugin->logAnalyticsEvent( |
| 148 | 148 | 'Created eventTrackingUrl for: {trackingUrl}', |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $result = true; |
| 167 | 167 | $request = Craft::$app->getRequest(); |
| 168 | 168 | |
| 169 | - $logExclusion = static function (string $setting) |
|
| 169 | + $logExclusion = static function(string $setting) |
|
| 170 | 170 | { |
| 171 | 171 | if (InstantAnalytics::$settings->logExcludedAnalytics) { |
| 172 | 172 | $request = Craft::$app->getRequest(); |
@@ -190,8 +190,8 @@ |
||
| 190 | 190 | // Prefix the keys with the global set name |
| 191 | 191 | $prefix = $global->handle; |
| 192 | 192 | $fields = array_combine( |
| 193 | - array_map(static function ($key) use ($prefix) { |
|
| 194 | - return $prefix . '.' . $key; |
|
| 193 | + array_map(static function($key) use ($prefix) { |
|
| 194 | + return $prefix.'.'.$key; |
|
| 195 | 195 | }, array_keys($fields)), |
| 196 | 196 | $fields |
| 197 | 197 | ); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param string $listName |
| 180 | 180 | * @throws \yii\base\InvalidConfigException |
| 181 | 181 | */ |
| 182 | - public function addCommerceProductImpression(Product|Variant $productVariant, $index, string $listName = 'default') { |
|
| 182 | + public function addCommerceProductImpression(Product | Variant $productVariant, $index, string $listName = 'default') { |
|
| 183 | 183 | InstantAnalytics::$plugin->commerce->addCommerceProductImpression($productVariant, $index, $listName); |
| 184 | 184 | } |
| 185 | 185 | |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | // Load them up for GA4 |
| 324 | 324 | foreach ($campaignParams as $key => $method) { |
| 325 | 325 | $value = $request->getParam($key) ?? $session->get($key) ?? null; |
| 326 | - $method = 'set' . $method; |
|
| 326 | + $method = 'set'.$method; |
|
| 327 | 327 | |
| 328 | 328 | $this->$method($value); |
| 329 | 329 | |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | ]; |
| 82 | 82 | |
| 83 | 83 | if (!array_key_exists($componentName, $componentMap)) { |
| 84 | - throw new \InvalidArgumentException(Craft::t('instant-analytics-ga4', 'Unknown event type - ' . $componentName)); |
|
| 84 | + throw new \InvalidArgumentException(Craft::t('instant-analytics-ga4', 'Unknown event type - '.$componentName)); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return new $componentMap[$componentName]; |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * The actions must be in 'kebab-case' |
| 32 | 32 | * @access protected |
| 33 | 33 | */ |
| 34 | - protected array|bool|int $allowAnonymous = [ |
|
| 34 | + protected array | bool | int $allowAnonymous = [ |
|
| 35 | 35 | 'track-page-view-url', |
| 36 | 36 | 'track-event-url' |
| 37 | 37 | ]; |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | // so we can't extract it from the passed in $config |
| 40 | 40 | $majorVersion = '4'; |
| 41 | 41 | // Dev server container name & port are based on the major version of this plugin |
| 42 | - $devPort = 3000 + (int)$majorVersion; |
|
| 43 | - $versionName = 'v' . $majorVersion; |
|
| 42 | + $devPort = 3000 + (int) $majorVersion; |
|
| 43 | + $versionName = 'v'.$majorVersion; |
|
| 44 | 44 | return [ |
| 45 | 45 | 'components' => [ |
| 46 | 46 | 'ga4' => Ga4::class, |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | 'assetClass' => InstantAnalyticsAsset::class, |
| 51 | 51 | 'checkDevServer' => true, |
| 52 | 52 | 'class' => VitePluginService::class, |
| 53 | - 'devServerInternal' => 'http://craft-instantanalytics-ga4-' . $versionName . '-buildchain-dev:' . $devPort, |
|
| 54 | - 'devServerPublic' => 'http://localhost:' . $devPort, |
|
| 53 | + 'devServerInternal' => 'http://craft-instantanalytics-ga4-'.$versionName.'-buildchain-dev:'.$devPort, |
|
| 54 | + 'devServerPublic' => 'http://localhost:'.$devPort, |
|
| 55 | 55 | 'errorEntry' => 'src/js/app.ts', |
| 56 | 56 | 'useDevServer' => true, |
| 57 | 57 | ], |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @param string $listName |
| 212 | 212 | * @throws \yii\base\InvalidConfigException |
| 213 | 213 | */ |
| 214 | - public function addCommerceProductImpression(Variant|Product $productVariant, int $index = 0, string $listName = 'default'): void |
|
| 214 | + public function addCommerceProductImpression(Variant | Product $productVariant, int $index = 0, string $listName = 'default'): void |
|
| 215 | 215 | { |
| 216 | 216 | if ($productVariant) { |
| 217 | 217 | $event = InstantAnalytics::$plugin->ga4->getAnalytics()->create()->ViewItemEvent(); |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | $name = $cat->title; |
| 380 | 380 | |
| 381 | 381 | while ($cat = $cat->parent) { |
| 382 | - $name = $cat->title . '/' . $name; |
|
| 382 | + $name = $cat->title.'/'.$name; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | $cats[] = $name; |
@@ -380,11 +380,11 @@ |
||
| 380 | 380 | // Private Methods |
| 381 | 381 | // ========================================================================= |
| 382 | 382 | |
| 383 | - /** |
|
| 384 | - * @param $layoutId |
|
| 385 | - * |
|
| 386 | - * @return mixed[]|array<string, string> |
|
| 387 | - */ |
|
| 383 | + /** |
|
| 384 | + * @param $layoutId |
|
| 385 | + * |
|
| 386 | + * @return mixed[]|array<string, string> |
|
| 387 | + */ |
|
| 388 | 388 | private function getPullFieldsFromLayoutId($layoutId): array |
| 389 | 389 | { |
| 390 | 390 | $result = ['' => 'none']; |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | // Add in our Twig extensions |
| 214 | 214 | $view->registerTwigExtension(new InstantAnalyticsTwigExtension()); |
| 215 | 215 | // Install our template hook |
| 216 | - $view->hook('iaSendPageView', fn(array $context): string => (string)$this->ga4->addPageViewEvent()); |
|
| 216 | + $view->hook('iaSendPageView', fn(array $context): string => (string) $this->ga4->addPageViewEvent()); |
|
| 217 | 217 | |
| 218 | 218 | // Register our variables |
| 219 | 219 | Event::on( |
| 220 | 220 | CraftVariable::class, |
| 221 | 221 | CraftVariable::EVENT_INIT, |
| 222 | - function (Event $event): void { |
|
| 222 | + function(Event $event): void { |
|
| 223 | 223 | /** @var CraftVariable $variable */ |
| 224 | 224 | $variable = $event->sender; |
| 225 | 225 | $variable->set('instantAnalytics', [ |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | Event::on( |
| 240 | 240 | Plugins::class, |
| 241 | 241 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 242 | - function (PluginEvent $event): void { |
|
| 242 | + function(PluginEvent $event): void { |
|
| 243 | 243 | if ($event->plugin === $this) { |
| 244 | 244 | $request = Craft::$app->getRequest(); |
| 245 | 245 | if ($request->isCpRequest) { |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | Event::on( |
| 270 | 270 | UrlManager::class, |
| 271 | 271 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 272 | - function (RegisterUrlRulesEvent $event): void { |
|
| 272 | + function(RegisterUrlRulesEvent $event): void { |
|
| 273 | 273 | Craft::debug( |
| 274 | 274 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 275 | 275 | __METHOD__ |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | Event::on( |
| 286 | 286 | View::class, |
| 287 | 287 | View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, |
| 288 | - static function (TemplateEvent $event): void { |
|
| 288 | + static function(TemplateEvent $event): void { |
|
| 289 | 289 | self::$currentTemplate = $event->template; |
| 290 | 290 | } |
| 291 | 291 | ); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | Event::on( |
| 294 | 294 | View::class, |
| 295 | 295 | View::EVENT_AFTER_RENDER_PAGE_TEMPLATE, |
| 296 | - function (TemplateEvent $event): void { |
|
| 296 | + function(TemplateEvent $event): void { |
|
| 297 | 297 | if (self::$settings->autoSendPageView) { |
| 298 | 298 | $this->ga4->addPageViewEvent(); |
| 299 | 299 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | Event::on( |
| 305 | 305 | Response::class, |
| 306 | 306 | Response::EVENT_BEFORE_SEND, |
| 307 | - function (Event $event): void { |
|
| 307 | + function(Event $event): void { |
|
| 308 | 308 | // Initialize this sooner rather than later, since it's possible this will want to tinker with cookies |
| 309 | 309 | $this->ga4->getAnalytics(); |
| 310 | 310 | } |
@@ -314,21 +314,21 @@ discard block |
||
| 314 | 314 | Event::on( |
| 315 | 315 | Response::class, |
| 316 | 316 | Response::EVENT_AFTER_SEND, |
| 317 | - function (Event $event): void { |
|
| 317 | + function(Event $event): void { |
|
| 318 | 318 | $this->ga4->getAnalytics()->sendCollectedEvents(); |
| 319 | 319 | } |
| 320 | 320 | ); |
| 321 | 321 | |
| 322 | 322 | // Commerce-specific hooks |
| 323 | 323 | if (self::$commercePlugin !== null) { |
| 324 | - Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function (Event $e): void { |
|
| 324 | + Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function(Event $e): void { |
|
| 325 | 325 | $order = $e->sender; |
| 326 | 326 | if (self::$settings->autoSendPurchaseComplete) { |
| 327 | 327 | $this->commerce->triggerOrderCompleteEvent($order); |
| 328 | 328 | } |
| 329 | 329 | }); |
| 330 | 330 | |
| 331 | - Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function (LineItemEvent $e): void { |
|
| 331 | + Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function(LineItemEvent $e): void { |
|
| 332 | 332 | $lineItem = $e->lineItem; |
| 333 | 333 | if (self::$settings->autoSendAddToCart) { |
| 334 | 334 | $this->commerce->triggerAddToCartEvent($lineItem); |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | }); |
| 337 | 337 | |
| 338 | 338 | // Check to make sure Order::EVENT_AFTER_REMOVE_LINE_ITEM is defined |
| 339 | - if (defined(Order::class . '::EVENT_AFTER_REMOVE_LINE_ITEM')) { |
|
| 340 | - Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function (LineItemEvent $e): void { |
|
| 339 | + if (defined(Order::class.'::EVENT_AFTER_REMOVE_LINE_ITEM')) { |
|
| 340 | + Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function(LineItemEvent $e): void { |
|
| 341 | 341 | $lineItem = $e->lineItem; |
| 342 | 342 | if (self::$settings->autoSendRemoveFromCart) { |
| 343 | 343 | $this->commerce->triggerRemoveFromCartEvent($lineItem); |