Skip to content

Commit

Permalink
fix: Remove posthog error capture from replay
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Oct 7, 2024
1 parent 5b33bdb commit 2723c3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/extensions/replay/sessionrecording-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
9 changes: 3 additions & 6 deletions src/extensions/replay/sessionrecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 2723c3e

Please sign in to comment.