我正在尝试使用Puppeteer和puppeteer-datalayer node.js模块自动进行GTM测试。但是,当我尝试实例化dataLayer类时,出现以下错误:没有'new'就无法调用类构造函数dataLayer。
这是我到目前为止尝试过的:
// @ts-ignore
const puppeteer = require('puppeteer');
const puppeteerDl = require('puppeteer-datalayer')
(async () => {
// Automate here
const browser = await puppeteer.launch();
const page = await browser.newPage();
const containerId = "GTM-XXXXXX";
await page.goto('example.com');
const div = await page.evaluate(() => {return (document.querySelector('p').innerHTML)});
console.log(div);
await page.click('div.user-box-links > a');
const dataLayerPupeteer = new dataLayer(page, containerId);
const latestEvent = dataLayerPupeteer.getLatestEvent();
console.log(latestEvent);
await browser.close();
})();
我在这里做什么错了?