A comprehensive monitoring utility that checks the health of URLs in Salesforce AQUA ViolationGroup records. This tool queries all AQUA_ViolationGroup__c records and validates the health of Component_Screenshot_URL__c, HTML_Source__c, and Screenshot_URL__c fields.
- π Autonomous Operation: Runs without user prompts
- π Concurrent Processing: Checks multiple URLs simultaneously for faster execution
- π Retry Logic: Automatically retries failed requests with exponential backoff
- π Comprehensive Reporting: Generates console, JSON, and CSV reports
- π― Special URL Handling: Includes support for absctl URLs (HTML_Source__c)
- π§ Configurable: Customizable timeouts, retry attempts, and concurrency limits
- π¨ Rich Console Output: Color-coded results with detailed summaries
-
Clone or download the project
-
Install dependencies:
npm install
-
Set up environment configuration:
cp env.template .env
-
Configure your credentials in
.env:# Salesforce credentials (for SOQL queries) SF_USERNAME=your_salesforce_username SF_PASSWORD=your_salesforce_password SF_LOGIN_URL=https://gus--aquatest.sandbox.my.salesforce.com # Data store authentication is now FULLY AUTOMATED! # Just run: npm run monitor # No manual configuration needed!
- Node.js 16+ and npm
- Salesforce credentials with access to AQUA_ViolationGroup__c objects
- For HTML_Source__c URLs using absctl:
absctlcommand-line tool installed
If your HTML_Source__c fields contain URLs that require the absctl command:
# Check if absctl is installed
which absctl
# If not installed, follow your organization's instructions for installing absctlπ Fully Automated: The monitoring utility now automatically handles authentication!
- No manual
absctl auth:loginneeded - No manual cookie configuration required
- Authentication is checked and performed automatically when you run
npm run monitor
If you want to test the authentication setup separately:
# Test automated JWT token retrieval
npm run test-authThis will verify that:
absctlis installed and accessible- JWT token retrieval is working
- Token caching is functional
Note: This is optional since npm run monitor now handles authentication automatically.
The monitoring utility now automatically handles authentication:
# This will automatically:
# 1. Check if absctl is available
# 2. Verify if you're already authenticated
# 3. Run "absctl auth:login" if needed
# 4. Build and start the monitoring utility
npm run monitor
# Or run in development mode (without auto-auth)
npm run devWhat happens automatically:
- β
Checks if
absctlis installed - β Verifies existing authentication status
- β
Runs
absctl auth:loginonly if needed - β Handles interactive authentication prompts
- β Continues gracefully if authentication fails
You can customize the behavior using environment variables:
# Custom configuration
MAX_CONCURRENT_CHECKS=5 REQUEST_TIMEOUT_MS=60000 npm run monitor| Variable | Description | Default | Required |
|---|---|---|---|
SF_USERNAME |
Salesforce username | - | Yes |
SF_PASSWORD |
Salesforce password | - | Yes |
SF_LOGIN_URL |
Salesforce login URL | https://test.salesforce.com |
Yes |
USE_AUTO_AUTH |
Enable automatic JWT token retrieval via absctl | true |
No |
DATA_STORE_COOKIES |
[LEGACY] Manual cookie string for data store auth | - | Only if auto-auth disabled |
DATA_STORE_SESSION_ID |
[LEGACY] Alternative: just session ID | - | Only if auto-auth disabled |
MAX_CONCURRENT_CHECKS |
Maximum concurrent URL checks | 10 |
No |
REQUEST_TIMEOUT_MS |
Request timeout in milliseconds | 30000 |
No |
RETRY_ATTEMPTS |
Number of retry attempts for failed requests | 3 |
No |
GENERATE_JSON |
Generate JSON report | true |
No |
GENERATE_CSV |
Generate CSV report | true |
No |
OUTPUT_DIR |
Output directory for reports | ./ |
No |
# Salesforce Configuration (for SOQL queries)
SF_USERNAME=your_username@company.com
SF_PASSWORD=your_password
SF_LOGIN_URL=https://test.salesforce.com
# Data Store Authentication (AUTOMATED via absctl)
# Just run: absctl auth:login
# No manual configuration needed!
# Advanced: Disable auto-auth if you want to use manual cookies
# USE_AUTO_AUTH=false
# DATA_STORE_COOKIES="session=abc123; auth=xyz789; csrf=token123"
# Monitoring Configuration
MAX_CONCURRENT_CHECKS=10
REQUEST_TIMEOUT_MS=30000
RETRY_ATTEMPTS=3
# Output Configuration
GENERATE_JSON=true
GENERATE_CSV=true
OUTPUT_DIR=./reportsFor HTML_Source__c URLs that use absctl, authentication is now completely automated:
# Just run the monitoring utility - that's it!
npm run monitor
# The system will automatically:
# β
Check if you're already authenticated
# β
Run "absctl auth:login" if needed
# β
Handle interactive authentication prompts
# β
Retrieve JWT tokens using 'absctl auth:login --show'
# β
Handle token caching and refresh
# β
Retry with fresh tokens if authentication failsIf you need to disable auto-auth and use manual cookies:
- Set
USE_AUTO_AUTH=falsein your.envfile - Open your browser and navigate to your data store service
- Login to the service normally
- Open Developer Tools (F12)
- Go to Network tab and make any request
- Find a request in the list and click on it
- Look at Headers section and find
Cookie: - Copy the entire cookie string (everything after
Cookie:) - Paste it in your
.envfile asDATA_STORE_COOKIES
Example:
USE_AUTO_AUTH=false
DATA_STORE_COOKIES="sessionid=abc123xyz; csrftoken=def456; auth=ghi789"Real-time colored output with granular URL type segregation:
- Executive summary with health statistics
- π Granular URL breakdown (e.g., "3/18 component screenshot URLs are broken")
- URL type summary table
- Detailed results for broken/partial records
- π Quick summary with broken URLs by type
- Actionable recommendations with specific URL type information
Machine-readable report containing:
- Complete monitoring results with granular URL type statistics
- Detailed error information
- Response times and status codes
- Timestamp and summary statistics
Spreadsheet-compatible format with enhanced URL type information:
- One row per URL check with URL type display names
- Record information and URL details
- Status and error information
- URL type segregation for easy filtering
- Suitable for further analysis and reporting
Standard HTTP/HTTPS URLs pointing to component screenshots.
Standard HTTP/HTTPS URLs pointing to general screenshots.
Special handling for two types:
- Standard URLs: Regular HTTP/HTTPS links
- absctl URLs: URLs with
filenameandrunIDparameters that use theabsctlcommand
- Connect to Salesforce using provided credentials
- Query all AQUA_ViolationGroup__c records with at least one URL field populated
- Process records in batches to avoid overwhelming the system
- Check each URL with appropriate method:
- Standard HTTP HEAD requests for regular URLs
absctlcommand execution for special HTML_Source__c URLs
- Retry failed requests with exponential backoff
- Generate comprehensive reports with health analysis
- Healthy: All URLs in the record are working correctly
- Partial: Some URLs are working, some are broken
- Broken: No URLs are working or no URLs found
- Healthy: HTTP status 200-399 or successful absctl download
- Broken: HTTP status 400+, DNS resolution failure, timeout, or absctl failure
π AQUA ViolationGroup URL Monitoring Utility
=========================================
π§ Validating configuration...
β
Configuration validated successfully
π Initializing services...
π Connecting to Salesforce...
β
Successfully connected to Salesforce
π Starting monitoring process...
π Found 25 AQUA ViolationGroup records with URLs
π Processing 25 records...
π¦ Processing batch 1/3...
β
Processed AVG-001: healthy (3/3 URLs healthy)
β
Processed AVG-002: partial (2/3 URLs healthy)
β
Processed AVG-003: broken (0/2 URLs healthy)
β±οΈ Monitoring completed in 45.67 seconds
π Generating reports...
================================================================================
AQUA VIOLATIONGROUP URL MONITORING REPORT
================================================================================
π EXECUTIVE SUMMARY
--------------------------------------------------
βββββββββββββββββββββββββββ¬βββββββββββ¬ββββββββββββββββββ
β Metric β Count β Percentage β
βββββββββββββββββββββββββββΌβββββββββββΌββββββββββββββββββ€
β Total Records β 25 β 100.0% β
β Healthy Records β 18 β 72.0% β
β Partial Records β 5 β 20.0% β
β Broken Records β 2 β 8.0% β
βββββββββββββββββββββββββββ΄βββββββββββ΄ββββββββββββββββββ
π GRANULAR URL BREAKDOWN
--------------------------------------------------
β
Component Screenshot URLs: 15/18 healthy, 3 broken
β 3/18 component screenshot urls are broken (16.7%)
β οΈ HTML Source URLs: 12/15 healthy, 3 broken
β 3/15 html source urls are broken (20.0%)
β
Screenshot URLs: 20/22 healthy, 2 broken
β 2/22 screenshot urls are broken (9.1%)
π QUICK SUMMARY
--------------------------------------------------
π Overall URL Health: 47/55 healthy (85.5%)
β Total Broken URLs: 8 (14.5%)
Broken by Type:
β’ 3/18 Component Screenshot URLs
β’ 3/15 HTML Source URLs
β’ 2/22 Screenshot URLs
-
Salesforce Connection Failed
- Verify username and password
- Check login URL (sandbox vs production)
- Ensure user has permission to access AQUA_ViolationGroup__c
-
JWT Token Authentication Issues
- Not authenticated: Run
absctl auth:loginto authenticate - Token expired: The system will automatically refresh tokens, but you may need to re-authenticate
- absctl not found: Install absctl and ensure it's in your PATH
- Permission errors: Ensure your absctl user has proper permissions
- Test first: Run
npm run test-authto verify authentication setup
- Not authenticated: Run
-
absctl Command Not Found
- Install absctl following your organization's guidelines
- Verify absctl is in your PATH:
which absctl - Authenticate after installation:
absctl auth:login - The utility will continue with other URLs even if absctl is missing
-
Legacy Manual Cookie Issues
- If you disabled auto-auth (
USE_AUTO_AUTH=false), ensureDATA_STORE_COOKIESis set - Update cookies if you get 401/403 errors
- Consider re-enabling auto-auth for easier maintenance
- If you disabled auto-auth (
-
Timeout Errors
- Increase
REQUEST_TIMEOUT_MSfor slow networks - Reduce
MAX_CONCURRENT_CHECKSto be less aggressive - JWT token retrieval may take longer on first run
- Increase
-
Memory Issues
- Reduce
MAX_CONCURRENT_CHECKS - Monitor large datasets and consider filtering
- Reduce
src/
βββ index.ts # Main application entry point
βββ types.ts # TypeScript type definitions
βββ config.ts # Configuration management
βββ salesforce.ts # Salesforce API integration
βββ url-checker.ts # URL health checking logic
βββ monitor.ts # Main monitoring orchestration
βββ reporter.ts # Report generation
# Build the project
npm run build
# Run built version
npm startnpm run build- Compile TypeScript to JavaScriptnpm start- Run the compiled applicationnpm run dev- Run in development mode with ts-nodenpm run monitor- Auto-authenticate and run the monitoring utilitynpm run pre-monitor- Just run the authentication setup (without monitoring)npm run test-auth- Test automated JWT token authentication
ISC License
For issues or questions:
- Check the troubleshooting section
- Review the logs for detailed error messages
- Ensure your environment configuration is correct
- Verify network connectivity and permissions