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

Function SentryRoot

packages/remix/src/client/performance.tsx:152–217  ·  view source on GitHub ↗
(props: P)

Source from the content-addressed store, hash-verified

150 instrumentNavigation?: boolean,
151): R {
152 const SentryRoot: React.FC<P> = (props: P) => {
153 setGlobals({ useEffect, useLocation, useMatches, instrumentNavigation: instrumentNavigation || true });
154
155 // Early return when any of the required functions is not available.
156 if (!_useEffect || !_useLocation || !_useMatches) {
157 DEBUG_BUILD &&
158 !isNodeEnv() &&
159 debug.warn('Remix SDK was unable to wrap your root because of one or more missing parameters.');
160
161 // @ts-expect-error Setting more specific React Component typing for `R` generic above
162 // will break advanced type inference done by react router params
163 return <OrigApp {...props} />;
164 }
165
166 let isBaseLocation: boolean = false;
167
168 const location = _useLocation();
169 const matches = _useMatches();
170
171 _useEffect(() => {
172 const lastMatch = matches?.[matches.length - 1];
173 if (lastMatch) {
174 const { name, source } = getTransactionNameAndSource(location.pathname, lastMatch.id);
175
176 getCurrentScope().setTransactionName(name);
177
178 const activeRootSpan = getActiveSpan();
179 if (activeRootSpan) {
180 const transaction = getRootSpan(activeRootSpan);
181
182 if (transaction) {
183 transaction.updateName(name);
184 transaction.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, source);
185 }
186 }
187 }
188
189 isBaseLocation = true;
190 }, []);
191
192 _useEffect(() => {
193 const activeRootSpan = getActiveSpan();
194
195 if (isBaseLocation) {
196 if (activeRootSpan) {
197 activeRootSpan.end();
198 }
199
200 return;
201 }
202
203 if (_instrumentNavigation && matches?.length) {
204 if (activeRootSpan) {
205 activeRootSpan.end();
206 }
207
208 startNavigationSpan(matches, location);
209 }

Callers

nothing calls this directly

Calls 12

isNodeEnvFunction · 0.90
getCurrentScopeFunction · 0.90
getActiveSpanFunction · 0.90
setGlobalsFunction · 0.85
getRootSpanFunction · 0.85
setTransactionNameMethod · 0.80
startNavigationSpanFunction · 0.70
warnMethod · 0.65
updateNameMethod · 0.65
setAttributeMethod · 0.65
endMethod · 0.65

Tested by

no test coverage detected