* The #track() method takes in a unique custom-event name, and the * corresponding request url (or an array of request urls). One can call * #track() multiple times with different eventType name (order doesn't * matter) before #build() is called. * @param {string} eventType * @param {
(eventType, request)
| 158 | * @return {!CustomEventReporterBuilder} |
| 159 | */ |
| 160 | track(eventType, request) { |
| 161 | request = isArray(request) ? request : [request]; |
| 162 | devAssert( |
| 163 | !this.config_['triggers'][eventType], |
| 164 | 'customEventReporterBuilder should not track same eventType twice' |
| 165 | ); |
| 166 | const requestList = []; |
| 167 | for (let i = 0; i < request.length; i++) { |
| 168 | const requestName = `${eventType}-request-${i}`; |
| 169 | this.config_['requests'][requestName] = request[i]; |
| 170 | requestList.push(requestName); |
| 171 | } |
| 172 | this.config_['triggers'][eventType] = { |
| 173 | 'on': eventType, |
| 174 | 'request': requestList, |
| 175 | }; |
| 176 | return this; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Call the #build() method to build and get the CustomEventReporter instance. |
no test coverage detected