MCPcopy Create free account
hub / github.com/getsentry/sentry-react-native / buildNodeFromTouchPath

Function buildNodeFromTouchPath

packages/core/src/js/ragetap.ts:158–182  ·  view source on GitHub ↗

* Build a node object compatible with the web SDK's `ReplayBaseDomFrameData` * so that `stringifyNodeAttributes` in the Sentry frontend can render it. * * Maps the React Native component info to the DOM-like shape: * - `tagName` → element type (e.g. "RCTView") or component name * - `attributes[

(
  root: TouchedComponentInfo,
  label?: string,
)

Source from the content-addressed store, hash-verified

156 * - `attributes['data-sentry-source-file']` → source file
157 */
158function buildNodeFromTouchPath(
159 root: TouchedComponentInfo,
160 label?: string,
161): { id: number; tagName: string; textContent: string; attributes: Record<string, string> } {
162 const attributes: Record<string, string> = {};
163
164 if (root.name) {
165 attributes['data-sentry-component'] = root.name;
166 }
167 if (root.file) {
168 attributes['data-sentry-source-file'] = root.file;
169 }
170 if (label) {
171 attributes['sentry-label'] = label;
172 }
173
174 return {
175 // Mobile replays don't have rrweb node IDs — 0 is a placeholder
176 // to satisfy the ReplayBaseDomFrameData shape expected by the frontend.
177 id: 0,
178 tagName: root.element ?? root.name ?? 'unknown',
179 textContent: '',
180 attributes,
181 };
182}
183
184function getCurrentRoute(): string | undefined {
185 try {

Callers 1

checkMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected