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

feat(ask-sdk-core/util) Add new helper function to get user id #546

Merged
merged 1 commit into from
May 6, 2019

Conversation

hideokamoto
Copy link
Contributor

@hideokamoto hideokamoto commented May 2, 2019

We can get user id from the SDK.

Description

Add the getUserId function into the utils.
We can get the user id more easier.

Motivation and Context

Now we can get the requested user's device id by the SDK.
But we want to get the user id too.

Before

const userId = handlerInput.requestEnvelope.context.System.user.userId 

Our code will be too long line :(

After

const userId = getUserId(handlerInput.requestEnvelope)

It is the simplest way to get the user ID :)

Testing

To run unit test by gulp.

$ lerna bootstrap
$ lerna --scope ask-sdk-core run gulp -- test
  110 passing (76ms)


=============================== Coverage summary ===============================
Statements   : 100% ( 351/351 )
Branches     : 100% ( 88/88 )
Functions    : 96.26% ( 103/107 )
Lines        : 100% ( 330/330 )
================================================================================

[09:57:52] Finished 'test' after 1.76 s
lerna success run Ran npm script 'gulp' in 1 package in 2.9s:
lerna success - ask-sdk-core

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Docs(Add new document content)
  • Translate Docs(Translate document content)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed
  • My commit message follows Conventional Commit Guideline

License

  • I confirm that this pull request can be released under the Apache 2 license

@kun432
Copy link

kun432 commented May 2, 2019

👍

@@ -43,7 +44,7 @@ describe('RequestEnvelopeUtils', () => {
templateVersion : '1.0',
markupVersion : '1.0',
},
};
};requestEnvelope.context.System.user.userId = 'mockUserId'
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please write this one in a new line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback!
I've fixed it :)

@ShenChen93
Copy link
Contributor

Hi @hideokamoto

The code looks good. Before I merge it in, could you please modify the commit name to "feat: add getUserId util function", In order to fit conventional commits structure.

Thanks,
Shen

feat(docs) add getUserId into the docs

fix(ask-sdk-core) lint error of getUserId

fix[ask-sdk-core] make a new line to define the user id
@hideokamoto
Copy link
Contributor Author

I've rebased my commits.

@nikhilym nikhilym requested a review from a team May 6, 2019 17:39
Copy link
Contributor

@nikhilym nikhilym left a comment

Choose a reason for hiding this comment

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

:shipit:

@ShenChen93 ShenChen93 merged commit 4941344 into alexa:2.0.x May 6, 2019
@ShenChen93
Copy link
Contributor

Hi, @hideokamoto

Thanks for the PR! Merging this in. It will be included in the next SDK release.

Regards,
Shen

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