• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
sunnyatlightswitch

sunnyatlightswitch

reddit-checker-for-analytics

Remix of sunnyatlightswitch/reddit-checker
Public
Like
reddit-checker-for-analytics
Home
Code
2
README.md
C
unified-reddit-monitor.ts
Branches
1
Pull requests
Remixes
History
Environment variables
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
/
Code
/
Search
README.md

Unified Reddit Monitor

A simplified, comprehensive Reddit monitoring system that consolidates all monitoring functionality into a single script with automated cron scheduling!

🚀 Features

  • Unified Monitoring: Single script handles all Reddit monitoring
  • Multiple Methods: Uses Reddit API with JSON and RSS fallbacks for reliability
  • Multi-Subreddit Support: Monitors 11 subreddits simultaneously
  • Dual Output: Email notifications and Notion database storage
  • Automated Scheduling: Runs on cron schedule for consistent monitoring
  • Manual Override: Can also be run manually when needed
  • Robust Error Handling: Continues monitoring even if some subreddits fail
  • Comprehensive Logging: Detailed console output for debugging

📁 Clean Project Structure

├── unified-reddit-monitor.ts  # 🎯 MAIN SCRIPT - Runs on cron schedule (CRON) ✅ READY
└── README.md                  # This file

All legacy files have been removed! The project now contains only the essential unified monitoring script.

🎯 How to Use

Automated Monitoring (Primary Usage) ✅ READY

The monitor runs automatically on a cron schedule. Set your preferred schedule in the Val Town web UI:

Recommended Schedules:

  • */30 * * * * - Every 30 minutes (active monitoring)
  • 0 * * * * - Every hour (balanced)
  • 0 */2 * * * - Every 2 hours (moderate)
  • 0 */4 * * * - Every 4 hours (conservative)
  • 0 9,21 * * * - Twice daily at 9 AM and 9 PM

Manual Override (Optional)

You can also run the monitor manually anytime by visiting the HTTP endpoint:

GET /unified-reddit-monitor.ts

Available Actions

GET /unified-reddit-monitor.ts?action=run      # Run the monitor (default)
GET /unified-reddit-monitor.ts?action=status   # Show current configuration
GET /unified-reddit-monitor.ts?action=reset    # Reset last checked timestamp
GET /unified-reddit-monitor.ts?action=help     # Show help information

⚙️ Configuration

Current Settings ✅ CONFIGURED

  • Subreddits: 11 subreddits monitored
    • r/lovable, r/AppBusiness, r/appdev, r/AppDevelopers
    • r/ChatGPTCoding, r/indiehackers, r/microsaas, r/replit
    • r/ReplitBuilders, r/vibecoding, r/ViralApps
  • Keywords:
    • Authentication: auth, authentication, login, user sessions
    • Monetization: stripe, subscriptions, monetization, paywall, feature gating
    • Analytics: analytics
    • Business: how do I make money with my app
  • Post Limit: 25 posts per subreddit per check
  • Notifications: Email notifications and Notion database storage enabled
  • Execution: Automated cron scheduling + manual override capability

Notion Database Setup 🔧 REQUIRED

To enable Notion integration, you need to:

  1. Create a Notion Database with these exact field names:

    • Title (Title field)
    • URL (URL field)
    • Subreddit (Text field)
    • Author (Text field)
    • Post Body (Text field)
    • Matched Keywords (Text field)
    • Date Found (Text field)
  2. Set Environment Variable: Add NOTION_DATABASE_ID environment variable in Val Town with your database ID

  3. Get Database ID: Copy the database ID from your Notion database URL (the long string after the last / and before any ?)

Reddit API Credentials ✅ CONFIGURED

  • Client ID: 151sZ8h5TaHVZGZZn0rOhA
  • Client Secret: rX_YGngVjaxRA3Y0F3STl2cuEmgHkQ

🔧 Usage

Primary Usage ✅ READY

Automated: The monitor runs automatically on your configured cron schedule.

Manual Override: Run the monitor manually anytime:

GET /unified-reddit-monitor.ts

Configuration Management

GET /unified-reddit-monitor.ts?action=status   # View current settings
GET /unified-reddit-monitor.ts?action=reset    # Reset last checked timestamp
GET /unified-reddit-monitor.ts?action=help     # Show help and usage

📱 Notifications & Storage ✅ CONFIGURED

When matches are found, the system will:

1. Send Email Notifications

  • Recipient: sunny@getlightswitch.com
  • Subject: 🚨 Unified Reddit Monitor Alert: X new matches in Y subreddits
  • Content: Formatted text with all post details
  • Format: Both plain text and HTML versions

2. Save to Notion Database

  • Fields Stored:
    • Title - Post title
    • URL - Full Reddit URL
    • Subreddit - Subreddit name (e.g., r/lovable)
    • Author - Reddit username (e.g., u/username)
    • Post Body - Content of the post
    • Matched Keywords - Comma-separated matched keywords
    • Date Found - Date when the match was discovered
  • Integration: Uses Notion API with secret key authentication

🔍 Monitoring Details

What Gets Monitored

  • Post Titles: Full text search for keywords across all 11 subreddits
  • Post Content: Self-text content of posts across all subreddits
  • Frequency: Automated cron execution + manual override capability
  • Scope: New posts since last check across all monitored subreddits
  • Methods: Reddit API (primary), JSON API (fallback), RSS feeds (last resort)

Keyword Matching ✅ TESTED

  • Case-insensitive matching
  • Partial word matching (e.g., "auth" matches "authentication")
  • Multiple keyword detection per post
  • Configurable keyword list

🛠️ Customization

To modify the configuration, edit the CONFIG object in unified-reddit-monitor.ts:

Adding New Keywords

const CONFIG: MonitorConfig = { keywords: [ 'auth', 'authentication', 'login', 'user sessions', 'stripe', 'subscriptions', 'monetization', 'paywall', 'feature gating', 'analytics', 'how do I make money with my app', 'YOUR_NEW_KEYWORD' // Add here ], // ... other settings };

Adding New Subreddits

const CONFIG: MonitorConfig = { subreddits: [ "lovable", "AppBusiness", "appdev", "AppDevelopers", "ChatGPTCoding", "indiehackers", "microsaas", "replit", "ReplitBuilders", "vibecoding", "ViralApps", "YOUR_NEW_SUBREDDIT" // Add here ], // ... other settings };

Adjusting Settings

const CONFIG: MonitorConfig = { postLimit: 50, // Check 50 posts per subreddit instead of 25 useEmail: false, // Enable/disable email notifications useNotion: true, // Enable/disable Notion database storage // ... other settings };

🔐 Security

  • Reddit API credentials are configured and working
  • Access tokens are cached and automatically refreshed
  • All API calls use proper authentication headers
  • Fallback methods ensure reliability even if primary API fails

✅ System Status

Current Status: FULLY OPERATIONAL - NOTION INTEGRATION ADDED

  • ✅ Single Script: One comprehensive monitoring script only
  • ✅ No Legacy Files: All unnecessary files removed
  • ✅ Notion Integration: Added Notion database storage for matches
  • ✅ Automated Scheduling: Runs consistently on cron schedule
  • ✅ Manual Override: Can still be run manually when needed
  • ✅ Multi-Method Fetching: Reddit API → JSON API → RSS fallbacks
  • ✅ Multi-Subreddit Support: 11 subreddits monitored simultaneously
  • ✅ Dual Output: Email notifications + Notion database storage
  • ✅ Robust Error Handling: Continues even if some subreddits fail
  • ✅ Comprehensive Logging: Detailed execution information

How to Use

  1. Set Cron Schedule: Configure your preferred schedule in Val Town web UI
  2. Monitor Automatically: The script runs on schedule and sends notifications
  3. Manual Override: Visit /unified-reddit-monitor.ts to run immediately
  4. Check Status: Use ?action=status to see current configuration
  5. Reset if Needed: Use ?action=reset to clear last checked timestamp
  6. Get Help: Use ?action=help for usage information

Clean Architecture

The project now contains only the essential unified monitoring script with email notifications and Notion database storage. All legacy files and test files have been removed for maximum simplicity and maintainability.

🐛 Troubleshooting

Common Issues

  1. No Recent Matches

    • Check if there are actually new posts with your keywords
    • Use ?action=status to see when last checked
    • Use ?action=reset to check all posts again
  2. API Errors

    • The script automatically falls back to JSON API then RSS
    • Check the response for detailed error information
  3. Notification Issues

    • Check spam folder for emails
    • Email notifications can be enabled/disabled in config
    • Verify Notion database ID is configured correctly

Debug Information

The unified script provides comprehensive logging:

  • Shows which method was used for each subreddit (API/JSON/RSS)
  • Reports errors per subreddit but continues with others
  • Provides detailed match information
  • Shows notification sending status

📊 Benefits of Notion-Integrated Monitoring

✅ Consistent Coverage: Never miss new posts with automated scheduling ✅ Hands-Free Operation: Set it once and let it run automatically
✅ Flexible Control: Manual override available when needed ✅ Organized Storage: All matches automatically saved to Notion database ✅ Easy Maintenance: One file to manage and update ✅ Reliable Operation: Multiple fallback methods with robust error handling ✅ Structured Data: Searchable and filterable posts in Notion

Cron
  • unified-reddit-monitor.ts
Code
README.md
C
unified-reddit-monitor.ts
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.