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

Id 367 get user registration from sam #4716

Merged
merged 23 commits into from
Apr 2, 2024

Conversation

Shakespeared
Copy link
Contributor

@Shakespeared Shakespeared commented Mar 14, 2024

Jira Ticket: https://broadworkbench.atlassian.net/browse/ID-367

Summary of changes:

remove use of Rex in the UI. Rex is only used to get the registration date to send to Appcues for the NPS Survey. This change gets the registration date from Sam instead, and removes references to Rex from the UI.

The unit tests in login.test.ts are testing new code areas, so I would appreciate a thorough review of those as well. Since these are some of the first auth.ts tests, I want to ensure we're setting a good example for future tests to work from.

Why

We are retiring Rex because we now have the same data stored in Sam

Testing strategy

Appcues itself isn't activated on lower envs, so I'm actually not sure how to test that. However I did verify that the result returned from Sam is the same as was returned from Rex. For testing the changes generally, logging into Terra should be sufficient as it is called on loadTerraUser which is called upon login.

Manually tested general functionality by running locally and logging in

@Shakespeared Shakespeared marked this pull request as ready for review March 18, 2024 22:00
Copy link
Contributor

@Ghost-in-a-Jar Ghost-in-a-Jar left a comment

Choose a reason for hiding this comment

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

Some small comments, not necessarily blocking

src/auth/login.test.ts Show resolved Hide resolved
src/auth/login.test.ts Outdated Show resolved Hide resolved
src/auth/login.test.ts Show resolved Hide resolved
src/libs/state.ts Outdated Show resolved Hide resolved
programLocationCountry: 'testProgramLocationCountry',
researchArea: 'testResearchArea',
starredWorkspaces: 'testStarredWorkspaces',
};
Copy link
Contributor

Choose a reason for hiding this comment

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

looks good!

Copy link
Contributor

@Ghost-in-a-Jar Ghost-in-a-Jar left a comment

Choose a reason for hiding this comment

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

double approved

src/auth/auth.ts Outdated Show resolved Hide resolved
export interface RexFirstTimestampResponse {
timestamp: Date;
}

export interface SamUserResponse {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added the undefined so we can initialize with an empty object in state

const { terraUser, samUser } = userStore.get();
// for Sam users who registered before we started tracking registration dates in Sam,
// registeredAt may be null in the Sam db. In that case, use epoch instead
const dateJoined = samUser.registeredAt ? samUser.registeredAt.getTime() : new Date('1970-01-01').getTime();
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 also just rely on the createdAt date, since its not nullable in Sam's DB. That might be preferable, just in case there's a real createdAt, but not a registeredAt, for some reason.

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 don't think we want to user createdAt because then a user who is invited, waits a month to register, then comes to Terra would immediately be shown the survey

src/auth/auth.ts Show resolved Hide resolved
Copy link

sonarcloud bot commented Apr 2, 2024

@Shakespeared Shakespeared added this pull request to the merge queue Apr 2, 2024
Merged via the queue into dev with commit de0fd22 Apr 2, 2024
8 of 9 checks passed
@Shakespeared Shakespeared deleted the id-367-get-user-registration-from-sam branch April 2, 2024 22:26
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.

4 participants