Devlog: Automating Live-Ops with GA4, Gemini AI, and Zero-Trust Cloud Functions

TL;DR: Millennium Falck Enterprise has successfully automated the telemetry-to-insight pipeline for the iOS game Silly Con Valley. Using Google Analytics 4, Gemini 2.5 Flash, and Cloud Firestore, the system compiles weekly community play stats into a satirical VC newsletter delivered dynamically to players on launch—requiring zero manual maintenance.

Silly Con Valley is an iOS startup simulator game developed by Millennium Falck Enterprise. In our quest for absolute efficiency and peak corporate sarcasm, we automated our weekly live-ops dashboard update. Instead of manually writing satirical VC reports analyzing player metrics (e.g., explaining why a 62% bankruptcy rate is “bullish”), we built a fully serverless data aggregation and generation pipeline.

How does the automated Live-Ops pipeline work?

The system runs on a serverless loop that fetches telemetry, aggregates it, runs it through generative AI, and publishes it back to the client-side game interface. The architecture operates in four automated stages:

  • 1. Sunday Trigger: A Cloud Scheduler cron job invokes our Firebase Cloud Function weekly at midnight.
  • 2. Telemetry Retrieval: The function queries Google Analytics 4 (GA4) using @google-analytics/data to retrieve player metrics (CEO archetypes, average valuation, and bankruptcy ratios).
  • 3. Satirical Synthesis: The raw metrics are structured and passed to the Gemini 2.5 Flash API with a instructions to output a strict JSON payload containing a VC-style newsletter.
  • 4. Firestore Publish: The function writes the structured JSON report directly to Cloud Firestore under live_insights/report_[year]_w[week].

How is player telemetry safely collected and queryable?

We leverage Google Analytics 4 to track anonymized user sessions. Our Firebase Cloud Function aggregates specific gameplay events from the last 7 days:

  • game_started logs the chosen ceo_archetype (e.g., “The Hacker”, “The Trust Fund Kid”).
  • ipo_secured tracks the final company ipo_valuation.
  • game_over records the game outcome (e.g., “bankruptcy” vs “IPO”) to compute the community failure rate.

How does Gemini AI write the VC newsletters?

To prevent format leakage or client-side parsing failures, the Cloud Function uses the Node.js @google/genai SDK with a strict JSON schema enforced. Gemini 2.5 Flash receives the raw stats and returns a structured format:

{
  "title": "A satirical title mimicking VC thought-leadership publications",
  "summary": "A 2-sentence summary of the week's market status",
  "outlook": "A humorous, elitist VC analysis of player bankruptcy rates"
}

Why is the pipeline zero-trust?

By running the pipeline entirely within the Google Cloud ecosystem, we eliminated the need for hardcoded service account keys or .json credentials. The authentication is managed via Application Default Credentials (ADC). The Firebase Admin SDK automatically authenticates using the runtime environment’s IAM service account, which has read-only access to our GA4 property and write access to Firestore. External API keys (like the Gemini key) are stored and decrypted securely using Google Cloud Secret Manager.

How does the iOS client retrieve the live newsletter?

On app launch, the game’s Swift client fetches the latest insight document from Firestore using the LiveContentManager class:

func fetchMarketInsights() async throws -> [LiveMarketInsight] {
    let snapshot = try await Firestore.firestore().collection("live_insights").getDocuments()
    return snapshot.documents.compactMap { doc in
        try? doc.data(as: LiveMarketInsight.self)
    }
}

If the user is offline, the client gracefully falls back to a cached local plist. Online users receive an immediate, dynamically generated dashboard representing last week’s aggregate community play stats, operating at a maintenance cost of exactly $0.00.