kenobi | 85339df8 | 2015-02-13 00:15:25 | [diff] [blame] | 1 | // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | var goog = {}; |
| 6 | goog.async = {}; |
| 7 | |
| 8 | /** |
kenobi | 70c5800 | 2015-03-11 14:51:37 | [diff] [blame] | 9 | * @constructor |
kenobi | 85339df8 | 2015-02-13 00:15:25 | [diff] [blame] | 10 | * @template VALUE |
| 11 | */ |
| 12 | goog.async.Deferred; |
| 13 | |
| 14 | /** |
| 15 | * @param {!function(this:T,VALUE):?} cb |
| 16 | * @param {T=} opt_scope |
| 17 | * @return {!goog.async.Deferred} |
| 18 | * @template T |
| 19 | */ |
| 20 | goog.async.Deferred.prototype.addCallback; |
| 21 | |
kenobi | 70c5800 | 2015-03-11 14:51:37 | [diff] [blame] | 22 | /** @param {VALUE=} opt_result */ |
kenobi | f7dd25c | 2015-03-10 17:02:51 | [diff] [blame] | 23 | goog.async.Deferred.prototype.callback; |
| 24 | |
| 25 | /** |
kenobi | 70c5800 | 2015-03-11 14:51:37 | [diff] [blame] | 26 | * @param {?(function(this:THIS, VALUE): |
kenobi | f7dd25c | 2015-03-10 17:02:51 | [diff] [blame] | 27 | * (RESULT|IThenable<RESULT>|Thenable))=} opt_onFulfilled |
| 28 | * @param {?(function(this:THIS, *): *)=} opt_onRejected |
| 29 | * @param {THIS=} opt_context |
kenobi | 70c5800 | 2015-03-11 14:51:37 | [diff] [blame] | 30 | * @return {!Promise<RESULT>} |
kenobi | f7dd25c | 2015-03-10 17:02:51 | [diff] [blame] | 31 | * @template RESULT,THIS |
| 32 | */ |
| 33 | goog.async.Deferred.prototype.then; |
| 34 | |
kenobi | 85339df8 | 2015-02-13 00:15:25 | [diff] [blame] | 35 | var analytics = {}; |
| 36 | |
| 37 | /** @typedef {string} */ |
| 38 | analytics.HitType; |
| 39 | |
| 40 | /** @enum {analytics.HitType} */ |
| 41 | analytics.HitTypes = { |
| 42 | APPVIEW: 'appview', |
| 43 | EVENT: 'event', |
| 44 | SOCIAL: 'social', |
| 45 | TRANSACTION: 'transaction', |
| 46 | ITEM: 'item', |
| 47 | TIMING: 'timing', |
| 48 | EXCEPTION: 'exception' |
| 49 | }; |
| 50 | |
| 51 | /** |
| 52 | * @typedef {{ |
| 53 | * id: string, |
| 54 | * name: string, |
| 55 | * valueType: analytics.ValueType, |
| 56 | * maxLength: (number|undefined), |
| 57 | * defaultValue: (string|undefined) |
| 58 | * }} |
| 59 | */ |
| 60 | analytics.Parameter; |
| 61 | |
| 62 | /** @typedef {string|number|boolean} */ |
| 63 | analytics.Value; |
| 64 | |
| 65 | /** @typedef {string} */ |
| 66 | analytics.ValueType; |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * @param {string} appName |
| 71 | * @param {string=} opt_appVersion |
| 72 | * @return {!analytics.GoogleAnalytics} |
| 73 | */ |
| 74 | analytics.getService; |
| 75 | |
| 76 | |
| 77 | /** @interface */ |
| 78 | analytics.GoogleAnalytics; |
| 79 | |
| 80 | /** |
| 81 | * @param {string} trackingId |
| 82 | * @return {!analytics.Tracker} |
| 83 | */ |
| 84 | analytics.GoogleAnalytics.prototype.getTracker; |
| 85 | |
| 86 | /** @return {!goog.async.Deferred.<!analytics.Config>} */ |
| 87 | analytics.GoogleAnalytics.prototype.getConfig; |
| 88 | |
| 89 | |
| 90 | /** @interface */ |
| 91 | analytics.Tracker; |
| 92 | |
| 93 | /** @typedef {function(!analytics.Tracker.Hit)} */ |
| 94 | analytics.Tracker.Filter; |
| 95 | |
| 96 | /** |
| 97 | * @param {!analytics.HitType|!analytics.EventBuilder} hitType |
| 98 | * @param {(!analytics.ParameterMap| |
| 99 | * !Object.<string, !analytics.Value>)=} opt_extraParams |
| 100 | * @return {!goog.async.Deferred} |
| 101 | */ |
| 102 | analytics.Tracker.prototype.send; |
| 103 | |
| 104 | /** |
| 105 | * @param {string} description |
| 106 | * @return {!goog.async.Deferred} |
| 107 | */ |
| 108 | analytics.Tracker.prototype.sendAppView; |
| 109 | |
| 110 | /** |
| 111 | * @param {string} category |
| 112 | * @param {string} action |
| 113 | * @param {string=} opt_label |
| 114 | * @param {number=} opt_value |
| 115 | * @return {!goog.async.Deferred} |
| 116 | */ |
| 117 | analytics.Tracker.prototype.sendEvent; |
| 118 | |
| 119 | /** |
| 120 | * @param {string} network Specifies the social network, for example Facebook |
| 121 | * or Google Plus. |
| 122 | * @param {string} action Specifies the social interaction action. |
| 123 | * For example on Google Plus when a user clicks the +1 button, |
| 124 | * the social action is 'plus'. |
| 125 | * @param {string} target Specifies the target of a social interaction. |
| 126 | * This value is typically a URL but can be any text. |
| 127 | * @return {!goog.async.Deferred} |
| 128 | */ |
| 129 | analytics.Tracker.prototype.sendSocial; |
| 130 | |
| 131 | /** |
| 132 | * @param {string=} opt_description Specifies the description of an exception. |
| 133 | * @param {boolean=} opt_fatal Was the exception fatal. |
| 134 | * @return {!goog.async.Deferred} |
| 135 | */ |
| 136 | analytics.Tracker.prototype.sendException; |
| 137 | |
| 138 | /** |
| 139 | * @param {string} category Specifies the category of the timing. |
| 140 | * @param {string} variable Specifies the variable name of the timing. |
| 141 | * @param {number} value Specifies the value of the timing. |
| 142 | * @param {string=} opt_label Specifies the optional label of the timing. |
| 143 | * @param {number=} opt_sampleRate |
| 144 | * @return {!goog.async.Deferred} |
| 145 | */ |
| 146 | analytics.Tracker.prototype.sendTiming; |
| 147 | |
| 148 | analytics.Tracker.prototype.forceSessionStart; |
| 149 | |
| 150 | /** |
| 151 | * @param {string} category |
| 152 | * @param {string} variable |
| 153 | * @param {string=} opt_label |
| 154 | * @param {number=} opt_sampleRate |
| 155 | * @return {!analytics.Tracker.Timing} |
| 156 | */ |
| 157 | analytics.Tracker.prototype.startTiming; |
| 158 | |
| 159 | /** @interface */ |
| 160 | analytics.Tracker.Timing; |
| 161 | |
| 162 | /** @return {!goog.async.Deferred} */ |
| 163 | analytics.Tracker.Timing.prototype.send; |
| 164 | |
| 165 | /** @param {!analytics.Tracker.Filter} filter */ |
| 166 | analytics.Tracker.prototype.addFilter; |
| 167 | |
| 168 | /** @interface */ |
| 169 | analytics.Tracker.Hit; |
| 170 | |
| 171 | /** @return {!analytics.HitType} */ |
| 172 | analytics.Tracker.Hit.prototype.getHitType; |
| 173 | |
| 174 | /** @return {!analytics.ParameterMap} */ |
| 175 | analytics.Tracker.Hit.prototype.getParameters; |
| 176 | |
| 177 | analytics.Tracker.Hit.prototype.cancel; |
| 178 | |
| 179 | |
| 180 | /** @interface */ |
| 181 | analytics.Config = function() {}; |
| 182 | |
| 183 | /** @param {boolean} permitted */ |
| 184 | analytics.Config.prototype.setTrackingPermitted; |
| 185 | |
| 186 | /** @return {boolean} */ |
| 187 | analytics.Config.prototype.isTrackingPermitted; |
| 188 | |
| 189 | /** @param {number} sampleRate */ |
| 190 | analytics.Config.prototype.setSampleRate; |
| 191 | |
kenobi | f7dd25c | 2015-03-10 17:02:51 | [diff] [blame] | 192 | /** @return {!goog.async.Deferred} Settles once the id has been reset. */ |
| 193 | analytics.Config.prototype.resetUserId; |
| 194 | |
kenobi | 85339df8 | 2015-02-13 00:15:25 | [diff] [blame] | 195 | |
| 196 | /** @interface */ |
| 197 | analytics.ParameterMap; |
| 198 | |
| 199 | /** |
| 200 | * @typedef {{ |
| 201 | * key: !analytics.Parameter, |
| 202 | * value: !analytics.Value |
| 203 | * }} |
| 204 | */ |
| 205 | analytics.ParameterMap.Entry; |
| 206 | |
| 207 | /** |
| 208 | * @param {!analytics.Parameter} param |
| 209 | * @param {!analytics.Value} value |
| 210 | */ |
| 211 | analytics.ParameterMap.prototype.set; |
| 212 | |
| 213 | /** |
| 214 | * @param {!analytics.Parameter} param |
| 215 | * @return {?analytics.Value} |
| 216 | */ |
| 217 | analytics.ParameterMap.prototype.get; |
| 218 | |
| 219 | /** @param {!analytics.Parameter} param */ |
| 220 | analytics.ParameterMap.prototype.remove; |
| 221 | |
| 222 | /** @return {!Object.<string, analytics.Value>} */ |
| 223 | analytics.ParameterMap.prototype.toObject; |
| 224 | |
| 225 | |
| 226 | /** @interface */ |
| 227 | analytics.EventBuilder; |
| 228 | |
| 229 | /** @typedef {{ index: number, value: string }} */ |
| 230 | analytics.EventBuilder.Dimension; |
| 231 | |
| 232 | /** @typedef {{ index: number, value: number }} */ |
| 233 | analytics.EventBuilder.Metric; |
| 234 | |
| 235 | /** @return {!analytics.EventBuilder} */ |
| 236 | analytics.EventBuilder.builder; |
| 237 | |
| 238 | /** |
| 239 | * @param {string} category |
| 240 | * @return {!analytics.EventBuilder} |
| 241 | */ |
| 242 | analytics.EventBuilder.prototype.category; |
| 243 | |
| 244 | /** |
| 245 | * @param {string} action |
| 246 | * @return {!analytics.EventBuilder} |
| 247 | */ |
| 248 | analytics.EventBuilder.prototype.action; |
| 249 | |
| 250 | /** |
| 251 | * @param {string} label |
| 252 | * @return {!analytics.EventBuilder} |
| 253 | */ |
| 254 | analytics.EventBuilder.prototype.label; |
| 255 | |
| 256 | /** |
| 257 | * @param {number} value |
| 258 | * @return {!analytics.EventBuilder} |
| 259 | */ |
| 260 | analytics.EventBuilder.prototype.value; |
| 261 | |
| 262 | /** |
| 263 | * @param {!analytics.EventBuilder.Dimension} dimension |
| 264 | * @return {!analytics.EventBuilder} |
| 265 | */ |
| 266 | analytics.EventBuilder.prototype.dimension; |
| 267 | |
| 268 | /** |
| 269 | * @param {!analytics.EventBuilder.Metric} metric |
| 270 | * @return {!analytics.EventBuilder} |
| 271 | */ |
| 272 | analytics.EventBuilder.prototype.metric; |
| 273 | |
| 274 | /** |
| 275 | * @param {!analytics.Tracker} tracker |
| 276 | * @return {!goog.async.Deferred} |
| 277 | */ |
| 278 | analytics.EventBuilder.prototype.send; |
| 279 | |
| 280 | /** @param {!analytics.ParameterMap} parameters */ |
| 281 | analytics.EventBuilder.prototype.collect; |