-
-
Notifications
You must be signed in to change notification settings - Fork 461
refactor(distribution): Use interface pattern for distribution API #4731
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
7 commits
Select commit
Hold shift + click to select a range
d0de779
refactor(distribution): Use interface pattern for distribution API
runningcode ed63c58
feat(distribution): Complete distribution module implementation
runningcode 9c81459
feat(distribution): Move UpdateStatus and UpdateInfo to core sentry m…
runningcode ec0b916
fix(distribution): Update ProGuard rules for new DistributionIntegrat…
runningcode a3d97e5
chore(distribution): Update API dump to reflect interface refactor
runningcode 24fca6f
refactor(distribution): Move DistributionOptions to SentryOptions to …
runningcode 55f4f2b
fix(distribution): Correct DistributionIntegration class name referen…
runningcode 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
81 changes: 5 additions & 76 deletions
81
sentry-android-distribution/api/sentry-android-distribution.api
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 |
|---|---|---|
| @@ -1,79 +1,8 @@ | ||
| public final class io/sentry/android/distribution/Distribution { | ||
| public static final field INSTANCE Lio/sentry/android/distribution/Distribution; | ||
| public final fun checkForUpdate (Landroid/content/Context;Lkotlin/jvm/functions/Function1;)V | ||
| public final fun checkForUpdateBlocking (Landroid/content/Context;)Lio/sentry/android/distribution/UpdateStatus; | ||
| public final fun downloadUpdate (Landroid/content/Context;Lio/sentry/android/distribution/UpdateInfo;)V | ||
| public final fun init (Landroid/content/Context;)V | ||
| public final fun init (Landroid/content/Context;Lkotlin/jvm/functions/Function1;)V | ||
| public final fun isEnabled ()Z | ||
| } | ||
|
|
||
| public final class io/sentry/android/distribution/DistributionOptions { | ||
| public fun <init> ()V | ||
| public final fun getBuildConfiguration ()Ljava/lang/String; | ||
| public final fun getOrgAuthToken ()Ljava/lang/String; | ||
| public final fun getOrganizationSlug ()Ljava/lang/String; | ||
| public final fun getProjectSlug ()Ljava/lang/String; | ||
| public final fun getSentryBaseUrl ()Ljava/lang/String; | ||
| public final fun setBuildConfiguration (Ljava/lang/String;)V | ||
| public final fun setOrgAuthToken (Ljava/lang/String;)V | ||
| public final fun setOrganizationSlug (Ljava/lang/String;)V | ||
| public final fun setProjectSlug (Ljava/lang/String;)V | ||
| public final fun setSentryBaseUrl (Ljava/lang/String;)V | ||
| } | ||
|
|
||
| public final class io/sentry/android/distribution/UpdateInfo { | ||
| public fun <init> (Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V | ||
| public final fun component1 ()Ljava/lang/String; | ||
| public final fun component2 ()Ljava/lang/String; | ||
| public final fun component3 ()I | ||
| public final fun component4 ()Ljava/lang/String; | ||
| public final fun component5 ()Ljava/lang/String; | ||
| public final fun component6 ()Ljava/lang/String; | ||
| public final fun copy (Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lio/sentry/android/distribution/UpdateInfo; | ||
| public static synthetic fun copy$default (Lio/sentry/android/distribution/UpdateInfo;Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lio/sentry/android/distribution/UpdateInfo; | ||
| public fun equals (Ljava/lang/Object;)Z | ||
| public final fun getAppName ()Ljava/lang/String; | ||
| public final fun getBuildNumber ()I | ||
| public final fun getBuildVersion ()Ljava/lang/String; | ||
| public final fun getCreatedDate ()Ljava/lang/String; | ||
| public final fun getDownloadUrl ()Ljava/lang/String; | ||
| public final fun getId ()Ljava/lang/String; | ||
| public fun hashCode ()I | ||
| public fun toString ()Ljava/lang/String; | ||
| } | ||
|
|
||
| public abstract class io/sentry/android/distribution/UpdateStatus { | ||
| } | ||
|
|
||
| public final class io/sentry/android/distribution/UpdateStatus$Error : io/sentry/android/distribution/UpdateStatus { | ||
| public fun <init> (Ljava/lang/String;)V | ||
| public final fun component1 ()Ljava/lang/String; | ||
| public final fun copy (Ljava/lang/String;)Lio/sentry/android/distribution/UpdateStatus$Error; | ||
| public static synthetic fun copy$default (Lio/sentry/android/distribution/UpdateStatus$Error;Ljava/lang/String;ILjava/lang/Object;)Lio/sentry/android/distribution/UpdateStatus$Error; | ||
| public fun equals (Ljava/lang/Object;)Z | ||
| public final fun getMessage ()Ljava/lang/String; | ||
| public fun hashCode ()I | ||
| public fun toString ()Ljava/lang/String; | ||
| } | ||
|
|
||
| public final class io/sentry/android/distribution/UpdateStatus$NewRelease : io/sentry/android/distribution/UpdateStatus { | ||
| public fun <init> (Lio/sentry/android/distribution/UpdateInfo;)V | ||
| public final fun component1 ()Lio/sentry/android/distribution/UpdateInfo; | ||
| public final fun copy (Lio/sentry/android/distribution/UpdateInfo;)Lio/sentry/android/distribution/UpdateStatus$NewRelease; | ||
| public static synthetic fun copy$default (Lio/sentry/android/distribution/UpdateStatus$NewRelease;Lio/sentry/android/distribution/UpdateInfo;ILjava/lang/Object;)Lio/sentry/android/distribution/UpdateStatus$NewRelease; | ||
| public fun equals (Ljava/lang/Object;)Z | ||
| public final fun getInfo ()Lio/sentry/android/distribution/UpdateInfo; | ||
| public fun hashCode ()I | ||
| public fun toString ()Ljava/lang/String; | ||
| } | ||
|
|
||
| public final class io/sentry/android/distribution/UpdateStatus$UpToDate : io/sentry/android/distribution/UpdateStatus { | ||
| public static final field INSTANCE Lio/sentry/android/distribution/UpdateStatus$UpToDate; | ||
| } | ||
|
|
||
| public final class io/sentry/android/distribution/internal/DistributionIntegration : io/sentry/Integration { | ||
| public fun <init> ()V | ||
| public final class io/sentry/android/distribution/DistributionIntegration : io/sentry/IDistributionApi, io/sentry/Integration { | ||
| public fun <init> (Landroid/content/Context;)V | ||
| public fun checkForUpdate (Lio/sentry/IDistributionApi$UpdateCallback;)V | ||
| public fun checkForUpdateBlocking ()Lio/sentry/UpdateStatus; | ||
| public fun downloadUpdate (Lio/sentry/UpdateInfo;)V | ||
| public fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V | ||
| } | ||
|
|
This file was deleted.
Oops, something went wrong.
87 changes: 0 additions & 87 deletions
87
sentry-android-distribution/src/main/java/io/sentry/android/distribution/Distribution.kt
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
...roid-distribution/src/main/java/io/sentry/android/distribution/DistributionIntegration.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,76 @@ | ||
| package io.sentry.android.distribution | ||
|
|
||
| import android.content.Context | ||
| import android.content.Intent | ||
| import android.net.Uri | ||
| import io.sentry.IDistributionApi | ||
| import io.sentry.IScopes | ||
| import io.sentry.Integration | ||
| import io.sentry.SentryOptions | ||
| import io.sentry.UpdateInfo | ||
| import io.sentry.UpdateStatus | ||
|
|
||
| /** | ||
| * The public Android SDK for Sentry Build Distribution. | ||
| * | ||
| * Provides functionality to check for app updates and download new versions from Sentry's preprod | ||
| * artifacts system. | ||
| */ | ||
| public class DistributionIntegration(context: Context) : Integration, IDistributionApi { | ||
|
|
||
| private lateinit var scopes: IScopes | ||
| private lateinit var sentryOptions: SentryOptions | ||
| private val context: Context = context.applicationContext | ||
|
|
||
| /** | ||
| * Registers the Distribution integration with Sentry. | ||
| * | ||
| * @param scopes the Scopes | ||
| * @param options the options | ||
| */ | ||
| public override fun register(scopes: IScopes, options: SentryOptions) { | ||
| // Store scopes and options for use by distribution functionality | ||
| this.scopes = scopes | ||
| this.sentryOptions = options | ||
| } | ||
|
|
||
| /** | ||
| * Check for available updates synchronously (blocking call). This method will block the calling | ||
| * thread while making the network request. Consider using checkForUpdate with callback for | ||
| * non-blocking behavior. | ||
| * | ||
| * @return UpdateStatus indicating if an update is available, up to date, or error | ||
| */ | ||
| public override fun checkForUpdateBlocking(): UpdateStatus { | ||
| throw NotImplementedError() | ||
| } | ||
|
|
||
| /** | ||
| * Check for available updates asynchronously using a callback. | ||
| * | ||
| * @param onResult Callback that will be called with the UpdateStatus result | ||
| */ | ||
| public override fun checkForUpdate(onResult: IDistributionApi.UpdateCallback) { | ||
| // TODO implement this in a async way | ||
| val result = checkForUpdateBlocking() | ||
| onResult.onResult(result) | ||
| } | ||
|
|
||
| /** | ||
| * Download and install the provided update by opening the download URL in the default browser or | ||
| * appropriate application. | ||
| * | ||
| * @param info Information about the update to download | ||
| */ | ||
| public override fun downloadUpdate(info: UpdateInfo) { | ||
| val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(info.downloadUrl)) | ||
| browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
|
|
||
| try { | ||
| context.startActivity(browserIntent) | ||
| } catch (e: android.content.ActivityNotFoundException) { | ||
| // No application can handle the HTTP/HTTPS URL, typically no browser installed | ||
| // Silently fail as this is expected behavior in some environments | ||
| } | ||
| } | ||
| } | ||
19 changes: 0 additions & 19 deletions
19
...-android-distribution/src/main/java/io/sentry/android/distribution/DistributionOptions.kt
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
sentry-android-distribution/src/main/java/io/sentry/android/distribution/UpdateInfo.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
sentry-android-distribution/src/main/java/io/sentry/android/distribution/UpdateStatus.kt
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...ribution/src/main/java/io/sentry/android/distribution/internal/DistributionIntegration.kt
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
...istribution/src/main/java/io/sentry/android/distribution/internal/DistributionInternal.kt
This file was deleted.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Async Update Check Fails Due to Unhandled Error
The
checkForUpdate()method callscheckForUpdateBlocking(), which throws an unhandledNotImplementedError(). This causes the application to crash and prevents theonResultcallback from being invoked, meaning async update checks fail with an exception instead of notifying the caller.