Add the Flytrap code transform to your Rollup configuration, so that all your code gets properly processed for replaying. This is an example configuration of using Rollup with an Express API.
Copy
import typescript from '@rollup/plugin-typescript'import nodeResolve from '@rollup/plugin-node-resolve'import commonjs from '@rollup/plugin-commonjs'import { FlytrapTransformPlugin } from 'useflytrap/transform'export default { input: 'src/index.ts', output: { file: 'dist/index.cjs', format: 'cjs' }, plugins: [ typescript(), // only add in production ...(process.env.NODE_ENV === 'production' ? [FlytrapTransformPlugin.rollup()] : []), nodeResolve({ preferBuiltins: true, extensions: ['.mjs', '.js', '.json', '.node', '.ts'] }), commonjs() ], external: ['express']}
Keep in mind that the Flytrap Transform should come before plugins such as nodeResolve, so we don’t wrap imported node modules.
Next up, create your Flytrap configuration file. The configuration file defines what project you are capturing & replaying for, and the replay & capture behavior.You can get the values for your Flytrap configuration file by creating a project as seen below.
Copy
import { defineFlytrapConfig } from 'useflytrap'export default defineFlytrapConfig({ projectId: 'your-project-id', captureId: 'capture id for replaying', publicApiKey: 'your public api key', secretApiKey: 'your secret api key', privateKey: 'your private key', mode: 'capture'})