Skip to content

fix: #identify argument type #384

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

Closed
wants to merge 4 commits into from
Closed

fix: #identify argument type #384

wants to merge 4 commits into from

Conversation

raminos
Copy link

@raminos raminos commented Nov 23, 2021

Hello library maintainers 👋 ,

thanks for this lovely library! @alan-eu we are happily using your service but we came across an incoherence between your docs and your code which I attempt to fix in this PR.

I read your contributing guidelines but couldn't find a pull request template. I hope the format I chose is okay.

Problem

In your docs you state for the userId argument of the identify method:

The database ID for this user. If you don’t know who the user is yet, you can omit the userId and just record traits.

But with the current implementation Typescript won't allow us to omit a userId. We circumvent this issue by passing undefined as any but this is suboptimal.

Solution

I tried to adjust the identify method's behaviour in a way that is in line with the existing logic, namely:

  • userId can be undefined
  • if userId is undefined the store is not updated

Tests

I added a test case checking that only the user traits are updated when passing undefined as a userId. I tried to follow the preexisting unit test style.

As stated in the guidelines I ran all the scripts mentioned to check that tests, linting and the typescript compiler pass.

I'm looking forward to your comments!

Best,
Ramin

Copy link
Contributor

@oscb oscb left a comment

Choose a reason for hiding this comment

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

Thanks so much for noticing this and taking action!
I left some minor suggestions but otherwise this looks good!

@raminos
Copy link
Author

raminos commented Nov 23, 2021

Thanks @oscb for your fast and positive feedback! I've applied your suggestions 😊

@alanjcharles
Copy link
Contributor

Hi @raminos Happy New Year! looks like there is still one comment left in our review. Happy to merge once that's been accounted for.

@raminos
Copy link
Author

raminos commented Jan 21, 2022

Hi @alanjcharles 🤗 Happy New Year to you too! I totally missed that I didn't update the second comment! Thanks for reminding me 😍 commit is coming in a sec!

@raminos
Copy link
Author

raminos commented Jan 21, 2022

@alanjcharles the code changed a bit in the meantime. The ternary operator is not super pretty but it gets the work done. Is there something I should change?

@alanjcharles
Copy link
Contributor

@raminos sorry for the delay!! we've had to take some unexpected time out of office in the past few weeks. Thanks so much for the update. I can take a closer look in a bit and let you know. Thanks again

@alanjcharles
Copy link
Contributor

@raminos we're ready to merge this as soon as the test you added passes! It looks pretty straightforward but let me know if I can help at all. Thanks!

@alanjcharles
Copy link
Contributor

accounted for in #436 thanks again!

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