Skip to content

Plugin system for custom analyzers #2

@Ouranos27

Description

@Ouranos27

Problem

The engine ships 8 built-in analyzers (CSS compatibility, spam, accessibility, links, images, inbox preview, size, templates). But teams often have domain-specific rules:

  • Brand compliance (logo size, brand colors, approved fonts)
  • Internal link policies (no shortened URLs, require UTM params)
  • Regulatory requirements (GDPR footer, CAN-SPAM physical address)
  • Company-specific Outlook workarounds

Currently there's no way to extend auditEmail() with custom checks.

Proposal

Add a plugin/analyzer API that lets users register custom analyzers:

import { auditEmail, defineAnalyzer } from "@emailens/engine";

const brandCheck = defineAnalyzer({
  id: "brand-compliance",
  name: "Brand Compliance",
  analyze(html, $) {
    const warnings = [];
    // Check logo dimensions
    $("img[src*='logo']").each((_, el) => {
      const width = $(el).attr("width");
      if (!width || parseInt(width) < 200) {
        warnings.push({ severity: "error", message: "Logo must be at least 200px wide" });
      }
    });
    return { score: 100 - warnings.length * 10, warnings };
  },
});

const report = auditEmail(html, { plugins: [brandCheck] });
// report.plugins["brand-compliance"].score → 90

Design Considerations

  • Plugins receive the parsed Cheerio $ instance (already available internally)
  • Plugin results should follow the same { score, warnings } shape as built-in analyzers
  • Should support async analyzers (e.g., fetching remote brand config)
  • Plugin order shouldn't matter (analyzers are independent)

Context

On the roadmap. This would make the engine useful for teams with specific email standards beyond generic best practices.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions