Skip to content

Commit

Permalink
Merge pull request #534 from matomo-org/L3-761-disable-re-import-ga3
Browse files Browse the repository at this point in the history
Disable re-import date range feature for GA3, #L3-761
  • Loading branch information
AltamashShaikh authored Jul 11, 2024
2 parents 4ad5bbe + 6609c54 commit c167681
Show file tree
Hide file tree
Showing 16 changed files with 1,936 additions and 1,354 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

# 5.0.18
- Disabled re-import date range feature for GA3 imports

# 5.0.17
- Updated translations

Expand Down
5 changes: 4 additions & 1 deletion Commands/ImportReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ protected function executeImpl() : int
$output->writeln(LogToSingleFileProcessor::$cliOutputPrefix . "Failed to import property entities, aborting.");
return self::FAILURE;
}
$dateRangesToReImport = empty($status['reimport_ranges']) ? [] : $status['reimport_ranges'];

// Disabled reimport of daterange for GA3
// $dateRangesToReImport = empty($status['reimport_ranges']) ? [] : $status['reimport_ranges'];
$dateRangesToReImport = [];
$dateRangesToReImport = array_map(function ($d) {
return [Date::factory($d[0]), Date::factory($d[1])];
}, $dateRangesToReImport);
Expand Down
3 changes: 3 additions & 0 deletions Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ public function scheduleReImport()
$idSite = Common::getRequestVar('idSite', null, 'int');
new Site($idSite);
$isGA4 = Common::getRequestVar('isGA4', 0, 'int') == 1;
if (!$isGA4) {
throw new \Exception('Reimport for GA3 is disabled, as it will lead to data loss for already imported date ranges.');
}
$startDate = Common::getRequestVar('startDate', null, 'string');
$startDate = Date::factory($startDate);
$endDate = Common::getRequestVar('endDate', null, 'string');
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "GoogleAnalyticsImporter",
"description": "Import reports from a Google Analytics account into Matomo.",
"version": "5.0.17",
"version": "5.0.18",
"theme": false,
"require": {
"matomo": ">=5.0.0-rc5,<6.0.0-b1"
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/ImportedFromGoogle.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function setUp() : void
}
$this->getGoogleAnalyticsParams();
$this->runGoogleImporter($this->importedDateRange1);
$this->extendEndDate($idSite = 1, '2019-06-27', '2019-07-02');
$this->scheduleReimport($idSite = 1, '2019-06-27', '2019-06-27');
$this->extendEndDate($idSite = 1, '2019-06-27', '2019-06-27');
// $this->scheduleReimport($idSite = 1, '2019-06-27', '2019-06-27');
$output = $this->runGoogleImporter($this->importedDateRange2, $idSite = 1);
$this->assertStringContainsString('Importing the following date ranges in order: 2019-06-27,2019-06-27', $output);
$this->runGoogleImporter($this->campaignDataDateRange);
Expand Down
4 changes: 4 additions & 0 deletions tests/System/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function testApi($api, $params)
if (version_compare(Version::VERSION, '4.10.0') <= 0) {
$this->markTestSkipped('Skipping tests for lower version');
}
if (version_compare(Version::VERSION, '5.2.0-alpha', '<') && is_array($api) && in_array('Goals.get', $api)) {
$keyToDelete = array_search('Goals.get', $api);
unset($api[$keyToDelete]);
}
$this->runApiTests($api, $params);
}
public function getApiTestsToRun()
Expand Down
8 changes: 4 additions & 4 deletions tests/System/expected/test___Goals.get_year.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<nb_visits_converted>202</nb_visits_converted>
<revenue>1926925</revenue>
<conversion_rate>29.66%</conversion_rate>
<nb_conversions_new_visit>0</nb_conversions_new_visit>
<nb_visits_converted_new_visit>0</nb_visits_converted_new_visit>
<revenue_new_visit>0</revenue_new_visit>
<conversion_rate_new_visit>0%</conversion_rate_new_visit>
<nb_conversions_new_visit>168</nb_conversions_new_visit>
<nb_visits_converted_new_visit>93</nb_visits_converted_new_visit>
<revenue_new_visit>506234</revenue_new_visit>
<conversion_rate_new_visit>9,300%</conversion_rate_new_visit>
<nb_conversions_returning_visit>417</nb_conversions_returning_visit>
<nb_visits_converted_returning_visit>201</nb_visits_converted_returning_visit>
<revenue_returning_visit>1926925</revenue_returning_visit>
Expand Down
17 changes: 0 additions & 17 deletions tests/UI/GoogleAnalyticsImporter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,7 @@ describe("GoogleAnalyticsImporter", function () {
expect(await content.screenshot()).to.matchImage('resumed_import');
});

it('should schedule a re-import when the modal is used', async function () {
await page.waitForTimeout(90000);

await page.click('#reimport-date-range');

await page.waitForSelector('#openScheduleReimportModal', { visible: true });
await page.type('#re-import-start-date', '2019-06-27');
await page.type('#re-import-end-date', '2019-06-27');

await page.click('#scheduleReimportSubmit');
await page.waitForNetworkIdle();
await page.waitForSelector('.pageWrap');

await removeStartResumeFinishTime();

const content = await page.$('.pageWrap');
expect(await content.screenshot()).to.matchImage('reimport_range');
});

it("should show that the import finished when the import finishes", async function () {
let totalTime = 0;
Expand Down
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.
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.
2,509 changes: 1,902 additions & 607 deletions vue/dist/GoogleAnalyticsImporter.umd.js

Large diffs are not rendered by default.

Loading

0 comments on commit c167681

Please sign in to comment.