Skip to content

fix: cross platform uuid #696

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
merged 2 commits into from
Jan 16, 2025
Merged

fix: cross platform uuid #696

merged 2 commits into from
Jan 16, 2025

Conversation

kwasniew
Copy link
Contributor

About the changes

UUID generation with crypto has better uniqueness guarantees, but Math.random() solution is good enough for our use case (which is not security critical) and works better across all platforms.

This PR will fix the NextJS SDK build issue.

We use UUID for estimated connection counting which is using imprecise HyperLogLog anyway.

Important files

Discussion points

*
* We use it for connection id generation which is not critical for security.
*/
export const uuidv4 = (): string => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

existing tests check uuid is 36 characters

@coveralls
Copy link

coveralls commented Jan 16, 2025

Coverage Status

coverage: 90.569% (+0.04%) from 90.53%
when pulling 8f297c7 on cross-platform-uuid
into 2e59c96 on main.

thomasheartman
thomasheartman previously approved these changes Jan 16, 2025
Copy link
Contributor

@thomasheartman thomasheartman left a comment

Choose a reason for hiding this comment

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

Yeah, I'm tempted to say that this is fine. Given our use case, I don't expect we'll run into issues, and if we do find that we're getting dupes, then we can always change ti later.

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
@kwasniew kwasniew merged commit 23a0f60 into main Jan 16, 2025
4 checks passed
@kwasniew kwasniew deleted the cross-platform-uuid branch January 16, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants