Skip to content
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

Update README.md #278

Merged
merged 10 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ Pluto is distributed through [***mavenCentral***](https://central.sonatype.com/a

> Note: add both the `pluto` and the `pluto-no-op` variant to isolate Pluto from release builds.
```groovy
def plutoVersion = "2.1.7"

dependencies {
....
debugImplementation 'com.plutolib:pluto:2.1.6'
releaseImplementation 'com.plutolib:pluto-no-op:2.1.6'
debugImplementation "com.plutolib:pluto:$plutoVersion"
releaseImplementation "com.plutolib:pluto-no-op:$plutoVersion"
....
}
```
Expand All @@ -47,8 +49,8 @@ Plugin bundle comes with all the basic plugins bundled together as single depend
```groovy
dependencies {
....
debugImplementation 'com.plutolib.plugins:bundle-core:2.1.6'
releaseImplementation 'com.plutolib.plugins:bundle-core-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:bundle-core:$plutoVersion"
releaseImplementation "com.plutolib.plugins:bundle-core-no-op:$plutoVersion"
....
}
```
Expand Down
4 changes: 2 additions & 2 deletions pluto-plugins/plugins/datastore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Datastore Preferences is distributed through [***mavenCentral***](https://
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:datastore-pref:2.1.6'
releaseImplementation 'com.plutolib.plugins:datastore-pref-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:datastore-pref:$plutoVersion"
releaseImplementation "com.plutolib.plugins:datastore-pref-no-op:$plutoVersion"
}
```
<br>
Expand Down
4 changes: 2 additions & 2 deletions pluto-plugins/plugins/exceptions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Exceptions is distributed through [***mavenCentral***](https://central.son
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:exceptions:2.1.6'
releaseImplementation 'com.plutolib.plugins:exceptions-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:exceptions:$plutoVersion"
releaseImplementation "com.plutolib.plugins:exceptions-no-op:$plutoVersion"
}
```
<br>
Expand Down
4 changes: 2 additions & 2 deletions pluto-plugins/plugins/layout-inspector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Layout Inspector is distributed through [***mavenCentral***](https://centr
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:layout-inspector:2.1.6'
releaseImplementation 'com.plutolib.plugins:layout-inspector-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:layout-inspector:$plutoVersion"
releaseImplementation "com.plutolib.plugins:layout-inspector-no-op:$plutoVersion"
}
```
<br>
Expand Down
4 changes: 2 additions & 2 deletions pluto-plugins/plugins/logger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Logger is distributed through [***mavenCentral***](https://central.sonatyp
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:logger:2.1.6'
releaseImplementation 'com.plutolib.plugins:logger-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:logger:$plutoVersion"
releaseImplementation "com.plutolib.plugins:logger-no-op:$plutoVersion"
}
```
<br>
Expand Down
72 changes: 56 additions & 16 deletions pluto-plugins/plugins/network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Network is distributed through [***mavenCentral***](https://central.sonaty
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:network:2.1.6'
releaseImplementation 'com.plutolib.plugins:network-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:network:$plutoVersion"
releaseImplementation "com.plutolib.plugins:network-no-op:$plutoVersion"
}
```
<br>
Expand All @@ -23,16 +23,66 @@ Pluto.Installer(this)
```
<br>

### Add interceptor
### Add interceptors

To debug HTTP requests/responses, plug the PlutoInterceptor in your OkHttp Client Builder
#### 1. Okhttp Interceptor
Add okhttp-interceptor dependency
```groovy
dependencies {
debugImplementation "com.plutolib.plugins:network-interceptor-okhttp:$plutoVersion"
releaseImplementation "com.plutolib.plugins:network-interceptor-okhttp-no-op:$plutoVersion"
}
```

Add interceptor in your OkHttp Client Builder
```kotlin
val client = OkHttpClient.Builder()
.addInterceptor(PlutoInterceptor())
.build()
addPlutoOkhttpInterceptor()
.build()
```
<br>

#### 2. Ktor Interceptor
Add ktor-interceptor dependency
```groovy
dependencies {
debugImplementation "com.plutolib.plugins:network-interceptor-ktor:$plutoVersion"
releaseImplementation "com.plutolib.plugins:network-interceptor-ktor-no-op:$plutoVersion"
}
```

Add interceptor in your HttpClient
```kotlin
val client = HttpClient {
...
}.apply {
addPlutoKtorInterceptor()
}
```
<br>

#### 3. Custom Interceptor
If you wish to use any interceptor, other than Okhttp or Ktor, Pluto provides way to capture network logs.
```kotlin
/* create interceptor */
val networkInterceptor = NetworkInterceptor.intercept(
NetworkData.Request(....),
NetworkInterceptor.Option()
)

/**
* wait for the network call to complete
**/

/* if error */
networkInterceptor.onError(exception)

/* if success */
networkInterceptor.onResponse(
NetworkData.Response(....)
)
```

🎉 &nbsp;You are all done!

Now re-build and run your app and open Pluto, you will see the Network plugin installed.
Expand All @@ -45,13 +95,3 @@ To open Network plugin screen via code, use this
Pluto.open(PlutoNetworkPlugin.ID)
```
<br>

### Log Custom Network traces
PlutoInterceptor works with OkHttp based interceptors, but to allow non-OkHttp based interceptors to track network calls Pluto provides utility to log network calls manually.
```kotlin
PlutoNetwork.logCustomTrace(
request = CustomRequest(),
response = CustomResponse()
)
```
Once logged successfully, the network call trace will appear in the network call list.
4 changes: 2 additions & 2 deletions pluto-plugins/plugins/rooms-database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Rooms Database is distributed through [***mavenCentral***](https://central
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:rooms-db:2.1.6'
releaseImplementation 'com.plutolib.plugins:rooms-db-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:rooms-db:$plutoVersion"
releaseImplementation "com.plutolib.plugins:rooms-db-no-op:$plutoVersion"
}
```
<br>
Expand Down
4 changes: 2 additions & 2 deletions pluto-plugins/plugins/shared-preferences/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pluto Shared Preferences is distributed through [***mavenCentral***](https://cen
> Note: add the `no-op` variant to isolate the plugin from release builds.
```groovy
dependencies {
debugImplementation 'com.plutolib.plugins:preferences:2.1.6'
releaseImplementation 'com.plutolib.plugins:preferences-no-op:2.1.6'
debugImplementation "com.plutolib.plugins:preferences:$plutoVersion"
releaseImplementation "com.plutolib.plugins:preferences-no-op:$plutoVersion"
}
```
<br>
Expand Down