Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AnalyticsEventsDocumenter for symbol event names #9582

Merged
merged 2 commits into from
Nov 13, 2023

Conversation

zachmargolis
Copy link
Contributor

🛠 Summary of changes

Why: The regex got tripped up by a method call on multiple lines

See screenshot below, idv_enter_password_submitted got parsed as:

  name: "idv_enter_password_submitted,\n    success: success,\n    deactivation_reason: deactivation_reason,\n    fraud_review_pending: fraud_review_pending,\n    gpo_verification_pending: gpo_verification_pending,\n    in_person_verification_pending: in_person_verification_pending,\n    fraud_rejection: fraud_rejection,\n    proofing_components: proofing_components,\n    **extra,\n  ",

👀 Screenshots

screenshot
Screenshot 2023-11-13 at 9 13 39 AM

**Why**: The regex got tripped up by a method call on multiple lines

changelog: Internal, Documentation, Update source parsing for analytics events documentation
@zachmargolis zachmargolis requested a review from a team November 13, 2023 17:15
@zachmargolis zachmargolis merged commit bdbc58f into main Nov 13, 2023
2 checks passed
@zachmargolis zachmargolis deleted the margolis-fix-analytics-events-parsing branch November 13, 2023 17:57
def extract_event_name(method_object)
m = /track_event\(\s*[:"'](?<event_name>[^"']+)["',)]/.match(method_object.source)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was the problem more that the negated [^"']+ didn't include the comma from the following character set ["',)]?

i.e.

- m = /track_event\(\s*[:"'](?<event_name>[^"']+)["',)]/.match(method_object.source)
+ m = /track_event\(\s*[:"'](?<event_name>[^"',]+)["',)]/.match(method_object.source)

Alternatively we could change that capture from greedy to lazy:

- m = /track_event\(\s*[:"'](?<event_name>[^"']+)["',)]/.match(method_object.source)
+ m = /track_event\(\s*[:"'](?<event_name>.+?)["',)]/.match(method_object.source)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically a comma would be valid inside the string of an event name, so I didn't want to try that. But realistically that would work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants