SlideShare a Scribd company logo
Session Replay
Lessons Learned from Building
a DOM capturing product
Wey Wey Web 2023 Francesco Novy
1
About Me
Sentry & Session Replay
How does Session Replay work?
Lessons Learned:
Know your Use Case
Expect the Unexpected
How to Optimize Bundle Size
How to Compress Data
Overview
2
Francesco Novy
hello@fnovy.com
www.fnovy.com
mydea
Living in Vienna, Austria
8+ years of building web UIs
At Sentry since 2022
Working on the JavaScript SDKs
3
4
Error Monitoring
Performance Monitoring
Profiling
Session Replay
What does Sentry do?
5
Capture what's happening in the user's
browser
See what happened leading up to an
error
In-depth debugging similar to the
Browser DevTools
Session Replay
6
Session Replay
7
Session Replay
8
import * as Sentry from '@sentry/browser';
Sentry.init({
integrations: [
new Sentry.Replay({
unmask: ['.show-this-class']
})
],
// Always capture when an error happens
replaysOnErrorSampleRate: 1.0,
// Capture 10% of sessions generally
replaysSessionSampleRate: 0.1,
});
1
2
3
4
5
6
7
8
9
10
11
12
13
How to use Session Replay?
9
We use a fork of
Mutation Observers
Monkey Patching* Stylesheet APIs
Monkey Patching* Canvas APIs
rrweb
How does it work?
10
* What is Monkey Patching?
const originalFetch = window.fetch;
window.fetch = function() {
console.log("A fetch happened!");
return originalFetch.apply(window, arguments);
}
// Later somewhere in the application
window.fetch('https://example.com');
// Will show the console log
1
2
3
4
5
6
7
8
9
"Monkey patching is a technique used to dynamically
update the behavior of a piece of code at run-time."
11
Know your Use Case
Expect the Unexpected
How to Optimize Bundle Size
How to Compress Data
Lessons Learned
12
Know your Use Case
Do we really need that?
13
Know your Use Case
What do you really need?
Hide text & user input by default
Opt-in to show certain text
Defaults matter: Make the best
way the easy way
Make the worst things impossible
14
Expect the Unexpected
Everything that can go wrong, will go wrong.
15
Expect the Unexpected
Low Level APIs are dangerous to tinker with
Monkey Patching is dangerous
Browser Extensions can do anything
try-catch everything
16
How to Optimize Bundle Size
Ship as little code as necessary.
17
Session Replay Bundle Size
Bundle Size v7.73.0: ~53 KB
Bundle Size v7.78.0: ~35 KB
Still large 😱
... but how?
18
Optimizing Bundle Size
Remove unused code from rrweb
Audit dependencies
Make certain recording features
opt-in
Optimize for Tree Shaking!
19
What is Tree Shaking?
describes the ability to
automatically remove unused code from
your build.
When code is written in a tree-shakeable
way, bundlers like Webpack can optimize
your application based on what is actually
used.
Tree Shaking
20
Tree Shaking: Simple Example
// SDK
import { large, small } from './my-code';
export function largeOrSmall(config) {
return config.useLage ? large() : small();
}
// Application
import { largeOrSmall } from 'sdk';
largeOrSmall({ useLarge: false });
1
2
3
4
5
6
7
8
9
10
11
❌Not tree shakeable
21
// SDK
export { large, small } from './my-code';
// Application
import { small } from 'sdk';
small();
1
2
3
4
5
6
7
✅Tree shakeable
Tree Shaking: Simple Example
22
// SDK
import {
CanvasManager
} from './canvas-manager';
export function record(options) {
if (options.recordCanvas) {
new CanvasManager();
}
}
// Application
import { record } from 'sdk';
record({ recordCanvas: false });
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
❌Not tree shakeable
Tree Shaking: Actual Example
23
// Application A
import {
record
} from 'sdk';
record({ getCanvasManager: undefined });
1
2
3
4
5
6
✅Tree shakeable
Tree Shaking: Actual Example
// SDK
import {
CanvasManager
} from './canvas-manager';
export function getCanvasManager() {
return new CanvasManager();
}
export function record(options) {
if (options.getCanvasManager) {
options.getCanvasManager();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Application B
import {
record,
getCanvasManager
} from 'sdk';
record({ getCanvasManager });
1
2
3
4
5
6
7
24
How to Compress Data
Avoid unnecessary network traffic, where possible.
25
Compressing Data
Compress data in a web worker
Gracefully handle errors
Make sure to compare libraries
(e.g. )
fflate
26
Web Workers
Setting up the web worker
// worker.js
import { compressSync } from 'fflate';
function handleMessage(e) {
const { input, id } = e.data;
const compressed = compressSync(input);
// Send compressed data back to main thread
postMessage({ id, output: compressed });
}
// Receive uncompressed data from main thread
addEventListener('message', handleMessage);
1
2
3
4
5
6
7
8
9
10
11
12
27
Web Workers
Using the web worker from your application
// Application
const worker = new Worker('/worker.js');
function compressData(data) {
const id = generateUuid();
return new Promise(function (resolve) {
function listener(response) {
if (response.data.id === id) {
worker.removeEventListener('message', listener);
resolve(response.data.output);
}
}
worker.addEventListener('message', listener);
worker.postMessage({ id, input: data });
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
28
https://github.com/getsentry/sentry-javascript
The Sentry SDK is Open
Source!
Everything we do is open source!
Look at the code, PRs, etc.
We love feedback!
29
Thank you!
hello@fnovy.com
www.fnovy.com
mydea
Francesco Novy
30

More Related Content

Similar to Lessons Learned from building Session Replay - Francesco Novy

Browser exploitation SEC-T 2019 stockholm
Browser exploitation SEC-T 2019 stockholmBrowser exploitation SEC-T 2019 stockholm
Browser exploitation SEC-T 2019 stockholm
Jameel Nabbo
 
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 RICOH THETA x IoT Developers Contest : Cloud API Seminar RICOH THETA x IoT Developers Contest : Cloud API Seminar
RICOH THETA x IoT Developers Contest : Cloud API Seminar
contest-theta360
 
Kraken.js Lab Primer
Kraken.js Lab PrimerKraken.js Lab Primer
Kraken.js Lab Primer
Aeshan Wijetunge
 
Lesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupLesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment Setup
University of Catania
 
NetWeaver Developer Studio for New-Beas
NetWeaver Developer Studio for New-BeasNetWeaver Developer Studio for New-Beas
NetWeaver Developer Studio for New-Beas
Chander445
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
Aishura Aishu
 
NetDevOps Development Environments
NetDevOps Development EnvironmentsNetDevOps Development Environments
NetDevOps Development Environments
Joel W. King
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
Alex Mikitenko
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
Tim Clark
 
Monitoring using Prometheus and Grafana
Monitoring using Prometheus and GrafanaMonitoring using Prometheus and Grafana
Monitoring using Prometheus and Grafana
Arvind Kumar G.S
 
Micro-Frontends JSVidCon
Micro-Frontends JSVidConMicro-Frontends JSVidCon
Micro-Frontends JSVidCon
Amir Zuker
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
Shai Raiten
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
Mark Rackley
 
React_Complete.pptx
React_Complete.pptxReact_Complete.pptx
React_Complete.pptx
kamalakantas
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
DataLeader.io
 
How to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.ioHow to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.io
Katy Slemon
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
Massimo Oliviero
 
Meteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoMeteor.js Workshop by Dopravo
Meteor.js Workshop by Dopravo
ArabNet ME
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
Chang W. Doh
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
Andreas Czakaj
 

Similar to Lessons Learned from building Session Replay - Francesco Novy (20)

Browser exploitation SEC-T 2019 stockholm
Browser exploitation SEC-T 2019 stockholmBrowser exploitation SEC-T 2019 stockholm
Browser exploitation SEC-T 2019 stockholm
 
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 RICOH THETA x IoT Developers Contest : Cloud API Seminar RICOH THETA x IoT Developers Contest : Cloud API Seminar
RICOH THETA x IoT Developers Contest : Cloud API Seminar
 
Kraken.js Lab Primer
Kraken.js Lab PrimerKraken.js Lab Primer
Kraken.js Lab Primer
 
Lesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment SetupLesson 02 - React Native Development Environment Setup
Lesson 02 - React Native Development Environment Setup
 
NetWeaver Developer Studio for New-Beas
NetWeaver Developer Studio for New-BeasNetWeaver Developer Studio for New-Beas
NetWeaver Developer Studio for New-Beas
 
Mean stack Magics
Mean stack MagicsMean stack Magics
Mean stack Magics
 
NetDevOps Development Environments
NetDevOps Development EnvironmentsNetDevOps Development Environments
NetDevOps Development Environments
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
Monitoring using Prometheus and Grafana
Monitoring using Prometheus and GrafanaMonitoring using Prometheus and Grafana
Monitoring using Prometheus and Grafana
 
Micro-Frontends JSVidCon
Micro-Frontends JSVidConMicro-Frontends JSVidCon
Micro-Frontends JSVidCon
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
 
React_Complete.pptx
React_Complete.pptxReact_Complete.pptx
React_Complete.pptx
 
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
A Microsoft Silverlight User Group Starter Kit Made Available for Everyone to...
 
How to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.ioHow to build a chat application with react js, nodejs, and socket.io
How to build a chat application with react js, nodejs, and socket.io
 
Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)Advanced iOS Debbuging (Reloaded)
Advanced iOS Debbuging (Reloaded)
 
Meteor.js Workshop by Dopravo
Meteor.js Workshop by DopravoMeteor.js Workshop by Dopravo
Meteor.js Workshop by Dopravo
 
Service Worker 201 (en)
Service Worker 201 (en)Service Worker 201 (en)
Service Worker 201 (en)
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 

More from Wey Wey Web

Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...
Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...
Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...
Wey Wey Web
 
Auditing Design Systems for Accessibility - Anna E. Cook
Auditing Design Systems for Accessibility - Anna E. CookAuditing Design Systems for Accessibility - Anna E. Cook
Auditing Design Systems for Accessibility - Anna E. Cook
Wey Wey Web
 
Adaptive Designs, Beyond Pixel Perfection - Stephanie Walter
Adaptive Designs, Beyond Pixel Perfection - Stephanie WalterAdaptive Designs, Beyond Pixel Perfection - Stephanie Walter
Adaptive Designs, Beyond Pixel Perfection - Stephanie Walter
Wey Wey Web
 
Sharing is caring: what to know before you build a Research Repository - Juli...
Sharing is caring: what to know before you build a Research Repository - Juli...Sharing is caring: what to know before you build a Research Repository - Juli...
Sharing is caring: what to know before you build a Research Repository - Juli...
Wey Wey Web
 
Unlocking collaboration: A framework for developers and designers - Alicia Ca...
Unlocking collaboration: A framework for developers and designers - Alicia Ca...Unlocking collaboration: A framework for developers and designers - Alicia Ca...
Unlocking collaboration: A framework for developers and designers - Alicia Ca...
Wey Wey Web
 
3 reasons to switch to OKLCH - Anton Lovchikov
3 reasons to switch to OKLCH - Anton Lovchikov3 reasons to switch to OKLCH - Anton Lovchikov
3 reasons to switch to OKLCH - Anton Lovchikov
Wey Wey Web
 
ChatGPT and AI for web developers - Maximiliano Firtman
ChatGPT and AI for web developers - Maximiliano FirtmanChatGPT and AI for web developers - Maximiliano Firtman
ChatGPT and AI for web developers - Maximiliano Firtman
Wey Wey Web
 
Declarative Design - Jeremy Keith - Wey Wey Wey 2023
Declarative Design - Jeremy Keith - Wey Wey Wey 2023Declarative Design - Jeremy Keith - Wey Wey Wey 2023
Declarative Design - Jeremy Keith - Wey Wey Wey 2023
Wey Wey Web
 
Form follows emotion - Isabella De Cuppis
Form follows emotion - Isabella De CuppisForm follows emotion - Isabella De Cuppis
Form follows emotion - Isabella De Cuppis
Wey Wey Web
 
UX for emerging tech - Josephine Scholtes
UX for emerging tech - Josephine ScholtesUX for emerging tech - Josephine Scholtes
UX for emerging tech - Josephine Scholtes
Wey Wey Web
 
Collaborative software with State Machines - Laura Kalbag
Collaborative software with State Machines -  Laura KalbagCollaborative software with State Machines -  Laura Kalbag
Collaborative software with State Machines - Laura Kalbag
Wey Wey Web
 
Let's get visual. Visual testing in your project - Ramona Schwering
Let's get visual. Visual testing in your project - Ramona SchweringLet's get visual. Visual testing in your project - Ramona Schwering
Let's get visual. Visual testing in your project - Ramona Schwering
Wey Wey Web
 
Solving Common Web Component Problems - Simon MacDonald
Solving Common Web Component Problems - Simon MacDonaldSolving Common Web Component Problems - Simon MacDonald
Solving Common Web Component Problems - Simon MacDonald
Wey Wey Web
 
The Future is Malleable - Aleksandra Sikora
The Future is Malleable - Aleksandra SikoraThe Future is Malleable - Aleksandra Sikora
The Future is Malleable - Aleksandra Sikora
Wey Wey Web
 
Trending tools & methodologies for UX - Josephine Scholtes.pdf
Trending tools & methodologies for UX - Josephine Scholtes.pdfTrending tools & methodologies for UX - Josephine Scholtes.pdf
Trending tools & methodologies for UX - Josephine Scholtes.pdf
Wey Wey Web
 
Decoding Web Accessibility through Testing - Anuradha Kumari
Decoding Web Accessibility through Testing  - Anuradha KumariDecoding Web Accessibility through Testing  - Anuradha Kumari
Decoding Web Accessibility through Testing - Anuradha Kumari
Wey Wey Web
 
Good Security is one question away - Wiktoria Dalach
Good Security is one  question away - Wiktoria DalachGood Security is one  question away - Wiktoria Dalach
Good Security is one question away - Wiktoria Dalach
Wey Wey Web
 
Dynamic CSS Secrets - Lea Verou
Dynamic CSS Secrets - Lea Verou Dynamic CSS Secrets - Lea Verou
Dynamic CSS Secrets - Lea Verou
Wey Wey Web
 
The Misty Report - Douglas Crockford
The Misty Report - Douglas CrockfordThe Misty Report - Douglas Crockford
The Misty Report - Douglas Crockford
Wey Wey Web
 
Web performance optimisations for the harsh conditions - Anna Migas
Web performance optimisations for the harsh conditions - Anna MigasWeb performance optimisations for the harsh conditions - Anna Migas
Web performance optimisations for the harsh conditions - Anna Migas
Wey Wey Web
 

More from Wey Wey Web (20)

Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...
Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...
Portable, secure, and lightweight: Wasm runtimes and their use-cases - Natali...
 
Auditing Design Systems for Accessibility - Anna E. Cook
Auditing Design Systems for Accessibility - Anna E. CookAuditing Design Systems for Accessibility - Anna E. Cook
Auditing Design Systems for Accessibility - Anna E. Cook
 
Adaptive Designs, Beyond Pixel Perfection - Stephanie Walter
Adaptive Designs, Beyond Pixel Perfection - Stephanie WalterAdaptive Designs, Beyond Pixel Perfection - Stephanie Walter
Adaptive Designs, Beyond Pixel Perfection - Stephanie Walter
 
Sharing is caring: what to know before you build a Research Repository - Juli...
Sharing is caring: what to know before you build a Research Repository - Juli...Sharing is caring: what to know before you build a Research Repository - Juli...
Sharing is caring: what to know before you build a Research Repository - Juli...
 
Unlocking collaboration: A framework for developers and designers - Alicia Ca...
Unlocking collaboration: A framework for developers and designers - Alicia Ca...Unlocking collaboration: A framework for developers and designers - Alicia Ca...
Unlocking collaboration: A framework for developers and designers - Alicia Ca...
 
3 reasons to switch to OKLCH - Anton Lovchikov
3 reasons to switch to OKLCH - Anton Lovchikov3 reasons to switch to OKLCH - Anton Lovchikov
3 reasons to switch to OKLCH - Anton Lovchikov
 
ChatGPT and AI for web developers - Maximiliano Firtman
ChatGPT and AI for web developers - Maximiliano FirtmanChatGPT and AI for web developers - Maximiliano Firtman
ChatGPT and AI for web developers - Maximiliano Firtman
 
Declarative Design - Jeremy Keith - Wey Wey Wey 2023
Declarative Design - Jeremy Keith - Wey Wey Wey 2023Declarative Design - Jeremy Keith - Wey Wey Wey 2023
Declarative Design - Jeremy Keith - Wey Wey Wey 2023
 
Form follows emotion - Isabella De Cuppis
Form follows emotion - Isabella De CuppisForm follows emotion - Isabella De Cuppis
Form follows emotion - Isabella De Cuppis
 
UX for emerging tech - Josephine Scholtes
UX for emerging tech - Josephine ScholtesUX for emerging tech - Josephine Scholtes
UX for emerging tech - Josephine Scholtes
 
Collaborative software with State Machines - Laura Kalbag
Collaborative software with State Machines -  Laura KalbagCollaborative software with State Machines -  Laura Kalbag
Collaborative software with State Machines - Laura Kalbag
 
Let's get visual. Visual testing in your project - Ramona Schwering
Let's get visual. Visual testing in your project - Ramona SchweringLet's get visual. Visual testing in your project - Ramona Schwering
Let's get visual. Visual testing in your project - Ramona Schwering
 
Solving Common Web Component Problems - Simon MacDonald
Solving Common Web Component Problems - Simon MacDonaldSolving Common Web Component Problems - Simon MacDonald
Solving Common Web Component Problems - Simon MacDonald
 
The Future is Malleable - Aleksandra Sikora
The Future is Malleable - Aleksandra SikoraThe Future is Malleable - Aleksandra Sikora
The Future is Malleable - Aleksandra Sikora
 
Trending tools & methodologies for UX - Josephine Scholtes.pdf
Trending tools & methodologies for UX - Josephine Scholtes.pdfTrending tools & methodologies for UX - Josephine Scholtes.pdf
Trending tools & methodologies for UX - Josephine Scholtes.pdf
 
Decoding Web Accessibility through Testing - Anuradha Kumari
Decoding Web Accessibility through Testing  - Anuradha KumariDecoding Web Accessibility through Testing  - Anuradha Kumari
Decoding Web Accessibility through Testing - Anuradha Kumari
 
Good Security is one question away - Wiktoria Dalach
Good Security is one  question away - Wiktoria DalachGood Security is one  question away - Wiktoria Dalach
Good Security is one question away - Wiktoria Dalach
 
Dynamic CSS Secrets - Lea Verou
Dynamic CSS Secrets - Lea Verou Dynamic CSS Secrets - Lea Verou
Dynamic CSS Secrets - Lea Verou
 
The Misty Report - Douglas Crockford
The Misty Report - Douglas CrockfordThe Misty Report - Douglas Crockford
The Misty Report - Douglas Crockford
 
Web performance optimisations for the harsh conditions - Anna Migas
Web performance optimisations for the harsh conditions - Anna MigasWeb performance optimisations for the harsh conditions - Anna Migas
Web performance optimisations for the harsh conditions - Anna Migas
 

Recently uploaded

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 

Recently uploaded (20)

Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 

Lessons Learned from building Session Replay - Francesco Novy

  • 1. Session Replay Lessons Learned from Building a DOM capturing product Wey Wey Web 2023 Francesco Novy 1
  • 2. About Me Sentry & Session Replay How does Session Replay work? Lessons Learned: Know your Use Case Expect the Unexpected How to Optimize Bundle Size How to Compress Data Overview 2
  • 3. Francesco Novy hello@fnovy.com www.fnovy.com mydea Living in Vienna, Austria 8+ years of building web UIs At Sentry since 2022 Working on the JavaScript SDKs 3
  • 4. 4
  • 6. Capture what's happening in the user's browser See what happened leading up to an error In-depth debugging similar to the Browser DevTools Session Replay 6
  • 9. import * as Sentry from '@sentry/browser'; Sentry.init({ integrations: [ new Sentry.Replay({ unmask: ['.show-this-class'] }) ], // Always capture when an error happens replaysOnErrorSampleRate: 1.0, // Capture 10% of sessions generally replaysSessionSampleRate: 0.1, }); 1 2 3 4 5 6 7 8 9 10 11 12 13 How to use Session Replay? 9
  • 10. We use a fork of Mutation Observers Monkey Patching* Stylesheet APIs Monkey Patching* Canvas APIs rrweb How does it work? 10
  • 11. * What is Monkey Patching? const originalFetch = window.fetch; window.fetch = function() { console.log("A fetch happened!"); return originalFetch.apply(window, arguments); } // Later somewhere in the application window.fetch('https://example.com'); // Will show the console log 1 2 3 4 5 6 7 8 9 "Monkey patching is a technique used to dynamically update the behavior of a piece of code at run-time." 11
  • 12. Know your Use Case Expect the Unexpected How to Optimize Bundle Size How to Compress Data Lessons Learned 12
  • 13. Know your Use Case Do we really need that? 13
  • 14. Know your Use Case What do you really need? Hide text & user input by default Opt-in to show certain text Defaults matter: Make the best way the easy way Make the worst things impossible 14
  • 15. Expect the Unexpected Everything that can go wrong, will go wrong. 15
  • 16. Expect the Unexpected Low Level APIs are dangerous to tinker with Monkey Patching is dangerous Browser Extensions can do anything try-catch everything 16
  • 17. How to Optimize Bundle Size Ship as little code as necessary. 17
  • 18. Session Replay Bundle Size Bundle Size v7.73.0: ~53 KB Bundle Size v7.78.0: ~35 KB Still large 😱 ... but how? 18
  • 19. Optimizing Bundle Size Remove unused code from rrweb Audit dependencies Make certain recording features opt-in Optimize for Tree Shaking! 19
  • 20. What is Tree Shaking? describes the ability to automatically remove unused code from your build. When code is written in a tree-shakeable way, bundlers like Webpack can optimize your application based on what is actually used. Tree Shaking 20
  • 21. Tree Shaking: Simple Example // SDK import { large, small } from './my-code'; export function largeOrSmall(config) { return config.useLage ? large() : small(); } // Application import { largeOrSmall } from 'sdk'; largeOrSmall({ useLarge: false }); 1 2 3 4 5 6 7 8 9 10 11 ❌Not tree shakeable 21
  • 22. // SDK export { large, small } from './my-code'; // Application import { small } from 'sdk'; small(); 1 2 3 4 5 6 7 ✅Tree shakeable Tree Shaking: Simple Example 22
  • 23. // SDK import { CanvasManager } from './canvas-manager'; export function record(options) { if (options.recordCanvas) { new CanvasManager(); } } // Application import { record } from 'sdk'; record({ recordCanvas: false }); 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ❌Not tree shakeable Tree Shaking: Actual Example 23
  • 24. // Application A import { record } from 'sdk'; record({ getCanvasManager: undefined }); 1 2 3 4 5 6 ✅Tree shakeable Tree Shaking: Actual Example // SDK import { CanvasManager } from './canvas-manager'; export function getCanvasManager() { return new CanvasManager(); } export function record(options) { if (options.getCanvasManager) { options.getCanvasManager(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // Application B import { record, getCanvasManager } from 'sdk'; record({ getCanvasManager }); 1 2 3 4 5 6 7 24
  • 25. How to Compress Data Avoid unnecessary network traffic, where possible. 25
  • 26. Compressing Data Compress data in a web worker Gracefully handle errors Make sure to compare libraries (e.g. ) fflate 26
  • 27. Web Workers Setting up the web worker // worker.js import { compressSync } from 'fflate'; function handleMessage(e) { const { input, id } = e.data; const compressed = compressSync(input); // Send compressed data back to main thread postMessage({ id, output: compressed }); } // Receive uncompressed data from main thread addEventListener('message', handleMessage); 1 2 3 4 5 6 7 8 9 10 11 12 27
  • 28. Web Workers Using the web worker from your application // Application const worker = new Worker('/worker.js'); function compressData(data) { const id = generateUuid(); return new Promise(function (resolve) { function listener(response) { if (response.data.id === id) { worker.removeEventListener('message', listener); resolve(response.data.output); } } worker.addEventListener('message', listener); worker.postMessage({ id, input: data }); }); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 28
  • 29. https://github.com/getsentry/sentry-javascript The Sentry SDK is Open Source! Everything we do is open source! Look at the code, PRs, etc. We love feedback! 29