Problem/Motivation
If you enable only the module's dependency google_analytics_reports_api and not google_analytics_reports the dates beneath the cart are invalid. The reason is, that the dates coming from Google Analytics are not converted into a timestamp, but being processed with
$chart_date[] = date('d-m-y', $records['date']);
That leads to wrong dates.

It is working with google_analytics_reports enabled, because it's implementing hook_google_analytics_reports_api_reported_data_alter and converts dates from Google into timestamps.
Proposed resolution
I see two different ways to solve it.
- Declare
google_analytics_reportsas the module dependency instead of the api submodule - Implement
hook_google_analytics_reports_api_reported_data_alter()and convert the date into a timestamp
When using approach 2, we would need to check, if the date was already converted into an timestamp, because otherwise the data alteration would happen twice and fail, when having google_analytics_reports enabled.
This could be possibly done in a naive fashion, checking if the value not an integer.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | ga_node_reports-broken_dates-3035484-3.patch | 791 bytes | szeidler |
| Bildschirmfoto 2019-02-21 um 10.46.03.png | 47.29 KB | szeidler |
Comments
Comment #2
szeidlerHere's a patch for approach 2.
Comment #3
szeidlerOops, that was the wrong hook. It should be fixed now.
Comment #5
saesa commentedThanks for the patch.