Skip to content

Commit bd09670

Browse files
authored
Merge pull request #3879 from magento-obsessive-owls/MC-1426
[Owls] MC-14937: Complete Page Builder Analytics data collection
2 parents 079770a + 3cd2008 commit bd09670

File tree

9 files changed

+88
-8
lines changed

9 files changed

+88
-8
lines changed

app/code/Magento/CatalogAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0",
66
"magento/framework": "*",
7-
"magento/module-catalog": "*"
7+
"magento/module-catalog": "*",
8+
"magento/module-analytics": "*"
89
},
910
"type": "magento2-module",
1011
"license": [

app/code/Magento/CustomerAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0",
66
"magento/framework": "*",
7-
"magento/module-customer": "*"
7+
"magento/module-customer": "*",
8+
"magento/module-analytics": "*"
89
},
910
"type": "magento2-module",
1011
"license": [

app/code/Magento/GiftMessage/Model/CompositeConfigProvider.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
use Magento\Checkout\Model\ConfigProviderInterface;
99

10+
/**
11+
* Class CompositeConfigProvider
12+
*/
1013
class CompositeConfigProvider implements ConfigProviderInterface
1114
{
1215
/**
@@ -18,13 +21,13 @@ class CompositeConfigProvider implements ConfigProviderInterface
1821
* @param ConfigProviderInterface[] $configProviders
1922
*/
2023
public function __construct(
21-
array $configProviders
24+
array $configProviders = []
2225
) {
2326
$this->configProviders = $configProviders;
2427
}
2528

2629
/**
27-
* {@inheritdoc}
30+
* @inheritdoc
2831
*/
2932
public function getConfig()
3033
{

app/code/Magento/QuoteAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0",
66
"magento/framework": "*",
7-
"magento/module-quote": "*"
7+
"magento/module-quote": "*",
8+
"magento/module-analytics": "*"
89
},
910
"type": "magento2-module",
1011
"license": [

app/code/Magento/ReviewAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0",
66
"magento/framework": "*",
7-
"magento/module-review": "*"
7+
"magento/module-review": "*",
8+
"magento/module-analytics": "*"
89
},
910
"type": "magento2-module",
1011
"license": [

app/code/Magento/SalesAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0",
66
"magento/framework": "*",
7-
"magento/module-sales": "*"
7+
"magento/module-sales": "*",
8+
"magento/module-analytics": "*"
89
},
910
"type": "magento2-module",
1011
"license": [

app/code/Magento/WishlistAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"require": {
55
"php": "~7.1.3||~7.2.0",
66
"magento/framework": "*",
7-
"magento/module-wishlist": "*"
7+
"magento/module-wishlist": "*",
8+
"magento/module-analytics": "*"
89
},
910
"type": "magento2-module",
1011
"license": [
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TestFramework\Dependency;
10+
11+
/**
12+
* Class provides dependency rule for analytics.xml config file.
13+
*/
14+
class AnalyticsConfigRule implements RuleInterface
15+
{
16+
/**
17+
* @inheritdoc
18+
*/
19+
public function getDependencyInfo($currentModule, $fileType, $file, &$contents)
20+
{
21+
if ('config' != $fileType || !preg_match('#.*/analytics\.xml$#', $file)) {
22+
return [];
23+
}
24+
25+
$dependenciesInfo = [];
26+
if (preg_match_all('#<[customProvider|reportProvider][^>]*class=[\'"]([^\'"]+)[\'"]#i', $contents, $matches)) {
27+
$classes = array_pop($matches);
28+
foreach ($classes as $class) {
29+
$classParts = explode('\\', $class);
30+
$module = implode('\\', array_slice($classParts, 0, 2));
31+
if (strtolower($currentModule) !== strtolower($module)) {
32+
$dependenciesInfo[] = [
33+
'module' => $module,
34+
'type' => RuleInterface::TYPE_HARD,
35+
'source' => $file,
36+
];
37+
}
38+
}
39+
}
40+
41+
return $dependenciesInfo;
42+
}
43+
}

dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\TestFramework\Dependency\LayoutRule;
1717
use Magento\TestFramework\Dependency\PhpRule;
1818
use Magento\TestFramework\Dependency\ReportsConfigRule;
19+
use Magento\TestFramework\Dependency\AnalyticsConfigRule;
1920
use Magento\TestFramework\Dependency\VirtualType\VirtualTypeMapper;
2021

2122
/**
@@ -78,6 +79,17 @@ class DependencyTest extends \PHPUnit\Framework\TestCase
7879
*/
7980
protected static $_listRoutesXml = [];
8081

82+
/**
83+
* List of analytics.xml
84+
*
85+
* Format: array(
86+
* '{Module_Name}' => '{Filename}'
87+
* )
88+
*
89+
* @var array
90+
*/
91+
protected static $_listAnalyticsXml = [];
92+
8193
/**
8294
* List of routers
8395
*
@@ -176,6 +188,7 @@ public static function setUpBeforeClass()
176188
self::_prepareListConfigXml();
177189
self::_prepareListDbSchemaXml();
178190
self::_prepareListRoutesXml();
191+
self::_prepareListAnalyticsXml();
179192

180193
self::_prepareMapRouters();
181194
self::_prepareMapLayoutBlocks();
@@ -240,6 +253,7 @@ protected static function _initRules()
240253
),
241254
new DiRule(new VirtualTypeMapper()),
242255
new ReportsConfigRule($dbRuleTables),
256+
new AnalyticsConfigRule(),
243257
];
244258
}
245259

@@ -571,6 +585,20 @@ protected static function _prepareListRoutesXml()
571585
}
572586
}
573587

588+
/**
589+
* Prepare list of analytics.xml files
590+
*/
591+
protected static function _prepareListAnalyticsXml()
592+
{
593+
$files = Files::init()->getDbSchemaFiles('analytics.xml', [], false);
594+
foreach ($files as $file) {
595+
if (preg_match('/(?<namespace>[A-Z][a-z]+)[_\/\\\\](?<module>[A-Z][a-zA-Z]+)/', $file, $matches)) {
596+
$module = $matches['namespace'] . '\\' . $matches['module'];
597+
self::$_listAnalyticsXml[$module] = $file;
598+
}
599+
}
600+
}
601+
574602
/**
575603
* Prepare map of routers
576604
*/

0 commit comments

Comments
 (0)