diff --git a/src/extensions/replay/sessionrecording-utils.ts b/src/extensions/replay/sessionrecording-utils.ts index a08ba24ca..aba786e87 100644 --- a/src/extensions/replay/sessionrecording-utils.ts +++ b/src/extensions/replay/sessionrecording-utils.ts @@ -36,7 +36,7 @@ export function circularReferenceReplacer() { } export function estimateSize(sizeable: unknown): number { - return JSON.stringify(sizeable, circularReferenceReplacer()).length + return JSON.stringify(sizeable, circularReferenceReplacer())?.length || 0 } export const replacementImageURI = diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index f7c6d5162..8c196c883 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -145,7 +145,7 @@ function gzipToString(data: unknown): string { // rrweb's packer takes an event and returns a string or the reverse on unpact, // but we want to be able to inspect metadata during ingestion, and don't want to compress the entire event // so we have a custom packer that only compresses part of some events -function compressEvent(event: eventWithTime, ph: PostHog): eventWithTime | compressedEventWithTime { +function compressEvent(event: eventWithTime): eventWithTime | compressedEventWithTime { const originalSize = estimateSize(event) if (originalSize < PARTIAL_COMPRESSION_THRESHOLD) { return event @@ -184,10 +184,7 @@ function compressEvent(event: eventWithTime, ph: PostHog): eventWithTime | compr } } } catch (e) { - logger.error(LOGGER_PREFIX + ' could not compress event', e) - ph.captureException((e as Error) || 'e was not an error', { - attempted_event_type: event?.type || 'no event type', - }) + logger.error(LOGGER_PREFIX + ' could not compress event - will use uncompressed event', e) } return event } @@ -945,7 +942,7 @@ export class SessionRecording { } const eventToSend = - this.instance.config.session_recording.compress_events ?? true ? compressEvent(event, this.instance) : event + this.instance.config.session_recording.compress_events ?? true ? compressEvent(event) : event const size = estimateSize(eventToSend) const properties = {