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

Report tracking into wrong Site ID and missing token auth #13493

Merged
merged 21 commits into from Dec 6, 2018
Merged

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 28, 2018

fix #12922

  • When a tracking request is invalid for any of the 2 reasons, we log the request as a failure
  • Any failed request older than 2 days ago is automatically deleted again
  • Weekly we check for tracking failures and email super users only (doing this for admins is bit tricky)
  • Admins and SuperUsers see a new widget on Admin Home screen plus it can be used in the dashboard:
    image
  • New diagnostics page that shows tracking failures in depth
    image

I was also thinking about showing a box in the reporting toolbar, eg on the right... but then thought it may not be needed for now and might be rather annoying. May be good to first see how many false reports maybe come in etc.

I reckon it is a good working solution v1 for this tool and see from there how/where it goes. Heaps could be done there.

Todo: We should write FAQ articles for those 2 particular errors and adjust the links in the code

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Sep 28, 2018
@tsteur tsteur added this to the 3.7.0 milestone Sep 28, 2018
@mattab
Copy link
Member

mattab commented Oct 3, 2018

@tsteur just thought of another use case which occurs from time to time, if Matomo is in an unstable state, there may be columns missing, this happened to me regularly, such errors:

DEBUG: Exception: Error query: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'last_idlink_va' in 'field list' In query: SELECT visit_last_action_time, visit_first_action_time, idvisitor, idvisit, user_id, visit_exit_idaction_url, visit_exit_idaction_name, visitor_returning, visitor_days_since_first, visitor_days_since_order, visitor_count_visits, visit_goal_buyer, location_country, location_region, location_city, location_latitude, location_longitude, referer_name, referer_keyword, referer_type, idsite, visit_entry_idaction_url, visit_total_actions, visit_total_interactions, visit_total_searches, config_device_brand, config_device_model, config_device_type, visit_total_events, visit_total_time, location_ip, location_browser_lang, campaign_content, campaign_id, campaign_keyword, campaign_medium, campaign_name, campaign_source, last_idlink_va, custom_var_k1, custom_var_v1, custom_var_k2, custom_var_v2, custom_var_k3, custom_var_v3, custom_var_k4, custom_var_v4, custom_var_k5, custom_var_v5   FROM log_visit WHERE visit_last_action_time >= ? AND visit_last_action_time <= ? AND idsite = ? AND config_id = ?
DEBUG:                 ORDER BY visit_last_action_time DESC
DEBUG:                 LIMIT 1 Parameters: array (
DEBUG:   0 => '2018-10-03 05:21:30',
DEBUG:   1 => '2018-10-03 06:21:30',
DEBUG:   2 => 1,
DEBUG:   3 => '/ƫK����',
DEBUG: )

So it would be really great if we could detect these problems and also report them in the page 👍

@tsteur
Copy link
Member Author

tsteur commented Oct 3, 2018

Not really so much possible. Cause it was said it is not needed to support anything else and therefore it is not built to include metadata etc. If something like this is possible, it would be only possible to say a column was missing, but not which column or table etc.

throw new UnexpectedWebsiteFoundException('Invalid idSite: \'' . $idSite . '\'');
// we allow 0... the request will fail anyway as the site won't exist... allowing 0 will help us
// reporting this tracking problem as it is a common issue. Otherwise we would not be able to report
// this problem in tracking failures
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean the exception cannot be caught later? If so, could log the failure there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it would otherwise not be caught later. and logging wouldn't work as people wouldn't see the logged error. Like nobody would really look there and eg on cloud people wouldn't even be able to see the logs. We have heaps of logs like idsite=0 already and want to make users aware of this problem with this PR. It's really the most common tracking error.

Copy link
Member

Choose a reason for hiding this comment

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

I meant log through Failures::logFailure(), like catch in Tracker::main() and log that failure. But if it can't be caught then that's not an option I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

Catching it there wouldn't 100% work eg when using bulk request or queued tracking and eg one request contains idsite=0...

The tracker handler starts processing each tracking request within $handler->process in the Tracker.:track method... and basically the only way be to handle it otherwise in Tracker::trackRequest() but by then this error might have already occurred.

@diosmosis
Copy link
Member

Left some comments & need to resolve some conflicts. Haven't tested locally yet, will do so next review.

@tsteur
Copy link
Member Author

tsteur commented Nov 30, 2018

@diosmosis applied the review feedback and resolved the conflicts. I might need to update some UI tests...

@diosmosis
Copy link
Member

Left one further comment, but will probably merge this today. if my comment is important can be done in a new PR

@tsteur
Copy link
Member Author

tsteur commented Dec 1, 2018

@diosmosis just realising a feature to log not auth request regressed due to another PR... because isVisitExcluded seems to no longer work basically when CIP is set... be good to not merge.

@tsteur
Copy link
Member Author

tsteur commented Dec 1, 2018

@diosmosis just pushing a fix, and also fixing the failed system and ui tests with this commit

@diosmosis
Copy link
Member

Looks like there are some other test failures now? the novisit tests are failing (and possibly a unit test). Maybe some others too.

@tsteur
Copy link
Member Author

tsteur commented Dec 1, 2018

hoping to have fixed them @diosmosis will check the results tomorrow.

@tsteur
Copy link
Member Author

tsteur commented Dec 2, 2018

this was tricky... hopefully this time it fixes most or all of the tests :)

@mattab
Copy link
Member

mattab commented Dec 5, 2018

Will be very useful 👍

Not really so much possible. Cause it was said it is not needed to support anything else and therefore it is not built to include metadata etc. If something like this is possible, it would be only possible to say a column was missing, but not which column or table etc.

Would it be possible to catch these sql error cases, and report them as failures in this new tool's UI? (currently they may go un-detected for a few hours or days until someone realises tracking does not anymore)

@tsteur
Copy link
Member Author

tsteur commented Dec 5, 2018

No, at least not as part of 3.8 release.

@diosmosis
Copy link
Member

Almost working, looks like BulkTracking & QueuedTracking have some failing integration tests

@tsteur
Copy link
Member Author

tsteur commented Dec 6, 2018

@diosmosis fixed the bulk and queued tracking tests. Looks like MarketingCampaignsReporting isn't directly failing because of this change. Hopefully can be finally merged :)

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.

Report tracking into wrong Site ID
3 participants