@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | // Add in our Twig extensions |
| 209 | 209 | $view->registerTwigExtension(new InstantAnalyticsTwigExtension()); |
| 210 | 210 | // Install our template hook |
| 211 | - $view->hook('iaSendPageView', fn(array $context): string => (string)$this->ga4->addPageViewEvent()); |
|
| 211 | + $view->hook('iaSendPageView', fn(array $context): string => (string) $this->ga4->addPageViewEvent()); |
|
| 212 | 212 | |
| 213 | 213 | // Register our variables |
| 214 | 214 | Event::on( |
| 215 | 215 | CraftVariable::class, |
| 216 | 216 | CraftVariable::EVENT_INIT, |
| 217 | - function (Event $event): void { |
|
| 217 | + function(Event $event): void { |
|
| 218 | 218 | /** @var CraftVariable $variable */ |
| 219 | 219 | $variable = $event->sender; |
| 220 | 220 | $variable->set('instantAnalytics', [ |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | Event::on( |
| 235 | 235 | Plugins::class, |
| 236 | 236 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 237 | - function (PluginEvent $event): void { |
|
| 237 | + function(PluginEvent $event): void { |
|
| 238 | 238 | if ($event->plugin === $this) { |
| 239 | 239 | $request = Craft::$app->getRequest(); |
| 240 | 240 | if ($request->isCpRequest) { |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | Event::on( |
| 248 | 248 | Plugins::class, |
| 249 | 249 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 250 | - static function () { |
|
| 250 | + static function() { |
|
| 251 | 251 | // Determine if Craft Commerce is installed & enabled |
| 252 | 252 | self::$commercePlugin = Craft::$app->getPlugins()->getPlugin(self::COMMERCE_PLUGIN_HANDLE); |
| 253 | 253 | // Determine if SEOmatic is installed & enabled |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | Event::on( |
| 276 | 276 | UrlManager::class, |
| 277 | 277 | UrlManager::EVENT_REGISTER_SITE_URL_RULES, |
| 278 | - function (RegisterUrlRulesEvent $event): void { |
|
| 278 | + function(RegisterUrlRulesEvent $event): void { |
|
| 279 | 279 | Craft::debug( |
| 280 | 280 | 'UrlManager::EVENT_REGISTER_SITE_URL_RULES', |
| 281 | 281 | __METHOD__ |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | Event::on( |
| 292 | 292 | View::class, |
| 293 | 293 | View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, |
| 294 | - static function (TemplateEvent $event): void { |
|
| 294 | + static function(TemplateEvent $event): void { |
|
| 295 | 295 | self::$currentTemplate = $event->template; |
| 296 | 296 | } |
| 297 | 297 | ); |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | Event::on( |
| 300 | 300 | View::class, |
| 301 | 301 | View::EVENT_AFTER_RENDER_PAGE_TEMPLATE, |
| 302 | - function (TemplateEvent $event): void { |
|
| 302 | + function(TemplateEvent $event): void { |
|
| 303 | 303 | if (self::$settings->autoSendPageView) { |
| 304 | 304 | $request = Craft::$app->getRequest(); |
| 305 | 305 | if (!$request->getIsAjax()) { |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | Event::on( |
| 314 | 314 | Response::class, |
| 315 | 315 | Response::EVENT_BEFORE_SEND, |
| 316 | - function (Event $event): void { |
|
| 316 | + function(Event $event): void { |
|
| 317 | 317 | // Initialize this sooner rather than later, since it's possible this will want to tinker with cookies |
| 318 | 318 | $this->ga4->getAnalytics(); |
| 319 | 319 | } |
@@ -323,21 +323,21 @@ discard block |
||
| 323 | 323 | Event::on( |
| 324 | 324 | Response::class, |
| 325 | 325 | Response::EVENT_AFTER_SEND, |
| 326 | - function (Event $event): void { |
|
| 326 | + function(Event $event): void { |
|
| 327 | 327 | $this->ga4->getAnalytics()->sendCollectedEvents(); |
| 328 | 328 | } |
| 329 | 329 | ); |
| 330 | 330 | |
| 331 | 331 | // Commerce-specific hooks |
| 332 | 332 | if (self::$commercePlugin !== null) { |
| 333 | - Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function (Event $e): void { |
|
| 333 | + Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function(Event $e): void { |
|
| 334 | 334 | $order = $e->sender; |
| 335 | 335 | if (self::$settings->autoSendPurchaseComplete) { |
| 336 | 336 | $this->commerce->triggerOrderCompleteEvent($order); |
| 337 | 337 | } |
| 338 | 338 | }); |
| 339 | 339 | |
| 340 | - Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function (LineItemEvent $e): void { |
|
| 340 | + Event::on(Order::class, Order::EVENT_AFTER_ADD_LINE_ITEM, function(LineItemEvent $e): void { |
|
| 341 | 341 | $lineItem = $e->lineItem; |
| 342 | 342 | if (self::$settings->autoSendAddToCart) { |
| 343 | 343 | $this->commerce->triggerAddToCartEvent($lineItem); |
@@ -345,8 +345,8 @@ discard block |
||
| 345 | 345 | }); |
| 346 | 346 | |
| 347 | 347 | // Check to make sure Order::EVENT_AFTER_REMOVE_LINE_ITEM is defined |
| 348 | - if (defined(Order::class . '::EVENT_AFTER_REMOVE_LINE_ITEM')) { |
|
| 349 | - Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function (LineItemEvent $e): void { |
|
| 348 | + if (defined(Order::class.'::EVENT_AFTER_REMOVE_LINE_ITEM')) { |
|
| 349 | + Event::on(Order::class, Order::EVENT_AFTER_REMOVE_LINE_ITEM, function(LineItemEvent $e): void { |
|
| 350 | 350 | $lineItem = $e->lineItem; |
| 351 | 351 | if (self::$settings->autoSendRemoveFromCart) { |
| 352 | 352 | $this->commerce->triggerRemoveFromCartEvent($lineItem); |
@@ -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 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * @deprecated `Analytics::addCommerceProductDetailView()` is deprecated. Use `Analytics::addCommerceProductImpression()` instead. |
| 193 | 193 | * @throws \yii\base\InvalidConfigException |
| 194 | 194 | */ |
| 195 | - public function addCommerceProductDetailView(Product|Variant $productVariant, $index, string $listName = 'default') { |
|
| 195 | + public function addCommerceProductDetailView(Product | Variant $productVariant, $index, string $listName = 'default') { |
|
| 196 | 196 | Craft::$app->getDeprecator()->log('Analytics::addCommerceProductDetailView()', '`Analytics::addCommerceProductDetailView()` is deprecated. Use `Analytics::addCommerceProductImpression()` instead.'); |
| 197 | 197 | InstantAnalytics::$plugin->commerce->addCommerceProductImpression($productVariant, $index, $listName); |
| 198 | 198 | } |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | // Load them up for GA4 |
| 339 | 339 | foreach ($campaignParams as $key => $method) { |
| 340 | 340 | $value = $request->getParam($key) ?? $session->get($key) ?? null; |
| 341 | - $method = 'set' . $method; |
|
| 341 | + $method = 'set'.$method; |
|
| 342 | 342 | |
| 343 | 343 | $this->$method($value); |
| 344 | 344 | |