Skip to content

Instantly share code, notes, and snippets.

@shricodev
Created February 6, 2026 09:21
Show Gist options
  • Select an option

  • Save shricodev/51289b10a19ad0b91071b9c0b537801d to your computer and use it in GitHub Desktop.

Select an option

Save shricodev/51289b10a19ad0b91071b9c0b537801d to your computer and use it in GitHub Desktop.
Prompt - Test 2: Google Earth Simulation (with Composio) - Prompt

You are extending an existing Google Earth inspired web app called TerraView, built with Next.js (App Router), TypeScript, Tailwind CSS, and a 3D globe library.

The base application already implements:

  • A full 3D globe viewer with camera controls
  • Search via OpenStreetMap Nominatim
  • Pins, saved places, layers, and measurement tools
  • Clean app architecture with Zustand, dynamic imports, and localStorage persistence

Your task is to add authentication and PostHog analytics integration, using Composio to connect and manage PostHog. This is not optional or conceptual. It must be implemented end to end with real code.


1) High level goal

We want to:

  • Authenticate users
  • Track user activity with PostHog
  • Capture and store user location data
  • Visually display active users on the globe in real time or near real time

When someone opens TerraView:

  • They authenticate
  • Their session is tracked in PostHog
  • Their approximate location is captured
  • A visible marker representing that user appears on the globe UI

This should feel native to the product, not bolted on.


2) Authentication requirements

Implement authentication with a clean, production friendly approach.

Requirements:

  • Use a standard auth solution compatible with Next.js App Router
  • Support at least email based login
  • Auth state must be available client side and server side
  • Protect analytics and user location tracking behind authentication
  • Persist user session across reloads

Expose:

  • user.id
  • user.email or equivalent identifier

This identifier must be used consistently for PostHog tracking.


3) PostHog integration requirements

Integrate PostHog for analytics and user tracking.

Use Composio to set up and manage the PostHog connection. Do not bypass Composio. The model must rely on Composio tooling to interact with PostHog.

You should review and use the following Composio documentation to understand how tools and providers work:

PostHog requirements:

  • Initialize PostHog once per authenticated session

  • Identify users using their authenticated user ID

  • Track core events such as:

    • App loaded
    • User logged in
    • Globe interaction
    • Location update
  • Store user properties where appropriate

All PostHog keys must be loaded via environment variables.


4) User location tracking

We want to capture and visualize user locations.

Requirements:

  • Capture approximate user location using browser APIs
  • Fall back gracefully if location access is denied
  • Send location data to PostHog as an event or user property
  • Use latitude and longitude with reasonable precision

Do not aggressively poll location. Capture on:

  • Initial load
  • Meaningful movement or session refresh

5) Globe visualization of users

This is critical.

On the TerraView globe:

  • Display markers representing authenticated users
  • These markers come from PostHog tracked data
  • Each marker should represent a user location

UI requirements:

  • User markers must be visually distinct from saved pins
  • Hover or click reveals basic info such as user ID or anonymized label
  • Markers update when location data changes
  • The globe must remain performant with multiple users

You may assume a reasonable number of concurrent users.


6) Data flow expectations

The implementation should clearly show:

  • How auth ties into PostHog identify
  • How location events are sent to PostHog via Composio
  • How location data is queried or retrieved for display
  • How client and server responsibilities are separated

If polling or periodic refresh is required, implement it cleanly and efficiently.


7) Architecture and code quality

You must:

  • Follow the existing app structure
  • Add new files only where appropriate
  • Keep concerns separated
  • Use strong TypeScript typing everywhere
  • Avoid hacks or brittle shortcuts

Include:

  • lib/ utilities for PostHog and Composio
  • Clear initialization logic
  • Graceful error handling
  • Comments where logic is non obvious

8) Deliverables

When you respond, you must output:

  1. A clear explanation of how authentication, Composio, and PostHog are wired together
  2. New and modified files with full code blocks
  3. Environment variables required
  4. Any PostHog event schemas used
  5. Notes on limitations and next improvements

Do not use pseudocode for core logic. This must be runnable.

The final app should still run with:

  • npm install
  • npm run dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment