MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / fetchAndStoreGroveConfig

Function fetchAndStoreGroveConfig

source code/services/api/grove.ts:200–227  ·  view source on GitHub ↗

* Fetch Grove config from API and store in cache

(accountId: string)

Source from the content-addressed store, hash-verified

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