( event: string, distinctId: string, properties: TelemetryProperties, )
| 99 | } |
| 100 | |
| 101 | function createTelemetryRequestBody( |
| 102 | event: string, |
| 103 | distinctId: string, |
| 104 | properties: TelemetryProperties, |
| 105 | ) { |
| 106 | const params = new URLSearchParams({ |
| 107 | cid: distinctId, |
| 108 | en: event, |
| 109 | tid: TELEMETRY_PROPERTY_ID, |
| 110 | v: '2', |
| 111 | }) |
| 112 | |
| 113 | for (const [key, value] of Object.entries(properties)) { |
| 114 | const normalizedValue = normalizeParamValue(value) |
| 115 | if (normalizedValue === undefined) { |
| 116 | continue |
| 117 | } |
| 118 | |
| 119 | const normalizedKey = normalizeParamKey(key) |
| 120 | const paramName = |
| 121 | typeof normalizedValue === 'number' |
| 122 | ? `${TELEMETRY_NUMERIC_PREFIX}${normalizedKey}` |
| 123 | : `${TELEMETRY_STRING_PREFIX}${normalizedKey}` |
| 124 | params.append(paramName, String(normalizedValue)) |
| 125 | } |
| 126 | |
| 127 | return params.toString() |
| 128 | } |
| 129 | |
| 130 | function getErrorCode(error: unknown) { |
| 131 | if (!error || typeof error !== 'object') { |
no test coverage detected