Skip to content

Commit

Permalink
refactor: docs
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbuon committed Aug 16, 2024
1 parent 2fcb323 commit 7477b41
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 27 deletions.
11 changes: 11 additions & 0 deletions rollbar-api/src/main/java/com/rollbar/api/payload/data/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@

import com.rollbar.api.json.JsonSerializable;

/**
* The Source of a payload.
*/
public enum Source implements JsonSerializable {

/**
* A Client source (e.g. Android)
*/
CLIENT("client"),

/**
* A Server source (e.g. Spring)
*/
SERVER("server");

private final String jsonName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,52 +38,25 @@ public List<TelemetryEvent> dump() {
return events;
}

/**
* Record log telemetry event. ({@link TelemetryType#LOG}).
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param message the message sent for this event (e.g. "hello world").
*/
public void recordLogEventFor(Level level, Source source, String message) {
Map<String, String> body = new HashMap<>();
body.put(LOG_KEY_MESSAGE, message);
addEvent(new TelemetryEvent(TelemetryType.LOG, level, timestampProvider.provide(), source, body));
}

/**
* Record manual telemetry event. ({@link TelemetryType#MANUAL}) .
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param message the message sent for this event (e.g. "hello world").
*/
public void recordManualEventFor(Level level, Source source, String message) {
Map<String, String> body = new HashMap<>();
body.put(LOG_KEY_MESSAGE, message);
addEvent(new TelemetryEvent(TelemetryType.MANUAL, level, timestampProvider.provide(), source, body));
}

/**
* Record navigation telemetry event with from (origin) and to (destination).({@link TelemetryType#NAVIGATION}) .
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param from the starting point (e.g. "SettingView").
* @param to the destination point (e.g. "HomeView").
*/
public void recordNavigationEventFor(Level level, Source source, String from, String to) {
Map<String, String> body = new HashMap<>();
body.put(NAVIGATION_KEY_FROM, from);
body.put(NAVIGATION_KEY_TO, to);
addEvent(new TelemetryEvent(TelemetryType.NAVIGATION, level, timestampProvider.provide(), source, body));
}

/**
* Record network telemetry event with method, url, and status code.({@link TelemetryType#NETWORK}).
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param method the verb used (e.g. "POST").
* @param url the api url (e.g. "<a href="http://rollbar.com/test/api">http://rollbar.com/test/api</a>").
* @param statusCode the response status code (e.g. "404").
*/
public void recordNetworkEventFor(Level level, Source source, String method, String url, String statusCode) {
Map<String, String> body = new HashMap<>();
body.put(NETWORK_KEY_METHOD, method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,53 @@
import com.rollbar.api.payload.data.Level;
import com.rollbar.api.payload.data.Source;
import com.rollbar.api.payload.data.TelemetryEvent;
import com.rollbar.api.payload.data.TelemetryType;

import java.util.List;

public interface TelemetryEventTracker {

/**
* Dump all the events recorded
*/
List<TelemetryEvent> dump();

/**
* Record log telemetry event. ({@link TelemetryType#LOG}).
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}).
* @param message the message sent for this event (e.g. "hello world").
*/
void recordLogEventFor(Level level, Source source, String message);

/**
* Record manual telemetry event. ({@link TelemetryType#MANUAL}) .
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}).
* @param message the message sent for this event (e.g. "hello world").
*/
void recordManualEventFor(Level level, Source source, String message);

/**
* Record navigation telemetry event with from (origin) and to (destination).({@link TelemetryType#NAVIGATION}) .
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}).
* @param from the starting point (e.g. "SettingView").
* @param to the destination point (e.g. "HomeView").
*/
void recordNavigationEventFor(Level level, Source source, String from, String to);

/**
* Record network telemetry event with method, url, and status code.({@link TelemetryType#NETWORK}).
*
* @param level the TelemetryEvent severity (e.g. {@link Level#DEBUG}).
* @param source the {@link Source} this event is recorded from (e.g. {@link Source#CLIENT}).
* @param method the verb used (e.g. "POST").
* @param url the api url (e.g. "<a href="http://rollbar.com/test/api">http://rollbar.com/test/api</a>").
* @param statusCode the response status code (e.g. "404").
*/
void recordNetworkEventFor(Level level, Source source, String method, String url, String statusCode);
}

0 comments on commit 7477b41

Please sign in to comment.