From 87c55c54f58c32ac22cef83f73c126d84939c8a5 Mon Sep 17 00:00:00 2001 From: Wes Risenmay Date: Mon, 25 Aug 2025 08:30:43 -0600 Subject: [PATCH 1/6] remove rawInstitution from the go to institution event --- src/views/oauth/OAuthDefault.js | 1 - src/views/oauth/__tests__/OAuthDefault-test.tsx | 1 - 2 files changed, 2 deletions(-) diff --git a/src/views/oauth/OAuthDefault.js b/src/views/oauth/OAuthDefault.js index 6ab47b0b46..8de3ebf517 100644 --- a/src/views/oauth/OAuthDefault.js +++ b/src/views/oauth/OAuthDefault.js @@ -72,7 +72,6 @@ export const OAuthDefault = (props) => { institution_guid: props.institution.guid, institution_name: props.institution.name, member_guid: sha256(props.currentMember.guid), - rawInstitution: props.institution, }) props.onSignInClick() }} diff --git a/src/views/oauth/__tests__/OAuthDefault-test.tsx b/src/views/oauth/__tests__/OAuthDefault-test.tsx index 4d0e750ad5..e6e4beb566 100644 --- a/src/views/oauth/__tests__/OAuthDefault-test.tsx +++ b/src/views/oauth/__tests__/OAuthDefault-test.tsx @@ -46,7 +46,6 @@ describe('', () => { institution_guid: institution.guid, institution_name: institution.name, member_guid: sha256(institution.guid), - rawInstitution: institution, widgetType: defaultEventMetadata.widgetType, }), ) From 89d3532d2da526ee33b69f1057b9ba66d7bcdc9b Mon Sep 17 00:00:00 2001 From: Wes Risenmay Date: Mon, 25 Aug 2025 09:00:18 -0600 Subject: [PATCH 2/6] added a function to the apiProvider to be called when oauth go to login is clicked --- docs/APIDOCUMENTATION.md | 23 +++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/const/apiProviderMock.ts | 1 + src/context/ApiContext.tsx | 2 ++ src/views/oauth/OAuthDefault.js | 8 ++++++++ src/views/oauth/OAuthStartError.js | 4 ++-- src/views/oauth/OAuthStep.js | 8 ++++---- 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/docs/APIDOCUMENTATION.md b/docs/APIDOCUMENTATION.md index ba46953af9..312701a8ee 100644 --- a/docs/APIDOCUMENTATION.md +++ b/docs/APIDOCUMENTATION.md @@ -188,6 +188,29 @@ --- +#### oAuthStart({ member, institution }) + +
+ Called when a user clicks an oauth login button + +##### Parameters + +> | name | type | data type | description | +> | ------------- | -------- | --------- | ----------- | +> | `member` | required | object | | +> | `institution` | required | object | | + +##### Responses + +> | http code | content-type | response | +> | --------- | ------------------ | -------------------------------------------------------------------------- | +> | `200` | `application/json` | `{}` | +> | `40#` | `application/json` | `{"response": {"status": 40#, "data": { "message": "Test message here"}}}` | + +
+ +--- + #### createSupportTicket(ticket)
diff --git a/package-lock.json b/package-lock.json index f2a89ca040..6e812823ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mxenabled/connect-widget", - "version": "0.15.5", + "version": "0.0.0-semantic-release", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mxenabled/connect-widget", - "version": "0.15.5", + "version": "0.0.0-semantic-release", "dependencies": { "@emotion/react": "^11.13.0", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index d8a65aa6ae..6535ec0e00 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@mxenabled/connect-widget", "description": "A simple ui library for React", - "version": "0.15.5", + "version": "0.0.0-semantic-release", "module": "dist/index.es.js", "types": "dist/index.d.ts", "type": "module", diff --git a/src/const/apiProviderMock.ts b/src/const/apiProviderMock.ts index d00154cebb..8b6d1e12e0 100644 --- a/src/const/apiProviderMock.ts +++ b/src/const/apiProviderMock.ts @@ -20,6 +20,7 @@ export const apiValue: ApiContextTypes = { loadInstitutions: () => Promise.resolve(SEARCHED_INSTITUTIONS), loadPopularInstitutions: () => Promise.resolve(FAVORITE_INSTITUTIONS), loadInstitutionByGuid: () => Promise.resolve(institutionData.institution), + oAuthStart: () => Promise.resolve(), updateMFA: () => Promise.resolve(member.member), loadJob: () => Promise.resolve(JOB_DATA), runJob: () => Promise.resolve(member.member), diff --git a/src/context/ApiContext.tsx b/src/context/ApiContext.tsx index f08bf99116..853be306d3 100644 --- a/src/context/ApiContext.tsx +++ b/src/context/ApiContext.tsx @@ -61,6 +61,7 @@ export type ApiContextTypes = { memberGuid: string, config: ClientConfigType, ) => Promise + oAuthStart?: ({ member, institution }: { member: object; institution: object }) => Promise //MFA updateMFA: ( member: object, @@ -119,6 +120,7 @@ export const defaultApiValue: ApiContextTypes = { loadOAuthState: () => Promise.resolve({} as OAuthStateResponseType), loadOAuthStates: () => Promise.resolve([] as OAuthStateResponseType[]), getOAuthWindowURI: () => Promise.resolve({} as OAuthWindowURIResponseType), + oAuthStart: () => Promise.resolve(), // Support createSupportTicket: () => Promise.resolve(), //Job diff --git a/src/views/oauth/OAuthDefault.js b/src/views/oauth/OAuthDefault.js index 8de3ebf517..29f5d51734 100644 --- a/src/views/oauth/OAuthDefault.js +++ b/src/views/oauth/OAuthDefault.js @@ -19,8 +19,11 @@ import { getDelay } from 'src/utilities/getDelay' import useAnalyticsPath from 'src/hooks/useAnalyticsPath' import useAnalyticsEvent from 'src/hooks/useAnalyticsEvent' import { AnalyticEvents, PageviewInfo } from 'src/const/Analytics' +import { useApi } from 'src/context/ApiContext' export const OAuthDefault = (props) => { + const { api } = useApi() + useAnalyticsPath(...PageviewInfo.CONNECT_OAUTH_INSTRUCTIONS, { institution_guid: props.institution.guid, institution_name: props.institution.name, @@ -73,6 +76,11 @@ export const OAuthDefault = (props) => { institution_name: props.institution.name, member_guid: sha256(props.currentMember.guid), }) + api.oAuthStart({ + member: props.currentMember, + institution: props.institution, + }) + props.onSignInClick() }} role="link" diff --git a/src/views/oauth/OAuthStartError.js b/src/views/oauth/OAuthStartError.js index e176612859..1d14e0568e 100644 --- a/src/views/oauth/OAuthStartError.js +++ b/src/views/oauth/OAuthStartError.js @@ -24,7 +24,7 @@ export const OAuthStartError = (props) => { - + @@ -56,6 +56,6 @@ const getStyles = (tokens) => ({ OAuthStartError.propTypes = { institution: PropTypes.object.isRequired, - oauthStartError: PropTypes.object.isRequired, + oAuthStartError: PropTypes.object.isRequired, onOAuthTryAgain: PropTypes.func.isRequired, } diff --git a/src/views/oauth/OAuthStep.js b/src/views/oauth/OAuthStep.js index 099bd003a9..471fa84158 100644 --- a/src/views/oauth/OAuthStep.js +++ b/src/views/oauth/OAuthStep.js @@ -37,7 +37,7 @@ export const OAuthStep = React.forwardRef((props, navigationRef) => { const interstitialNavRef = useRef(null) const containerRef = useRef(null) const [isWaitingForOAuth, setIsWaitingForOAuth] = useState(false) - const [oauthStartError, setOAuthStartError] = useState(null) + const [oAuthStartError, setOAuthStartError] = useState(null) const [isStartingOauth, setIsStartingOauth] = useState(false) const config = useSelector(selectConfig) const member = useSelector((state) => getCurrentMember(state)) @@ -80,7 +80,7 @@ export const OAuthStep = React.forwardRef((props, navigationRef) => { return true }, } - }, [isWaitingForOAuth, oauthStartError, showInterstitialDisclosure]) + }, [isWaitingForOAuth, oAuthStartError, showInterstitialDisclosure]) /** * Called when we succesfully generate an oauth window uri for the exsting @@ -247,11 +247,11 @@ export const OAuthStep = React.forwardRef((props, navigationRef) => { onOAuthSuccess={handleOAuthSuccess} /> ) - } else if (oauthStartError) { + } else if (oAuthStartError) { oauthView = ( From efba818f0f8a2b9ed51b1f5390c8558320e8e218 Mon Sep 17 00:00:00 2001 From: Wes Risenmay Date: Mon, 25 Aug 2025 09:29:58 -0600 Subject: [PATCH 3/6] undo accidental variable rename --- src/views/oauth/OAuthStartError.js | 4 ++-- src/views/oauth/OAuthStep.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/views/oauth/OAuthStartError.js b/src/views/oauth/OAuthStartError.js index 1d14e0568e..e176612859 100644 --- a/src/views/oauth/OAuthStartError.js +++ b/src/views/oauth/OAuthStartError.js @@ -24,7 +24,7 @@ export const OAuthStartError = (props) => { - + @@ -56,6 +56,6 @@ const getStyles = (tokens) => ({ OAuthStartError.propTypes = { institution: PropTypes.object.isRequired, - oAuthStartError: PropTypes.object.isRequired, + oauthStartError: PropTypes.object.isRequired, onOAuthTryAgain: PropTypes.func.isRequired, } diff --git a/src/views/oauth/OAuthStep.js b/src/views/oauth/OAuthStep.js index 471fa84158..099bd003a9 100644 --- a/src/views/oauth/OAuthStep.js +++ b/src/views/oauth/OAuthStep.js @@ -37,7 +37,7 @@ export const OAuthStep = React.forwardRef((props, navigationRef) => { const interstitialNavRef = useRef(null) const containerRef = useRef(null) const [isWaitingForOAuth, setIsWaitingForOAuth] = useState(false) - const [oAuthStartError, setOAuthStartError] = useState(null) + const [oauthStartError, setOAuthStartError] = useState(null) const [isStartingOauth, setIsStartingOauth] = useState(false) const config = useSelector(selectConfig) const member = useSelector((state) => getCurrentMember(state)) @@ -80,7 +80,7 @@ export const OAuthStep = React.forwardRef((props, navigationRef) => { return true }, } - }, [isWaitingForOAuth, oAuthStartError, showInterstitialDisclosure]) + }, [isWaitingForOAuth, oauthStartError, showInterstitialDisclosure]) /** * Called when we succesfully generate an oauth window uri for the exsting @@ -247,11 +247,11 @@ export const OAuthStep = React.forwardRef((props, navigationRef) => { onOAuthSuccess={handleOAuthSuccess} /> ) - } else if (oAuthStartError) { + } else if (oauthStartError) { oauthView = ( From 7dd736d2c6ce7123dde731c816213d8b0da4ee1b Mon Sep 17 00:00:00 2001 From: Wes Risenmay Date: Mon, 25 Aug 2025 09:35:50 -0600 Subject: [PATCH 4/6] only call oAuthStart if it exists --- src/views/oauth/OAuthDefault.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/oauth/OAuthDefault.js b/src/views/oauth/OAuthDefault.js index 29f5d51734..1cab162738 100644 --- a/src/views/oauth/OAuthDefault.js +++ b/src/views/oauth/OAuthDefault.js @@ -76,7 +76,7 @@ export const OAuthDefault = (props) => { institution_name: props.institution.name, member_guid: sha256(props.currentMember.guid), }) - api.oAuthStart({ + api?.oAuthStart({ member: props.currentMember, institution: props.institution, }) From 4223c78de8f735c6a68d32743976e9b51f994a91 Mon Sep 17 00:00:00 2001 From: Wes Risenmay Date: Mon, 25 Aug 2025 09:56:22 -0600 Subject: [PATCH 5/6] feat(oauthdefault): changed an analytics event and added a function to the api provider Removed rawInstitution from the go to oauth login analytics event and added a function to the api provider to be called when a user clicks go to institution in the oauth flow. --- src/utilities/testingLibrary.tsx | 15 ++++++++++++--- src/views/oauth/__tests__/OAuthDefault-test.tsx | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/utilities/testingLibrary.tsx b/src/utilities/testingLibrary.tsx index c7b702cc69..3927686f7a 100644 --- a/src/utilities/testingLibrary.tsx +++ b/src/utilities/testingLibrary.tsx @@ -11,12 +11,13 @@ import { WidgetDimensionObserver } from 'src/components/app/WidgetDimensionObser import { PostMessageContext } from 'src/ConnectWidget' import { AnalyticContext } from 'src/Connect' import { initialState } from 'src/services/mockedData' -import { ApiProvider } from 'src/context/ApiContext' -import { apiValue } from 'src/const/apiProviderMock' +import { ApiContextTypes, ApiProvider } from 'src/context/ApiContext' +import { apiValue as apiValueMock } from 'src/const/apiProviderMock' // This type interface extends the default options for render from RTL, as well // as allows the user to specify other things such as initialState, store. interface ExtendedRenderOptions extends Omit { + apiValue?: ApiContextTypes onAnalyticsEvent?: () => void preloadedState?: Partial store?: AppStore @@ -32,10 +33,12 @@ interface ExtendedRenderOptions extends Omit { If you want to include global redux store. */ export const AllTheProviders = ({ + apiValue = apiValueMock, children, onAnalyticsEvent = () => {}, store, }: { + apiValue?: ApiContextTypes children: React.ReactNode onAnalyticsEvent?: () => void store: AppStore @@ -63,6 +66,7 @@ export const AllTheProviders = ({ const renderWithUser = ( ui: ReactElement, { + apiValue = apiValueMock, preloadedState = initialState, store = createReduxStore(preloadedState), onAnalyticsEvent, @@ -72,7 +76,12 @@ const renderWithUser = ( return { ...render(ui, { wrapper: (props) => ( - + ), ...options, }), diff --git a/src/views/oauth/__tests__/OAuthDefault-test.tsx b/src/views/oauth/__tests__/OAuthDefault-test.tsx index e6e4beb566..10972ddbc7 100644 --- a/src/views/oauth/__tests__/OAuthDefault-test.tsx +++ b/src/views/oauth/__tests__/OAuthDefault-test.tsx @@ -5,14 +5,16 @@ import { expect, vi } from 'vitest' import userEvent from '@testing-library/user-event' import { AnalyticEvents, defaultEventMetadata } from 'src/const/Analytics' import { sha256 } from 'js-sha256' +import { ApiContextTypes } from 'src/context/ApiContext' describe('', () => { - it('sends an analytics event onClick and calls onSignInClick', async () => { + it('sends an analytics event onClick, calls oAuthStart, and calls onSignInClick', async () => { const onSignInClick = vi.fn() const onAnalyticsEvent = vi.fn() const institution = { guid: 'testGuid', name: 'testName', testProp: 'testValue' } + const member = { guid: 'testGuid' } const store = createTestReduxStore({ connect: { @@ -21,15 +23,20 @@ describe('', () => { }, }) + const apiValue = { + oAuthStart: vi.fn(), + } as unknown as ApiContextTypes + render( {}} />, { + apiValue, onAnalyticsEvent, store, }, @@ -49,5 +56,9 @@ describe('', () => { widgetType: defaultEventMetadata.widgetType, }), ) + expect(apiValue.oAuthStart).toHaveBeenCalledWith({ + institution, + member, + }) }) }) From 73e32ba4748cf1ce90dd7eee20243b87059b6d61 Mon Sep 17 00:00:00 2001 From: Wes Risenmay Date: Thu, 28 Aug 2025 09:11:04 -0600 Subject: [PATCH 6/6] removed institution from oauthStart --- docs/APIDOCUMENTATION.md | 9 ++++----- src/context/ApiContext.tsx | 2 +- src/views/oauth/OAuthDefault.js | 1 - src/views/oauth/__tests__/OAuthDefault-test.tsx | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/APIDOCUMENTATION.md b/docs/APIDOCUMENTATION.md index 312701a8ee..50a10cf11f 100644 --- a/docs/APIDOCUMENTATION.md +++ b/docs/APIDOCUMENTATION.md @@ -188,17 +188,16 @@ --- -#### oAuthStart({ member, institution }) +#### oAuthStart({ member })
Called when a user clicks an oauth login button ##### Parameters -> | name | type | data type | description | -> | ------------- | -------- | --------- | ----------- | -> | `member` | required | object | | -> | `institution` | required | object | | +> | name | type | data type | description | +> | -------- | -------- | --------- | ----------- | +> | `member` | required | object | | ##### Responses diff --git a/src/context/ApiContext.tsx b/src/context/ApiContext.tsx index 853be306d3..abb78719f6 100644 --- a/src/context/ApiContext.tsx +++ b/src/context/ApiContext.tsx @@ -61,7 +61,7 @@ export type ApiContextTypes = { memberGuid: string, config: ClientConfigType, ) => Promise - oAuthStart?: ({ member, institution }: { member: object; institution: object }) => Promise + oAuthStart?: ({ member }: { member: object }) => Promise //MFA updateMFA: ( member: object, diff --git a/src/views/oauth/OAuthDefault.js b/src/views/oauth/OAuthDefault.js index 1cab162738..58a5be562d 100644 --- a/src/views/oauth/OAuthDefault.js +++ b/src/views/oauth/OAuthDefault.js @@ -78,7 +78,6 @@ export const OAuthDefault = (props) => { }) api?.oAuthStart({ member: props.currentMember, - institution: props.institution, }) props.onSignInClick() diff --git a/src/views/oauth/__tests__/OAuthDefault-test.tsx b/src/views/oauth/__tests__/OAuthDefault-test.tsx index 10972ddbc7..a1f26ecd19 100644 --- a/src/views/oauth/__tests__/OAuthDefault-test.tsx +++ b/src/views/oauth/__tests__/OAuthDefault-test.tsx @@ -57,7 +57,6 @@ describe('', () => { }), ) expect(apiValue.oAuthStart).toHaveBeenCalledWith({ - institution, member, }) })