Skip to content

Commit

Permalink
Merge branch 'main' into devx-2835
Browse files Browse the repository at this point in the history
  • Loading branch information
mhan83 authored Apr 23, 2024
2 parents 99670d0 + d7cc774 commit f4afe3d
Showing 1 changed file with 55 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ backtraceClient.metrics.enable(new BacktraceMetricsSettings(credentials));
</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
```java
// replace with your submission url
val credentials = BacktraceCredentials("<submissionUrl>")
val backtraceClient = BacktraceClient(applicationContext, credentials)
Expand All @@ -60,7 +60,7 @@ backtraceClient.metrics.enable(BacktraceMetricsSettings(credentials))

## Global Custom Attributes

You can set global custom attributes to be included with each report. To set global custom attributes, pass a map with custom attributes to the `BacktraceClient` constructor method, as shown below.
Custom attributes can be included with both managed and native reports. To set global custom attributes, pass in a map of attributes to the `BacktraceClient` constructor method.

<Tabs groupId="languages">
<TabItem value="java" label="Java">
Expand All @@ -75,14 +75,62 @@ BacktraceClient backtraceClient = new BacktraceClient(context, credentials, attr
</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
```java
val attributes: HashMap<String, Any> = hashMapOf("custom-attribute-key" to "custom-attribute-value")
val backtraceClient = BacktraceClient(context, credentials, attributes)
```

</TabItem>
</Tabs>

## Dynamic Custom Attributes

Use `BacktraceClient.addAttribute` to add global attributes to both the managed and native layer after initialization.

<Tabs groupId="languages">
<TabItem value="java" label="Java">

```java
BacktraceClient backtraceClient = new BacktraceClient(context, credentials, database);
// ...

// Add a single attribute
final String attributeKey = "test-attribute";
final String attributeValue = "test-value";
backtraceClient.addAttribute(attributeKey, attributeValue);

// Append an attribute map
final String attributeKey = "test-attribute";
final String attributeValue = "test-value";
Map<String, Object> attributes = new HashMap<>();
attributes.put(attributeKey, attributeValue);
backtraceClient.addAttribute(attributes);

```

</TabItem>
<TabItem value="kotlin" label="Kotlin">

```java
val backtraceClient = BacktraceClient(context, credentials, database)
// ...

// Add a single attribute
val attributeKey = "test-attribute"
val attributeValue = "test-value"
backtraceClient.addAttribute(attributeKey, attributeValue)

// Append an attribute map
val attributeKey = "test-attribute"
val attributeValue = "test-value"
val attributes: HashMap<String, Any> = HashMap<String, Any> ()
attributes[attributeKey] = attributeValue
backtraceClient.addAttribute(attributes)
```

</TabItem>
</Tabs>

## File Attachments

You can enable default file attachments which will be sent with all Backtrace reports both managed and native.
Expand Down Expand Up @@ -183,7 +231,7 @@ try {
</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
```java
try {
// throw exception here
}
Expand Down Expand Up @@ -215,7 +263,7 @@ client.send(report, new OnServerResponseEventListener() {
</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
```java
client.send(report) { backtraceResult ->
// process result here
}
Expand Down Expand Up @@ -249,7 +297,7 @@ try {
</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
```java
try {
// throw exception here
} catch (exception: Exception) {
Expand Down Expand Up @@ -286,7 +334,7 @@ backtraceClient.setOnBeforeSendEventListener(new OnBeforeSendEventListener() {
</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
```java
backtraceClient.setOnBeforeSendEventListener { data ->
// another code
data
Expand Down

0 comments on commit f4afe3d

Please sign in to comment.