(ad: AdResponse)
| 230 | } |
| 231 | |
| 232 | const recordClick = (ad: AdResponse): void => { |
| 233 | const authToken = getAuthToken() |
| 234 | if (!authToken) { |
| 235 | logger.warn('[ads] No auth token, skipping ad click recording') |
| 236 | return |
| 237 | } |
| 238 | |
| 239 | void fetch(`${WEBSITE_URL}/api/v1/ads/click`, { |
| 240 | method: 'POST', |
| 241 | headers: { |
| 242 | 'Content-Type': 'application/json', |
| 243 | Authorization: `Bearer ${authToken}`, |
| 244 | 'User-Agent': getCliAdRequestUserAgent(), |
| 245 | }, |
| 246 | body: JSON.stringify({ impUrl: ad.impUrl, surface: surface ?? 'chat' }), |
| 247 | }) |
| 248 | .then((res) => { |
| 249 | if (!res.ok) { |
| 250 | logger.debug( |
| 251 | { status: res.status }, |
| 252 | '[ads] Failed to record ad click', |
| 253 | ) |
| 254 | } |
| 255 | }) |
| 256 | .catch((err) => { |
| 257 | logger.debug({ err }, '[ads] Failed to record ad click') |
| 258 | }) |
| 259 | } |
| 260 | |
| 261 | type FetchAdResult = { ads: AdResponse[] } | null |
| 262 |
nothing calls this directly
no test coverage detected