File Path | Event Name | Additional Properties |
---|---|---|
src/applications/combined-debt-portal/combined/routes.jsx | cta-link-click-enter-mcp | { } |
src/applications/combined-debt-portal/combined/routes.jsx | cta-link-click-enter-ltr | { } |
src/applications/combined-debt-portal/combined/actions/debts.js | bam-get-veteran-vbms-info-failed | { } |
src/applications/combined-debt-portal/combined/actions/debts.js | bam-get-veteran-dmc-info-failed | { } |
src/applications/combined-debt-portal/combined/actions/debts.js | bam-get-veteran-dmc-info-successful | { "veteran-has-dependent-debt": hasDependentDebts, } |
src/applications/combined-debt-portal/combined/actions/debts.js | bam-cards-retrieved | { "number-of-current-debt-cards": filteredResponse.length, } |
src/applications/combined-debt-portal/combined/actions/debts.js | bam-get-veteran-dmc-info-failed | { } |
src/applications/combined-debt-portal/combined/components/ComboAlerts.jsx | cdp-alert-card-error | { "cdp-alert-card-error": "true", } |
src/applications/combined-debt-portal/combined/components/MCPAlerts.jsx | cta-link-click-debt-request-help | { } |
src/applications/combined-debt-portal/combined/components/MCPAlerts.jsx | visible-alert-box | { "alert-box-type": "warning", "alert-box-heading": "You’re not enrolled in VA health care", } |
src/applications/combined-debt-portal/combined/components/MCPAlerts.jsx | visible-alert-box | { "alert-box-type": "info", "alert-box-heading": "You haven’t received a copay bill in the past 6 months", } |
src/applications/combined-debt-portal/combined/components/MCPAlerts.jsx | visible-alert-box | { "alert-box-type": "info", "alert-box-heading": "You don’t need to make a payment at this time", } |
src/applications/combined-debt-portal/combined/components/MCPAlerts.jsx | visible-alert-box | { "alert-box-type": "info", "alert-box-heading": "Your balance may be overdue", } |
src/applications/combined-debt-portal/combined/components/MCPAlerts.jsx | visible-alert-box | { "alert-box-type": "error", "alert-box-heading": "We can't access your current copay balances right now", "error-key": ${error?.status} |
src/applications/combined-debt-portal/debt-letters/components/DebtDetailsCard.jsx | cta-link-click-debt-make-payment | { } |
src/applications/combined-debt-portal/debt-letters/components/DebtDetailsCard.jsx | cta-link-click-debt-request-help | { } |
src/applications/combined-debt-portal/debt-letters/components/DebtLettersTable.jsx | bam-debt-letter-download | { "letter-type": type, "letter-received-date": date, } |
src/applications/combined-debt-portal/debt-letters/components/DebtSummaryCard.jsx | cta-link-click-debt-summary-card | { } |
src/applications/combined-debt-portal/medical-copays/components/BalanceCard.jsx | cta-link-click-copay-balance-card | { } |
src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx | debt-mcp-pdf-download | { "letter-received-date": date, } |
src/applications/combined-debt-portal/medical-copays/components/DownloadStatement.jsx | cta-link-click-copay-statement-download | { } |
src/applications/combined-debt-portal/medical-copays/components/HTMLStatementLink.jsx | cta-link-click-copay-statement-link | { } |
Last active
April 10, 2024 20:48
-
-
Save amponce/7e8c8c7f6b13b2faca3aee72f2ae26ca to your computer and use it in GitHub Desktop.
Find EventRecords
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs').promises; | |
const path = require('path'); | |
async function findRecordEvent(dirPath, results) { | |
try { | |
const files = await fs.readdir(dirPath, { withFileTypes: true }); | |
await Promise.all( | |
files.map(async file => { | |
if (file.isDirectory()) { | |
await findRecordEvent(path.join(dirPath, file.name), results); | |
} else if (file.name.endsWith('.js') || file.name.endsWith('.jsx')) { | |
const filePath = path.join(dirPath, file.name); | |
const contents = await fs.readFile(filePath, 'utf8'); | |
const regex = /recordEvent\((\{[\s\S]*?\})\);?/g; | |
let match; | |
// eslint-disable-next-line no-cond-assign | |
while ((match = regex.exec(contents)) !== null) { | |
const relativePath = path.relative(__dirname, filePath); | |
results.push(`${relativePath} --- ${match[1]}`); | |
} | |
} | |
}), | |
); | |
} catch (err) { | |
// eslint-disable-next-line no-console | |
console.error(`Error processing directory ${dirPath}: ${err}`); | |
} | |
} | |
function safeParseEventDetails(eventDetails) { | |
// Extract the event name using a regular expression. | |
const eventMatch = eventDetails.match( | |
/event:\s*(?:[`'"])?([^\s,`'"]+)(?:[`'"],)?/, | |
); | |
const eventName = eventMatch ? eventMatch[1] : 'Unknown'; | |
// Flatten additional properties to a string that's safe for Markdown. | |
// This involves removing line breaks and trimming trailing commas. | |
const additionalProps = eventDetails | |
.replace(/event:\s*['"][^'"]+['"],?\s*/, '') // Remove the 'event' property | |
.replace(/\s*\n\s*/g, ' ') // Remove newlines and excess whitespace | |
.replace(/,\s*$/, ''); // Remove trailing commas | |
return { | |
event: eventName, | |
additionalProps: additionalProps.replace(/'/g, `"`), // Replace single quotes with double quotes for consistency | |
}; | |
} | |
async function writeResultsToFile(results, outputFile) { | |
const tableRows = results.map(result => { | |
const [filePath, eventDetails] = result.split(' --- '); | |
const { event: eventName, additionalProps } = safeParseEventDetails( | |
eventDetails, | |
); | |
// Ensuring additionalProps are displayed in a single line and Markdown-safe | |
const formattedAdditionalProps = | |
additionalProps.length > 0 ? `\`${additionalProps}\`` : '-'; | |
return `| ${filePath} | ${eventName} | ${formattedAdditionalProps} |`; | |
}); | |
const tableHeader = `| File Path | Event Name | Additional Properties |\n|-----------|-----------|----------------------|`; | |
const markdownTable = `${tableHeader}\n${tableRows.join('\n')}`; | |
await fs.writeFile(outputFile, markdownTable, 'utf8'); | |
// eslint-disable-next-line no-console | |
console.log(`Results written to ${outputFile}`); | |
} | |
(async () => { | |
const args = process.argv.slice(2); | |
if (args.length !== 2) { | |
// eslint-disable-next-line no-console | |
console.log('Usage: node EventCrawler.js <directory> <output-file>'); | |
process.exit(1); | |
} | |
const directory = args[0]; | |
const outputFile = args[1]; | |
const results = []; | |
await findRecordEvent(directory, results); | |
await writeResultsToFile(results, outputFile); | |
})(); |
File Path | Event Name | Additional Properties |
---|---|---|
src/applications/financial-status-report/containers/IntroductionPage.jsx | howToWizard-start-over | { } |
src/applications/financial-status-report/components/shared/DownloadFormPDF.jsx | debt-fsr-pdf-content-fetch | { } |
src/applications/financial-status-report/components/shared/DownloadFormPDF.jsx | debt-fsr-pdf-content-fetch-fail | { } |
src/applications/financial-status-report/components/shared/DownloadFormPDF.jsx | download-financial-status-report | { "financial-status-report-download-type": "pdf", } |
src/applications/financial-status-report/components/shared/ReviewCardField.jsx | uiSchema.saveClickTrackEvent | { event: uiSchema.saveClickTrackEvent } |
src/applications/financial-status-report/wizard/pages/Appeals.jsx | howToWizard-alert-displayed | { "reason-for-alert": "appeal the decision with the Board of Veterans" Appeals", } |
src/applications/financial-status-report/wizard/pages/Appeals.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "request a Board Appeal", } |
src/applications/financial-status-report/wizard/pages/Appeals.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Find out how to request a Board Appeal", } |
src/applications/financial-status-report/wizard/pages/Appeals.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "contested claim", } |
src/applications/financial-status-report/wizard/pages/Copays.jsx | howToWizard-alert-displayed | { "reason-for-alert": "debt related to VA health care copays", } |
src/applications/financial-status-report/wizard/pages/Copays.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Learn how to make a payment now", } |
src/applications/financial-status-report/wizard/pages/Copays.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Learn how to dispute your VA copay charges", } |
src/applications/financial-status-report/wizard/pages/Copays.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Learn how to request a VA hardship determination and copay exemption", } |
src/applications/financial-status-report/wizard/pages/Benefits.jsx | howToWizard-alert-displayed | { "reason-for-alert": "debt related to separation pay/attorney fees", } |
src/applications/financial-status-report/wizard/pages/Decision.jsx | howToWizard-formChange | { "form-field-type": "form-radio-buttons", "form-field-label": label, "form-field-value": value, } |
src/applications/financial-status-report/wizard/pages/Dependents.jsx | howToWizard-alert-displayed | { "reason-for-alert": "request help with debt for spouses or dependents", } |
src/applications/financial-status-report/wizard/pages/Dependents.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Financial Status Report (VA Form 5655).", } |
src/applications/financial-status-report/wizard/pages/Error.jsx | howToWizard-alert-displayed | { "reason-for-alert": "debt is due to an error", } |
src/applications/financial-status-report/wizard/pages/Error.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Contact us through Ask VA", } |
src/applications/financial-status-report/wizard/pages/Disagree.jsx | howToWizard-alert-displayed | { "reason-for-alert": "disagree with the VA decision that resulted in this debt", } |
src/applications/financial-status-report/wizard/pages/Disagree.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Learn more about decision reviews and appeals", } |
src/applications/financial-status-report/wizard/pages/Disagree.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Find helpful VA phone numbers", } |
src/applications/financial-status-report/wizard/pages/Disagree.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Request help with VA Form 5655", } |
src/applications/financial-status-report/wizard/pages/LessThanFive.jsx | howToWizard-alert-displayed | { "reason-for-alert": "no submission needed to request an extended monthly payment plan of up to 5 years", } |
src/applications/financial-status-report/wizard/pages/LessThanFive.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Contact us through Ask VA", } |
src/applications/financial-status-report/wizard/pages/MakePayment.jsx | howToWizard-alert-displayed | { "reason-for-alert": "make a payment on a debt", } |
src/applications/financial-status-report/wizard/pages/MakePayment.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Find out how to manage your debt", } |
src/applications/financial-status-report/wizard/pages/Recipients.jsx | howToWizard-formChange | { "form-field-type": "form-radio-buttons", "form-field-label": label, "form-field-value": value, } |
src/applications/financial-status-report/wizard/pages/Reconsider.jsx | howToWizard-formChange | { "form-field-type": "form-radio-buttons", "form-field-label": label, "form-field-value": value, } |
src/applications/financial-status-report/wizard/pages/Repayment.jsx | howToWizard-formChange | { "form-field-type": "form-radio-buttons", "form-field-label": label, "form-field-value": value, } |
src/applications/financial-status-report/wizard/pages/Request.jsx | howToWizard-formChange | { "form-field-type": "form-radio-buttons", "form-field-label": label, "form-field-value": value, } |
src/applications/financial-status-report/wizard/pages/RogersStem.jsx | howToWizard-alert-displayed | { "reason-for-alert": "help with STEM program debt", } |
src/applications/financial-status-report/wizard/pages/Start.jsx | howToWizard-formChange | { "form-field-type": "form-radio-buttons", "form-field-label": label, "form-field-value": value, } |
src/applications/financial-status-report/wizard/pages/VetTec.jsx | howToWizard-alert-displayed | { "reason-for-alert": "help with VET TEC program debt", } |
src/applications/financial-status-report/wizard/pages/Waivers.jsx | howToWizard-alert-displayed | { "reason-for-alert": "ask Committee of Waivers and Compromises to reconsider waiver", } |
src/applications/financial-status-report/wizard/pages/Waivers.jsx | howToWizard-alert-link-click | { "howToWizard-alert-link-click-label": "Contact us through Ask VA", } |
src/applications/financial-status-report/wizard/WizardContainer.jsx | howToWizard-skip | { event: howToWizard-skip, } |
src/applications/financial-status-report/components/alerts/ComboAlerts.jsx | cdp-alert-card-error | { "cdp-alert-card-error": "true", } |
src/applications/financial-status-report/wizard/components/StartFormButton.jsx | howToWizard-cta-displayed | { } |
src/applications/financial-status-report/wizard/components/StartFormButton.jsx | cta-button-click | { "button-type": "primary", "button-click-label": label, } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To execute the script, place the EventCrawler.js file in the root directory of the vets-website project. Then, in your terminal, specify the path to the project directory and an output filename as arguments like so:
Alternatively, if you place the EventCrawler.js file inside a specific project directory, you can simply use a period (.) to represent the current directory instead of specifying the full path:
node EventCrawler.js . output.md
Remember to replace
output.md
with your desired output file name. (markdown only)