Skip to content
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

Merged

Conversation

mahesh-singh-rajawat
Copy link
Contributor

@mahesh-singh-rajawat mahesh-singh-rajawat commented Apr 26, 2022

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)

  1. Google Universal Analytics will be EOL July 2023 #35204

Manual testing scenarios (*)

  1. ...
  2. ...

@m2-assistant
Copy link

m2-assistant bot commented Apr 26, 2022

Hi @mahesh-singh-rajawat. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

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.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 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

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

Copy link
Contributor

@sidolov sidolov left a 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;
Copy link
Contributor

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

Copy link
Contributor Author

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make property private

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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.

@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in Pull Requests Dashboard Apr 27, 2022
@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run Functional Tests B2B,Functional Tests CE,Functional Tests EE

@magento-automated-testing
Copy link

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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';
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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();
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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)) ?>,
Copy link
Contributor

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

Copy link
Contributor Author

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

@m2-community-project m2-community-project bot moved this from Review in Progress to Changes Requested in Pull Requests Dashboard May 4, 2022
@sdzhepa sdzhepa added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label May 5, 2022
@m2-community-project m2-community-project bot removed this from Changes Requested in Pull Requests Dashboard May 5, 2022
@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in High Priority Pull Requests Dashboard May 6, 2022
@magento-automated-testing
Copy link

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.

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in High Priority Pull Requests Dashboard May 20, 2022
@ishakhsuvarov
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

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.

@glo41183
Copy link

@magento run all tests

@magento-automated-testing
Copy link

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.

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run Functional Tests B2B,Functional Tests EE,Integration Tests

@magento-automated-testing
Copy link

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.

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

@mahesh-singh-rajawat
Copy link
Contributor Author

mahesh-singh-rajawat commented May 25, 2022

@magento run Functional Tests B2B,Functional Tests EE,Database Compare,Static Tests

@mahesh-singh-rajawat
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

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.

@ryanisn
Copy link

ryanisn commented May 27, 2022

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?
Merchants would want to install this update ASAP to keep more historical data, google will only keep 6mo data on GA3

@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 9b91ff9 into magento:2.4-develop May 27, 2022
@ishakhsuvarov ishakhsuvarov moved this from Review in Progress to Recently Merged in High Priority Pull Requests Dashboard Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants