Skip to content

Commit

Permalink
Merge pull request #560 from embrace-io/add-payload-flag
Browse files Browse the repository at this point in the history
Add remote config that controls whether v2 payload is sent or not
  • Loading branch information
fractalwrench committed Mar 14, 2024
2 parents 169a8bb + 3755a17 commit 3ad0571
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ internal class SessionBehavior(
fun shouldSendFullForErrorLog() =
getFullSessionEvents().contains(SessionGatingKeys.FULL_SESSION_ERROR_LOGS)

/**
* Whether to use the V2 payload format for sending sessions.
*/
fun useV2Payload() = remote?.sessionConfig?.useV2Payload ?: false

/**
* Checks whether a feature should be gated.
* If [getSessionComponents] is null, this will return false.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ internal data class SessionRemoteConfig(
@Json(name = "enable")
val isEnabled: Boolean? = null,

@Json(name = "use_v2_payload")
val useV2Payload: Boolean? = null,

/**
* A list of session components (i.e. Breadcrumbs, Session properties, etc) that will be
* included in the session payload. If components list exists, the services should restrict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ internal class EmbraceGatingServiceTest {
private fun buildCustomRemoteConfig(components: Set<String>?, fullSessionEvents: Set<String>?) =
RemoteConfig(
sessionConfig = SessionRemoteConfig(
true,
components,
fullSessionEvents
isEnabled = true,
sessionComponents = components,
fullSessionEvents = fullSessionEvents
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ internal class SessionBehaviorTest {
private val remote = RemoteConfig(
sessionConfig = SessionRemoteConfig(
isEnabled = true,
useV2Payload = true,
sessionComponents = setOf("test"),
fullSessionEvents = setOf("test2")
),
Expand All @@ -36,6 +37,7 @@ internal class SessionBehaviorTest {
assertFalse(isGatingFeatureEnabled())
assertFalse(isSessionControlEnabled())
assertEquals(10, getMaxSessionProperties())
assertFalse(useV2Payload())
}
}

Expand All @@ -46,6 +48,7 @@ internal class SessionBehaviorTest {
assertEquals(setOf("breadcrumbs"), getSessionComponents())
assertEquals(setOf("crash"), getFullSessionEvents())
assertTrue(isGatingFeatureEnabled())
assertFalse(useV2Payload())
}
}

Expand All @@ -57,6 +60,7 @@ internal class SessionBehaviorTest {
assertEquals(setOf("test"), getSessionComponents())
assertEquals(setOf("test2"), getFullSessionEvents())
assertEquals(57, getMaxSessionProperties())
assertTrue(useV2Payload())
}
}

Expand Down

0 comments on commit 3ad0571

Please sign in to comment.