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(DIA-815): add AuthImpression and ResetYourPassword events (and more!) #10978

Merged
merged 8 commits into from
Oct 21, 2024

Conversation

iskounen
Copy link
Contributor

@iskounen iskounen commented Oct 18, 2024

This PR resolves DIA-815

Description

  • Add "tap" to AuthTrigger schema
  • Add AuthImpression event
  • Add trigger property to AuthImpression
  • Add ResetYourPassword event
  • "Password reset link set—check your email. Please note, you must wait 5 minutes to receive another link."
  • "Get Artsy’s emails on the art market, products, services, editorial, and promotional content. Unsubscribe at any time."
  • Determine whether we can surmise a signup or login from the social sign-in service
  • Handle TODO in onSocialLogin

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

iOS user-facing changes

Android user-facing changes

Dev changes

  • Add AuthImpression and ResetYourPassword events to new auth flow - iskounen

Need help with something? Have a look at our docs, or get in touch with us.

@iskounen iskounen self-assigned this Oct 18, 2024
@iskounen iskounen marked this pull request as draft October 18, 2024 18:01
@iskounen iskounen changed the title fix(DIA-815): add AuthImpression and ResetYourPassword events (and more!) [WIP] fix(DIA-815): add AuthImpression and ResetYourPassword events (and more!) Oct 18, 2024
@@ -74,3 +82,10 @@ export const AuthModal: React.FC = ({ children }) => {
// </KeyboardAvoidingView>
)
}

const tracks = {
Copy link
Member

@damassi damassi Oct 18, 2024

Choose a reason for hiding this comment

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

#blocking @iskounen - we've been migrating away from this pattern across all of our codebases in favor of something a little easier to work with, test etc.

For any given "app", we should create an associated useAppNameTracking hook. And then in there we drop all the tracking calls in a form similar to

By grouping in this way, we can consolidate all tracking behavior in one thing, which keeps it tidy and easier to maintain through time. And from there, test wise, we can simplify:

At call sites in component code can do something like

import { useAppNameTracking } from 'path/to/useAppNameTracking'

// SomeComponent.test.tsx
jest.mock('path/to/useAppNameTracking')

... 
const mockUseAppNameTracking = useAppNameTracking as jest.Mock
... 

it('tracks clicks', () => {
  const spy = jest.fn() 
  mockUseAppNameTracking.mockReturnValue({ trackSomeThing: spy })
  
  thing.fireEvent('click') 
  expect(spy).toHaveBeenCalled() 
}) 

And then in the useAppNameTracking.tests.ts file, the tests can test actual properties by simply invoking each of the tracking functions individually and asserting the return values.

Copy link
Contributor Author

@iskounen iskounen Oct 21, 2024

Choose a reason for hiding this comment

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

I thought tracks was the latest pattern, so thanks for clarifying that.

There are a few tracking calls in ./src/app/store/AuthModel.ts that I want to switch to this pattern, but I can't use a hook there since it's not a React component. How would you handle those tracking calls?

Copy link
Member

@damassi damassi Oct 21, 2024

Choose a reason for hiding this comment

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

In that case (ie, outside of a given subapp), we just leave it alone -- the hook should only be used within the scope of a given "app". (The idea is to make things better, but it doesn't necessarily have to be totally uniform)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good 👍

})
} else {
tracking.trackEvent(tracks.resetYourPassword())
Copy link
Member

Choose a reason for hiding this comment

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

By rolling tracking up in this way we're constraining all of the different APIs into one function call:

const tracking = useAppNameTracking()
...
onClick={() => tracking.resetYourPassword()}

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 added the AuthImpression event to the tracking hook, but I decided to move this tracking event out of the Form and put it into the AuthModel handler (where the CreatedAccount and SuccessfullyLoggedIn events are fired) where it should have been this whole time.

@iskounen iskounen marked this pull request as ready for review October 21, 2024 14:53
@ArtsyOpenSource
Copy link
Contributor

This PR contains the following changes:

  • Dev changes (Add AuthImpression and ResetYourPassword events to new auth flow - iskounen)

Generated by 🚫 dangerJS against 71dd70e

@iskounen iskounen merged commit 655d1ad into main Oct 21, 2024
8 checks passed
@iskounen iskounen deleted the iskounen/fix/auth-tracking-events-and-more branch October 21, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants