All Projects β†’ humanmade β†’ trafficator

humanmade / trafficator

Licence: GPL-3.0 license
Traffic generator for local analytics testing

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to trafficator

puppeteer-screenshot-tester
Small library that allows us to compare screenshots generated by puppeteer in our tests.
Stars: ✭ 50 (+85.19%)
Mutual labels:  testing-tools, puppeteer
Recorder
A browser extension that generates Cypress, Playwright and Puppeteer test scripts from your interactions πŸ–± ⌨
Stars: ✭ 277 (+925.93%)
Mutual labels:  testing-tools, puppeteer
page-modeller
βš™οΈ Browser DevTools extension for modelling web pages for automation.
Stars: ✭ 66 (+144.44%)
Mutual labels:  testing-tools, puppeteer
Perftools Runner
Google Performance Tools runner using Puppeteer
Stars: ✭ 79 (+192.59%)
Mutual labels:  testing-tools, puppeteer
Acot
πŸ’Ž Accessibility Testing Framework. More accessible web, all over the world.
Stars: ✭ 112 (+314.81%)
Mutual labels:  testing-tools, puppeteer
DTA
This repository documents MATLAB implementation of a dynamic user equilibrium solver, including a dynamic network loading sub-routine
Stars: ✭ 55 (+103.7%)
Mutual labels:  traffic, traffic-simulation
Reactopt
A CLI React performance optimization tool that identifies potential unnecessary re-rendering
Stars: ✭ 1,975 (+7214.81%)
Mutual labels:  testing-tools, puppeteer
SmartTrafficIntersection
Another AI toy project, of a traffic intersection controlled by a Reinforcement Learning AI agent to optimize traffic flow in an intersection of vehicles or pedestrians
Stars: ✭ 30 (+11.11%)
Mutual labels:  traffic, traffic-simulation
json-crate
πŸ“¦ json-crate: a minimalistic promise-based json database
Stars: ✭ 29 (+7.41%)
Mutual labels:  testing-tools
evolutio
ab testing framework with automated code removing
Stars: ✭ 15 (-44.44%)
Mutual labels:  testing-tools
website-fingerprinting
Deanonymizing Tor or VPN users with website fingerprinting and machine learning.
Stars: ✭ 59 (+118.52%)
Mutual labels:  traffic
barclayscrape
A small app to programmatically mainpulate Barclays online banking
Stars: ✭ 57 (+111.11%)
Mutual labels:  puppeteer
puppeteer-jest-starter
A starter-kit quipped with the minimal requirements for Puppeteer + Jest, making E2E testing a breeze.
Stars: ✭ 17 (-37.04%)
Mutual labels:  puppeteer
p4-traffictool
p4-traffictool helps in packet generation, parsing and dissection for popular backends
Stars: ✭ 31 (+14.81%)
Mutual labels:  traffic-generator
testcontainers
Selenide + TestContainers (Docker) sample project
Stars: ✭ 28 (+3.7%)
Mutual labels:  testing-tools
DebugWindow
δΈ€δΈͺεœ¨ηœŸζœΊδΈŠζ΅‹θ―•ζ—Άζ–ΉδΎΏζŸ₯ηœ‹θΎ“ε‡Ίζ—₯εΏ—ηš„ε°ε·₯具。(A debug tool which helps you view the console logs on the device when you test you APP.)
Stars: ✭ 36 (+33.33%)
Mutual labels:  testing-tools
react-router-testing-utils
A collection of utilities to test React Router with React Testing Library (Work in progress 🚧)
Stars: ✭ 34 (+25.93%)
Mutual labels:  testing-tools
apitest
this is a tool for testing Laravel REST API
Stars: ✭ 11 (-59.26%)
Mutual labels:  testing-tools
mugshot
Framework independent visual testing library
Stars: ✭ 126 (+366.67%)
Mutual labels:  puppeteer
abeamer
frame-by-frame Web Animation framework
Stars: ✭ 49 (+81.48%)
Mutual labels:  puppeteer

Trafficator

npm version

A simple web traffic generator built on Puppeteer for local analytics testing.

Intallation

npm install trafficator

Or globally

npm install --global trafficator

Usage

Trafficator uses Puppeteer under the hood to power interactions and activities on each page.

To get started you need to create a .trafficator.js file with at least one funnel configured:

# .trafficator.js

module.exports = {
  funnels: [
    {
      entry: 'https://my-project.local/'
    }
  ]
};

This is a minimal example and will instruct Trafficator to open the page at https://my-project.local/ before closing it and moving on to another session.

Once you have the file you can run the trafficator command, either directly from the command line for a global installation or from an npm script for a local installation.

# See command lines options.
trafficator --help
# Change the configured sessions or concurrency values.
trafficator --sessions 100 --concurrency 10
# Run with a different config file than .trafficator.js.
trafficator --config path/to/config.js

Funnel options

entry <string | array>

A single URL or array of URLs. If an array is provided one will be chosen at random.

steps <array>

An array of step objects.

Funnel steps

The flexibility of trafficator comes from defining funnel steps. These are a set of instructions for puppeteer to execute in order on the website such as clicking links or other interactions.

module.exports = {
  funnels: [
    {
      entry: 'https://my-project.local/'
      steps: [
        {
          action: async (page) => {
            // Page is the `page` object from Puppeteer.
            await page.click('.main-menu a');
          }
        }
      ]
    }
  ]
};

You can define as many steps as you like but at a minimum they must define an action callback.

Step options

name <string>

An optional name for the step shown in output logs.

action <function>

A callback that accepts the page puppeteer option. Check the Puppeteer docs for more details on what you can do.

probability <number | function>

A number between 1 and 0 or function that resolves to a number, determines the likelihood that the action is carried out. Use this to create a drop off effect at each stage of your funnel.

If probability is callback it recieves the page object from Puppeteer as an argument allowing you to return a dynamic value, ffor example:

{
  action: async (page) => await page.click('a'),
  probability: async (page) => {
    // Get data from the browser context.
    return await page.evaluate(() => {
      if ( localStorage.getItem('ab_test') === 2 ) {
        // 30% chance.
        return 0.3;
      }
      // 10% chance.
      return 0.1;
    });
  }
}

willNotNavigate <boolean>

Trafficator makes the assumption that action callbacks will trigger a navigation event, in which case the steps are advanced automatically.

If the action does not navigate set willNotNavigate to true so that the next step is run.

Full configuration example

module.exports = {
  // <integer>: number of sessions to run
  sessions: 10,
  // <integer>: number of concurrent sessions
  concurrency: 5,
  // <array>: funnel definitions
  funnels: [
    // <object>: funnel object
    {
      // <string|array>: entry point URL.
      entry: 'https://my-project.local/',
      // <array>: step objects
      steps: [
        // <object>: step object
        {
          // <string>: step name
          name: 'Scroll down',
          // <function>: step action callback
          action: async page => await page.evaluate(() => {
            window.scrollTo(0, 500);
          }),
          // <boolean>: whether the action callback causes a navigation event
          willNotNavigate: true
        },
        {
          name: 'Click target link',
          action: async page => await page.click('a.target'),
          // <number|function>: probability of drop-off
          probability: 0.5
        }
      ]
    }
  ],
  // array: custom referrers added sent with the entry page request
  referer: [
    // string: referrer URL
    '',
    'https://www.google.com/',
    'https://twitter.com/',
  ],
  // object: configuration for the user-agents library
  browsers: {},
  // object: key/value pairs of custom request headers to send
  headers: {},
};

Browsers / User Agents

User agent support is provided by the user-agents library. By default this will choose a random user agent string for the visitors based on common distributions.

The user-agents library accepts a configuration object that can be passed by settings the browsers property in your .trafficator.js config file.

For example to select only mobile device user agents strings you could do the following:

module.exports = {
  funnels: [
    {
      entry: 'https://example.org'
    }
  ],
  browsers: {
    deviceCategory: 'mobile'
  }
};

You can find more complete configuration information on the user-agents repository.

Request Headers

To send custom request headers for each visit you can provide them in your configuration under the headers property. This should be key/value pairs where the keys are the header names and values are the header contents. If an array of header values is provided a random one will be selected.

For example to mimic possible AWS CloudFront headers such as CloudFront-Viewer-Country you could set the following:

module.exports = {
  funnels: [
    {
      entry: 'https://example.org'
    }
  ],
  headers: {
    'CloudFront-Viewer-IsMobile': '1',
    'CloudFront-Viewer-Country': [
      'US',
      'GB',
      'FR'
    ]
  }
};

Roadmap

This is a simple initial iteration and there's much more it could do in future. This includes:

  • Device emulation
  • Campaigns eg. utm_source, utm_campaign
  • Geo location
  • Customisable request headers
  • Ability to define trends or random chance for all of the above

Made with ❀️ by Human Made

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].