docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a utility that generates responsive email templates with embedded tracking attributes for analytics and testing purposes.
Your utility should generate an MJML-based email template that includes multiple content sections (hero, features, call-to-action). The generated HTML must include custom data attributes on specific elements to enable analytics tracking without modifying the visual structure.
Create a function generateTrackedEmail(config) that:
data-track-id, data-analytics-type, data-test-id) into the rendered HTML elements using CSS selectorsThe configuration object should support:
trackingId: A unique identifier for the email campaignsections: An array of content sections (each with title, description, and selector)attributeMappings: Mappings of CSS selectors to attribute key-value pairs that should be injectedThe generated HTML should:
/**
* Generates a tracked email template with analytics attributes
*
* @param {Object} config - Configuration object
* @param {string} config.trackingId - Unique tracking identifier
* @param {Array} config.sections - Content sections for the email
* @param {Object} config.attributeMappings - CSS selector to attribute mappings
* @returns {string} Compiled HTML email with injected tracking attributes
*/
function generateTrackedEmail(config) {
// IMPLEMENTATION HERE
}
module.exports = { generateTrackedEmail };Provides email template compilation and HTML generation support.