Skip to content

Connecting REX to PDK

By default, the rex-demo extension uses rex-local-download to store collected data inside the extension. In this guide you will swap that out for rex-passive-data-kit, which sends data to the PDK server automatically as it is collected.

This guide assumes you have PDK running locally at http://localhost:8000. If you have not done that yet, start with Setting Up a Local PDK Server.


Before making changes, it helps to understand what you are switching between.

rex-local-download stores all collected data in the browser’s local extension storage. The researcher retrieves it by clicking the Download button in the extension popup, which exports a JSON file. Data never leaves the participant’s machine unless the researcher manually downloads it. This works well for demos and single-session pilots, but it is not practical for multi-week studies where you want data flowing continuously.

rex-passive-data-kit sends records to a PDK server as they are collected, over HTTP. The researcher logs in to the PDK admin interface to view, filter, and export data. There is no Download button in the extension; the extension just transmits and the server accumulates.


Open your extension’s src/extension/config.json and add a rex_passive_data_kit section:

"rex_passive_data_kit": {
"enabled": true,
"data_server": "http://localhost:8000"
}

Place this alongside your other module configuration keys. If you are working from rex-demo, the file already has entries for other modules; add this one at the same level.


Open src/typescript/service-worker.ts (the path may vary slightly depending on your extension). A module registers itself when it is imported, so swapping modules means swapping one import line.

Remove the rex-local-download import:

import localDownloadPlugin from '@bric/rex-local-download/service-worker'

Add the rex-passive-data-kit import in its place:

import passiveDataKitPlugin from '@bric/rex-passive-data-kit/service-worker'

If src/typescript/extension.ts imports @bric/rex-local-download/extension (for a download button), remove that import too.


Open package.json in the root of your extension directory. In the dependencies object:

Remove:

"@bric/rex-local-download": "github:bric-digital/rex-local-download#main"

Add:

"@bric/rex-passive-data-kit": "github:bric-digital/rex-passive-data-kit#main"

Install the updated dependencies and rebuild:

Terminal window
npm install
npm run build

Then reload the extension in Chrome:

  1. Go to chrome://extensions
  2. Find your extension in the list
  3. Click the refresh icon (circular arrow) on the extension card

The extension is now using rex-passive-data-kit and will begin transmitting data to your local PDK server.


Browse a few sites: visit a search engine, a news site, anything. Then open http://localhost:8000/ in a new tab and log in to the PDK admin interface.

Navigate to the data sources or participants section. You should see records starting to appear with the participant identifier you set in the extension popup. If records are not appearing after a minute or two, check the browser console (right-click the extension tab, choose Inspect) for any error messages related to the PDK server URL.


Now that data is flowing to PDK, the next guide covers how to navigate the PDK admin interface and export your data for analysis.

Understanding PDK Data