Skip to content

LG-7058 | IrsAttemptsApi::Tracker sets up base parameters#6664

Merged
n1zyy merged 11 commits intomainfrom
mattw/LG-7058_attempt_event_new
Aug 9, 2022
Merged

LG-7058 | IrsAttemptsApi::Tracker sets up base parameters#6664
n1zyy merged 11 commits intomainfrom
mattw/LG-7058_attempt_event_new

Conversation

@n1zyy
Copy link
Contributor

@n1zyy n1zyy commented Jul 29, 2022

Why: Simplifies the addition of new events. There are a bunch of base parameters used in every event, so let's set them up in the constructor rather than in every call to track_event.

For bonus points, this hashes our session ID, and passes in a couple newly-requested parameters like device ID.

changelog: Internal: Attempts API: Establish base event attributes

changelog: Internal: Attempts API: Establish base event attributes
Copy link
Contributor Author

@n1zyy n1zyy left a comment

Choose a reason for hiding this comment

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

This is still a WIP, but I wanted to push this up before the weekend and see if it breaks anything.


return nil unless spi.present?
new(spi).link_identity
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works and is in keeping with some of the existing patterns, but it feels a bit ugly to me.

sp1 = create_identity(user, 'http://localhost:3000', 'UUID1')
create_identity(user, 'urn:gov:gsa:openidconnect:test', 'UUID2')
sp1 = create_service_provider_identity(user, 'http://localhost:3000', 'UUID1')
create_service_provider_identity(user, 'urn:gov:gsa:openidconnect:test', 'UUID2')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed this which created a lot of noise.

end

context 'and there is no service provider identity' do
it 'returns nil' do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this seem like reasonable behavior?


def create_agency_identity(user, agency, uuid)
AgencyIdentity.create!(user: user, agency: agency, uuid: uuid)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only used in one place, but I wanted to follow the pattern of the existing create_identity. I paid a bit of a price in terms of PR noise, though...

sp: service_provider,
enabled_for_session: enabled_for_session,
)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be clear, this isn't testing anything new, just passing in everything now needed.

Trying to reason about here a good test for this should go, though... I feel like there should probably be an end-to-end test somewhere for this.

@n1zyy
Copy link
Contributor Author

n1zyy commented Aug 5, 2022

With these applied, a login event has this for event_metadata:

{:user_agent=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0",
 :unique_session_id=>"9b69723bc4e3efea805cb37e376e6dab8fc9c49d",
 :user_uuid=>"63de095e-8ba3-4823-aa96-ffd656abbd8e",
 :device_fingerprint=>"4f75cd5f3967063bd1230ee1497cc67d901850955bf415fa3313231d2a5d7121f2d36916e3f9eb39a19f4398e2a6e95245e4f39d44712e07e8b90bbd7b16a1e1",
 :user_ip_address=>"127.0.0.1",
 :irs_application_url=>"http://localhost:9292/auth/result",
 :email=>"matt@example.com",
 :success=>true}

changelog: Internal, Attempts API, Establish base event attributes
@n1zyy n1zyy force-pushed the mattw/LG-7058_attempt_event_new branch from 7391687 to 1c1f3c6 Compare August 5, 2022 20:36
@n1zyy n1zyy changed the title LG-7058 | IrsAttemptsApi::Tracker sets up base parameters [wip] LG-7058 | IrsAttemptsApi::Tracker sets up base parameters Aug 5, 2022
@n1zyy n1zyy marked this pull request as ready for review August 5, 2022 20:51
@n1zyy n1zyy requested a review from a team August 5, 2022 20:51
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, some small comments

).take

return nil unless spi.present?
new(spi).link_identity
Copy link
Contributor

Choose a reason for hiding this comment

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

I would love a version of this method that is read-only and doesn't attempt to link? But I'm not sure that would work here, for the AttemptsAPI.... since usually the ID is only created after an account is created + consented to? Maybe we put in a pin and circle back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was unclear on some of the existing semantics here. Just to be clear, are you suggesting to leave this as-is for now but consider circling back on this later? Or are you saying that this is will prematurely create these links and should be changed now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry that was a mess of a comment. Let's leave this as-is

n1zyy and others added 3 commits August 8, 2022 14:14
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
@n1zyy n1zyy merged commit 6282dc7 into main Aug 9, 2022
@n1zyy n1zyy deleted the mattw/LG-7058_attempt_event_new branch August 9, 2022 15:54
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.

2 participants