Skip to content

Commit

Permalink
Update README.md (#4)
Browse files Browse the repository at this point in the history
* Update README.md
  • Loading branch information
Dimdron authored Jan 2, 2019
1 parent 2dc2541 commit 43127f7
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Debugging doesn't have to be painful!
* [Configure](#configure)
* [SDK start/stop](#sdk-startstop)
* [Custom device name](#custom-device-name)
* [Filtering your data](#filtering-your-data)
* [Getting session URL](#getting-session-url)
* [Features](#features)

Expand Down Expand Up @@ -124,6 +125,53 @@ AppSpector
.addMetadata(AppSpector.METADATA_KEY_DEVICE_NAME, "YOUR_DEVICE_NAME")
.run("YOUR_API_KEY");
```
## Filtering your data

Sometimes you may want to adjust or completely skip some pieces of data AppSpector gather. We have a special feature called Sanitizing for this, for now it’s available only for HTTP and logs monitors, more coming. For these two monitors you can provide a filter which allows to modify or block events before AppSpector sends them to the backend. You can specify filters via `addHttpMonitor(HTTPFilter)` and `addLogMonitor(LogMonitor.Filter)` methods.

Some examples. Let's say we want to skip our auth token from requests headers:
```java
public class TokenFilter implements HTTPFilter {
@Nullable
@Override
public HttpRequest filter(HttpRequest request) {
if (request.getHeaders().containsKey("YOUR-AUTH-HEADER")) {
request.getHeaders().remove("YOUR-AUTH-HEADER");
}
return request;
}

@Nullable
@Override
public HttpResponse filter(HttpResponse response) {
return response;
}
}
```

And here, for example, we want to change a log level to WARN for all messages with word *token*:
```java
public class LogFilter implements Filter {

@Nullable
@Override
public LogEvent filter(LogEvent event) {
if (event.message.contains("token")) {
event.level = LogLevel.WARN;
}
return request;
}
}
```
Let's provide them to monitors:
```java
AppSpector
.build(this)
.withDefaultMonitors()
.addLogMonitor(new LogFilter())
.addHttpMonitor(new TokenFilter())
.run("YOUR_API_KEY");
```

## Getting session URL

Expand Down

0 comments on commit 43127f7

Please sign in to comment.