MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / recordClick

Function recordClick

cli/src/hooks/use-gravity-ad.ts:232–259  ·  view source on GitHub ↗
(ad: AdResponse)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

getAuthTokenFunction · 0.90
getCliAdRequestUserAgentFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected