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.

ARC Variation Status Tracker

Monitors the status of multiple variations via the ARC Research Office API.

Features

  • Multi-ID Tracking: Monitors an unlimited number of variation IDs simultaneously.
  • Smart Notifications: Bundles all detected status changes into a single, clean email (including your custom descriptions) to prevent inbox spam.
  • State Management: Uses Val Town's standard SQLite database for robust, permanent storage of your variation IDs and their last known statuses.
  • OPSEC-Friendly Scheduling: Uses a time-zone-aware gatekeeper script driven by environment variables to handle Daylight Saving Time (DST) and mask operational schedules.

Setup Instructions

1. Remix this Project

  1. Remix this Project in Val Town to create your own private copy.
  2. Note the two main files in your project sidebar: the setup script (e.g., init-db.ts) and the daily tracker (main.ts).

2. Configure Environment Variables

Navigate to your Val Town Settings -> Environment Variables (Secrets) and add the following keys.

Required Variables

VariableDescriptionExample
ARC_API_KEYYour private ARC API key.00000000-0000-0000...

Optional Operational Schedule Variables

If left unset, the script will default to running 24/7.

VariableDescriptionExample
TRACKING_TIMEZONEYour local time zone (IANA format) to handle DST automatically.Australia/Melbourne
TRACKING_START_HOURThe hour to begin tracking (24-hour format).9
TRACKING_END_HOURThe hour to stop tracking (24-hour format).17
TRACKING_WORK_DAYSComma-separated days of the week to run (0=Sun, 1=Mon... 6=Sat).1,2,3,4,5

3. Initialize the Database

  1. Open your setup script (e.g., init-db.ts).
  2. Click the Run button manually exactly one time.
  3. Check the console log at the bottom of the screen to confirm the tracked_variations table was created successfully.

4. Add Your Variations

  1. Navigate to the SQLite tab on the left sidebar in your Val Town workspace.
  2. Click on the tracked_variations table.
  3. Manually add a row for each grant you want to track:
    • Enter the variation_id (e.g., 1234567).
    • Enter a custom description (e.g., End of Year Correction).
    • Note: You can safely leave added_at blank (NULL). The main tracking script will automatically stamp the correct date and time for you when it first runs.

5. Schedule the Tracker

  1. Open main.ts.
  2. Ensure the trigger at the top is set to Scheduled (Cron).
  3. Set the schedule to run every 30 minutes using the cron expression: */30 * * * *

How It Works

  1. Trigger: Val Town runs main.ts every 30 minutes.
  2. Gatekeeper: The script checks the current time against your hidden TRACKING_TIMEZONE and schedule. If outside configured business hours, it quietly exits.
  3. Fetch: It queries your SQLite database to retrieve all active variation IDs and their custom descriptions.
  4. Compare: It pings the ARC API for each ID and compares the live response against the last_status saved in the database.
  5. Notify & Update: If differences are found, it sends a single bundled email to the Val Town account owner and updates the SQLite database with the new statuses.