Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .changeset/android-v4-major.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- **Breaking:** rename `PostHogConfig.maxRetries` to `pushNotificationSubscriptionMaxRetries`, because it only limits push-notification subscription retries
- **Breaking:** set `$lib` and `$lib_version` from the `PostHog-Sdk-Info` request header; a value set in properties, super properties or `beforeSend` is removed before sending
- **Breaking:** send `$session_id` and `$window_id` as top-level `session_id` and `window_id` fields; a non-string value is dropped with a warning
- **Breaking:** disable the SDK at setup when `projectToken` is a personal API key (`phx_...`), as for an empty token
- **Breaking:** disable the SDK at setup when `projectToken` is a personal API key (`phx_...`), as for an empty token, and print a warning for both even when `debug` is off
- **Breaking:** add an `options` argument to `capture`, `screen`, `identify`, `setPersonProperties`, `alias`, `group` and `captureException` for per-event capture options such as `cookieless_mode`, sent apart from the properties and editable in `beforeSend` through `PostHogEvent.options`; Java callers pass the trailing argument or `null`, and classes that implement `PostHogInterface` add the parameter
- **Breaking:** move `identify(distinctId, userProperties, userPropertiesSetOnce)` from `PostHogCoreInterface` to `PostHogStatelessInterface`; `PostHogInterface` declares `identify` with the trailing `options` parameter
- **Breaking:** registered super properties now override the properties the SDK sets itself, such as `$os_name`; super and event properties also override `$is_identified`, `$process_person_profile` and the session replay debug properties, which the SDK no longer re-applies after the caller's values
Expand All @@ -30,7 +30,7 @@
- use the current distinct ID when the `distinctId` argument to `capture` is empty or whitespace-only, instead of dropping the event
- **Breaking:** skip deep link query parameters whose name starts with `$` in the `Deep Link Opened` event, so a link can't set a PostHog property such as `$process_person_profile`
- stop storing or matching the person-properties deduplication hash for a `$set` sent with `process_person_profile: false`
- debug logs for capture requests name the event count and the response status instead of printing the request and response bodies, and count the events PostHog drops, the duplicate copies it drops and the events it asks to retry, in one line per batch
- debug logs for capture requests name the event count and the response status instead of printing the request and response bodies, and count the events PostHog drops, the duplicate copies it drops and the events it asks to retry, in one line per batch, and log the status when PostHog rejects a whole batch
- **Breaking:** drop an event whose name is empty before sending it, including one `beforeSend` renames to `""`
- **Breaking:** let `userProperties`, `userPropertiesSetOnce` and `groups` win key by key over `$set`, `$set_once` and `$groups` maps passed in the same call's properties, instead of being replaced by them, and merge a `$groups` map in properties into the groups set with `group()`
- add `captureAiCompression`, `captureAiMaxQueueSize`, `captureAiTimeout` and `captureAiMaxEventBytes` to `PostHogConfig` to tune AI requests separately from other events; the defaults are gzip, 100 queued events (and at most 50 MiB), 60 seconds and 8 MiB + 64 KiB per serialized event
Expand Down
4 changes: 2 additions & 2 deletions posthog/src/main/java/com/posthog/PostHog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ public class PostHog private constructor(
if (config.logger is PostHogNoOpLogger) PostHogPrintLogger(config) else config.logger

if (config.projectToken.isEmpty()) {
config.logger.log(
config.logger.logWarning(
"PostHog SDK is disabled because the project token is required and was empty after trimming whitespace.",
)
return
}

if (config.projectToken.startsWith("phx_")) {
config.logger.log(
config.logger.logWarning(
"PostHog SDK is disabled because the project token is a personal API key (phx_...), " +
"use your project token (phc_...).",
)
Expand Down
4 changes: 2 additions & 2 deletions posthog/src/main/java/com/posthog/PostHogStateless.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public open class PostHogStateless protected constructor(
if (config.logger is PostHogNoOpLogger) PostHogPrintLogger(config) else config.logger

if (config.projectToken.isEmpty()) {
config.logger.log(
config.logger.logWarning(
"PostHog SDK is disabled because the project token is required and was empty after trimming whitespace.",
)
return
}

if (config.projectToken.startsWith("phx_")) {
config.logger.log(
config.logger.logWarning(
"PostHog SDK is disabled because the project token is a personal API key (phx_...), " +
"use your project token (phc_...).",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,5 +751,6 @@ internal fun deleteFilesIfAPIError(

return false
}
logger.log("Flushing failed with ${e.statusCode}, dropping $actualBatchSize records.")
return true
}
4 changes: 2 additions & 2 deletions posthog/src/test/java/com/posthog/PostHogStatelessTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ internal class PostHogStatelessTest {
sut.setup(config)

assertFalse(sut.isEnabledPublic())
assertTrue(mockLogger.messages.any { it.contains("PostHog SDK is disabled because the project token is required") })
assertTrue(mockLogger.warnings.any { it.contains("PostHog SDK is disabled because the project token is required") })
}

@Test
Expand All @@ -289,7 +289,7 @@ internal class PostHogStatelessTest {
sut.setup(config)

assertFalse(sut.isEnabledPublic())
assertTrue(mockLogger.messages.any { it.contains("PostHog SDK is disabled because the project token is a personal API key") })
assertTrue(mockLogger.warnings.any { it.contains("PostHog SDK is disabled because the project token is a personal API key") })
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions posthog/src/test/java/com/posthog/PostHogTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ internal class PostHogTest {
)

assertTrue(sut.isOptOut())
assertTrue(logger.messages.any { it.contains("PostHog SDK is disabled because the project token is required") })
assertTrue(logger.warnings.any { it.contains("PostHog SDK is disabled because the project token is required") })

sut.close()
}
Expand All @@ -297,7 +297,7 @@ internal class PostHogTest {
)

assertTrue(sut.isOptOut())
assertTrue(logger.messages.any { it.contains("PostHog SDK is disabled because the project token is a personal API key") })
assertTrue(logger.warnings.any { it.contains("PostHog SDK is disabled because the project token is a personal API key") })

sut.close()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.posthog.PostHogConfig
import com.posthog.PostHogEvent
import com.posthog.PostHogEventName
import com.posthog.TestHttpServers
import com.posthog.TestLogger
import com.posthog.awaitExecution
import com.posthog.generateEvent
import com.posthog.internal.errortracking.ThrowableCoercer
Expand Down Expand Up @@ -958,8 +959,10 @@ internal class PostHogQueueTest {
val e = PostHogApiError(400, "", null)
val config = PostHogConfig(PROJECT_TOKEN)
val limits = initialBatchLimits(config)
val logger = TestLogger()

assertTrue(deleteFilesIfAPIError(e, limits, actualBatchSize = limits.cap, logger = config.logger))
assertTrue(deleteFilesIfAPIError(e, limits, actualBatchSize = limits.cap, logger = logger))
assertEquals(listOf("Flushing failed with 400, dropping ${limits.cap} records."), logger.messages)
}

@Test
Expand Down
Loading