MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / eventFromPlainObject

Function eventFromPlainObject

packages/browser/src/eventbuilder.ts:52–99  ·  view source on GitHub ↗
(
  stackParser: StackParser,
  exception: Record<string, unknown>,
  syntheticException?: Error,
  isUnhandledRejection?: boolean,
)

Source from the content-addressed store, hash-verified

50}
51
52function eventFromPlainObject(
53 stackParser: StackParser,
54 exception: Record<string, unknown>,
55 syntheticException?: Error,
56 isUnhandledRejection?: boolean,
57): Event {
58 const client = getClient();
59 const normalizeDepth = client?.getOptions().normalizeDepth;
60
61 // If we can, we extract an exception from the object properties
62 const errorFromProp = getErrorPropertyFromObject(exception);
63
64 const extra = {
65 __serialized__: normalizeToSize(exception, normalizeDepth),
66 };
67
68 if (errorFromProp) {
69 return {
70 exception: {
71 values: [exceptionFromError(stackParser, errorFromProp)],
72 },
73 extra,
74 };
75 }
76
77 const event = {
78 exception: {
79 values: [
80 {
81 type: isEvent(exception) ? exception.constructor.name : isUnhandledRejection ? 'UnhandledRejection' : 'Error',
82 value: getNonErrorObjectExceptionValue(exception, { isUnhandledRejection }),
83 } as Exception,
84 ],
85 },
86 extra,
87 } satisfies Event;
88
89 if (syntheticException) {
90 const frames = parseStackFrames(stackParser, syntheticException);
91 if (frames.length) {
92 // event.exception.values[0] has been set above
93 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
94 event.exception.values[0]!.stacktrace = { frames };
95 }
96 }
97
98 return event;
99}
100
101function eventFromError(stackParser: StackParser, ex: Error): Event {
102 return {

Callers 1

eventFromUnknownInputFunction · 0.85

Calls 8

getClientFunction · 0.90
normalizeToSizeFunction · 0.85
isEventFunction · 0.85
exceptionFromErrorFunction · 0.70
parseStackFramesFunction · 0.70
getOptionsMethod · 0.65

Tested by

no test coverage detected