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.

  1. Declare google_analytics_reports as the module dependency instead of the api submodule
  2. 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

Comments

szeidler created an issue. See original summary.

szeidler’s picture

Status: Active » Needs review
StatusFileSize
new797 bytes

Here's a patch for approach 2.

szeidler’s picture

StatusFileSize
new791 bytes

Oops, that was the wrong hook. It should be fixed now.

  • saesa committed e7a258f on 7.x-1.x
    Issue #3035484 by szeidler: Charts shows wrong dates, when not having...
saesa’s picture

Status: Needs review » Fixed

Thanks for the patch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.