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

Implements "Social network" as a new referrer type #12993

Merged
merged 12 commits into from Jul 23, 2018
Merged

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented May 26, 2018

fixes #11102

@sgiehl sgiehl added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label May 26, 2018
@sgiehl sgiehl added this to the 3.6.0 milestone May 26, 2018
@sgiehl sgiehl self-assigned this May 26, 2018
@tsteur
Copy link
Member

tsteur commented May 27, 2018

FYI: We'll need to check and adjust some plugins as well (not part of this PR) like Users Flow, Attribution, Funnels, ...

I presume people will see afterwards a drop in websites referrer types? I wonder if we need to mention in a blog post and explain they are now attributed differently?

@sgiehl
Copy link
Member Author

sgiehl commented May 27, 2018

I presume people will see afterwards a drop in websites referrer types?

I'm wondering if it maybe would make sense to automatically add an annotation to referrer type report on the day of update to point that out?

@tsteur
Copy link
Member

tsteur commented May 27, 2018

Could do it maybe for a week after the update or so?

@sgiehl sgiehl force-pushed the socialreports branch 3 times, most recently from 21696ee to 69aeb7b Compare May 31, 2018 20:25
@sgiehl sgiehl force-pushed the socialreports branch 19 times, most recently from 75cca51 to aa3c60a Compare June 17, 2018 18:28
@sgiehl sgiehl added the Needs Review PRs that need a code review label Jun 17, 2018
@sgiehl
Copy link
Member Author

sgiehl commented Jun 19, 2018

I've updated the code according to the review comments.

For dates before this goes into effect, I see that 'Social Networks' isn't added to the "Referrer Types" report:

That's not easily doable without reprocessing the reports, as the old reports for referrer type did not include that metric. Instead the social networks were included in the websites metric.

@diosmosis
Copy link
Member

That's not easily doable without reprocessing the reports, as the old reports for referrer type did not include that metric. Instead the social networks were included in the websites metric.

I thought you could do the same thing for when there is no social data in Referrers.getSocials in Referrers.getReferrerType. Ie, if $idSubtable == REFERRER_TYPE_SOCIAL and there is no data returned by the getSocials method, then build the datatable from the getWebsites() result. I guess you would also have to remove social URLs from the getWebsites() result if $idSubtable == REFERRER_TYPE_WEBSITE. I guess this isn't doable? Of course, I haven't thought it through to the point that I know it'll work.

@sgiehl
Copy link
Member Author

sgiehl commented Jul 9, 2018

I thought you could do the same thing for when there is no social data in Referrers.getSocials in Referrers.getReferrerType. Ie, if $idSubtable == REFERRER_TYPE_SOCIAL and there is no data returned by the getSocials method, then build the datatable from the getWebsites() result. I guess you would also have to remove social URLs from the getWebsites() result if $idSubtable == REFERRER_TYPE_WEBSITE. I guess this isn't doable? Of course, I haven't thought it through to the point that I know it'll work.

Sorry for the delay. The referrer type numbers shown in that table are stored in an extra report. Splitting up the number for websites and socials for older data is not easy. We would need to query the reports for websites and split it up to websites and socials and then calculate all the numbers based on those resulting reports. I think that might be getting very slow when e.g. viewing row evolution. Also those referrer type reports are calculated as goal reports. I guess recalculating those would only be possible by reprocessing the logs.
Also the resulting numbers might differ if e.g. a website has more referrers than the report limit allows. While the calculated type report would show the correct number, the websites reports would only contain the limited dataset...

Copy link
Member

@diosmosis diosmosis left a comment

Choose a reason for hiding this comment

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

Ok, thought it might be too difficult to be worth it.

Will leave final review/merge to @mattab / @tsteur


private function completeSocialTablesWithOldReports($dataTable, $idSite, $period, $date, $segment, $expanded, $flat)
{
return $this->combineDataTables($dataTable, function() use ($idSite, $period, $date, $segment, $expanded, $flat) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could just add a simple comment to state that we may want to remove this in a year or more likely two years as it then not really won't be needed anymore? With a link to this issue...

/**
* @param DataTable $dataTable
*/
protected function filterWebsitesForSocials($dataTable, $idSite, $period, $date, $segment, $expanded, $flat)
Copy link
Member

Choose a reason for hiding this comment

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

can we make those methods private or are there tests for it?

*/
protected function filterWebsitesForSocials($dataTable, $idSite, $period, $date, $segment, $expanded, $flat)
{
$dataTable->filter('ColumnCallbackDeleteRow', array('label', function ($url) {
Copy link
Member

@tsteur tsteur Jul 9, 2018

Choose a reason for hiding this comment

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

Might be good to check performance at some stage with a profiler on real data ideally just to see... especially re the groupby and mergeSubtables but also everything else like those filters.

$isMap = true;
$dataTables = $dataTable->getDataTables();
} else {
$dataTables = [$dataTable];
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the code could be simplified there eg just if (!$dataTable->getRowCount()) return $callbackForAdditionalData();? Bit hard to understand currently with if's in top and bottom

@tsteur
Copy link
Member

tsteur commented Jul 9, 2018

Left a few minor comments... we will then definitely need to check which plugins need updating. I think eg funnels, multi attribution ...

@sgiehl
Copy link
Member Author

sgiehl commented Jul 16, 2018

@tsteur I've improved the code according to your suggestions. I've not yet done a profiling and don't know when I will find some time to do that properly.
But actually the filters aren't new. Those filters were used before to generate the social networks reports on the fly as well...

@tsteur
Copy link
Member

tsteur commented Jul 16, 2018

Should be all fine then @sgiehl if they were all there before. If there are new ones, be good to have a look just to be sure.

@diosmosis diosmosis merged commit 2b33801 into 3.x-dev Jul 23, 2018
@diosmosis diosmosis deleted the socialreports branch July 23, 2018 21:23
@mattab mattab added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Aug 28, 2018
InfinityVoid pushed a commit to InfinityVoid/matomo that referenced this pull request Oct 11, 2018
* Implements new referrer type for social networks

* removes footer message from social report

* Show social network referrers in Transitions

* update / improve tests

* Improves API code

* use transient cache instead of static properties

* remove debugging statement

* updates changelog

* cs

* Update expected test files.

* Update expected screenshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split "Social network" as its own referrer type in "All referrers" report
4 participants