(props: P)
| 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 | } |
nothing calls this directly
no test coverage detected