-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12525 from martoboto/analytics-to-gtag-v4
Update analytics.js to gtag to support ga4
- Loading branch information
Showing
3 changed files
with
76 additions
and
21 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
app/bundles/CoreBundle/Tests/Functional/Controller/JsControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mautic\CoreBundle\Tests\Functional\Controller; | ||
|
||
use Mautic\CoreBundle\Test\MauticMysqlTestCase; | ||
use PHPUnit\Framework\Assert; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
/** | ||
* This test is breaking other tests, so running it in a separate process. | ||
* | ||
* @runTestsInSeparateProcesses | ||
* | ||
* @preserveGlobalState disabled | ||
*/ | ||
final class JsControllerTest extends MauticMysqlTestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
$this->configParams['google_analytics_id'] = 'G-F3825DS9CD'; | ||
$this->configParams['google_analytics_trackingpage_enabled'] = true; | ||
$this->configParams['site_url'] = 'https://mautic.test'; | ||
$this->configParams['google_analytics_anonymize_ip'] = 'testIndexActionRendersSuccessfullyWithAnonymizeIp' === $this->getName(); | ||
parent::setUp(); | ||
} | ||
|
||
public function testIndexActionRendersSuccessfully(): void | ||
{ | ||
$this->client->request('GET', '/mtc.js'); | ||
Assert::assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); | ||
Assert::assertStringContainsString('https://www.googletagmanager.com/gtag/js?id=G-F3825DS9CD', $this->client->getResponse()->getContent()); | ||
Assert::assertStringContainsString('gtag(\'config\',\'G-F3825DS9CD\')', $this->client->getResponse()->getContent()); | ||
} | ||
|
||
public function testIndexActionRendersSuccessfullyWithAnonymizeIp(): void | ||
{ | ||
$this->client->request('GET', '/mtc.js'); | ||
Assert::assertSame(Response::HTTP_OK, $this->client->getResponse()->getStatusCode()); | ||
Assert::assertStringContainsString('https://www.googletagmanager.com/gtag/js?id=G-F3825DS9CD', $this->client->getResponse()->getContent()); | ||
Assert::assertStringContainsString('gtag(\'config\',\'G-F3825DS9CD\',{"anonymize_ip":true})', $this->client->getResponse()->getContent()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters