Skip to content

Validate event name for frontend logging#9438

Merged
mitchellhenke merged 16 commits intomainfrom
mitchellhenke/require-validating-event-name
Oct 31, 2023
Merged

Validate event name for frontend logging#9438
mitchellhenke merged 16 commits intomainfrom
mitchellhenke/require-validating-event-name

Conversation

@mitchellhenke
Copy link
Contributor

🛠 Summary of changes

Action item from the 2023-09-07 contingency planning scenario to require validation of events logged from the frontend

Related to #9421

@mitchellhenke mitchellhenke requested a review from aduth October 24, 2023 14:42
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/require-validating-event-name branch from 1fd3f3f to 94dc73a Compare October 24, 2023 15:31
@aduth
Copy link
Contributor

aduth commented Oct 25, 2023

There's a couple more through ClickObserverComponent event_name:

<%= render ClickObserverComponent.new(event_name: 'IdV: user clicked what to bring link on ready to verify page') do %>

<%= render ClickObserverComponent.new(event_name: 'IdV: user clicked sp link on ready to verify page') do %>

Copy link
Contributor

Choose a reason for hiding this comment

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

Is **extra unused on purpose?

Copy link
Contributor Author

@mitchellhenke mitchellhenke Oct 27, 2023

Choose a reason for hiding this comment

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

yeah, frontend events only accept keys that are defined (due to this) so passing extra into the logging is not doing anything. I've updated the other frontend events accordingly.

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/require-validating-event-name branch 3 times, most recently from b0348f0 to 842ded8 Compare October 27, 2023 14:36
@mitchellhenke
Copy link
Contributor Author

There's a couple more through ClickObserverComponent event_name:

<%= render ClickObserverComponent.new(event_name: 'IdV: user clicked what to bring link on ready to verify page') do %>

<%= render ClickObserverComponent.new(event_name: 'IdV: user clicked sp link on ready to verify page') do %>

added in 5e03e1b9e3fe128f95d6e938e7973fd117f59951

@mitchellhenke mitchellhenke marked this pull request as ready for review October 27, 2023 14:57
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/require-validating-event-name branch 2 times, most recently from 5b25c9e to 6e3bcd2 Compare October 27, 2023 15:03
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

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

I think this looks good, I'll take a detailed look a little later.

Copy link
Contributor

Choose a reason for hiding this comment

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

To the earlier point about this **_extra, can we just exclude it? Or is the problem that the send will always try to pass a hash of values; in which case, could we make sure that only happens if it's non-empty? I guess I'm thinking that we should either never expect **extra to be passed, or we could just log the **extra for consistency with other events (except for methods like this which don't have any arguments).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're limited by https://github.com/18F/identity-idp/blob/d099da2181ab73c733f8a0dea561ca4152e5aa10/lib/analytics_events_documenter.rb#L114-L116 which ends up failing lint with:

app/services/analytics_events.rb:704 idv_back_image_clicked missing **extra

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/require-validating-event-name branch 2 times, most recently from d099da2 to 8dbe5f0 Compare October 27, 2023 16:13
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

We could add a { ... }.compact inside AnalyticsEvents if we wanted to minimize diff noise here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing nil values is a change to downstream logging behavior and I'm not sure if the presence of nil is important or depended on in some way :/

Copy link
Contributor

Choose a reason for hiding this comment

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

usually nil values are elided by CW, so it's not meaningful, but happy to err on the conservative side of this and leave these nils in there

@mitchellhenke mitchellhenke force-pushed the mitchellhenke/require-validating-event-name branch 3 times, most recently from 0775bda to bca802f Compare October 31, 2023 16:30
@mitchellhenke mitchellhenke force-pushed the mitchellhenke/require-validating-event-name branch from bca802f to 4b16f6c Compare October 31, 2023 17:06
@mitchellhenke mitchellhenke merged commit 5caa0d9 into main Oct 31, 2023
@mitchellhenke mitchellhenke deleted the mitchellhenke/require-validating-event-name branch October 31, 2023 17:38
@amirbey amirbey mentioned this pull request Nov 2, 2023
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