FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
lightweight
lightweightglimpse2-runbook-view-glimpse-save-login-react
Remix of lightweight/glimpse2-runbook-view-glimpse-save-login
Public
Like
glimpse2-runbook-view-glimpse-save-login-react
Home
Code
8
_townie
13
backend
7
frontend
9
shared
3
.vtignore
README.md
deno.json
H
main.tsx
Branches
2
Pull requests
Remixes
History
Environment variables
6
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
backend
/
crons
/
README.md
Code
/
backend
/
crons
/
README.md
Search
…
README.md

Crons

Scheduled task handlers for automated system maintenance.

Available Crons

cleanup-viewing.ts

  • Purpose: Cleans up stale viewing sessions that haven't received heartbeat updates
  • Schedule: Every minute
  • Threshold: Sessions older than 60 seconds without heartbeat updates
  • Function: Marks stale sessions as not viewing and syncs to Notion

How Viewing Sessions Work:

The viewing system tracks user sessions through periodic heartbeat updates:

  1. Active Tracking: While users view pages, the frontend sends heartbeat updates every 10 seconds
  2. Session Detection: Sessions are considered active when they have recent heartbeat updates
  3. Stale Session Cleanup: This cron identifies sessions without heartbeats for 60+ seconds and marks them as inactive

Processing Flow:

  1. Lists all viewing blobs with prefix glimpse--viewing--
  2. Checks each blob's lastUpdate timestamp
  3. Identifies sessions where:
    • sessionStart is not null (marked as actively viewing)
    • lastUpdate is older than 60 seconds (no recent heartbeat)
  4. Updates blob: sets sessionStart to null, updates lastUpdate
  5. Syncs to Notion: Sets "Session start" property to null
  6. Logs cleanup statistics and any errors

cleanup-agent.ts

  • Purpose: Cleans up orphaned agent blobs
  • Schedule: Every minute
  • Function: Deletes agent blobs where the agent ID doesn't match the demo's "Glimpse agents" relation in Notion
  • Read-Only Notion: Only reads Notion data, never modifies it
  • Blob Cleanup: Removes mismatched/orphaned blobs to keep storage synchronized with Notion

Configuration

Cron schedules are managed through the Val Town web interface. Click on each cron file to modify its schedule as needed.

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.