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: Move ready queue processing after identity request #933

Merged

Conversation

alexs-mparticle
Copy link
Collaborator

@alexs-mparticle alexs-mparticle commented Oct 11, 2024

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • Changes the order of when we purge the ready queue so that it comes after the identify request is attempted.
  • Will also continue to clear out the ready queue as part of the initial init flow if an identify request is unnecessary, such as if there is an existing session.
  • This attempts to solve an issue where a User Identity Change should occur before event logs are queued in the ready queue, but will be queued after because the ready queue is purged before the identify request returns.

Testing Plan

  • Was this tested locally? If not, explain why.
  • {explain how this has been tested, and what, if any, additional testing should be done}

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@alexs-mparticle alexs-mparticle force-pushed the fix/SQDSDKS-6835-event-logging-wo-identities branch from 8b5ffb4 to 6478269 Compare October 24, 2024 20:04
@alexs-mparticle alexs-mparticle marked this pull request as ready for review October 25, 2024 14:14
Comment on lines 1365 to 1366
// If for some reason the identity call inside of Session Manager does not run
// we should clear out the ready queue.
Copy link
Member

Choose a reason for hiding this comment

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

Your PR description appropriately states when this is the case, rather than "for some reason", so I'd turn that into a comment.

"Will also continue to clear out the ready queue as part of the initial init flow if an identify request is unnecessary, such as if there is an existing session".

src/pre-init-utils.ts Outdated Show resolved Hide resolved
src/pre-init-utils.ts Outdated Show resolved Hide resolved
const functionSpy = jest.fn();
(window.mParticle as any) = {
fakeFunction: functionSpy,
args: () => {},
Copy link
Member

Choose a reason for hiding this comment

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

Is this args function necessary? I haven't pulled this code down, but as I read through the processReadyQueue function, the only times I see args is where it references the item in the array, as opposed to it being a key on window.mParticle.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm open to discussing this further. Adding args here was the only way I could get it to hit that specific codepath in my tests.

Copy link
Member

Choose a reason for hiding this comment

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

let's hop on a zoom about this to walk through

Copy link
Member

@rmi22186 rmi22186 Oct 30, 2024

Choose a reason for hiding this comment

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

hm. when i comment out line 32, it passes for me. see screenshot below:
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's weird but commenting out arg goes to a different code path that has the same result. It's likely a redundant conditional and could use some clean up. We should definitely sync up on the use cases to make sure nothing is missed.

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

one last comment, but looks good otherwise

Copy link

sonarcloud bot commented Oct 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
21.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

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

lgtm!

@alexs-mparticle alexs-mparticle merged commit 678ccb7 into development Nov 5, 2024
25 of 29 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 5, 2024
## [2.30.4](v2.30.3...v2.30.4) (2024-11-05)

### Bug Fixes

* Move ready queue processing after identity request ([#933](#933)) ([678ccb7](678ccb7))
@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 2.30.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants