-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create unified Delivery interface (#299)
- Loading branch information
Showing
31 changed files
with
666 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Feature: Using custom API clients for reporting errors | ||
|
||
Scenario: Set a custom session client and flush a stored session | ||
When I run "CustomClientSessionFlushScenario" with the defaults | ||
When I force stop the "com.bugsnag.android.mazerunner" Android app | ||
And I set environment variable "EVENT_TYPE" to "CustomClientSessionFlushScenario" | ||
And I set environment variable "EVENT_METADATA" to "DeliverSessions" | ||
And I start the "com.bugsnag.android.mazerunner" Android app using the "com.bugsnag.android.mazerunner.MainActivity" activity | ||
Then I should receive 2 requests | ||
And the "Custom-Client" header equals "Hello World" for request 0 | ||
And the "Custom-Client" header equals "Hello World" for request 1 | ||
|
||
Scenario: Set a custom error API client and notify an error | ||
When I run "CustomClientErrorScenario" with the defaults | ||
Then I should receive 1 request | ||
And the "Custom-Client" header equals "Hello World" | ||
And the request is a valid for the error reporting API | ||
|
||
Scenario: Set a custom session API client and start a session | ||
When I run "CustomClientSessionScenario" with the defaults | ||
Then I should receive 1 request | ||
And the "Custom-Client" header equals "Hello World" | ||
And the request is a valid for the session tracking API | ||
|
||
Scenario: Set a custom error client and flush a stored error | ||
When I run "CustomClientErrorFlushScenario" with the defaults | ||
When I force stop the "com.bugsnag.android.mazerunner" Android app | ||
And I set environment variable "EVENT_TYPE" to "CustomClientErrorFlushScenario" | ||
And I set environment variable "EVENT_METADATA" to "DeliverReports" | ||
And I start the "com.bugsnag.android.mazerunner" Android app using the "com.bugsnag.android.mazerunner.MainActivity" activity | ||
Then I should receive 1 request | ||
And the "Custom-Client" header equals "Hello World" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
.../src/main/java/com/bugsnag/android/mazerunner/scenarios/CustomClientErrorFlushScenario.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.createCustomHeaderDelivery | ||
|
||
/** | ||
* Sends an unhandled exception which is cached on disk to Bugsnag, then sent on a separate launch, | ||
* using a custom API client which modifies the request. | ||
*/ | ||
internal class CustomClientErrorFlushScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
if ("DeliverReports" == eventMetaData) { | ||
config.delivery = createCustomHeaderDelivery(context) | ||
} | ||
super.run() | ||
|
||
if ("DeliverReports" != eventMetaData) { | ||
disableAllDelivery() | ||
throw RuntimeException("ReportCacheScenario") | ||
} | ||
|
||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...unner/src/main/java/com/bugsnag/android/mazerunner/scenarios/CustomClientErrorScenario.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.createCustomHeaderDelivery | ||
|
||
/** | ||
* Sends a handled exception to Bugsnag using a custom API client which modifies the request. | ||
*/ | ||
internal class CustomClientErrorScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
config.delivery = createCustomHeaderDelivery(context) | ||
super.run() | ||
Bugsnag.notify(RuntimeException("Hello")) | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...rc/main/java/com/bugsnag/android/mazerunner/scenarios/CustomClientSessionFlushScenario.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.createCustomHeaderDelivery | ||
import com.bugsnag.android.createDefaultDelivery | ||
|
||
/** | ||
* Sends a session which is cached on disk to Bugsnag, then sent on a separate launch, | ||
* using a custom API client which modifies the request. | ||
*/ | ||
internal class CustomClientSessionFlushScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
super.run() | ||
|
||
if ("DeliverSessions" == eventMetaData) { | ||
// simulate activity lifecycle callback occurring before api client can be set | ||
Bugsnag.startSession() | ||
config.delivery = createCustomHeaderDelivery(context) | ||
} else { | ||
disableAllDelivery() | ||
Bugsnag.startSession() | ||
} | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...ner/src/main/java/com/bugsnag/android/mazerunner/scenarios/CustomClientSessionScenario.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.createCustomHeaderDelivery | ||
import com.bugsnag.android.createDefaultDelivery | ||
|
||
/** | ||
* Sends a session using a custom API client which modifies the request. | ||
*/ | ||
internal class CustomClientSessionScenario(config: Configuration, | ||
context: Context) : Scenario(config, context) { | ||
|
||
override fun run() { | ||
config.delivery = createCustomHeaderDelivery(context) | ||
super.run() | ||
Bugsnag.startSession() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.