(
eventName: E,
measures?: Record<string, number>,
properties?: P[E],
ex?: Error
)
| 163 | > = P[E] extends TelemetryEventInfo<infer R> ? PickType<UnionToIntersection<R>, number> : undefined; |
| 164 | |
| 165 | function sendTelemetryEventInternal<P extends IEventNamePropertyMapping, E extends keyof P>( |
| 166 | eventName: E, |
| 167 | measures?: Record<string, number>, |
| 168 | properties?: P[E], |
| 169 | ex?: Error |
| 170 | ) { |
| 171 | const reporter = getTelemetryReporter(); |
| 172 | let customProperties: Record<string, string> = {}; |
| 173 | let eventNameSent = eventName as string; |
| 174 | |
| 175 | if (ex) { |
| 176 | // Include a property failed, to indicate there are errors. |
| 177 | // Lets pay the price for better data. |
| 178 | customProperties = {}; |
| 179 | // Add shared properties to telemetry props (we may overwrite existing ones). |
| 180 | Object.assign(customProperties, sharedProperties); |
| 181 | Object.assign(customProperties, properties || {}); |
| 182 | populateTelemetryWithErrorInfo(customProperties, ex) |
| 183 | .then(() => { |
| 184 | customProperties = sanitizeProperties(eventNameSent, customProperties); |
| 185 | reporter.sendTelemetryEvent(eventNameSent, customProperties, measures); |
| 186 | }) |
| 187 | .catch(noop); |
| 188 | } else { |
| 189 | if (properties) { |
| 190 | customProperties = sanitizeProperties(eventNameSent, properties); |
| 191 | } |
| 192 | |
| 193 | // Add shared properties to telemetry props (we may overwrite existing ones). |
| 194 | Object.assign(customProperties, sharedProperties); |
| 195 | if (isPerfMeasurementOnCI(eventNameSent)) { |
| 196 | reporter.sendDangerousTelemetryEvent(eventNameSent, customProperties, measures); |
| 197 | } else { |
| 198 | reporter.sendTelemetryEvent(eventNameSent, customProperties, measures); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | // Type-parameterized form of MethodDecorator in lib.es5.d.ts. |
| 204 | type TypedMethodDescriptor<T> = ( |
no test coverage detected