-
Notifications
You must be signed in to change notification settings - Fork 36
fix: route timestamps through PostHogDateProvider #462
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "posthog": patch | ||
| --- | ||
|
|
||
| fix: route all timestamps through PostHogDateProvider |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,11 @@ internal object TimeBasedEpochGenerator { | |
| private val numberGenerator: Random = SecureRandom() | ||
| private val lock: Lock = ReentrantLock() | ||
|
|
||
| private val defaultTimeProvider: () -> Long = { System.currentTimeMillis() } | ||
|
|
||
| @Volatile | ||
| var customTimeProvider: (() -> Long)? = null | ||
|
Comment on lines
+27
to
+30
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'd rather keep just one, and non nullable, that can be replaced with a setter instead of having both custom + default and one nullable |
||
|
|
||
| /* | ||
| / ********************************************************************** | ||
| / * UUID generation | ||
|
|
@@ -34,7 +39,7 @@ internal object TimeBasedEpochGenerator { | |
| * @return unix epoch time based UUID | ||
| */ | ||
| fun generate(): UUID { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think generate() could take the provider or even the timestamp as a param so its easier to test/debug and no need to use a lambda function?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that would be cleaner if all caller paths have access to the config. will check
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like this is used in a couple of places were we don't have a config object
So I would say it would be easier for this to stay as-is. wdyt?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wdyt about #463 ? |
||
| return generate(System.currentTimeMillis()) | ||
| return generate((customTimeProvider ?: defaultTimeProvider)()) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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.
if you do this, then you dont need that