Skip to content

Commit

Permalink
chore: file name in storage matches the event uuid (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Aug 22, 2024
1 parent 382f9c3 commit 51ce6ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion posthog/src/main/java/com/posthog/internal/PostHogQueue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal class PostHogQueue(
dirCreated = true
}

val uuid = TimeBasedEpochGenerator.generate()
val uuid = event.uuid ?: TimeBasedEpochGenerator.generate()
val file = File(dir, "$uuid.event")
synchronized(dequeLock) {
deque.add(file)
Expand Down
7 changes: 5 additions & 2 deletions posthog/src/test/java/com/posthog/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@ public val groupProps: Map<String, Any> = mapOf("premium" to true)
public val props: Map<String, Any> = mapOf<String, Any>("prop" to "value")
public val uuid: UUID = UUID.fromString("8c04e5c1-8f6e-4002-96fd-1804799b6ffe")

public fun generateEvent(eventName: String? = null): PostHogEvent {
public fun generateEvent(
eventName: String? = null,
givenUuuid: UUID? = null,
): PostHogEvent {
return PostHogEvent(
eventName ?: EVENT,
distinctId = DISTINCT_ID,
properties = props,
timestamp = date,
uuid = uuid,
uuid = givenUuuid ?: uuid,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.junit.Rule
import org.junit.rules.TemporaryFolder
import java.io.File
import java.text.ParsePosition
import java.util.UUID
import java.util.concurrent.Executors
import kotlin.test.Test
import kotlin.test.assertEquals
Expand Down Expand Up @@ -313,7 +314,7 @@ internal class PostHogQueueTest {

http.enqueue(MockResponse().setResponseCode(300).setBody("error"))

sut.add(generateEvent())
sut.add(generateEvent(givenUuuid = UUID.randomUUID()))

executor.awaitExecution()

Expand Down

0 comments on commit 51ce6ae

Please sign in to comment.