{"id":19808138,"url":"https://github.com/firefox-devtools/bidi-har-export","last_synced_at":"2026-01-12T09:37:56.456Z","repository":{"id":145380260,"uuid":"604271215","full_name":"firefox-devtools/bidi-har-export","owner":"firefox-devtools","description":"Experimental module to compile WebDriver BiDi network events as a HAR file","archived":false,"fork":false,"pushed_at":"2025-09-19T08:12:39.000Z","size":113,"stargazers_count":7,"open_issues_count":6,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-19T09:45:37.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firefox-devtools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-20T17:42:14.000Z","updated_at":"2025-09-19T08:11:23.000Z","dependencies_parsed_at":"2024-05-13T16:38:44.954Z","dependency_job_id":"976bedc5-7903-4c03-98ea-eedeae2fd2df","html_url":"https://github.com/firefox-devtools/bidi-har-export","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":0.06818181818181823,"last_synced_commit":"542ca4069b2cc801512dd770272b783b5726aec3"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/firefox-devtools/bidi-har-export","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firefox-devtools%2Fbidi-har-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firefox-devtools%2Fbidi-har-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firefox-devtools%2Fbidi-har-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firefox-devtools%2Fbidi-har-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firefox-devtools","download_url":"https://codeload.github.com/firefox-devtools/bidi-har-export/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firefox-devtools%2Fbidi-har-export/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278510961,"owners_count":25999016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T09:13:06.292Z","updated_at":"2025-10-05T20:18:43.171Z","avatar_url":"https://github.com/firefox-devtools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bidi-har-export\n\nExperimental module to compile WebDriver BiDi network events as a HAR file. The WebDriver BiDi network events are currently only available in Firefox 110 or newer.\n\n## Warning\n\nThis module is meant for experimenting with HAR file generation based on WebDriver BiDi network events. It is not meant for widespread use, it was only tested with Firefox and might break as the WebDriver BiDi specification gets updated.\n\n## Examples\n\n### HarRecorder\n\n`HarRecorder` is a base class for recording HAR. The consumer is responsible for indicating the beginning and end of the recording by using the `startRecording` and `stopRecording` methods. During the recording the consumer should forward all the relevant BiDi events to the recorder. The useful events for HAR generation are:\n\n- network.beforeRequestSent\n- network.responseCompleted\n- browsingContext.domContentLoaded\n- browsingContext.load\n\nThe recorder will not handle subscribing or unsubscribing to those events. For Selenium users, the `SeleniumBiDiHarRecorder` can be used to facilitate the process.\n\n```javascript\nconst { HarRecorder } = require(\"bidi-har-export\");\n\nconst harRecorder = new HarRecorder({ browser: \"firefox\", version: \"111.0a1\"});\n\n// It is mandatory to call startRecording before forwarding any event to the\n// recorder.\nharRecorder.startRecording();\n\n// Forward network and browser context events to the recorder.\n// The recorder expects events as objects containing a \"method\"\n// and a \"params\" property.\nharRecorder.recordEvent(beforeRequestSentEvent);\nharRecorder.recordEvent(domContentLoadedEvent);\nharRecorder.recordEvent(loadEvent);\nharRecorder.recordEvent(responseCompletedEvent);\n\n// To complete the recording and generate the HAR record,\n// call stopRecording().\nconst harRecord = harRecorder.stopRecording();\n\n// `harRecord` is an object following the HAR specification at\n// https://w3c.github.io/web-performance/specs/HAR/Overview.html\n// It is an object with a single property at the root called `log`\n// See the specification for more details.\n```\n\n### SeleniumBiDiHarRecorder\n\nThe `SeleniumBiDiHarRecorder` can be used with the [JavaScript binding for Selenium](https://www.selenium.dev/selenium/docs/api/javascript/) in order to facilitate a recording. This recorder will take care of subscribing and unsubscribing to the necessary event, so that the consumer only has to start and stop the recording.\n\nThis recorder is available under the `adapters` namespace.\n\n```javascript\nconst fs = require('fs');\nconst { BrowsingContext, Builder }  = require('selenium-webdriver');\nconst firefox = require('selenium-webdriver/firefox');\nconst { adapters } = require('bidi-har-export');\n\nconst driver = await new Builder()\n  .forBrowser('firefox')\n  .setFirefoxOptions(new firefox.Options().enableBidi())\n  .build();\n\nconst id = await driver.getWindowHandle();\nconst browsingContext = await BrowsingContext(driver, { browsingContextId: id });\n\n// The SeleniumBiDiHarRecorder expects a Selenium driver object as well as an\n// array of browsing context ids which will be used to know which browsing\n// contexts should be monitored.\nconst harRecorder = new adapters.SeleniumBiDiHarRecorder({\n  driver,\n  browsingContextIds: [id],\n});\n\n// Start the recording, perform some navigations (just as an example) and stop\n// the recording.\nawait harRecorder.startRecording();\nawait browsingContext.navigate('https://example.com', 'complete');\nawait browsingContext.navigate('https://wikipedia.org', 'complete');\nconst harExport = await harRecorder.stopRecording();\n\n// Save the HAR data to a .har file\nconst harData = JSON.stringify(harExport, null, \"  \");\nconst filename = `http_archive_${new Date().toISOString()}`;\nfs.writeFileSync(`./your-har-export.har`, harData);\n```\n\n### EventsCollectionExporter\n\nThe `EventsCollectionExporter` can be useful if you are assembling and filtering BiDi events regardless of performing a HAR recording, but you still want to generate a HAR record after the fact. This exporter expects an array of events to be passed to its constructor. The exporter will take attempt to replay those events in chronological order to generate the same HAR export as if they had been recorded live by a base recorder.\n\nThis exporter is available under the `adapters` namespace.\n\n```javascript\nconst { adapters } = require('bidi-har-export');\n\n// Here `bidiEvents` should be an array of network.beforeRequestSent,\n// network.responseCompleted, browsingContext.domContentLoaded and\n// browsingContext.load events. The array does not have to be in chronological\n// order, the exporter will attempt to sort the events based on the timestamp\n// included in each event.\nconst exporter = new adapters.EventsCollectionExporter({\n  browser: \"Firefox\",\n  events: bidiEvents,\n  version: \"111.0a1\",\n});\nconst harExport = exporter.exportAsHar();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirefox-devtools%2Fbidi-har-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirefox-devtools%2Fbidi-har-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirefox-devtools%2Fbidi-har-export/lists"}