forked from pendo-sandbox/pendo-sandbox.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interaction-a4p.js
executable file
·39 lines (33 loc) · 1.05 KB
/
interaction-a4p.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const puppeteer = require('puppeteer');
const openOpportunities = require('./automation/demoPaths/open-opportunity');
const addAccount = require('./automation/demoPaths/add-account');
const openContacts = require('./automation/demoPaths/open-contacts');
const trackEvent = require('./automation/demoPaths/track-event');
let instance = null;
async function getBrowserInstance() {
if (!instance) {
instance = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
}
return instance;
}
(async () => {
const browser = await getBrowserInstance();
const url = 'https://www.acmecrm.io/?account=Associated%20Strategies';
let pages = await browser.pages();
pages.forEach(async (page) => {
await page.close();
});
try {
await openOpportunities(browser, url);
await addAccount(browser, url);
await openContacts(browser, url);
await trackEvent(browser, url);
return process.exit();
} catch (error) {
console.error(error);
await browser.close();
return process.exit(error);
}
})();