Skip to content

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

Merged

Conversation

sarayev
Copy link
Contributor

@sarayev sarayev commented May 23, 2025

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: #14398

Issue #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

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Siteproxy

Siteproxy

搜索引擎


常用网站


新闻网站


海外论坛


Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@sarayev sarayev requested a review from a team as a code owner May 23, 2025 12:46

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@sarayev sarayev requested a review from a team as a code owner May 23, 2025 13:58
soberm
soberm previously approved these changes May 23, 2025
@@ -55,4 +55,15 @@ describe('EventBuffer', () => {
buffer.push(EVENT_OBJECT);
buffer.push(EVENT_OBJECT);
});

test('haveCredentialsChanged returns true if credentials has changed', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should be have

Copy link
Member

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)) {
Copy link
Contributor

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();
}

Copy link
Member

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

stocaaro
stocaaro previously approved these changes May 23, 2025
Copy link
Member

@stocaaro stocaaro left a 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)) {
Copy link
Member

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', () => {
Copy link
Member

Choose a reason for hiding this comment

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

have vs hasCredentialsChanged?

stocaaro and others added 2 commits May 23, 2025 15:29

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@sarayev sarayev dismissed stale reviews from soberm and stocaaro via 3fb6bbe May 26, 2025 08:43
stocaaro and others added 2 commits May 28, 2025 14:44

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@sarayev sarayev merged commit 2b4282a into aws-amplify:main Jun 10, 2025
30 checks passed
soberm pushed a commit that referenced this pull request Jun 13, 2025

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
…#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>
Simone319 pushed a commit that referenced this pull request Jun 30, 2025

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
…#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>
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.

None yet

4 participants