-
Notifications
You must be signed in to change notification settings - Fork 27
feat!: Add uuidv4 to platform. #56
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
Conversation
This pull request has been linked to Shortcut Story #192052: Look at removing nanoid dependency.. |
} | ||
|
||
uuidv4() { | ||
return randomUUID(); |
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.
Our targeted versions of node should have this built-in. Which is better than a dependency. But it isn't something we can promise will be in all server SDKs.
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.
Less code = more better
@@ -103,7 +102,7 @@ export default class DiagnosticsManager { | |||
this.startTime = Date.now(); | |||
this.dataSinceDate = this.startTime; | |||
this.id = { | |||
diagnosticId: nanoid(), | |||
diagnosticId: platform.crypto.uuidv4(), |
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.
Now we use the platform provided uuidv4. (Platform here being our implementation of the platform. Like server-node,)
Nanoid was dependent on
Buffers
which is not standard and caused some problems with some edge providers. It seemed better to remove it now.Also originally I had switched from uuid to nanoid for a similar compatibility reason. Now that dependency is removed from common code and pushed to the platform. So the platform can use the UUID implementation that works for it.
For edge environments I hope most of them support
crypto.randomUUID
. Assuming that the securecontext requirement is not applicable, because it is server side, or that it doesn't interfere with their operation.This change should generally make it easier to support uuidv4 generation without requiring a polyfill in the shared packages.