-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow early session starts in auto mode (#2006)
* feat(session)Allow early session starts in auto mode * feat(session)Allow early session starts in auto mode * feat(session)End to end test * feat(feature flags): don't copy FeatureFlags on the crashing thread * feat(session)Allow early session starts in auto mode --------- Co-authored-by: jason <[email protected]>
- Loading branch information
1 parent
cabac65
commit 43e4cc8
Showing
7 changed files
with
88 additions
and
3 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
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
32 changes: 32 additions & 0 deletions
32
...ures/mazerunner/app/src/main/java/com/bugsnag/android/mazerunner/StartSessionBehaviour.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,32 @@ | ||
package com.bugsnag.android.mazerunner | ||
|
||
import android.app.Application | ||
import com.bugsnag.android.Bugsnag | ||
import com.bugsnag.android.Configuration | ||
import com.bugsnag.android.EndpointConfiguration | ||
|
||
fun Application.triggerManualSessionIfRequired() { | ||
val prefs = getSharedPreferences("SessionPreferences", android.content.Context.MODE_PRIVATE) | ||
val manualSession = prefs.getBoolean("manualSession", false) | ||
|
||
if (manualSession) { | ||
val notifyEndpoint = prefs.getString("notify", null) | ||
val sessionsEndpoint = prefs.getString("sessions", null) | ||
|
||
// we remove the preferences so that we don't affect any future startup | ||
prefs.edit() | ||
.remove("notify") | ||
.remove("sessions") | ||
.remove("manualSession") | ||
.commit() | ||
|
||
// we have to startup Bugsnag at this point | ||
val config = Configuration.load(this) | ||
if (!notifyEndpoint.isNullOrBlank() && !sessionsEndpoint.isNullOrBlank()) { | ||
config.endpoints = EndpointConfiguration(notifyEndpoint, sessionsEndpoint) | ||
} | ||
|
||
Bugsnag.start(this, config) | ||
Bugsnag.startSession() | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...os/src/main/java/com/bugsnag/android/mazerunner/scenarios/StartSessionAutoModeScenario.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,27 @@ | ||
package com.bugsnag.android.mazerunner.scenarios | ||
|
||
import android.content.Context | ||
import com.bugsnag.android.Configuration | ||
import kotlin.system.exitProcess | ||
|
||
internal class StartSessionAutoModeScenario( | ||
config: Configuration, | ||
context: Context, | ||
eventMetadata: String? | ||
) : Scenario(config, context, eventMetadata) { | ||
override fun startScenario() { | ||
context.applicationContext | ||
.getSharedPreferences("SessionPreferences", Context.MODE_PRIVATE) | ||
.edit() | ||
.putBoolean("manualSession", MANUAL_START) | ||
.putString("notify", config.endpoints.notify) | ||
.putString("sessions", config.endpoints.sessions) | ||
.commit() | ||
|
||
exitProcess(0) | ||
} | ||
|
||
companion object { | ||
private const val MANUAL_START = true | ||
} | ||
} |
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