Skip to content

Commit

Permalink
Remove the Throwable/Error feature (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico committed Nov 11, 2020
1 parent 6efc556 commit f2d35fd
Show file tree
Hide file tree
Showing 39 changed files with 28 additions and 1,027 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ Please add your entries according to this format.
### Removed

* Removed parametrized `ChuckerInterceptor` constructor in favour of builder pattern. Constructor that accepts only `Context` is still available.
* Removed the Throwable reporting feature as well as all the @Deprecated related methods.

## Version 3.4.0 *(2020-11-05)*

Expand Down
25 changes: 5 additions & 20 deletions README.md
Expand Up @@ -11,7 +11,6 @@ _A fork of [Chuck](https://github.com/jgilfelt/chuck)_
* [Features](#features-)
* [Multi-Window](#multi-window-)
* [Configure](#configure-)
* [Throwables](#throwables-️)
* [Redact-Header️](#redact-header-️)
* [Migrating](#migrating-)
* [Snapshots](#snapshots-)
Expand All @@ -21,13 +20,13 @@ _A fork of [Chuck](https://github.com/jgilfelt/chuck)_
* [Acknowledgments](#acknowledgments-)
* [License](#license-)

Chucker simplifies the inspection of **HTTP(S) requests/responses**, and **Throwables** fired by your Android App. Chucker works as an **OkHttp Interceptor** persisting all those events inside your application, and providing a UI for inspecting and sharing their content.
Chucker simplifies the inspection of **HTTP(S) requests/responses** fired by your Android App. Chucker works as an **OkHttp Interceptor** persisting all those events inside your application, and providing a UI for inspecting and sharing their content.

Apps using Chucker will display a **push notification** showing a summary of ongoing HTTP activity and Throwables. Tapping on the notification launches the full Chucker UI. Apps can optionally suppress the notification, and launch the Chucker UI directly from within their own interface.
Apps using Chucker will display a **push notification** showing a summary of ongoing HTTP activity. Tapping on the notification launches the full Chucker UI. Apps can optionally suppress the notification, and launch the Chucker UI directly from within their own interface.

| HTTP Calls | Throwables |
| --- | --- |
| ![Chucker HTTP transactions](assets/chucker-http.gif) | ![Chucker errors](assets/chucker-error.gif) |
<p align="center">
<img src="assets/chucker-http.gif" alt="chucker http sample" width="50%"/>
</p>

## Getting Started 👣

Expand Down Expand Up @@ -108,20 +107,6 @@ val client = OkHttpClient.Builder()
.build()
```

### Throwables (Deprected) ☄️

#### Warning: This functionality will be unavailable in 4.x release. Details in [this issue](https://github.com/ChuckerTeam/chucker/issues/321#issuecomment-626138370)

Chucker can also collect and display **Throwables** of your application. To inform Chucker that a `Throwable` was fired you need to call the `onError` method of the `ChuckerCollector` (you need to retain an instance of your collector):

```kotlin
try {
// Do something risky
} catch (IOException exception) {
chuckerCollector.onError("TAG", exception)
}
```

### Redact-Header 👮‍♂️

**Warning** The data generated and stored when using Chucker may contain sensitive information such as Authorization or Cookie headers, and the contents of request and response bodies.
Expand Down
Binary file removed assets/chucker-error.gif
Binary file not shown.
Expand Up @@ -8,37 +8,14 @@ import android.content.Intent
*/
public object Chucker {

@Deprecated("This variable will be removed in 4.x release")
public const val SCREEN_HTTP: Int = 1
@Deprecated("This variable will be removed in 4.x release")
public const val SCREEN_ERROR: Int = 2

@Suppress("MayBeConst ") // https://github.com/ChuckerTeam/chucker/pull/169#discussion_r362341353
public val isOp: Boolean = false

@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.getLaunchIntent(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
public fun getLaunchIntent(context: Context, screen: Int): Intent = Intent()

@JvmStatic
public fun getLaunchIntent(context: Context): Intent = Intent()

@JvmStatic
public fun registerDefaultCrashHandler(collector: ChuckerCollector) {
// Empty method for the library-no-op artifact
}

@JvmStatic
public fun dismissTransactionsNotification(context: Context) {
// Empty method for the library-no-op artifact
}

@JvmStatic
public fun dismissErrorsNotification(context: Context) {
public fun dismissNotifications(context: Context) {
// Empty method for the library-no-op artifact
}
}
Expand Up @@ -9,14 +9,4 @@ public class ChuckerCollector @JvmOverloads constructor(
context: Context,
public var showNotification: Boolean = true,
retentionPeriod: RetentionManager.Period = RetentionManager.Period.ONE_WEEK
) {

@Deprecated(
"This fun will be removed in 4.x release as part of Throwable functionality removal.",
ReplaceWith(""),
DeprecationLevel.WARNING
)
public fun onError(obj: Any?, obj2: Any?) {
// Empty method for the library-no-op artifact
}
}
)
4 changes: 0 additions & 4 deletions library/src/main/AndroidManifest.xml
Expand Up @@ -21,10 +21,6 @@
android:theme="@style/Chucker.Theme"
android:parentActivityName="com.chuckerteam.chucker.internal.ui.MainActivity"/>

<activity android:name="com.chuckerteam.chucker.internal.ui.throwable.ThrowableActivity"
android:theme="@style/Chucker.Theme"
android:parentActivityName="com.chuckerteam.chucker.internal.ui.MainActivity" />

<service
android:name="com.chuckerteam.chucker.internal.support.ClearDatabaseService"
android:exported="false" />
Expand Down
72 changes: 0 additions & 72 deletions library/src/main/java/com/chuckerteam/chucker/api/Chucker.kt
Expand Up @@ -2,8 +2,6 @@ package com.chuckerteam.chucker.api

import android.content.Context
import android.content.Intent
import androidx.annotation.IntDef
import com.chuckerteam.chucker.internal.support.ChuckerCrashHandler
import com.chuckerteam.chucker.internal.support.NotificationHelper
import com.chuckerteam.chucker.internal.ui.MainActivity

Expand All @@ -12,34 +10,13 @@ import com.chuckerteam.chucker.internal.ui.MainActivity
*/
public object Chucker {

@Deprecated("This variable will be removed in 4.x release")
public const val SCREEN_HTTP: Int = 1
@Deprecated("This variable will be removed in 4.x release")
public const val SCREEN_ERROR: Int = 2

/**
* Check if this instance is the operation one or no-op.
* @return `true` if this is the operation instance.
*/
@Suppress("MayBeConst ") // https://github.com/ChuckerTeam/chucker/pull/169#discussion_r362341353
public val isOp: Boolean = true

/**
* Get an Intent to launch the Chucker UI directly.
* @param context An Android [Context].
* @param screen The [Screen] to display: SCREEN_HTTP or SCREEN_ERROR.
* @return An Intent for the main Chucker Activity that can be started with [Context.startActivity].
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.getLaunchIntent(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
public fun getLaunchIntent(context: Context, @Screen screen: Int): Intent {
return getLaunchIntent(context).putExtra(MainActivity.EXTRA_SCREEN, screen)
}

/**
* Get an Intent to launch the Chucker UI directly.
* @param context An Android [Context].
Expand All @@ -51,60 +28,11 @@ public object Chucker {
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}

/**
* Configure the default crash handler of the JVM to report all uncaught [Throwable] to Chucker.
* You may only use it for debugging purpose.
*
* @param collector the ChuckerCollector
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith(""),
DeprecationLevel.WARNING
)
@JvmStatic
public fun registerDefaultCrashHandler(collector: ChuckerCollector) {
Thread.setDefaultUncaughtExceptionHandler(ChuckerCrashHandler(collector))
}

/**
* Method to dismiss the Chucker notification of HTTP Transactions
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.dismissNotifications(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
public fun dismissTransactionsNotification(context: Context) {
NotificationHelper(context).dismissTransactionsNotification()
}

/**
* Method to dismiss the Chucker notification of Uncaught Errors.
*/
@Deprecated(
"This fun will be removed in 4.x release",
ReplaceWith("Chucker.dismissNotifications(context)"),
DeprecationLevel.WARNING
)
@JvmStatic
public fun dismissErrorsNotification(context: Context) {
NotificationHelper(context).dismissErrorsNotification()
}

/**
* Dismisses all previous Chucker notifications.
*/
@JvmStatic
public fun dismissNotifications(context: Context) {
NotificationHelper(context).dismissNotifications()
}

/**
* Annotation used to specify which screen of Chucker should be launched.
*/
@Deprecated("This param will be removed in 4.x release")
@IntDef(value = [SCREEN_HTTP, SCREEN_ERROR])
public annotation class Screen
}
Expand Up @@ -2,7 +2,6 @@ package com.chuckerteam.chucker.api

import android.content.Context
import com.chuckerteam.chucker.internal.data.entity.HttpTransaction
import com.chuckerteam.chucker.internal.data.entity.RecordedThrowable
import com.chuckerteam.chucker.internal.data.repository.RepositoryProvider
import com.chuckerteam.chucker.internal.support.NotificationHelper
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -32,27 +31,6 @@ public class ChuckerCollector @JvmOverloads constructor(
RepositoryProvider.initialize(context)
}

/**
* Call this method when a throwable is triggered and you want to record it.
* @param tag A tag you choose
* @param throwable The triggered [Throwable]
*/
@Deprecated(
"This fun will be removed in 4.x release as part of Throwable functionality removal.",
ReplaceWith(""),
DeprecationLevel.WARNING
)
public fun onError(tag: String, throwable: Throwable) {
val recordedThrowable = RecordedThrowable(tag, throwable)
CoroutineScope(Dispatchers.IO).launch {
RepositoryProvider.throwable().saveThrowable(recordedThrowable)
}
if (showNotification) {
notificationHelper.show(recordedThrowable)
}
retentionManager.doMaintenance()
}

/**
* Call this method when you send an HTTP request.
* @param transaction The HTTP transaction sent
Expand Down
Expand Up @@ -10,8 +10,8 @@ import kotlinx.coroutines.launch
import java.util.concurrent.TimeUnit

/**
* Class responsible of holding the logic for the retention of your HTTP transactions
* and your throwable. You can customize how long data should be stored here.
* Class responsible of holding the logic for the retention of your HTTP transactions.
* You can customize how long data should be stored here.
* @param context An Android Context
* @param retentionPeriod A [Period] to specify the retention of data. Default 1 week.
*/
Expand Down Expand Up @@ -66,7 +66,6 @@ public class RetentionManager @JvmOverloads constructor(
private fun deleteSince(threshold: Long) {
CoroutineScope(Dispatchers.IO).launch {
RepositoryProvider.transaction().deleteOldTransactions(threshold)
RepositoryProvider.throwable().deleteOldThrowables(threshold)
}
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit f2d35fd

Please sign in to comment.