New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AC-2574: Commerce Integrated Google Modules Upgrade - Added new module Google Gtag #35376
AC-2574: Commerce Integrated Google Modules Upgrade - Added new module Google Gtag #35376
Conversation
Hi @mahesh-singh-rajawat. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add strict types to all methods where it's possible
- Move all files into one module - GoogleGtag
- Property name shouldn't contain an underscore and should be private where it's possible
/** | ||
* @var Data | ||
*/ | ||
protected $_googleGtagData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, make property private and remove underscore from the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the variable scope and removed underscore
* | ||
* @return Data | ||
*/ | ||
public function getHelper() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where this method is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | ||
* @var Data | ||
*/ | ||
protected $_googleGtagData = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, make property private and remove underscore from the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the variable scope and removed underscore
/** | ||
* @var CollectionFactory | ||
*/ | ||
protected $_salesOrderCollection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, make property private and remove underscore from the name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the variable scope and removed underscore
* @param string $path | ||
* @return mixed | ||
*/ | ||
public function getConfig($path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add strict types to all methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was not used, i have removed this.
/** | ||
* Return information about page for GA tracking | ||
* | ||
* @link https://developers.google.com/analytics/devguides/collection/gtagjs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these links are still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link shows the use of gtag for page_view event, if it requires to find easily reference of using Gtag, we can keep it.
/** | ||
* @var Data | ||
*/ | ||
protected $googleGtagData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make property private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the variable scope to private
* | ||
* @api | ||
*/ | ||
class Data extends AbstractHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename the helper in to GtagConfiguration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helper Data renamed to GtagConfiguration and respective files updated.
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests B2B,Functional Tests CE,Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
* | ||
* @api | ||
*/ | ||
class GtagConfiguration extends AbstractHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the point of extending AbstractHelper
? I would suggest to avoid extending layer supertypes, especially helpers, whenever it is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helper class removed and Model created to provide config values.
use Magento\Store\Model\Store; | ||
|
||
/** | ||
* GoogleAnalytics data helper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make a configuration model out of this. Helper is not really a recommended approach as there is absolutely no clear indication of its purpose and responsibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helper class removed and Model created to provide config values.
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\GoogleGtag\Helper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move it to Model namespace along with other refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helper class removed and Model created to provide config values
/** | ||
* Config paths for using throughout the code | ||
*/ | ||
public const XML_PATH_ACTIVE = 'google/gtag/analytics4/active'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these constants need to be public?
(same question applies to all public
constants below) We need a clear reason to make it public – otherwise should be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the scope of constants.
* Google Ads Code block | ||
* | ||
* @api | ||
* @since 100.0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it exactly 100.0.2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block removed now
* @link https://developers.google.com/gtagjs/reference/event#purchase | ||
* | ||
* @return array | ||
* @since 100.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this specific method is marked with @since
and how is it exactly 100.2.0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this code, as its a new Module
return $result; | ||
} | ||
|
||
$collection = $this->salesOrderCollection->create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could possibly make sense to use an api \Magento\Sales\Api\OrderRepositoryInterface::getList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to get order list via Order \Magento\Sales\Api\OrderRepositoryInterface::getList
* | ||
* @api | ||
*/ | ||
class Head extends Template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this block be replaced by a view model?
See reference above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this block to View model
* @param float $numberString | ||
* @return Float | ||
*/ | ||
public function formatToDec($numberString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this just be used in place? Do we really need a public method (say @api
) for this operation located in the arbitrary helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it and directly use this function in Block
"isCookieRestrictionModeEnabled": <?= (int)$block->isCookieRestrictionModeEnabled() ?>, | ||
"currentWebsite": <?= (int)$block->getCurrentWebsiteId() ?>, | ||
"cookieName": "<?= /* @noEscape */ \Magento\Cookie\Helper\Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>", | ||
"pageTrackingData": <?= /* @noEscape */ json_encode($block->getPageTrackingData($measurementId)) ?>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest serializing it in the block (or view model) using an api like \Magento\Framework\Serialize\SerializerInterface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved code to Ga Block
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests B2B,Functional Tests EE,Integration Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests B2B,Functional Tests EE,Database Compare,Static Tests |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
When do we expect this released? Can this be released as official marketplace extension so we can install it on earlier 2.4.x versions? |
Fetched all the Gtag changes only from #32623 and creates New module Google Gtag.
Description (*)
Fetched all the Gtag changes only from #32623 and creates New module Google Gtag.
Related Pull Requests
https://github.com/magento-commerce/magento2ee/pull/3297
https://github.com/magento-commerce/magento2-infrastructure/pull/1676
Fixed Issues (if relevant)
Manual testing scenarios (*)