diff --git a/backend/pkg/messages/messages.go b/backend/pkg/messages/messages.go index ec9e9c52d..46c91dd38 100644 --- a/backend/pkg/messages/messages.go +++ b/backend/pkg/messages/messages.go @@ -56,7 +56,7 @@ const ( MsgPageRenderTiming = 24 - MsgJSException = 25 + MsgJSExceptionDeprecated = 25 MsgIntegrationEvent = 26 @@ -158,7 +158,7 @@ const ( MsgSessionSearch = 127 - MsgExceptionWithMeta = 78 + MsgJSException = 78 MsgIOSBatchMeta = 107 @@ -1144,14 +1144,14 @@ func (msg *PageRenderTiming) TypeID() int { return 24 } -type JSException struct { +type JSExceptionDeprecated struct { message Name string Message string Payload string } -func (msg *JSException) Encode() []byte { +func (msg *JSExceptionDeprecated) Encode() []byte { buf := make([]byte, 31+len(msg.Name)+len(msg.Message)+len(msg.Payload)) buf[0] = 25 p := 1 @@ -1161,7 +1161,7 @@ func (msg *JSException) Encode() []byte { return buf[:p] } -func (msg *JSException) EncodeWithIndex() []byte { +func (msg *JSExceptionDeprecated) EncodeWithIndex() []byte { encoded := msg.Encode() if IsIOSType(msg.TypeID()) { return encoded @@ -1172,11 +1172,11 @@ func (msg *JSException) EncodeWithIndex() []byte { return data } -func (msg *JSException) Decode() Message { +func (msg *JSExceptionDeprecated) Decode() Message { return msg } -func (msg *JSException) TypeID() int { +func (msg *JSExceptionDeprecated) TypeID() int { return 25 } @@ -3074,7 +3074,7 @@ func (msg *SessionSearch) TypeID() int { return 127 } -type ExceptionWithMeta struct { +type JSException struct { message Name string Message string @@ -3082,7 +3082,7 @@ type ExceptionWithMeta struct { Metadata string } -func (msg *ExceptionWithMeta) Encode() []byte { +func (msg *JSException) Encode() []byte { buf := make([]byte, 41+len(msg.Name)+len(msg.Message)+len(msg.Payload)+len(msg.Metadata)) buf[0] = 78 p := 1 @@ -3093,7 +3093,7 @@ func (msg *ExceptionWithMeta) Encode() []byte { return buf[:p] } -func (msg *ExceptionWithMeta) EncodeWithIndex() []byte { +func (msg *JSException) EncodeWithIndex() []byte { encoded := msg.Encode() if IsIOSType(msg.TypeID()) { return encoded @@ -3104,11 +3104,11 @@ func (msg *ExceptionWithMeta) EncodeWithIndex() []byte { return data } -func (msg *ExceptionWithMeta) Decode() Message { +func (msg *JSException) Decode() Message { return msg } -func (msg *ExceptionWithMeta) TypeID() int { +func (msg *JSException) TypeID() int { return 78 } diff --git a/backend/pkg/messages/read-message.go b/backend/pkg/messages/read-message.go index e43deeea4..fad608863 100644 --- a/backend/pkg/messages/read-message.go +++ b/backend/pkg/messages/read-message.go @@ -409,9 +409,9 @@ func DecodePageRenderTiming(reader io.Reader) (Message, error) { return msg, err } -func DecodeJSException(reader io.Reader) (Message, error) { +func DecodeJSExceptionDeprecated(reader io.Reader) (Message, error) { var err error = nil - msg := &JSException{} + msg := &JSExceptionDeprecated{} if msg.Name, err = ReadString(reader); err != nil { return nil, err } @@ -1315,9 +1315,9 @@ func DecodeSessionSearch(reader io.Reader) (Message, error) { return msg, err } -func DecodeExceptionWithMeta(reader io.Reader) (Message, error) { +func DecodeJSException(reader io.Reader) (Message, error) { var err error = nil - msg := &ExceptionWithMeta{} + msg := &JSException{} if msg.Name, err = ReadString(reader); err != nil { return nil, err } @@ -1817,7 +1817,7 @@ func ReadMessage(t uint64, reader io.Reader) (Message, error) { return DecodePageRenderTiming(reader) case 25: - return DecodeJSException(reader) + return DecodeJSExceptionDeprecated(reader) case 26: return DecodeIntegrationEvent(reader) @@ -1970,7 +1970,7 @@ func ReadMessage(t uint64, reader io.Reader) (Message, error) { return DecodeSessionSearch(reader) case 78: - return DecodeExceptionWithMeta(reader) + return DecodeJSException(reader) case 107: return DecodeIOSBatchMeta(reader) diff --git a/ee/connectors/msgcodec/messages.py b/ee/connectors/msgcodec/messages.py index c3457c21a..254832267 100644 --- a/ee/connectors/msgcodec/messages.py +++ b/ee/connectors/msgcodec/messages.py @@ -245,7 +245,7 @@ class PageRenderTiming(Message): self.time_to_interactive = time_to_interactive -class JSException(Message): +class JSExceptionDeprecated(Message): __id__ = 25 def __init__(self, name, message, payload): @@ -751,7 +751,7 @@ class SessionSearch(Message): self.partition = partition -class ExceptionWithMeta(Message): +class JSException(Message): __id__ = 78 def __init__(self, name, message, payload, metadata): diff --git a/ee/connectors/msgcodec/msgcodec.py b/ee/connectors/msgcodec/msgcodec.py index fd9bc9b8f..724105b1e 100644 --- a/ee/connectors/msgcodec/msgcodec.py +++ b/ee/connectors/msgcodec/msgcodec.py @@ -264,7 +264,7 @@ class MessageCodec(Codec): ) if message_id == 25: - return JSException( + return JSExceptionDeprecated( name=self.read_string(reader), message=self.read_string(reader), payload=self.read_string(reader) @@ -668,7 +668,7 @@ class MessageCodec(Codec): ) if message_id == 78: - return ExceptionWithMeta( + return JSException( name=self.read_string(reader), message=self.read_string(reader), payload=self.read_string(reader), diff --git a/frontend/app/player/MessageDistributor/messages/tracker-legacy.ts b/frontend/app/player/MessageDistributor/messages/tracker-legacy.ts index fc16b5a9b..24670a516 100644 --- a/frontend/app/player/MessageDistributor/messages/tracker-legacy.ts +++ b/frontend/app/player/MessageDistributor/messages/tracker-legacy.ts @@ -26,7 +26,7 @@ export const TP_MAP = { 22: "console_log", 23: "page_load_timing", 24: "page_render_timing", - 25: "js_exception", + 25: "js_exception_deprecated", 27: "raw_custom_event", 28: "user_id", 29: "user_anonymous_id", @@ -62,7 +62,7 @@ export const TP_MAP = { 76: "adopted_ss_add_owner", 77: "adopted_ss_remove_owner", 79: "zustand", - 78: "exception_with_meta", + 78: "js_exception", 90: "ios_session_start", 93: "ios_custom_event", 96: "ios_screen_changes", diff --git a/frontend/app/player/MessageDistributor/messages/tracker.ts b/frontend/app/player/MessageDistributor/messages/tracker.ts index da8ff1f48..a0a375052 100644 --- a/frontend/app/player/MessageDistributor/messages/tracker.ts +++ b/frontend/app/player/MessageDistributor/messages/tracker.ts @@ -153,7 +153,7 @@ type TrPageRenderTiming = [ timeToInteractive: number, ] -type TrJSException = [ +type TrJSExceptionDeprecated = [ type: 25, name: string, message: string, @@ -389,7 +389,7 @@ type TrZustand = [ state: string, ] -type TrExceptionWithMeta = [ +type TrJSException = [ type: 78, name: string, message: string, @@ -398,7 +398,7 @@ type TrExceptionWithMeta = [ ] -export type TrackerMessage = TrBatchMetadata | TrPartitionedMessage | TrTimestamp | TrSetPageLocation | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrJSException | TrRawCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrRedux | TrVuex | TrMobX | TrNgRx | TrGraphQL | TrPerformanceTrack | TrResourceTiming | TrConnectionInformation | TrSetPageVisibility | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrZustand | TrExceptionWithMeta +export type TrackerMessage = TrBatchMetadata | TrPartitionedMessage | TrTimestamp | TrSetPageLocation | TrSetViewportSize | TrSetViewportScroll | TrCreateDocument | TrCreateElementNode | TrCreateTextNode | TrMoveNode | TrRemoveNode | TrSetNodeAttribute | TrRemoveNodeAttribute | TrSetNodeData | TrSetNodeScroll | TrSetInputTarget | TrSetInputValue | TrSetInputChecked | TrMouseMove | TrConsoleLog | TrPageLoadTiming | TrPageRenderTiming | TrJSExceptionDeprecated | TrRawCustomEvent | TrUserID | TrUserAnonymousID | TrMetadata | TrCSSInsertRule | TrCSSDeleteRule | TrFetch | TrProfiler | TrOTable | TrStateAction | TrRedux | TrVuex | TrMobX | TrNgRx | TrGraphQL | TrPerformanceTrack | TrResourceTiming | TrConnectionInformation | TrSetPageVisibility | TrLongTask | TrSetNodeAttributeURLBased | TrSetCSSDataURLBased | TrTechnicalInfo | TrCustomIssue | TrCSSInsertRuleURLBased | TrMouseClick | TrCreateIFrameDocument | TrAdoptedSSReplaceURLBased | TrAdoptedSSInsertRuleURLBased | TrAdoptedSSDeleteRule | TrAdoptedSSAddOwner | TrAdoptedSSRemoveOwner | TrZustand | TrJSException export default function translate(tMsg: TrackerMessage): RawMessage | null { switch(tMsg[0]) { diff --git a/mobs/messages.rb b/mobs/messages.rb index a115e8767..f2795e49f 100644 --- a/mobs/messages.rb +++ b/mobs/messages.rb @@ -146,7 +146,8 @@ message 24, 'PageRenderTiming', :replayer => false do uint 'VisuallyComplete' uint 'TimeToInteractive' end -message 25, 'JSException', :replayer => false do +# depricated since 4.1.6 / 1.8.2 +message 25, 'JSExceptionDeprecated', :replayer => false do string 'Name' string 'Message' string 'Payload' @@ -472,7 +473,7 @@ message 127, 'SessionSearch', :tracker => false, :replayer => false do uint 'Partition' end -message 78, 'ExceptionWithMeta', :replayer => false do +message 78, 'JSException', :replayer => false do string 'Name' string 'Message' string 'Payload' diff --git a/tracker/tracker/src/common/messages.gen.ts b/tracker/tracker/src/common/messages.gen.ts index aa53d3e29..491f3371b 100644 --- a/tracker/tracker/src/common/messages.gen.ts +++ b/tracker/tracker/src/common/messages.gen.ts @@ -24,7 +24,7 @@ export declare const enum Type { ConsoleLog = 22, PageLoadTiming = 23, PageRenderTiming = 24, - JSException = 25, + JSExceptionDeprecated = 25, RawCustomEvent = 27, UserID = 28, UserAnonymousID = 29, @@ -58,7 +58,7 @@ export declare const enum Type { AdoptedSSAddOwner = 76, AdoptedSSRemoveOwner = 77, Zustand = 79, - ExceptionWithMeta = 78, + JSException = 78, } @@ -211,8 +211,8 @@ export type PageRenderTiming = [ /*timeToInteractive:*/ number, ] -export type JSException = [ - /*type:*/ Type.JSException, +export type JSExceptionDeprecated = [ + /*type:*/ Type.JSExceptionDeprecated, /*name:*/ string, /*message:*/ string, /*payload:*/ string, @@ -447,8 +447,8 @@ export type Zustand = [ /*state:*/ string, ] -export type ExceptionWithMeta = [ - /*type:*/ Type.ExceptionWithMeta, +export type JSException = [ + /*type:*/ Type.JSException, /*name:*/ string, /*message:*/ string, /*payload:*/ string, @@ -456,5 +456,5 @@ export type ExceptionWithMeta = [ ] -type Message = BatchMetadata | PartitionedMessage | Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | ConsoleLog | PageLoadTiming | PageRenderTiming | JSException | RawCustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | Zustand | ExceptionWithMeta +type Message = BatchMetadata | PartitionedMessage | Timestamp | SetPageLocation | SetViewportSize | SetViewportScroll | CreateDocument | CreateElementNode | CreateTextNode | MoveNode | RemoveNode | SetNodeAttribute | RemoveNodeAttribute | SetNodeData | SetNodeScroll | SetInputTarget | SetInputValue | SetInputChecked | MouseMove | ConsoleLog | PageLoadTiming | PageRenderTiming | JSExceptionDeprecated | RawCustomEvent | UserID | UserAnonymousID | Metadata | CSSInsertRule | CSSDeleteRule | Fetch | Profiler | OTable | StateAction | Redux | Vuex | MobX | NgRx | GraphQL | PerformanceTrack | ResourceTiming | ConnectionInformation | SetPageVisibility | LongTask | SetNodeAttributeURLBased | SetCSSDataURLBased | TechnicalInfo | CustomIssue | CSSInsertRuleURLBased | MouseClick | CreateIFrameDocument | AdoptedSSReplaceURLBased | AdoptedSSInsertRuleURLBased | AdoptedSSDeleteRule | AdoptedSSAddOwner | AdoptedSSRemoveOwner | Zustand | JSException export default Message diff --git a/tracker/tracker/src/main/app/messages.gen.ts b/tracker/tracker/src/main/app/messages.gen.ts index 8834c654e..509340673 100644 --- a/tracker/tracker/src/main/app/messages.gen.ts +++ b/tracker/tracker/src/main/app/messages.gen.ts @@ -281,13 +281,13 @@ export function PageRenderTiming( ] } -export function JSException( +export function JSExceptionDeprecated( name: string, message: string, payload: string, -): Messages.JSException { +): Messages.JSExceptionDeprecated { return [ - Messages.Type.JSException, + Messages.Type.JSExceptionDeprecated, name, message, payload, @@ -719,14 +719,14 @@ export function Zustand( ] } -export function ExceptionWithMeta( +export function JSException( name: string, message: string, payload: string, metadata: string, -): Messages.ExceptionWithMeta { +): Messages.JSException { return [ - Messages.Type.ExceptionWithMeta, + Messages.Type.JSException, name, message, payload, diff --git a/tracker/tracker/src/main/index.ts b/tracker/tracker/src/main/index.ts index 59bd2a0e2..deb7c9071 100644 --- a/tracker/tracker/src/main/index.ts +++ b/tracker/tracker/src/main/index.ts @@ -271,7 +271,10 @@ export default class API { } } - handleError = (e: Error | ErrorEvent | PromiseRejectionEvent, metadata?: Record) => { + handleError = ( + e: Error | ErrorEvent | PromiseRejectionEvent, + metadata: Record = {}, + ) => { if (this.app === null) { return } diff --git a/tracker/tracker/src/main/modules/exception.ts b/tracker/tracker/src/main/modules/exception.ts index 58cc401b7..0db10afca 100644 --- a/tracker/tracker/src/main/modules/exception.ts +++ b/tracker/tracker/src/main/modules/exception.ts @@ -1,6 +1,6 @@ import type App from '../app/index.js' import type Message from '../app/messages.gen.js' -import { JSException, ExceptionWithMeta } from '../app/messages.gen.js' +import { JSException } from '../app/messages.gen.js' import ErrorStackParser from 'error-stack-parser' export interface Options { @@ -30,21 +30,19 @@ function getDefaultStack(e: ErrorEvent): Array { export function getExceptionMessage( error: Error, fallbackStack: Array, - metadata?: Record, + metadata: Record = {}, ): Message { let stack = fallbackStack try { stack = ErrorStackParser.parse(error) } catch (e) {} - const metaPresent = !!metadata - const method = metaPresent ? ExceptionWithMeta : JSException - return method(error.name, error.message, JSON.stringify(stack), JSON.stringify(metadata)) + return JSException(error.name, error.message, JSON.stringify(stack), JSON.stringify(metadata)) } export function getExceptionMessageFromEvent( e: ErrorEvent | PromiseRejectionEvent, context: typeof globalThis = window, - metadata?: Record, + metadata: Record = {}, ): Message | null { if (e instanceof ErrorEvent) { if (e.error instanceof Error) { @@ -55,9 +53,12 @@ export function getExceptionMessageFromEvent( name = 'Error' message = e.message } - const metaPresent = !!metadata - const method = metaPresent ? ExceptionWithMeta : JSException - return method(name, message, JSON.stringify(getDefaultStack(e)), JSON.stringify(metadata)) + return JSException( + name, + message, + JSON.stringify(getDefaultStack(e)), + JSON.stringify(metadata), + ) } } else if ('PromiseRejectionEvent' in context && e instanceof context.PromiseRejectionEvent) { if (e.reason instanceof Error) { @@ -69,9 +70,7 @@ export function getExceptionMessageFromEvent( } catch (_) { message = String(e.reason) } - const metaPresent = !!metadata - const method = metaPresent ? ExceptionWithMeta : JSException - return method('Unhandled Promise Rejection', message, '[]', JSON.stringify(metadata)) + return JSException('Unhandled Promise Rejection', message, '[]', JSON.stringify(metadata)) } } return null diff --git a/tracker/tracker/src/webworker/MessageEncoder.gen.ts b/tracker/tracker/src/webworker/MessageEncoder.gen.ts index e79ec582a..6d21eda00 100644 --- a/tracker/tracker/src/webworker/MessageEncoder.gen.ts +++ b/tracker/tracker/src/webworker/MessageEncoder.gen.ts @@ -98,7 +98,7 @@ export default class MessageEncoder extends PrimitiveEncoder { return this.uint(msg[1]) && this.uint(msg[2]) && this.uint(msg[3]) break - case Messages.Type.JSException: + case Messages.Type.JSExceptionDeprecated: return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) break @@ -234,7 +234,7 @@ export default class MessageEncoder extends PrimitiveEncoder { return this.string(msg[1]) && this.string(msg[2]) break - case Messages.Type.ExceptionWithMeta: + case Messages.Type.JSException: return this.string(msg[1]) && this.string(msg[2]) && this.string(msg[3]) && this.string(msg[4]) break