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

Function applyClientOptions

packages/core/src/utils/prepareEvent.ts:129–157  ·  view source on GitHub ↗
(event: Event, options: ClientOptions)

Source from the content-addressed store, hash-verified

127 * @param event event instance to be enhanced
128 */
129export function applyClientOptions(event: Event, options: ClientOptions): void {
130 const { environment, release, dist, maxValueLength } = options;
131
132 // empty strings do not make sense for environment, release, and dist
133 // so we handle them the same as if they were not provided
134 event.environment = event.environment || environment || DEFAULT_ENVIRONMENT;
135
136 if (!event.release && release) {
137 event.release = release;
138 }
139
140 if (!event.dist && dist) {
141 event.dist = dist;
142 }
143
144 const request = event.request;
145 if (request?.url && maxValueLength) {
146 request.url = truncate(request.url, maxValueLength);
147 }
148
149 if (maxValueLength) {
150 event.exception?.values?.forEach(exception => {
151 if (exception.value) {
152 // Truncates error messages
153 exception.value = truncate(exception.value, maxValueLength);
154 }
155 });
156 }
157}
158
159/**
160 * Puts debug IDs into the stack frames of an error event.

Callers 2

prepareEventFunction · 0.85

Calls 2

truncateFunction · 0.90
forEachMethod · 0.65

Tested by

no test coverage detected