-
Notifications
You must be signed in to change notification settings - Fork 136
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
⚡️ [RUM-6813] Lazy load session replay #3152
base: v6
Are you sure you want to change the base?
Changes from all commits
a79ab4a
a2e770a
a2ca8f0
c6c30b2
2205ee9
f101a0f
3e1bc2a
04ff36b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,34 @@ export function collectAsyncCalls<F extends jasmine.Func>( | |
fail(`Unexpected extra call for spec '${currentSpec!.fullName}'`) | ||
} | ||
} | ||
export function asyncCollectAsyncCalls<F extends jasmine.Func>( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💭 thought: Not a big fan of that function name. Maybe we could use the same function as above, but also return a Promise export function collectAsyncCalls<F extends jasmine.Func>(
spy: jasmine.Spy<F>,
expectedCallsCount: number,
callback?: (calls: jasmine.Calls<F>) => void
): Promise<jasmine.Calls<F>> {
...
} and deprecate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree! Sry my intention was not clear. I introduced There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah nice! |
||
spy: jasmine.Spy<F>, | ||
expectedCallsCount: number | ||
): Promise<jasmine.Calls<F>> { | ||
return new Promise((resolve, reject) => { | ||
const currentSpec = getCurrentJasmineSpec() | ||
if (!currentSpec) { | ||
reject(new Error('collectAsyncCalls should be called within jasmine code')) | ||
return | ||
} | ||
|
||
const checkCalls = () => { | ||
if (spy.calls.count() === expectedCallsCount) { | ||
spy.and.callFake(extraCallDetected as F) | ||
resolve(spy.calls) | ||
} else if (spy.calls.count() > expectedCallsCount) { | ||
extraCallDetected() | ||
} | ||
} | ||
|
||
checkCalls() | ||
|
||
spy.and.callFake((() => { | ||
checkCalls() | ||
}) as F) | ||
|
||
function extraCallDetected() { | ||
reject(new Error(`Unexpected extra call for spec '${currentSpec!.fullName}'`)) | ||
} | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function lazyLoadRecorder() { | ||
return import(/* webpackChunkName: "recorder" */ './startRecording').then((module) => module.startRecording) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❓ question: I have a doubt, does this means that customer need to use webpack as well? or is this a stupid question? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly, I used the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should use a fixed name for chunks though. It should include a hash or something to avoid cache issues, because I don't trust cloudfront/the browser to invalidate both files exactly at the same time. We can talk about it. |
||
} |
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.
For now, I introduced an async version of
runOnReadyState
but if we agree on this lazy loading approach I'll refactor the originalrunOnReadyState
to use promises.