Skip to content

Commit

Permalink
move validation behind a (n unused) boolean check
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 15, 2023
1 parent ae4bda3 commit df9c4b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ee/frontend/mobile-replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function couldBeEventWithTime(x: unknown): x is eventWithTime | mobileEventWithT
return typeof x === 'object' && x !== null && 'type' in x && 'timestamp' in x
}

export function transformEventToWeb(event: unknown): eventWithTime {
export function transformEventToWeb(event: unknown, validateTransformation?: boolean): eventWithTime {
// the transformation needs to never break a recording itself
// so, we default to returning what we received
// replacing it only if there's a valid transformation
Expand All @@ -46,7 +46,9 @@ export function transformEventToWeb(event: unknown): eventWithTime {
const transformer = transformers[event.type]
if (transformer) {
const transformed = transformer(event)
validateAgainstWebSchema(transformed)
if (validateTransformation) {
validateAgainstWebSchema(transformed)
}
result = transformed
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions frontend/@posthog/ee/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { eventWithTime } from '@rrweb/types'
export type PostHogEE = {
enabled: boolean
mobileReplay?: {
// defined as unknown while the mobileEventWithTime type is in the ee folder
transformEventToWeb(x: unknown): eventWithTime | null
transformEventToWeb(x: unknown, validationTransformation?: boolean): eventWithTime | null
transformToWeb(x: unknown[]): eventWithTime[]
}
}

0 comments on commit df9c4b5

Please sign in to comment.