MCPcopy Create free account
hub / github.com/garrytan/gstack / parseJSONL

Function parseJSONL

scripts/analytics.ts:31–46  ·  view source on GitHub ↗
(content: string)

Source from the content-addressed store, hash-verified

29 * Parse JSONL content into AnalyticsEvent[], skipping malformed lines.
30 */
31export function parseJSONL(content: string): AnalyticsEvent[] {
32 const events: AnalyticsEvent[] = [];
33 for (const line of content.split('\n')) {
34 const trimmed = line.trim();
35 if (!trimmed) continue;
36 try {
37 const obj = JSON.parse(trimmed);
38 if (typeof obj === 'object' && obj !== null && typeof obj.ts === 'string') {
39 events.push(obj as AnalyticsEvent);
40 }
41 } catch {
42 // skip malformed lines
43 }
44 }
45 return events;
46}
47
48/**
49 * Filter events by period. Supports "7d", "30d", and "all".

Callers 3

runScriptFunction · 0.90
analytics.test.tsFile · 0.90
mainFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by 1

runScriptFunction · 0.72