Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ constructor(
response.body?.buffer?.size?.ifHasValidLength { contentLength ->
bodySize = contentLength
}
data = body
if (scopes.options.dataCollectionResolver.isIncomingResponseBody) {
data = body
}
}

fingerprints.add(response.statusCode.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,26 @@ class SentryApollo3InterceptorClientErrors {
)
}

@Test
fun `data collection can disable incoming response body`() {
val sut =
fixture.getSut(responseBody = fixture.responseBodyNotOk) {
dataCollection.httpBodies = emptySet()
}
executeQuery(sut)

verify(fixture.scopes)
.captureEvent(
check {
val response = it.contexts.response!!
assertEquals(200, response.statusCode)
assertEquals(200, response.bodySize)
assertNull(response.data)
},
any<Hint>(),
)
}

@Test
fun `capture errors with more response context if sendDefaultPii is enabled`() {
val sut = fixture.getSut(responseBody = fixture.responseBodyNotOk, sendDefaultPii = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ constructor(
response.body?.buffer?.size?.ifHasValidLength { contentLength ->
bodySize = contentLength
}
data = body
if (scopes.options.dataCollectionResolver.isIncomingResponseBody) {
data = body
}
}

fingerprints.add(response.statusCode.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,26 @@ abstract class SentryApollo4BuilderExtensionsClientErrorsTest(
)
}

@Test
fun `data collection can disable incoming response body`() {
val sut =
fixture.getSut(responseBody = fixture.responseBodyNotOk) {
dataCollection.httpBodies = emptySet()
}
executeQuery(sut)

verify(fixture.scopes)
.captureEvent(
check {
val response = it.contexts.response!!
assertEquals(200, response.statusCode)
assertEquals(200, response.bodySize)
assertNull(response.data)
},
any<Hint>(),
)
}

@Test
fun `capture errors with more response context if sendDefaultPii is enabled`() {
val sut = fixture.getSut(responseBody = fixture.responseBodyNotOk, sendDefaultPii = true)
Expand Down
Loading