-
-
Notifications
You must be signed in to change notification settings - Fork 456
feat(android-distribution): Add module foundation with compilation stubs #4712
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
Changes from all commits
8c9917f
1e1e214
c6f5bc5
0ff9750
b68cb00
9b0cd9f
614b2c5
33974d1
ae4d425
289b360
f5bc2bc
5dce724
a4323c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,79 @@ | ||
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 fun register (Lio/sentry/IScopes;Lio/sentry/SentryOptions;)V | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not needed anymore if we define a |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,87 @@ | ||
package io.sentry.android.distribution | ||
|
||
public class Distribution {} | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import io.sentry.android.distribution.internal.DistributionInternal | ||
|
||
/** | ||
* 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 object Distribution { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is almost exactly the same API as in the Emerge Build Distribution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For new-ish features like logging and replay, we're exposing top level entry points under the Sentry class. E.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good point, I looked in to it and it seems like a bigger change, I will add this in a future PR. |
||
/** | ||
* Initialize build distribution with default options. This should be called once per process, | ||
* typically in Application.onCreate(). | ||
* | ||
* @param context Android context | ||
*/ | ||
public fun init(context: Context) { | ||
init(context) {} | ||
} | ||
|
||
/** | ||
* Initialize build distribution with the provided configuration. This should be called once per | ||
* process, typically in Application.onCreate(). | ||
* | ||
* @param context Android context | ||
* @param configuration Configuration handler for build distribution options | ||
*/ | ||
public fun init(context: Context, configuration: (DistributionOptions) -> Unit) { | ||
val options = DistributionOptions() | ||
configuration(options) | ||
DistributionInternal.init(context, options) | ||
} | ||
|
||
/** | ||
* Check if build distribution is enabled and properly configured. | ||
* | ||
* @return true if build distribution is enabled | ||
*/ | ||
public fun isEnabled(): Boolean { | ||
return DistributionInternal.isEnabled() | ||
} | ||
|
||
/** | ||
* 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. | ||
* | ||
* @param context Android context | ||
* @return UpdateStatus indicating if an update is available, up to date, or error | ||
*/ | ||
public fun checkForUpdateBlocking(context: Context): UpdateStatus { | ||
return DistributionInternal.checkForUpdateBlocking(context) | ||
} | ||
|
||
/** | ||
* Check for available updates asynchronously using a callback. | ||
* | ||
* @param context Android context | ||
* @param onResult Callback that will be called with the UpdateStatus result | ||
*/ | ||
public fun checkForUpdate(context: Context, onResult: (UpdateStatus) -> Unit) { | ||
DistributionInternal.checkForUpdateAsync(context, onResult) | ||
} | ||
|
||
/** | ||
* Download and install the provided update by opening the download URL in the default browser or | ||
* appropriate application. | ||
* | ||
* @param context Android context | ||
* @param info Information about the update to download | ||
*/ | ||
public fun downloadUpdate(context: Context, 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 | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.sentry.android.distribution | ||
|
||
/** Configuration options for Sentry Build Distribution. */ | ||
public class DistributionOptions { | ||
/** Organization authentication token for API access */ | ||
public var orgAuthToken: String = "" | ||
|
||
/** Sentry organization slug */ | ||
public var organizationSlug: String = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just a nit, but would be nice to be consistent with naming - i.e. either call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. I’ll do this in a follow up |
||
|
||
/** Sentry project slug */ | ||
public var projectSlug: String = "" | ||
|
||
/** Base URL for Sentry API (defaults to https://sentry.io) */ | ||
public var sentryBaseUrl: String = "https://sentry.io" | ||
|
||
/** Optional build configuration name for filtering (e.g., "debug", "release", "staging") */ | ||
public var buildConfiguration: String? = null | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since it is part of the public API, should we also use regular There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds good, will do in a follow up |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.sentry.android.distribution | ||
|
||
/** | ||
* Information about an available app update. | ||
* | ||
* @param id Unique identifier for this build artifact | ||
* @param buildVersion Version string (e.g., "1.2.0") | ||
* @param buildNumber Build number for this version | ||
* @param downloadUrl URL where the update can be downloaded | ||
* @param appName Application name | ||
* @param createdDate ISO timestamp when this build was created | ||
*/ | ||
public data class UpdateInfo( | ||
val id: String, | ||
val buildVersion: String, | ||
val buildNumber: Int, | ||
val downloadUrl: String, | ||
val appName: String, | ||
val createdDate: String, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.sentry.android.distribution | ||
|
||
/** Represents the result of checking for app updates. */ | ||
public sealed class UpdateStatus { | ||
/** Current app version is up to date, no update available. */ | ||
public object UpToDate : UpdateStatus() | ||
|
||
/** A new release is available for download. */ | ||
public data class NewRelease(val info: UpdateInfo) : UpdateStatus() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here about using regular |
||
|
||
/** An error occurred during the update check. */ | ||
public data class Error(val message: String) : UpdateStatus() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.sentry.android.distribution.internal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking if we should move this out of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, hmm i messed this up then, I think I should have made the |
||
|
||
import io.sentry.IScopes | ||
import io.sentry.Integration | ||
import io.sentry.SentryOptions | ||
|
||
/** | ||
* Integration that automatically enables distribution functionality when the module is included. | ||
*/ | ||
public class DistributionIntegration : Integration { | ||
public override fun register(scopes: IScopes, options: SentryOptions) { | ||
// Distribution integration automatically enables when module is present | ||
// No configuration needed - just having this class on the classpath enables the feature | ||
|
||
// If needed, we could initialize DistributionInternal here in the future | ||
// For now, Distribution.init() still needs to be called manually | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.