Custom CDP Methods

Rebrowser supports custom CDP methods that you can use in your software to make your workflow smoother and your analytics more insightful.

All custom CDP methods use the Rebrowser.* domain. Here are some examples of how to call custom CDP commands:

Puppeteer

1
2
3
4
5
await page._client().send('Rebrowser.addRunEvent', {
    eventName: 'error', 
    eventData: 'captcha' 
})
await page._client().send('Rebrowser.saveProfileData')

Playwright

1
2
3
4
5
6
const cdpSession = await browser.newBrowserCDPSession()
await cdpSession.send('Rebrowser.addRunEvent', {
    eventName: 'error', 
    eventData: 'captcha' 
})
await cdpSession.send('Rebrowser.saveProfileData')

Rebrowser.addRunEvent

You can log custom events during your run. This helps you get more insights on your dashboard and identify if there are any issues during your runs. For example, you can send a success event when login succeeds, or a fail event if your script fails to log in to a website.

Supported params:

1
2
3
4
5
6
7
8
9
10
11
{
  // string, we recommend using one of the next values:
  // success | warning | error
  eventName: 'error',
  
  // could be string or object (will be converted to JSON)
  eventData: {
    error: 'loginFailed',
    accountId: 1337
  }
}

Rebrowser.finishRun

This will immediately finish the current run. Your CDP session will be interrupted, and the browser will begin the clean-up procedure.

It's always recommended to finish your runs explicitly instead of relying on automatic finish. This way, you can be sure that you won't be charged for browser time being idle.

Rebrowser.saveProfileData

By default, Rebrowser will save your profile data in the cloud after every run finishes. You can trigger this action manually by sending this CDP command.

For example, you might want to keep the browser running while doing some operation, but you also want to get updated cookies for your other script while it's running. You can send the CDP Rebrowser.saveProfileData command every X minutes, and call the API endpoint getProfileData to get current cookies and other data while keeping your run active.