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

Adjustments according to new no data page layout #456

Merged
merged 6 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions SiteContentDetection/GoogleAnalyticsImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public static function getName(): string
return Piwik::translate('GoogleAnalyticsImporter_AdminMenuTitle');
}

public static function getContentType(): string
public static function getIcon(): string
{
return './plugins/GoogleAnalyticsImporter/images/ga-icon.svg';
}

public static function getContentType(): int
{
return self::TYPE_OTHER;
}
Expand All @@ -43,16 +48,18 @@ public function isDetected(?string $data = null, ?array $headers = null): bool
return false;
}

public function shouldShowInstructionTab(SiteContentDetector $detector = null): bool
public function isRecommended(SiteContentDetector $detector): bool
{
return Piwik::hasUserSuperUserAccess() && (
$detector->wasDetected(GoogleAnalytics3::getId()) || $detector->wasDetected(GoogleAnalytics4::getId())
);
return $detector->wasDetected(GoogleAnalytics3::getId()) || $detector->wasDetected(GoogleAnalytics4::getId());
}

public function shouldHighlightTabIfShown(): bool
public function getRecommendationDetails(SiteContentDetector $detector): array
{
return true;
return [
'title' => Piwik::translate('GoogleAnalyticsImporter_RecommendationTitle'),
'text' => Piwik::translate('GoogleAnalyticsImporter_RecommendationText'),
'button' => Piwik::translate('GoogleAnalyticsImporter_RecommendationButton'),
];
}

public function renderInstructionsTab(SiteContentDetector $detector): string
Expand All @@ -71,7 +78,6 @@ public function renderInstructionsTab(SiteContentDetector $detector): string
$view->extensions = Controller::getComponentExtensions(true);
$view->hasClientConfiguration = $authorization->hasClientConfiguration();
$view->isConfigured = $authorization->hasAccessToken();
$view->isNoDataPage = true;
return $view->render();
}

Expand Down
5 changes: 5 additions & 0 deletions images/ga-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/google-analytics.png
Binary file not shown.
2 changes: 1 addition & 1 deletion javascripts/googleAnalyticsImporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(async () => {
const response = await fetch(window.piwik.piwik_url + '/index.php?' + new URLSearchParams(searchParams));
const data = await response.json();
if ($('.site-without-data').length && data.isGASite) {
if ($('#site-without-data').length && data.isGASite) {
displayPendingNotification('', 'successMessage');
} else if (data.displayPending) {
displayPendingNotification(data.availableDate, 'infoMessage');
Expand Down
5 changes: 4 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
"UploadSuccessful": "Upload successful!",
"StreamId": "Stream ID",
"StreamIdFilter": "Filter by Stream ID (optional)",
"StreamIdFilterHelpText": "The Stream ID for which you want to import data. %1$sLearn more.%2$s %3$sNote:%4$s Leave this field blank to import data from all streams."
"StreamIdFilterHelpText": "The Stream ID for which you want to import data. %1$sLearn more.%2$s %3$sNote:%4$s Leave this field blank to import data from all streams.",
"RecommendationTitle": "Import Google Analytics data to Matomo (recommended for you)",
"RecommendationText": "We have detected Google Analytics on your site, so you can set up Matomo by importing your Google Analytics data.",
"RecommendationButton": "Import data"
}
}
7 changes: 5 additions & 2 deletions stylesheets/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
}

#site-without-data {
#googleanalyticsimporter {
#start-tracking-details[data-method=GoogleAnalyticsImporter] {
.form-group.row {
margin-top: -0.5rem;
margin-bottom: unset;

.col {
padding-left: 0;
}
}

.ga-import-warning {
Expand All @@ -37,7 +41,6 @@
}

.btn-quick-connect, .advance-upload-button, .btn-forward-to-Oauth {
margin-left: 1.5rem;
margin-top: 1rem;
margin-bottom: 1.2rem;
}
Expand Down
9 changes: 3 additions & 6 deletions templates/gaImportNoData.twig
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<h2>{{ 'SitesManager_StepByStepGuide'|translate }}</h2>

{% if isGA3 %}
<div class="alert alert-warning" id="ga3WarningNotification">
{{ 'GoogleAnalyticsImporter_ConfigureTheImporterHelpNewDate'|translate('<strong>', '</strong>')|raw }}
<button type="button" class="close" data-dismiss="alert"> × </button>
</div>
{% endif %}
<div class="right">
<img src="plugins/GoogleAnalyticsImporter/images/google-analytics.png" style="height: 3rem;">
</div>
<p>{{ 'GoogleAnalyticsImporter_NoDataScreenIntro'|translate }}</p>
<br>
{% if isConnectAccountsActivated %}
Expand All @@ -15,8 +14,7 @@
{% else %}
<p>{{ 'GoogleAnalyticsImporter_NoDataScreenFollowThisSteps'|translate }}</p>
{% endif %}
<ul class="list-style-decimal" id="{{ isConnectAccountsActivated ? 'manual-advance-option' : 'manual-option' }}">
<div
<ul class="list-style-decimal" id="{{ isConnectAccountsActivated ? 'manual-advance-option' : 'manual-option' }}"
vue-entry="GoogleAnalyticsImporter.Connect"
is-no-data-page="true"
extensions="{{ extensions|json_encode }}"
Expand All @@ -28,7 +26,6 @@
configure-connection-props="{{ configureConnectionProps|json_encode }}"
strategy-to-use="{{ strategy }}"
>
</div>
</ul>
<br>
<p>{{ 'GoogleAnalyticsImporter_NoDataScreenFollowStepComplete'|translate('<strong>', '</strong>', '<a href="'~ linkTo({'action': 'index', 'module': 'GoogleAnalyticsImporter'}) ~ '" target="_blank" rel="noreferrer noopener ">', '</a>')|raw }}</p>
Expand Down
50 changes: 0 additions & 50 deletions tests/Fixtures/EmptySiteWithSiteContentDetectionGA.php

This file was deleted.

50 changes: 0 additions & 50 deletions tests/Fixtures/EmptySiteWithSiteContentDetectionGA4.php

This file was deleted.

25 changes: 0 additions & 25 deletions tests/UI/EmptySite_GA4_spec.js

This file was deleted.

48 changes: 45 additions & 3 deletions tests/UI/EmptySite_GA_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,58 @@
describe("EmptySite_GA", function () {
this.timeout(0);

this.fixture = "Piwik\\Plugins\\GoogleAnalyticsImporter\\tests\\Fixtures\\EmptySiteWithSiteContentDetectionGA";
this.fixture = "Piwik\\Tests\\Fixtures\\EmptySite";

const generalParams = 'idSite=1&period=day&date=2010-01-03';

it('should show no data screen with GA import and with ga3 offset banner', async function () {
before(function () {
testEnvironment.detectedContentDetections = [];
testEnvironment.connectedConsentManagers = [];
testEnvironment.save();
});

after(function () {
// unset all detections so fake class is no longer used
delete testEnvironment.detectedContentDetections;
delete testEnvironment.connectedConsentManagers;
testEnvironment.save();
});

it('should show no data screen with GA import recommended', async function () {
testEnvironment.detectedContentDetections = ['GoogleAnalytics3', 'Cloudflare'];
testEnvironment.connectedConsentManagers = [];
testEnvironment.save();

const urlToTest = "?" + generalParams + "&module=CoreHome&action=index";
await page.goto(urlToTest);

const pageElement = await page.$('.page');
expect(await pageElement.screenshot()).to.matchImage('emptySiteDashboard');
expect(await pageElement.screenshot()).to.matchImage('list');
});

it('should show import details with ga3 offset banner', async function () {
await page.evaluate(() => $('#start-tracking-detection a[href="#googleanalyticsimporter"]')[0].click());

const pageElement = await page.$('.page');
expect(await pageElement.screenshot()).to.matchImage('details_ga3');
});

it('should show no data screen with GA import recommended', async function () {
testEnvironment.detectedContentDetections = ['GoogleAnalytics4', 'Cloudflare'];
testEnvironment.connectedConsentManagers = [];
testEnvironment.save();

const urlToTest = "?" + generalParams + "&module=CoreHome&action=index";
await page.goto(urlToTest);

const pageElement = await page.$('.page');
expect(await pageElement.screenshot()).to.matchImage('list');
});

it('should show import details', async function () {
await page.evaluate(() => $('#start-tracking-detection a[href="#googleanalyticsimporter"]')[0].click());

const pageElement = await page.$('.page');
expect(await pageElement.screenshot()).to.matchImage('details_ga4');
});
});
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading