-
-
Notifications
You must be signed in to change notification settings - Fork 465
Add GraphQL Apollo Kotlin 4 integration #4166
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4fac45d
Apollo 4 initial setup
cvb941 18d3d8d
rename some stuff, change and add a few tests
lcian 47fbe9e
parametrize tests to run with both v3 and v4 implementations of `Apol…
lcian 9ab4abf
Merge branch 'main' into lcian/feat/apollo-4
lcian 10b6902
changelog
lcian 5997787
rename SentryApollo4BuilderExtensions back to SentryApolloBuilderExte…
lcian 8a31a54
Merge branch 'main' into lcian/feat/apollo-4
lcian 20ae2af
Merge branch 'main' into lcian/feat/apollo-4
lcian 621d2a4
make api
lcian de7eeb9
add README.md
lcian b584414
Merge branch 'main' into lcian/feat/apollo-4
lcian 0b526c7
update comment
lcian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # sentry-apollo-4 | ||
|
|
||
| This module provides an integration for [Apollo Kotlin 4](https://www.apollographql.com/docs/kotlin/v4). | ||
|
|
||
| Please consult the documentation on how to install and use this integration in the Sentry Docs for [Android](https://docs.sentry.io/platforms/android/integrations/apollo4/) or [Java](https://docs.sentry.io/platforms/java/tracing/instrumentation/apollo4/). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| public final class io/sentry/apollo4/BuildConfig { | ||
| public static final field SENTRY_APOLLO4_SDK_NAME Ljava/lang/String; | ||
| public static final field VERSION_NAME Ljava/lang/String; | ||
| } | ||
|
|
||
| public final class io/sentry/apollo4/SentryApollo4ClientException : java/lang/Exception { | ||
| public static final field Companion Lio/sentry/apollo4/SentryApollo4ClientException$Companion; | ||
| public fun <init> (Ljava/lang/String;)V | ||
| } | ||
|
|
||
| public final class io/sentry/apollo4/SentryApollo4ClientException$Companion { | ||
| } | ||
|
|
||
| public final class io/sentry/apollo4/SentryApollo4HttpInterceptor : com/apollographql/apollo/network/http/HttpInterceptor { | ||
| public static final field Companion Lio/sentry/apollo4/SentryApollo4HttpInterceptor$Companion; | ||
| public static final field DEFAULT_CAPTURE_FAILED_REQUESTS Z | ||
| public fun <init> ()V | ||
| public fun <init> (Lio/sentry/IScopes;)V | ||
| public fun <init> (Lio/sentry/IScopes;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;)V | ||
| public fun <init> (Lio/sentry/IScopes;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;Z)V | ||
| public fun <init> (Lio/sentry/IScopes;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;ZLjava/util/List;)V | ||
| public synthetic fun <init> (Lio/sentry/IScopes;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;ZLjava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
| public fun intercept (Lcom/apollographql/apollo/api/http/HttpRequest;Lcom/apollographql/apollo/network/http/HttpInterceptorChain;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; | ||
| } | ||
|
|
||
| public abstract interface class io/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback { | ||
| public abstract fun execute (Lio/sentry/ISpan;Lcom/apollographql/apollo/api/http/HttpRequest;Lcom/apollographql/apollo/api/http/HttpResponse;)Lio/sentry/ISpan; | ||
| } | ||
|
|
||
| public final class io/sentry/apollo4/SentryApollo4HttpInterceptor$Companion { | ||
| } | ||
|
|
||
| public final class io/sentry/apollo4/SentryApollo4Interceptor : com/apollographql/apollo/interceptor/ApolloInterceptor { | ||
| public fun <init> ()V | ||
| public fun <init> (Lio/sentry/IScopes;)V | ||
| public synthetic fun <init> (Lio/sentry/IScopes;ILkotlin/jvm/internal/DefaultConstructorMarker;)V | ||
| public fun intercept (Lcom/apollographql/apollo/api/ApolloRequest;Lcom/apollographql/apollo/interceptor/ApolloInterceptorChain;)Lkotlinx/coroutines/flow/Flow; | ||
| } | ||
|
|
||
| public final class io/sentry/apollo4/SentryApolloBuilderExtensionsKt { | ||
| public static final fun sentryTracing (Lcom/apollographql/apollo/ApolloClient$Builder;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static final fun sentryTracing (Lcom/apollographql/apollo/ApolloClient$Builder;Lio/sentry/IScopes;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static final fun sentryTracing (Lcom/apollographql/apollo/ApolloClient$Builder;Lio/sentry/IScopes;Z)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static final fun sentryTracing (Lcom/apollographql/apollo/ApolloClient$Builder;Lio/sentry/IScopes;ZLjava/util/List;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static final fun sentryTracing (Lcom/apollographql/apollo/ApolloClient$Builder;Lio/sentry/IScopes;ZLjava/util/List;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static final fun sentryTracing (Lcom/apollographql/apollo/ApolloClient$Builder;ZLjava/util/List;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static synthetic fun sentryTracing$default (Lcom/apollographql/apollo/ApolloClient$Builder;Lio/sentry/IScopes;ZLjava/util/List;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;ILjava/lang/Object;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| public static synthetic fun sentryTracing$default (Lcom/apollographql/apollo/ApolloClient$Builder;ZLjava/util/List;Lio/sentry/apollo4/SentryApollo4HttpInterceptor$BeforeSpanCallback;ILjava/lang/Object;)Lcom/apollographql/apollo/ApolloClient$Builder; | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import net.ltgt.gradle.errorprone.errorprone | ||
| import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
|
||
| plugins { | ||
| `java-library` | ||
| kotlin("jvm") | ||
| jacoco | ||
| id(Config.QualityPlugins.errorProne) | ||
| id(Config.QualityPlugins.gradleVersions) | ||
| id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion | ||
| } | ||
|
|
||
| configure<JavaPluginExtension> { | ||
| sourceCompatibility = JavaVersion.VERSION_1_8 | ||
| targetCompatibility = JavaVersion.VERSION_1_8 | ||
| } | ||
|
|
||
| tasks.withType<KotlinCompile>().configureEach { | ||
| kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString() | ||
| kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion | ||
| } | ||
|
|
||
| dependencies { | ||
| api(projects.sentry) | ||
| api(projects.sentryKotlinExtensions) | ||
|
|
||
| compileOnly(Config.Libs.apolloKotlin4) | ||
|
|
||
| compileOnly(Config.CompileOnly.nopen) | ||
| errorprone(Config.CompileOnly.nopenChecker) | ||
| errorprone(Config.CompileOnly.errorprone) | ||
| errorprone(Config.CompileOnly.errorProneNullAway) | ||
| compileOnly(Config.CompileOnly.jetbrainsAnnotations) | ||
|
|
||
| // tests | ||
| testImplementation(projects.sentryTestSupport) | ||
| testImplementation(Config.Libs.coroutinesCore) | ||
| testImplementation(kotlin(Config.kotlinStdLib)) | ||
| testImplementation(Config.TestLibs.kotlinTestJunit) | ||
| testImplementation(Config.TestLibs.mockitoKotlin) | ||
| testImplementation(Config.TestLibs.mockitoInline) | ||
| testImplementation(Config.TestLibs.mockWebserver) | ||
| testImplementation(Config.Libs.apolloKotlin4) | ||
| testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3") | ||
| testImplementation("org.jetbrains.kotlin:kotlin-reflect:2.0.0") | ||
| } | ||
|
|
||
| configure<SourceSetContainer> { | ||
| test { | ||
| java.srcDir("src/test/java") | ||
| } | ||
| } | ||
|
|
||
| jacoco { | ||
| toolVersion = Config.QualityPlugins.Jacoco.version | ||
| } | ||
|
|
||
| tasks.jacocoTestReport { | ||
| reports { | ||
| xml.required.set(true) | ||
| html.required.set(false) | ||
| } | ||
| } | ||
|
|
||
| tasks { | ||
| jacocoTestCoverageVerification { | ||
| violationRules { | ||
| rule { limit { minimum = Config.QualityPlugins.Jacoco.minimumCoverage } } | ||
| } | ||
| } | ||
| check { | ||
| dependsOn(jacocoTestCoverageVerification) | ||
| dependsOn(jacocoTestReport) | ||
| } | ||
| } | ||
|
|
||
| tasks.withType<JavaCompile>().configureEach { | ||
| options.errorprone { | ||
| check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR) | ||
| option("NullAway:AnnotatedPackages", "io.sentry") | ||
| } | ||
| } | ||
|
|
||
| buildConfig { | ||
| useJavaOutput() | ||
| packageName("io.sentry.apollo4") | ||
| buildConfigField("String", "SENTRY_APOLLO4_SDK_NAME", "\"${Config.Sentry.SENTRY_APOLLO4_SDK_NAME}\"") | ||
| buildConfigField("String", "VERSION_NAME", "\"${project.version}\"") | ||
| } |
17 changes: 17 additions & 0 deletions
17
sentry-apollo-4/src/main/java/io/sentry/apollo4/SentryApollo4.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package io.sentry.apollo4 | ||
|
|
||
| /** | ||
| * Common constants used across the module | ||
| */ | ||
| internal const val OPERATION_ID_HEADER_NAME = "SENTRY-APOLLO-4-OPERATION-ID" | ||
| internal const val OPERATION_NAME_HEADER_NAME = "SENTRY-APOLLO-4-OPERATION-NAME" | ||
| internal const val OPERATION_TYPE_HEADER_NAME = "SENTRY-APOLLO-4-OPERATION-TYPE" | ||
| internal const val VARIABLES_HEADER_NAME = "SENTRY-APOLLO-4-VARIABLES" | ||
| internal val INTERNAL_HEADER_NAMES by lazy { | ||
| listOf( | ||
| OPERATION_ID_HEADER_NAME, | ||
| OPERATION_NAME_HEADER_NAME, | ||
| OPERATION_TYPE_HEADER_NAME, | ||
| VARIABLES_HEADER_NAME | ||
| ) | ||
| } |
11 changes: 11 additions & 0 deletions
11
sentry-apollo-4/src/main/java/io/sentry/apollo4/SentryApollo4ClientException.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package io.sentry.apollo4 | ||
|
|
||
| /** | ||
| * Used for holding an Apollo4 client error, for example. An integration that does not throw when API | ||
| * returns 4xx, 5xx or the `errors` field. | ||
| */ | ||
| class SentryApollo4ClientException(message: String?) : Exception(message) { | ||
| companion object { | ||
| private const val serialVersionUID = 4312160066430858144L | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.