// ThousandEyes Transaction script which uses proxies with custom configuration
import {markers, fetchAgent } from 'thousandeyes';
import fetch from 'node-fetch';
import assert from 'assert';
async function runScript() {
markers.start('HTTP Proxy');
const httpProxySettings = {
// get a HTTP proxy agent
const httpProxyAgent = fetchAgent.getHttpProxyAgent(httpProxySettings)
// set the agent in the request options
const httpProxyRequestOptions = {
// call the endpoint with a self signed certificate
// NOTE: this is a fake endpoint make sure to replace with a real one
const response1 = await fetch('http://some-website.com', httpProxyRequestOptions);
// verify that response status is 200
assert.equal(200, response1.status);
markers.end('HTTP Proxy');
markers.start('HTTPS Proxy');
const httpsProxySettings = {
host: 'ssl-proxy-host.com',
// get a HTTPS proxy agent
const httpsProxyAgent = fetchAgent.getHttpsProxyAgent(httpsProxySettings)
// set the agent in the request options
const httpsProxyRequestOptions = {
// call the endpoint with a self signed certificate
// NOTE: this is a fake endpoint make sure to replace with a real one
const response2 = await fetch('https://some-website.com', httpsProxyRequestOptions);
// verify that response status is 200
assert.equal(200, response2.status);
markers.end('HTTPS Proxy');
markers.start('PAC Proxy');
const pacProxySettings = {
pacScriptUrl: 'http://pac-script-location.com',
const pacProxyAgent = fetchAgent.getPACProxyAgent(pacProxySettings)
// set the agent in the request options
const pacProxyRequestOptions = {
// call the endpoint with a self signed certificate
// NOTE: this is a fake endpoint make sure to replace with a real one
const response3 = await fetch('https://some-website.com', pacProxyRequestOptions);
// verify that response status is 200
assert.equal(200, response3.status);
markers.end('PAC Proxy');