From 5663c907e493dd652aa70c7931d994f7746624c7 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 15:26:42 +0200 Subject: [PATCH 01/12] test reduce bundle size --- packages/core/src/domain/error/error.ts | 2 +- packages/core/src/tools/serialisation/sanitize.ts | 3 ++- packages/rum/src/boot/recorderApi.ts | 4 ++-- packages/rum/src/domain/record/trackers/trackFrustration.ts | 3 ++- packages/rum/src/domain/record/trackers/trackMutation.ts | 2 +- .../memory-performance/compute-memory-performance.js | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/core/src/domain/error/error.ts b/packages/core/src/domain/error/error.ts index d2962a06b2..49decc01ab 100644 --- a/packages/core/src/domain/error/error.ts +++ b/packages/core/src/domain/error/error.ts @@ -35,7 +35,7 @@ export function computeRawError({ ? toStackTraceString(stackTrace) : NO_ERROR_STACK_PRESENT_MESSAGE const causes = isErrorInstance ? flattenErrorCauses(originalError as ErrorWithCause, source) : undefined - const type = stackTrace?.name + const type = stackTrace ? stackTrace.name : undefined const fingerprint = tryToGetFingerprint(originalError) return { diff --git a/packages/core/src/tools/serialisation/sanitize.ts b/packages/core/src/tools/serialisation/sanitize.ts index 6b67c463ce..21d00c6c48 100644 --- a/packages/core/src/tools/serialisation/sanitize.ts +++ b/packages/core/src/tools/serialisation/sanitize.ts @@ -59,7 +59,8 @@ export function sanitize(source: unknown, maxCharacterCount = SANITIZE_DEFAULT_M containerQueue, visitedObjectsWithPath ) - let accumulatedCharacterCount = JSON.stringify(sanitizedData)?.length || 0 + let accumulatedCharacterCount = JSON.stringify(sanitizedData) ? JSON.stringify(sanitizedData).length : 0 + if (accumulatedCharacterCount > maxCharacterCount) { warnOverCharacterLimit(maxCharacterCount, 'discarded', source) return undefined diff --git a/packages/rum/src/boot/recorderApi.ts b/packages/rum/src/boot/recorderApi.ts index 643471b295..7eda590af2 100644 --- a/packages/rum/src/boot/recorderApi.ts +++ b/packages/rum/src/boot/recorderApi.ts @@ -144,7 +144,7 @@ export function makeRecorderApi( startStrategy = (options?: StartRecordingOptions) => { const session = sessionManager.findTrackedSession() - if (!session || (session.sessionReplay === SessionReplayState.OFF && !options?.force)) { + if (!session || (session.sessionReplay === SessionReplayState.OFF && (!options || !options.force))) { state = { status: RecorderStatus.IntentToStart } return } @@ -181,7 +181,7 @@ export function makeRecorderApi( } }) - if (options?.force && session.sessionReplay === SessionReplayState.OFF) { + if (options && options.force && session.sessionReplay === SessionReplayState.OFF) { sessionManager.setForcedReplay() } } diff --git a/packages/rum/src/domain/record/trackers/trackFrustration.ts b/packages/rum/src/domain/record/trackers/trackFrustration.ts index e86dd67962..ab3227023e 100644 --- a/packages/rum/src/domain/record/trackers/trackFrustration.ts +++ b/packages/rum/src/domain/record/trackers/trackFrustration.ts @@ -18,7 +18,8 @@ export function trackFrustration( data.rawRumEvent.action.type === ActionType.CLICK && data.rawRumEvent.action.frustration?.type?.length && 'events' in data.domainContext && - data.domainContext.events?.length + data.domainContext.events && + data.domainContext.events.length ) { frustrationCb({ timestamp: data.rawRumEvent.date, diff --git a/packages/rum/src/domain/record/trackers/trackMutation.ts b/packages/rum/src/domain/record/trackers/trackMutation.ts index 007eeb42fd..918d88ba55 100644 --- a/packages/rum/src/domain/record/trackers/trackMutation.ts +++ b/packages/rum/src/domain/record/trackers/trackMutation.ts @@ -338,7 +338,7 @@ function processAttributesMutations( const handledElements = new Map>() const filteredMutations = mutations.filter((mutation) => { const handledAttributes = handledElements.get(mutation.target) - if (handledAttributes?.has(mutation.attributeName!)) { + if (handledAttributes && handledAttributes.has(mutation.attributeName!)) { return false } if (!handledAttributes) { diff --git a/scripts/performance/memory-performance/compute-memory-performance.js b/scripts/performance/memory-performance/compute-memory-performance.js index 3c6df5a9d3..1721f4c5d2 100644 --- a/scripts/performance/memory-performance/compute-memory-performance.js +++ b/scripts/performance/memory-performance/compute-memory-performance.js @@ -1,6 +1,6 @@ const puppeteer = require('puppeteer') const { fetchPR, LOCAL_BRANCH } = require('../../lib/git-utils') -const NUMBER_OF_RUNS = 40 // Rule of thumb: this should be enough to get a good average +const NUMBER_OF_RUNS = 1 // Rule of thumb: this should be enough to get a good average const TESTS = [ { name: 'RUM - add global context', From 2224f8a78d31ba1d7aa11284efe549cd61dd4da0 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 15:42:38 +0200 Subject: [PATCH 02/12] more changes about ?. --- packages/rum-core/src/boot/rumPublicApi.ts | 10 +++++----- packages/rum-core/src/browser/performanceObservable.ts | 8 ++++++-- packages/rum-core/src/browser/polyfills.ts | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/rum-core/src/boot/rumPublicApi.ts b/packages/rum-core/src/boot/rumPublicApi.ts index c02592ac77..a8bb6d3b94 100644 --- a/packages/rum-core/src/boot/rumPublicApi.ts +++ b/packages/rum-core/src/boot/rumPublicApi.ts @@ -331,8 +331,8 @@ export function makeRumPublicApi( addTelemetryUsage({ feature: 'start-duration-vital' }) return strategy.startDurationVital({ name: sanitize(name)!, - context: sanitize(options?.context) as Context, - details: sanitize(options?.details) as string | undefined, + context: sanitize(options && options.context) as Context, + details: sanitize(options && options.details) as string | undefined, }) } ) @@ -355,8 +355,8 @@ export function makeRumPublicApi( type: VitalType.DURATION, startClocks: timeStampToClocks(options.startTime as TimeStamp), duration: options.duration as Duration, - context: sanitize(options?.context) as Context, - details: sanitize(options?.details) as string | undefined, + context: sanitize(options && options.context) as Context, + details: sanitize(options && options.details) as string | undefined, }) } ) @@ -524,7 +524,7 @@ export function makeRumPublicApi( getSessionReplayLink: monitor(() => recorderApi.getSessionReplayLink()), startSessionReplayRecording: monitor((options?: StartRecordingOptions) => { recorderApi.start(options) - addTelemetryUsage({ feature: 'start-session-replay-recording', force: options?.force }) + addTelemetryUsage({ feature: 'start-session-replay-recording', force: options && options.force }) }), stopSessionReplayRecording: monitor(() => recorderApi.stop()), diff --git a/packages/rum-core/src/browser/performanceObservable.ts b/packages/rum-core/src/browser/performanceObservable.ts index 2ea90e83d0..59ba00e9ab 100644 --- a/packages/rum-core/src/browser/performanceObservable.ts +++ b/packages/rum-core/src/browser/performanceObservable.ts @@ -193,7 +193,9 @@ export function createPerformanceObservable( manageResourceTimingBufferFull(configuration) return () => { - observer?.disconnect() + if (observer) { + observer.disconnect() + } if (timeoutId) { clearTimeout(timeoutId) } @@ -210,7 +212,9 @@ function manageResourceTimingBufferFull(configuration: RumConfiguration) { }) } return () => { - resourceTimingBufferFullListener?.stop() + if (resourceTimingBufferFullListener) { + resourceTimingBufferFullListener.stop() + } } } diff --git a/packages/rum-core/src/browser/polyfills.ts b/packages/rum-core/src/browser/polyfills.ts index 31f32ee803..333cb2126a 100644 --- a/packages/rum-core/src/browser/polyfills.ts +++ b/packages/rum-core/src/browser/polyfills.ts @@ -62,7 +62,7 @@ export function getClassList(element: Element): DOMTokenList | string[] { return element.classList } - const classes = element.getAttribute('class')?.trim() + const classes = (element.getAttribute('class') || '').trim() return classes ? classes.split(/\s+/) : [] } From 6d36602eea533c89a357bb510f79f0f3a7e3f619 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 15:51:02 +0200 Subject: [PATCH 03/12] delete more ?. --- packages/rum-core/src/domain/assembly.ts | 3 +- .../src/domain/view/viewCollection.ts | 61 +++++++++++++------ packages/rum-core/test/testSetupBuilder.ts | 4 +- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/packages/rum-core/src/domain/assembly.ts b/packages/rum-core/src/domain/assembly.ts index a9496ec3ac..62a6d06607 100644 --- a/packages/rum-core/src/domain/assembly.ts +++ b/packages/rum-core/src/domain/assembly.ts @@ -225,7 +225,8 @@ function shouldSend( } } - const rateLimitReached = eventRateLimiters[event.type]?.isLimitReached() + const rateLimitReached = eventRateLimiters[event.type] && eventRateLimiters[event.type].isLimitReached() + return !rateLimitReached } diff --git a/packages/rum-core/src/domain/view/viewCollection.ts b/packages/rum-core/src/domain/view/viewCollection.ts index df55a29efd..16ec505c83 100644 --- a/packages/rum-core/src/domain/view/viewCollection.ts +++ b/packages/rum-core/src/domain/view/viewCollection.ts @@ -69,28 +69,53 @@ function processViewUpdate( frustration: { count: view.eventCounts.frustrationCount, }, - cumulative_layout_shift: view.commonViewMetrics.cumulativeLayoutShift?.value, - cumulative_layout_shift_time: toServerDuration(view.commonViewMetrics.cumulativeLayoutShift?.time), - cumulative_layout_shift_target_selector: view.commonViewMetrics.cumulativeLayoutShift?.targetSelector, - first_byte: toServerDuration(view.initialViewMetrics.navigationTimings?.firstByte), - dom_complete: toServerDuration(view.initialViewMetrics.navigationTimings?.domComplete), - dom_content_loaded: toServerDuration(view.initialViewMetrics.navigationTimings?.domContentLoaded), - dom_interactive: toServerDuration(view.initialViewMetrics.navigationTimings?.domInteractive), + cumulative_layout_shift: + view.commonViewMetrics.cumulativeLayoutShift && view.commonViewMetrics.cumulativeLayoutShift.value, + cumulative_layout_shift_time: toServerDuration( + view.commonViewMetrics.cumulativeLayoutShift && view.commonViewMetrics.cumulativeLayoutShift.time + ), + cumulative_layout_shift_target_selector: + view.commonViewMetrics.cumulativeLayoutShift && view.commonViewMetrics.cumulativeLayoutShift.targetSelector, + first_byte: toServerDuration( + view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.firstByte + ), + dom_complete: toServerDuration( + view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.domComplete + ), + dom_content_loaded: toServerDuration( + view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.domContentLoaded + ), + dom_interactive: toServerDuration( + view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.domInteractive + ), error: { count: view.eventCounts.errorCount, }, first_contentful_paint: toServerDuration(view.initialViewMetrics.firstContentfulPaint), - first_input_delay: toServerDuration(view.initialViewMetrics.firstInput?.delay), - first_input_time: toServerDuration(view.initialViewMetrics.firstInput?.time), - first_input_target_selector: view.initialViewMetrics.firstInput?.targetSelector, - interaction_to_next_paint: toServerDuration(view.commonViewMetrics.interactionToNextPaint?.value), - interaction_to_next_paint_time: toServerDuration(view.commonViewMetrics.interactionToNextPaint?.time), - interaction_to_next_paint_target_selector: view.commonViewMetrics.interactionToNextPaint?.targetSelector, + first_input_delay: toServerDuration( + view.initialViewMetrics.firstInput && view.initialViewMetrics.firstInput.delay + ), + first_input_time: toServerDuration(view.initialViewMetrics.firstInput && view.initialViewMetrics.firstInput.time), + first_input_target_selector: + view.initialViewMetrics.firstInput && view.initialViewMetrics.firstInput.targetSelector, + interaction_to_next_paint: toServerDuration( + view.commonViewMetrics.interactionToNextPaint && view.commonViewMetrics.interactionToNextPaint.value + ), + interaction_to_next_paint_time: toServerDuration( + view.commonViewMetrics.interactionToNextPaint && view.commonViewMetrics.interactionToNextPaint.time + ), + interaction_to_next_paint_target_selector: + view.commonViewMetrics.interactionToNextPaint && view.commonViewMetrics.interactionToNextPaint.targetSelector, is_active: view.isActive, name: view.name, - largest_contentful_paint: toServerDuration(view.initialViewMetrics.largestContentfulPaint?.value), - largest_contentful_paint_target_selector: view.initialViewMetrics.largestContentfulPaint?.targetSelector, - load_event: toServerDuration(view.initialViewMetrics.navigationTimings?.loadEvent), + largest_contentful_paint: toServerDuration( + view.initialViewMetrics.largestContentfulPaint && view.initialViewMetrics.largestContentfulPaint.value + ), + largest_contentful_paint_target_selector: + view.initialViewMetrics.largestContentfulPaint && view.initialViewMetrics.largestContentfulPaint.targetSelector, + load_event: toServerDuration( + view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.loadEvent + ), loading_time: discardNegativeDuration(toServerDuration(view.commonViewMetrics.loadingTime)), loading_type: view.loadingType, long_task: { @@ -108,7 +133,9 @@ function processViewUpdate( max_depth: view.commonViewMetrics.scroll.maxDepth, max_depth_scroll_top: view.commonViewMetrics.scroll.maxDepthScrollTop, max_scroll_height: view.commonViewMetrics.scroll.maxScrollHeight, - max_scroll_height_time: toServerDuration(view.commonViewMetrics.scroll.maxScrollHeightTime), + max_scroll_height_time: toServerDuration( + view.commonViewMetrics.scroll && view.commonViewMetrics.scroll.maxScrollHeightTime + ), }, } : undefined, diff --git a/packages/rum-core/test/testSetupBuilder.ts b/packages/rum-core/test/testSetupBuilder.ts index 59e6b72e5d..b2689dcb39 100644 --- a/packages/rum-core/test/testSetupBuilder.ts +++ b/packages/rum-core/test/testSetupBuilder.ts @@ -224,7 +224,9 @@ export function setup(): TestSetupBuilder { registerCleanupTask(() => { cleanupTasks.forEach((task) => task()) // perform these steps at the end to generate correct events in cleanup and validate them - clock?.cleanup() + if (clock) { + clock.cleanup() + } rawRumEventsCollected.unsubscribe() }) return setupBuilder From 32324000946111dab13867dcbf5dc98403b10ed3 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 15:55:23 +0200 Subject: [PATCH 04/12] fix build --- packages/rum-core/src/domain/assembly.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rum-core/src/domain/assembly.ts b/packages/rum-core/src/domain/assembly.ts index 62a6d06607..c7006b3611 100644 --- a/packages/rum-core/src/domain/assembly.ts +++ b/packages/rum-core/src/domain/assembly.ts @@ -225,7 +225,7 @@ function shouldSend( } } - const rateLimitReached = eventRateLimiters[event.type] && eventRateLimiters[event.type].isLimitReached() + const rateLimitReached = eventRateLimiters[event.type]?.isLimitReached() return !rateLimitReached } From f2e43176af1d17b6ae6de07c4de860598ff5fd86 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 16:04:13 +0200 Subject: [PATCH 05/12] update viewCollection --- .../src/domain/view/viewCollection.ts | 61 ++++++------------- 1 file changed, 17 insertions(+), 44 deletions(-) diff --git a/packages/rum-core/src/domain/view/viewCollection.ts b/packages/rum-core/src/domain/view/viewCollection.ts index 16ec505c83..df55a29efd 100644 --- a/packages/rum-core/src/domain/view/viewCollection.ts +++ b/packages/rum-core/src/domain/view/viewCollection.ts @@ -69,53 +69,28 @@ function processViewUpdate( frustration: { count: view.eventCounts.frustrationCount, }, - cumulative_layout_shift: - view.commonViewMetrics.cumulativeLayoutShift && view.commonViewMetrics.cumulativeLayoutShift.value, - cumulative_layout_shift_time: toServerDuration( - view.commonViewMetrics.cumulativeLayoutShift && view.commonViewMetrics.cumulativeLayoutShift.time - ), - cumulative_layout_shift_target_selector: - view.commonViewMetrics.cumulativeLayoutShift && view.commonViewMetrics.cumulativeLayoutShift.targetSelector, - first_byte: toServerDuration( - view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.firstByte - ), - dom_complete: toServerDuration( - view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.domComplete - ), - dom_content_loaded: toServerDuration( - view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.domContentLoaded - ), - dom_interactive: toServerDuration( - view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.domInteractive - ), + cumulative_layout_shift: view.commonViewMetrics.cumulativeLayoutShift?.value, + cumulative_layout_shift_time: toServerDuration(view.commonViewMetrics.cumulativeLayoutShift?.time), + cumulative_layout_shift_target_selector: view.commonViewMetrics.cumulativeLayoutShift?.targetSelector, + first_byte: toServerDuration(view.initialViewMetrics.navigationTimings?.firstByte), + dom_complete: toServerDuration(view.initialViewMetrics.navigationTimings?.domComplete), + dom_content_loaded: toServerDuration(view.initialViewMetrics.navigationTimings?.domContentLoaded), + dom_interactive: toServerDuration(view.initialViewMetrics.navigationTimings?.domInteractive), error: { count: view.eventCounts.errorCount, }, first_contentful_paint: toServerDuration(view.initialViewMetrics.firstContentfulPaint), - first_input_delay: toServerDuration( - view.initialViewMetrics.firstInput && view.initialViewMetrics.firstInput.delay - ), - first_input_time: toServerDuration(view.initialViewMetrics.firstInput && view.initialViewMetrics.firstInput.time), - first_input_target_selector: - view.initialViewMetrics.firstInput && view.initialViewMetrics.firstInput.targetSelector, - interaction_to_next_paint: toServerDuration( - view.commonViewMetrics.interactionToNextPaint && view.commonViewMetrics.interactionToNextPaint.value - ), - interaction_to_next_paint_time: toServerDuration( - view.commonViewMetrics.interactionToNextPaint && view.commonViewMetrics.interactionToNextPaint.time - ), - interaction_to_next_paint_target_selector: - view.commonViewMetrics.interactionToNextPaint && view.commonViewMetrics.interactionToNextPaint.targetSelector, + first_input_delay: toServerDuration(view.initialViewMetrics.firstInput?.delay), + first_input_time: toServerDuration(view.initialViewMetrics.firstInput?.time), + first_input_target_selector: view.initialViewMetrics.firstInput?.targetSelector, + interaction_to_next_paint: toServerDuration(view.commonViewMetrics.interactionToNextPaint?.value), + interaction_to_next_paint_time: toServerDuration(view.commonViewMetrics.interactionToNextPaint?.time), + interaction_to_next_paint_target_selector: view.commonViewMetrics.interactionToNextPaint?.targetSelector, is_active: view.isActive, name: view.name, - largest_contentful_paint: toServerDuration( - view.initialViewMetrics.largestContentfulPaint && view.initialViewMetrics.largestContentfulPaint.value - ), - largest_contentful_paint_target_selector: - view.initialViewMetrics.largestContentfulPaint && view.initialViewMetrics.largestContentfulPaint.targetSelector, - load_event: toServerDuration( - view.initialViewMetrics.navigationTimings && view.initialViewMetrics.navigationTimings.loadEvent - ), + largest_contentful_paint: toServerDuration(view.initialViewMetrics.largestContentfulPaint?.value), + largest_contentful_paint_target_selector: view.initialViewMetrics.largestContentfulPaint?.targetSelector, + load_event: toServerDuration(view.initialViewMetrics.navigationTimings?.loadEvent), loading_time: discardNegativeDuration(toServerDuration(view.commonViewMetrics.loadingTime)), loading_type: view.loadingType, long_task: { @@ -133,9 +108,7 @@ function processViewUpdate( max_depth: view.commonViewMetrics.scroll.maxDepth, max_depth_scroll_top: view.commonViewMetrics.scroll.maxDepthScrollTop, max_scroll_height: view.commonViewMetrics.scroll.maxScrollHeight, - max_scroll_height_time: toServerDuration( - view.commonViewMetrics.scroll && view.commonViewMetrics.scroll.maxScrollHeightTime - ), + max_scroll_height_time: toServerDuration(view.commonViewMetrics.scroll.maxScrollHeightTime), }, } : undefined, From f66f955ecf0902b7827f2f3a29230bdfd5b12037 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 16:18:56 +0200 Subject: [PATCH 06/12] update other ?. --- packages/core/test/interceptRequests.ts | 4 +++- packages/logs/src/domain/assembly.ts | 2 +- packages/rum-core/src/domain/view/trackViews.ts | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/test/interceptRequests.ts b/packages/core/test/interceptRequests.ts index ba1b3f447f..11cbf9657f 100644 --- a/packages/core/test/interceptRequests.ts +++ b/packages/core/test/interceptRequests.ts @@ -79,7 +79,9 @@ export function interceptRequests() { if (originalFetch) { window.fetch = originalFetch } - xhrManager?.reset() + if (xhrManager) { + xhrManager.reset() + } MockXhr.onSend = noop }, } diff --git a/packages/logs/src/domain/assembly.ts b/packages/logs/src/domain/assembly.ts index cf352491a0..ec68c5c212 100644 --- a/packages/logs/src/domain/assembly.ts +++ b/packages/logs/src/domain/assembly.ts @@ -39,7 +39,7 @@ export function startLogsAssembly( const log = combine( { service: configuration.service, - session_id: session?.id, + session_id: session ? session.id : undefined, // Insert user first to allow overrides from global context usr: !isEmptyObject(commonContext.user) ? commonContext.user : undefined, view: commonContext.view, diff --git a/packages/rum-core/src/domain/view/trackViews.ts b/packages/rum-core/src/domain/view/trackViews.ts index 85fe96c48f..15313f8ea1 100644 --- a/packages/rum-core/src/domain/view/trackViews.ts +++ b/packages/rum-core/src/domain/view/trackViews.ts @@ -159,7 +159,9 @@ export function trackViews( }, stop: () => { - locationChangeSubscription?.unsubscribe() + if (locationChangeSubscription) { + locationChangeSubscription.unsubscribe() + } currentView.end() activeViews.forEach((view) => view.stop()) }, From a6200d5f4e7ce652022d6a3503f87bbe3de763df Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 16:28:31 +0200 Subject: [PATCH 07/12] test to see bundle reduction --- packages/core/src/domain/error/error.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/domain/error/error.ts b/packages/core/src/domain/error/error.ts index 49decc01ab..d2962a06b2 100644 --- a/packages/core/src/domain/error/error.ts +++ b/packages/core/src/domain/error/error.ts @@ -35,7 +35,7 @@ export function computeRawError({ ? toStackTraceString(stackTrace) : NO_ERROR_STACK_PRESENT_MESSAGE const causes = isErrorInstance ? flattenErrorCauses(originalError as ErrorWithCause, source) : undefined - const type = stackTrace ? stackTrace.name : undefined + const type = stackTrace?.name const fingerprint = tryToGetFingerprint(originalError) return { From c997bc9a4f176ceb5e9a5e99717530058f8fa494 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 16:33:06 +0200 Subject: [PATCH 08/12] revert last commit --- packages/core/src/domain/error/error.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/domain/error/error.ts b/packages/core/src/domain/error/error.ts index d2962a06b2..49decc01ab 100644 --- a/packages/core/src/domain/error/error.ts +++ b/packages/core/src/domain/error/error.ts @@ -35,7 +35,7 @@ export function computeRawError({ ? toStackTraceString(stackTrace) : NO_ERROR_STACK_PRESENT_MESSAGE const causes = isErrorInstance ? flattenErrorCauses(originalError as ErrorWithCause, source) : undefined - const type = stackTrace?.name + const type = stackTrace ? stackTrace.name : undefined const fingerprint = tryToGetFingerprint(originalError) return { From 58dea3e8bb0b78b4452587b91ccdeca212470c56 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 16:46:53 +0200 Subject: [PATCH 09/12] change an other ?. --- packages/core/src/transport/startBatchWithReplica.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/transport/startBatchWithReplica.ts b/packages/core/src/transport/startBatchWithReplica.ts index 83b1e1284c..8b6fd18508 100644 --- a/packages/core/src/transport/startBatchWithReplica.ts +++ b/packages/core/src/transport/startBatchWithReplica.ts @@ -62,7 +62,9 @@ export function startBatchWithReplica( stop: () => { primaryBatch.stop() - replicaBatch?.stop() + if (replicaBatch) { + replicaBatch.stop() + } }, } } From 9faf96aef5d33193a35ea75450eebaf0a37b3eef Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Fri, 19 Jul 2024 16:49:42 +0200 Subject: [PATCH 10/12] fix --- packages/rum-core/src/browser/performanceObservable.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/rum-core/src/browser/performanceObservable.ts b/packages/rum-core/src/browser/performanceObservable.ts index 59ba00e9ab..b73aeb2403 100644 --- a/packages/rum-core/src/browser/performanceObservable.ts +++ b/packages/rum-core/src/browser/performanceObservable.ts @@ -212,9 +212,7 @@ function manageResourceTimingBufferFull(configuration: RumConfiguration) { }) } return () => { - if (resourceTimingBufferFullListener) { - resourceTimingBufferFullListener.stop() - } + resourceTimingBufferFullListener?.stop() } } From c0c0ed12d51c4f1832157ca9ccd6445f2d04ac74 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Mon, 22 Jul 2024 14:27:53 +0200 Subject: [PATCH 11/12] update number of runs --- .../memory-performance/compute-memory-performance.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/performance/memory-performance/compute-memory-performance.js b/scripts/performance/memory-performance/compute-memory-performance.js index 1721f4c5d2..3c6df5a9d3 100644 --- a/scripts/performance/memory-performance/compute-memory-performance.js +++ b/scripts/performance/memory-performance/compute-memory-performance.js @@ -1,6 +1,6 @@ const puppeteer = require('puppeteer') const { fetchPR, LOCAL_BRANCH } = require('../../lib/git-utils') -const NUMBER_OF_RUNS = 1 // Rule of thumb: this should be enough to get a good average +const NUMBER_OF_RUNS = 40 // Rule of thumb: this should be enough to get a good average const TESTS = [ { name: 'RUM - add global context', From ff5491efd3da90baafcdd25577295e726a188021 Mon Sep 17 00:00:00 2001 From: "roman.gaignault" Date: Tue, 23 Jul 2024 14:18:36 +0200 Subject: [PATCH 12/12] don't use JSON.stringify twice --- packages/core/src/tools/serialisation/sanitize.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/src/tools/serialisation/sanitize.ts b/packages/core/src/tools/serialisation/sanitize.ts index 21d00c6c48..58531aaebf 100644 --- a/packages/core/src/tools/serialisation/sanitize.ts +++ b/packages/core/src/tools/serialisation/sanitize.ts @@ -59,7 +59,8 @@ export function sanitize(source: unknown, maxCharacterCount = SANITIZE_DEFAULT_M containerQueue, visitedObjectsWithPath ) - let accumulatedCharacterCount = JSON.stringify(sanitizedData) ? JSON.stringify(sanitizedData).length : 0 + const serializedSanitizedData = JSON.stringify(sanitizedData) + let accumulatedCharacterCount = serializedSanitizedData ? serializedSanitizedData.length : 0 if (accumulatedCharacterCount > maxCharacterCount) { warnOverCharacterLimit(maxCharacterCount, 'discarded', source)