MCPcopy Index your code
hub / github.com/codeaashu/claude-code / fetchAndStoreGroveConfig

Function fetchAndStoreGroveConfig

src/services/api/grove.ts:198–225  ·  view source on GitHub ↗

* Fetch Grove config from API and store in cache

(accountId: string)

Source from the content-addressed store, hash-verified

196 * Fetch Grove config from API and store in cache
197 */
198async function fetchAndStoreGroveConfig(accountId: string): Promise<void> {
199 try {
200 const result = await getGroveNoticeConfig()
201 if (!result.success) {
202 return
203 }
204 const groveEnabled = result.data.grove_enabled
205 const cachedEntry = getGlobalConfig().groveConfigCache?.[accountId]
206 if (
207 cachedEntry?.grove_enabled === groveEnabled &&
208 Date.now() - cachedEntry.timestamp <= GROVE_CACHE_EXPIRATION_MS
209 ) {
210 return
211 }
212 saveGlobalConfig(current => ({
213 ...current,
214 groveConfigCache: {
215 ...current.groveConfigCache,
216 [accountId]: {
217 grove_enabled: groveEnabled,
218 timestamp: Date.now(),
219 },
220 },
221 }))
222 } catch (err) {
223 logForDebugging(`Grove: Failed to fetch and store config: ${err}`)
224 }
225}
226
227/**
228 * Get Grove Statsig configuration from the API.

Callers 1

isQualifiedForGroveFunction · 0.85

Calls 3

getGlobalConfigFunction · 0.85
saveGlobalConfigFunction · 0.85
logForDebuggingFunction · 0.85

Tested by

no test coverage detected