-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: recreate event buffer in pinpoint if the credentials has changed #14403
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: recreate event buffer in pinpoint if the credentials has changed #14403
Conversation
@@ -55,4 +55,15 @@ describe('EventBuffer', () => { | |||
buffer.push(EVENT_OBJECT); | |||
buffer.push(EVENT_OBJECT); | |||
}); | |||
|
|||
test('haveCredentialsChanged returns true if credentials has changed', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have
vs hasCredentialsChanged
?
@@ -42,6 +42,8 @@ export const getEventBuffer = ({ | |||
*/ | |||
if (buffer.identityHasChanged(identityId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this can be simplified to be
if (buffer.identityHasChanged(identityId) || buffer.haveCredentialsChanged(credentials)) {
buffer.flush();
}
You can also define a variable
const shouldFlushBuffer = buffer.identityHasChanged(identityId) ||
buffer.haveCredentialsChanged(credentials);
if (shouldFlushBuffer) {
buffer.flush();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had this same thought as a nit. Good either way, but would prefer to simplify to a single branch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. There are a couple good nits that I would vote we fix, but this is in disused category behavior, so wouldn't want to over invest in getting things perfect.
@@ -42,6 +42,8 @@ export const getEventBuffer = ({ | |||
*/ | |||
if (buffer.identityHasChanged(identityId)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had this same thought as a nit. Good either way, but would prefer to simplify to a single branch
@@ -55,4 +55,15 @@ describe('EventBuffer', () => { | |||
buffer.push(EVENT_OBJECT); | |||
buffer.push(EVENT_OBJECT); | |||
}); | |||
|
|||
test('haveCredentialsChanged returns true if credentials has changed', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have
vs hasCredentialsChanged
?
…#14403) * fix: recreate event buffer in pinpoint if the credentials has changed * fix: update the size limit for the analytics package * chore: address code styling comments --------- Co-authored-by: Aaron S. <94858815+stocaaro@users.noreply.github.com>
…#14403) * fix: recreate event buffer in pinpoint if the credentials has changed * fix: update the size limit for the analytics package * chore: address code styling comments --------- Co-authored-by: Aaron S. <94858815+stocaaro@users.noreply.github.com>
Description of changes
This change makes sure that the
getEventBuffer
function of the pinpoint flushes and recreates a new EventBuffer when the credentials are updated.Continuing to use the older credentials were causing to get
403
error when events are emitted by Analytics as described in this issue: #14398Issue #14398
Description of how you validated changes
I've validated the changed by linking the updated library to a testing repo and following the reproducing steps provided in the issue.
Checklist
yarn test
passesChecklist for repo maintainers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.