@grafana/faro-instrumentation-replay
v2.2.2
Published
Faro instrumentation for session replay with rrweb
Downloads
9,279
Maintainers
Readme
@grafana/faro-instrumentation-replay
Faro instrumentation for session replay with rrweb.
Installation
npm install @grafana/faro-instrumentation-replayUsage
import { ReplayInstrumentation } from '@grafana/faro-instrumentation-replay';
import { getWebInstrumentations, initializeFaro } from '@grafana/faro-web-sdk';
initializeFaro({
url: 'https://your-faro-endpoint.com',
instrumentations: [
...getWebInstrumentations(),
new ReplayInstrumentation({
maskInputOptions: {
password: true,
email: true,
},
maskAllInputs: false,
recordCrossOriginIframes: false,
}),
],
});Configuration Options
Privacy & Masking Options
maskAllInputs(default:false): Whether to mask all input elementsmaskInputOptions(default:{ password: true }): Fine-grained control over which input types to mask. Available options:password- Password inputstext- Text inputsemail- Email inputstel- Telephone inputsnumber- Number inputssearch- Search inputsurl- URL inputsdate,datetime-local,month,week,time- Date/time inputscolor- Color inputsrange- Range inputstextarea- Textarea elementsselect- Select dropdowns
maskTextSelector: Custom CSS selector to mask specific elementsblockSelector: CSS selector to completely block elements from recordingignoreSelector: CSS selector to ignore specific elements
Recording Options
recordCrossOriginIframes(default:false): Whether to record cross-origin iframesrecordCanvas(default:false): Whether to record canvas elementscollectFonts(default:false): Whether to collect font filesinlineImages(default:false): Whether to inline images in the recordinginlineStylesheet(default:false): Whether to inline stylesheets
Hooks
beforeSend: Custom function to transform or filter events before they are sent. Return the modified event ornull/undefinedto skip sending
Privacy and Security
This instrumentation records user interactions on your website. Make sure to:
- Enable appropriate masking options - By default, only password inputs are masked.
Configure
maskInputOptionsto mask additional sensitive fields - Use CSS selectors - Use
maskTextSelectorto mask sensitive content,blockSelectorto completely exclude elements - Implement filtering - Use the
beforeSendhook to filter or transform events before sending - Review your privacy policy - Ensure you have proper user consent for session recording
- Test your configuration - Verify no sensitive information is captured in recordings
Example: Advanced Privacy Configuration
new ReplayInstrumentation({
// Mask all text and email inputs, but allow number inputs
maskInputOptions: {
password: true,
text: true,
email: true,
tel: true,
textarea: true,
},
// Mask elements with specific CSS classes
maskTextSelector: '.sensitive-data, .pii',
// Block elements completely from recording
blockSelector: '.payment-form, .credit-card-info',
// Ignore certain elements (won't be recorded at all)
ignoreSelector: '.analytics-widget',
// Filter or transform events before sending
beforeSend: (event) => {
// Example: Skip events that might contain sensitive data
if (event.type === 3 && event.data?.source === 'CanvasMutation') {
return null; // Skip this event
}
return event; // Send the event as-is
},
});