MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / patchView

Function patchView

apps/web/src/scripts/posthog/audit-microdollar-usage.ts:140–166  ·  view source on GitHub ↗
(view: DataWarehouseSavedQuery)

Source from the content-addressed store, hash-verified

138}
139
140async function patchView(view: DataWarehouseSavedQuery): Promise<void> {
141 if (!view.query) return;
142
143 const updatedQuery = {
144 ...view.query,
145 query: view.query.query.replace(SEARCH_REGEX, REPLACEMENT_TERM),
146 };
147
148 const url = `${POSTHOG_API_BASE}/api/environments/${PROJECT_ID}/warehouse_saved_queries/${view.id}`;
149 console.log(`\n🔄 Patching view "${view.name}" (ID: ${view.id})`);
150 console.log(` URL: ${url}`);
151 console.log(` History ID: ${view.latest_history_id}`);
152 console.log(` Old query: ${view.query.query}`);
153 console.log(` New query: ${updatedQuery.query}`);
154
155 const response = await fetchWithAuth(url, {
156 method: 'PATCH',
157 body: JSON.stringify({
158 query: updatedQuery,
159 edited_history_id: view.latest_history_id,
160 }),
161 });
162
163 const result = await response.json();
164 console.log(`✅ Successfully patched view "${view.name}"`);
165 console.log(` Response:`, JSON.stringify(result, null, 2));
166}
167
168async function patchInsight(insight: Insight): Promise<void> {
169 const updatedQuery = replaceInQuery(insight.query);

Callers 1

runFunction · 0.85

Calls 4

fetchWithAuthFunction · 0.70
replaceMethod · 0.65
logMethod · 0.65
jsonMethod · 0.65

Tested by

no test coverage detected