-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add notification when report w/ segment has no data, but segment is unprocessed #12823
Conversation
…and display an explanatory notification.
…ble views to add notifications, use to display unprocessed segment message.
<a href="{{ visitorLogLink }}" target="_blank">In the Visitor Log</a>, you can test whether your segment will match your users | ||
correctly by applying it there. When applied, you can see immediately which visits and actions were matched by your segment. | ||
This can help you confirm your Segment matches the users and actions you expect it to. | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for not adding this translatable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right, forgot
Adding to 3.5.0 milestone in case it can go in, if not can remove it. |
@tsteur would you have time to review this PR? |
… found and segment is used, then detect exception in new event.
} | ||
|
||
// get segment | ||
$segment = Common::getRequestVar('segment', false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to use Request::getRawSegmentFromRequest
?
@diosmosis @tsteur @mattab does this one need another review or anything else so it can be merged? |
core/API/Request.php
Outdated
public static function isRootApiRequestHandlingMethod($methodToCheck = null) | ||
{ | ||
if (empty($methodToCheck)) { | ||
$methodToCheck = Common::getRequestVar('method', '', 'string'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not quite sure if this works / makes too much sense? $_GET/$_POST['method']
will be overwritten during API calls within the code etc. And it seems to be only called once but without a parameter? And what is the difference to isRootRequestApiRequest()
when called without a parameter or so? I've tried to understand what is happening here but couldn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The process is split over a couple functions, I'll explain it below:
- on request start via
Platform.initialized
event,Request::setIsRootRequestApiRequest()
is called w/ the api method being called (see plugins/API/API.phpdetectIsApiRequest()
method in this PR) - this value is saved in the transient cache
- later some code wants to see if the current request is the root API method so they call
isRootApiRequestHandlingMethod()
w/o any value. this finds the current executing API method & checks if its the same as the value that was cached before. if it is, then this is the root request (though I suppose this won't work w/ a recursive API method...). if it isn't, then this was invoked within another API request. - later some code wants to see if the root request is a specific method, say Actions.getPageTitles, then they call
isRootApiRequestHandlingMethod('Actions.getPageTitles')
.
anyway, since this won't work w/ recursive methods I'll have to change it...
} | ||
|
||
/** | ||
* Returns the current API method being executed, if the current request is an API request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need to clarify API request vs root API request... in this case here we would be also returning a method when an API request is being executed as part of a regular request... maybe we also need some wordings for it to better talk about it? not sure though.
CHANGELOG.md
Outdated
@@ -9,6 +9,8 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)* | |||
### New APIs | |||
|
|||
* Added new method `Piwik\API\Request::isRootRequestApiRequest()` to detect if the root request is an API request. | |||
* New event `Archive.noArchivedData` which can be used to execute code when no archive data is found for an API method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the events from changelog again as we "ignore" them and don't consider them API?
Had a look through the code again but to really say whether it covers all cases or not, what else we need to consider etc I would need a day or two to understand things fully. As long as nothing is API and we can change things easily later I presume it should be fine to merge as long as we don't say "Data will become available later" when it actually maybe won't. |
Applied some changes, but nothing w/ regard to when the message is displayed or not. Maybe the following changes would help:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback
- please add tests for the API outputs for the 3 use cases covered here:
- custom segment with archiving disabled -> won't be ever available
- segment created in editor as real-time processed but web archiving is disabled so they need to set the segment to pre-processed
- segment created in editor as pre-processed, will be available soon
tests will ensure we don't regress this key information/new user feedback.
{% set visitorLogLinkHtml %}<a href="{{ visitorLogLink }}" target="_blank">{% endset %} | ||
{% if isSegmentToPreprocess %} | ||
<p> | ||
{{ 'SegmentEditor_UnprocessedSegmentNoData1'|translate('<strong>(' ~ segmentName ~ ')</strong>')|raw }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering about the |raw
here, maybe it could lead to XSS for specially crafted segments, ie. maybe segmentName
needs to be escaped?
@@ -0,0 +1,87 @@ | |||
<?php | |||
/** | |||
* Created by PhpStorm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Header comment missing
plugins/SegmentEditor/lang/en.json
Outdated
"CustomUnprocessedSegmentApiError4": "Once created the segment in the editor (or via API), this error message will disappear and within a few hours you will see your segmented report data, after the segment data has been pre-processed.", | ||
"CustomUnprocessedSegmentApiError5": "Please note that you can test whether your segment will work without having to wait for it to be processed by using the Live.getLastVisitsDetails API.", | ||
"CustomUnprocessedSegmentApiError6": "When using this API method, you will see which users and actions were matched by your &segment= parameter.", | ||
"CustomUnprocessedSegmentNoData2": "To see data for this segment, you must create this segment manually in the Segment Editor, then wait a couple hours for preprocessing to complete." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this could be renamed to CustomUnprocessedSegmentNoData
as there was no other key called this?
Change which message to this one? |
Both, since they both tell the user when data will become available. |
Found issues w/ this one, don't merge yet. |
Issues should be fixed |
@diosmosis Build is failing at least in https://travis-ci.org/matomo-org/matomo/jobs/411881882 |
Build should be passing (UI test failures are unrelated to this PR, will have to be fixed in another PR) |
…nprocessed (matomo-org#12823) * When a report has no data, check if it is for an unprocessed segment and display an explanatory notification. * Remove transient notifications on reporting page change, allow datatable views to add notifications, use to display unprocessed segment message. * Update changelog. * Internationalize unprocessed segment message. * Parse notification divs in dashboardWidget.js when setting widget content. * Tweak message. * Change PR to use different approach: throw exception when no archives found and segment is used, then detect exception in new event. * Update changelog + document new event. * Unfinished review changes * more review fixes * Do not show notification w/ custom segments. * apply pr review * Apply review. * undo escaping since it was not needed & get test to pass * Different strategy + new test. * Fix tests. * Update two expected screenshots.
This pull request has been mentioned on Matomo forums. There might be relevant details there: https://forum.matomo.org/t/custom-segment-archiving-question/49322/3 |
Hi, Really wishing there was a "force" option only on the API side. We can't allow customers to create segments via the web because they're often too data intensive, risking an outage with a complex segment with millions of records. However, we have in-app dashboards that are generated dynamically based on API calls, and to create every dashboard segment beforehand wouldn't be practical. We have dashboards that can report on a per profile basis, and one customer might have 500,000 profiles. Also then if they delete profiles, we need to keep the segment list in sync, not to mention we would be required to maintain thousands of segments many of which would never be used. |
@metalocator If you have a feature request or suggestion for improvement please consider open a new issue, if non exist yet. |
Note: this PR has API changes.
This PR makes two changes to the way notifications are handled/displayed:
Individual changes:
notification.service.js
angular service.getSegmentByDefinition()
function to SegmentEditorModel
.Visualization.onLoadingError
that is triggered when there an exception is caught when loading report data.Archive.noArchivedData
that is triggered when during an API request no archive data can be found.Fixes #12256
Fixes #12255