- 
                Notifications
    
You must be signed in to change notification settings  - Fork 197
 
feat: remove the eager loaded session replay code from the bundle #2404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 
           The latest updates on your projects. Learn more about Vercel for GitHub. 
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
12 files reviewed, 1 comment
        
          
                packages/browser/src/__tests__/extensions/replay/sessionRecording-onRemoteConfig.test.ts
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           Size Change: -298 kB (-5.84%) ✅ Total Size: 4.8 MB 
 ℹ️ View Unchanged
  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the eager loaded session replay code from the browser bundle and switches to lazy loaded replay as the default, achieving significant bundle size reduction. The main changes include:
- Removal of the 
SessionRecordingclass in favor of lazy loading implementation - Moving replay-related code to an 
externaldirectory structure - Updating imports to use the new module organization
 - Converting the 
SessionRecordingWrapperto the primarySessionRecordingclass 
Reviewed Changes
Copilot reviewed 20 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description | 
|---|---|
| packages/browser/terser-mangled-names.json | Removes mangled names for eager loaded session recording methods | 
| packages/browser/src/utils/globals.ts | Updates imports to use external replay modules and adds lazy-recorder extension type | 
| packages/browser/src/types.ts | Updates imports to use external replay modules for type definitions | 
| packages/browser/src/posthog-core.ts | Simplifies session recording initialization by removing eager loading logic | 
| packages/browser/src/extensions/replay/sessionrecording.ts | Complete removal of the eager loaded session recording implementation | 
| packages/browser/src/extensions/replay/session-recording.ts | Converts wrapper class to main SessionRecording class with simplified implementation | 
| packages/browser/src/extensions/replay/external/ | Multiple files moved/updated to external directory for lazy loading | 
| Various test files | Updates imports and test expectations to work with new lazy loading structure | 
| .changeset/gentle-wings-retire.md | Documents the breaking change for version tracking | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
we're running lazy loaded replay as the default
now we can remove the eager loaded replay and get the bundle savings
i believe that this doesn't break older clients expecting things to be loadable in some way 🙈
why do i believe that this is not a breaking change?
we haven't edited the recorder.js
so any existing array.js or npm install will load the recorder.js as before - no change
we haven't renamed any methods
we have moved/changed trigger matching but any existing array.js will have it bundled already it is not lazy loaded
we load a new lazy-recorder.js
so, if you have cached remote assets it doesn't matter because we load that new asset regardless of what all you have cached