Skip to content

3.2.0: Merge pull request #323 from rajnandan1/feature/optimize-1

Latest
Compare
Choose a tag to compare
@rajnandan1 rajnandan1 released this 27 Feb 05:29
· 1 commit to main since this release
87f2c33

v3.2.0

🚀

Features

  • Improved Monitor Evaluation Functions

    • Replaced unsafe eval() with secure Function() constructors across all monitor types
    • Added support for using modules (like cheerio) directly in evaluation functions
  • Enhanced API Monitors

    • Raw response data is now passed directly to eval functions instead of base64 encoded
    • Added modules parameter with access to cheerio for HTML parsing
    • Updated default evaluation function to use the new parameter structure
  • Improved TCP & Ping Monitors

    • Simplified evaluation functions with direct access to ping/TCP data
    • Removed unnecessary base64 encoding/decoding steps
    • Better error handling for invalid evaluation functions
  • Documentation Updates

    • Updated all examples and documentation for the new evaluation function signatures
    • Added more detailed explanations of input parameters
    • Improved examples showing usage with the new parameter structure

Breaking Changes

  • Monitor Evaluation Functions
    • Custom evaluation functions will need to be updated to the new parameter structure
    • API monitors: (statusCode, responseTime, responseRaw, modules) instead of (statusCode, responseTime, responseDataBase64)
    • TCP/Ping monitors: (arrayOfPings) instead of (responseDataBase64)

Fixes

  • Fixed "cheerio is undefined" errors in API monitor evaluations
  • Improved error handling and logging for monitor evaluation failures
  • Security enhancements by removing eval() usage

Migration

If you're using custom evaluation functions in your monitors, you'll need to update them to the new format:

API Monitors

// Old format
(async function (statusCode, responseTime, responseDataBase64) {
    const resp = atob(responseDataBase64)
    // Your logic here
})
// New format
(async function (statusCode, responseTime, responseRaw, modules) {
    // responseRaw is the direct response - no need to decode
    // Access cheerio with modules.cheerio
    // Your logic here
})

TCP/Ping Monitors

// Old format
(async function (responseDataBase64) {
    let arrayOfPings = JSON.parse(atob(responseDataBase64))
    // Your logic here
})
// New format
(async function (arrayOfPings) {
    // arrayOfPings is directly available - no need to decode
    // Your logic here
})