Commit b22a7c028a558a0a416d48ccf66a044b7427ebad
1 parent
2617218b
empty dimension
Showing
1 changed file
with
9 additions
and
8 deletions
Show diff stats
app/library/App/Controllers/GaController.php
@@ -29,7 +29,7 @@ class GaController extends CrudResourceController { | @@ -29,7 +29,7 @@ class GaController extends CrudResourceController { | ||
29 | $get_metrics = $this->request->get('metric') ?? 'users'; | 29 | $get_metrics = $this->request->get('metric') ?? 'users'; |
30 | $get_start_date = $this->request->get('start') ?? '30daysAgo'; | 30 | $get_start_date = $this->request->get('start') ?? '30daysAgo'; |
31 | $get_end_date = $this->request->get('end') ?? 'today'; | 31 | $get_end_date = $this->request->get('end') ?? 'today'; |
32 | - $get_dimensions = $this->request->get('dimension') ?? 'browser'; | 32 | + $get_dimensions = $this->request->get('dimension'); |
33 | 33 | ||
34 | 34 | ||
35 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); | 35 | putenv('GOOGLE_APPLICATION_CREDENTIALS=/var/www/phalcon/'.self::SECRET_JSON); |
@@ -54,15 +54,16 @@ class GaController extends CrudResourceController { | @@ -54,15 +54,16 @@ class GaController extends CrudResourceController { | ||
54 | } | 54 | } |
55 | 55 | ||
56 | //Create the Dimensions object. | 56 | //Create the Dimensions object. |
57 | - $dimensions = []; | ||
58 | - $get_dimensions = explode(',', $get_dimensions); | ||
59 | - foreach ($get_dimensions as $dimension) { | ||
60 | - $dimension_obj = new Google_Service_AnalyticsReporting_Dimension(); | ||
61 | - $dimension_obj->setName("ga:".$dimension); | ||
62 | - $dimensions[] = $dimension_obj; | 57 | + if (!empty($get_dimensions)) { |
58 | + $dimensions = []; | ||
59 | + $get_dimensions = explode(',', $get_dimensions); | ||
60 | + foreach ($get_dimensions as $dimension) { | ||
61 | + $dimension_obj = new Google_Service_AnalyticsReporting_Dimension(); | ||
62 | + $dimension_obj->setName("ga:".$dimension); | ||
63 | + $dimensions[] = $dimension_obj; | ||
64 | + } | ||
63 | } | 65 | } |
64 | 66 | ||
65 | - | ||
66 | // Создание объекта ReportRequest. | 67 | // Создание объекта ReportRequest. |
67 | $request = new Google_Service_AnalyticsReporting_ReportRequest(); | 68 | $request = new Google_Service_AnalyticsReporting_ReportRequest(); |
68 | $request->setViewId($view_id); | 69 | $request->setViewId($view_id); |