MCPcopy Index your code
hub / github.com/getsentry/sentry / extractFieldFromJsx

Method extractFieldFromJsx

scripts/extractFormFields.ts:170–204  ·  view source on GitHub ↗
(
    node: ts.JsxElement | ts.JsxSelfClosingElement,
    formId: string,
    route: string,
    sourceFile: ts.SourceFile
  )

Source from the content-addressed store, hash-verified

168 }
169
170 private extractFieldFromJsx(
171 node: ts.JsxElement | ts.JsxSelfClosingElement,
172 formId: string,
173 route: string,
174 sourceFile: ts.SourceFile
175 ): ExtractedField | null {
176 // Check if this is <form.AppField> or <AutoSaveForm>
177 const tagName = this.getJsxTagName(node, sourceFile);
178 const isAppField = tagName?.includes('AppField');
179 const isAutoSaveForm = tagName === 'AutoSaveForm';
180 if (!isAppField && !isAutoSaveForm) {
181 return null;
182 }
183
184 // Extract 'name' attribute
185 const nameAttr = this.getJsxAttribute(node, 'name');
186 if (!nameAttr) {
187 return null;
188 }
189
190 // Extract metadata from render prop children
191 const fieldMetadata = this.extractFieldMetadata(node, sourceFile);
192
193 // Omit the entire entry if we cannot extract a string label
194 if (!fieldMetadata.label) {
195 return null;
196 }
197
198 return {
199 name: nameAttr,
200 formId,
201 route,
202 ...fieldMetadata,
203 };
204 }
205
206 private extractFieldMetadata(
207 node: ts.JsxElement | ts.JsxSelfClosingElement,

Callers 1

visitMethod · 0.95

Calls 3

getJsxTagNameMethod · 0.95
getJsxAttributeMethod · 0.95
extractFieldMetadataMethod · 0.95

Tested by

no test coverage detected