Skip to content

Commit 854d52e

Browse files
committed
Merge pull request #2 from philipwalton/add-src-param
Add a _src param to all API requests.
2 parents 1787c7a + 1d83aba commit 854d52e

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

google-analytics-chart.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@
9494
*/
9595
options: null,
9696

97-
output: 'dataTable',
98-
9997
data: null,
10098

10199
publish: {
@@ -138,6 +136,11 @@
138136
}
139137
},
140138

139+
beforeQuerySend: function(query) {
140+
query.output = 'dataTable';
141+
query._src = 'gwc-ga-chart';
142+
},
143+
141144
handleResponse: function(response) {
142145
if (response.error) {
143146
this.fire('analytics-query-error', response.error);
@@ -164,7 +167,10 @@
164167
function queryMetadataAPI() {
165168
return new Promise(function(resolve, reject) {
166169
gapi.client.analytics.metadata.columns
167-
.list({reportType:'ga'})
170+
.list({
171+
reportType: 'ga',
172+
_src: 'gwc-ga-chart'
173+
})
168174
.execute(function(response) {
169175
if (response.error) {
170176
reject(response.error);

google-analytics-query.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@
262262
if (this.output) query.output = this.output;
263263
if (this.fields) query.fields = this.fields;
264264

265+
this.beforeQuerySend(query);
266+
265267
gapi.client.analytics.data.ga.get(query)
266268
.execute(this.handleResponse.bind(this));
267269

@@ -285,6 +287,18 @@
285287
}
286288
},
287289

290+
/**
291+
* A hook to alter the query params object (if needed) before
292+
* the request is made. This method allows subclasses to change the
293+
* request without overriding the entire `getData` method.
294+
*
295+
* @method beforeQuerySend
296+
* @param {Object} query - The query params object.
297+
*/
298+
beforeQuerySend: function(query) {
299+
query._src = 'gwt-ga-query';
300+
},
301+
288302
get hasRequiredParams() {
289303
return !!(this.ids && this.metrics && this.startDate && this.endDate);
290304
},

google-analytics-view-selector.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@
230230
var summaries = [];
231231
function makeRequest(startIndex) {
232232
gapi.client.analytics.management.accountSummaries
233-
.list({'start-index': startIndex || 1})
233+
.list({
234+
'start-index': startIndex || 1,
235+
'_src': 'gwc-ga-view-selector'
236+
})
234237
.execute(ensureComplete);
235238
}
236239
function ensureComplete(resp) {

0 commit comments

Comments
 (0)