docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
{
"context": "This evaluation assesses how well the engineer implements automatic Google Analytics script loading functionality, focusing on proper script injection, duplicate detection mechanisms, and client-side execution handling as demonstrated in the @nuxtjs/google-analytics package.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Script injection",
"description": "Creates and injects a script tag dynamically into the document (typically using document.createElement('script') and document.head.appendChild or similar DOM manipulation) to load the Google Analytics library from the appropriate CDN (e.g., https://www.google-analytics.com/analytics.js or similar GA3 URL).",
"max_score": 25
},
{
"name": "Tracking ID usage",
"description": "Correctly uses the provided tracking ID from the configuration object (config.id) to initialize Google Analytics, typically by setting window.ga or creating the ga function and calling ga('create', trackingId, 'auto') or equivalent initialization.",
"max_score": 20
},
{
"name": "Duplicate detection",
"description": "Implements logic to check for existing Google Analytics scripts in the DOM when checkDuplicatedScript is enabled, using methods like document.querySelector or document.getElementsByTagName to search for existing script elements with analytics URLs, and skips loading if found.",
"max_score": 20
},
{
"name": "Browser environment check",
"description": "Checks for browser environment availability (e.g., typeof window !== 'undefined' and typeof document !== 'undefined') before attempting DOM operations, and handles non-browser contexts gracefully without throwing errors.",
"max_score": 15
},
{
"name": "Async loading pattern",
"description": "Returns a Promise that resolves when the script has finished loading, typically by listening to the script's 'load' event or using the script.onload callback, allowing callers to wait for initialization completion.",
"max_score": 15
},
{
"name": "Configuration handling",
"description": "Properly extracts and uses configuration parameters from the config object, including the required 'id' field and optional 'checkDuplicatedScript' field with appropriate default value (false).",
"max_score": 5
}
]
}