Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #102 Dependabot, Library Management #107

Merged
merged 4 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=false
indent_style=space
indent_size=4

[*.yml]
charset=utf-8
end_of_line=lf
indent_style=space
indent_size=2

19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "monthly"
rebase-strategy: "disabled"
commit-message:
prefix: "chore"
include: "scope"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
rebase-strategy: "disabled"
commit-message:
prefix: "chore"
include: "scope"
22 changes: 13 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,23 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')

// Usage option A: Use and build from local provider library src
implementation project(':provider')
// Usage option B: Use and build from external repo
// 1. Use
// implementation 'com.raygun:raygun4android:x.y.z'
// or
// 2. Change version in Gradle library register and use
// implementation(libs.raygun)
implementation(libs.androidx.appcompat.appcompat)
implementation(libs.androidx.constraintlayout.constraintlayout)
implementation(libs.android.material.material)
implementation(libs.androidx.multidex.multidex)

testImplementation(libs.junit)

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.multidex:multidex:2.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.test.espresso.core)

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
debugImplementation(libs.leakcanary)
}
92 changes: 74 additions & 18 deletions app/src/main/java/com/raygun/raygun4android/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,60 @@ class MainActivity : AppCompatActivity() {
tw["secondkey"] = "secondvalue"

// Manual exception creation & sending
RaygunClient.send(Exception("Congratulations, you have sent errors with Raygun4Android"), null, tw)
Snackbar.make(it, getString(R.string.you_have_just_sent_an_error_with_raygun4android), Snackbar.LENGTH_SHORT).show()
RaygunClient.send(
Exception("Congratulations, you have sent errors with Raygun4Android"),
null,
tw,
)
Snackbar.make(
it,
getString(R.string.you_have_just_sent_an_error_with_raygun4android),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonCrash.setOnClickListener {
// A real exception will be thrown here, which will be caught & sent by RaygunClient
val i = 3 / 0
Log.d("Raygun4Android-Sample", "This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i")
Log.d(
"Raygun4Android-Sample",
"This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i",
)
}

buttonHandleException.setOnClickListener {
// Handle an exception yourself - nothing should be sent to Raygun
try {
val i = 3 / 0
Log.d("Raygun4Android-Sample", "This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i")
Log.d(
"Raygun4Android-Sample",
"This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i",
)
} catch (ex: Exception) {
val i = 4
Log.d("Raygun4Android-Sample", "This is here purely so that our alternative value for i gets used and not optimised away in a release build: $i")
Snackbar.make(it, getString(R.string.you_just_created_and_caught_an_exception), Snackbar.LENGTH_SHORT).show()
Log.d(
"Raygun4Android-Sample",
"This is here purely so that our alternative value for i gets used and not optimised away in a release build: $i",
)
Snackbar.make(
it,
getString(R.string.you_just_created_and_caught_an_exception),
Snackbar.LENGTH_SHORT,
)
.show()
}
}

buttonSetUserAnon.setOnClickListener {
val user = RaygunUserInfo()
RaygunClient.setUser(user)
Snackbar.make(it, getString(R.string.user_is_now_set_to_anonymous_for_future_raygun_reports), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
it,
getString(R.string.user_is_now_set_to_anonymous_for_future_raygun_reports),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonSetUserA.setOnClickListener {
Expand All @@ -81,7 +109,12 @@ class MainActivity : AppCompatActivity() {
user.email = "[email protected]"
RaygunClient.setUser(user)
RaygunClient.recordBreadcrumb("I'm now user A")
Snackbar.make(it, getString(R.string.user_is_now_set_to_user_a_for_future_raygun_reports), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
it,
getString(R.string.user_is_now_set_to_user_a_for_future_raygun_reports),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonSetUserB.setOnClickListener {
Expand All @@ -91,25 +124,48 @@ class MainActivity : AppCompatActivity() {
user.email = "[email protected]"
RaygunClient.setUser(user)
RaygunClient.recordBreadcrumb("I'm now user B")
Snackbar.make(it, getString(R.string.user_is_now_set_to_user_b_for_future_raygun_reports), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
it,
getString(R.string.user_is_now_set_to_user_b_for_future_raygun_reports),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonSecondActivity.setOnClickListener {
startSecondActivity.launch(SecondActivity.getIntent(this@MainActivity))
}

textViewAppVersion.text = getString(R.string.app_version_text, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE)
textViewProviderVersion.text = getString(R.string.provider_version_text, com.raygun.raygun4android.BuildConfig.VERSION_NAME, com.raygun.raygun4android.BuildConfig.VERSION_CODE, com.raygun.raygun4android.BuildConfig.BUILD_TYPE)
textViewAppVersion.text =
getString(
R.string.app_version_text,
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE,
BuildConfig.BUILD_TYPE,
)
textViewProviderVersion.text =
getString(
R.string.provider_version_text,
com.raygun.raygun4android.BuildConfig.VERSION_NAME,
com.raygun.raygun4android.BuildConfig.VERSION_CODE,
com.raygun.raygun4android.BuildConfig.BUILD_TYPE,
)

RaygunClient.recordBreadcrumb("I'm here in Main Activity")
}

private val startSecondActivity = registerForActivityResult(
ActivityResultContracts.StartActivityForResult(),
) { result ->
if (result.resultCode == RESULT_OK) {
val rootView: View = findViewById(android.R.id.content)
Snackbar.make(rootView, getString(R.string.we_returned_to_first_activity), Snackbar.LENGTH_SHORT).show()
private val startSecondActivity =
registerForActivityResult(
ActivityResultContracts.StartActivityForResult(),
) { result ->
if (result.resultCode == RESULT_OK) {
val rootView: View = findViewById(android.R.id.content)
Snackbar.make(
rootView,
getString(R.string.we_returned_to_first_activity),
Snackbar.LENGTH_SHORT,
)
.show()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import com.raygun.raygun4android.messages.crashreporting.RaygunMessage

internal class SampleOnBeforeSend : CrashReportingOnBeforeSend {
override fun onBeforeSend(message: RaygunMessage): RaygunMessage {
Log.i("Raygun4Android-Sample", "In SampleOnBeforeSend - About to post to Raygun, returning the payload as is...")
Log.i(
"Raygun4Android-Sample",
"In SampleOnBeforeSend - About to post to Raygun, returning the payload as is...",
)
return message
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,62 @@ class SecondActivity : AppCompatActivity() {
tw["secondkey"] = "secondvalue"

// Manual exception creation & sending
RaygunClient.send(Exception("Congratulations, you have sent errors with Raygun4Android from SecondActivity"), null, tw)
Snackbar.make(it, getString(R.string.you_have_just_sent_an_error_with_raygun4android), Snackbar.LENGTH_SHORT).show()
RaygunClient.send(
Exception(
"Congratulations, you have sent errors with Raygun4Android from SecondActivity",
),
null,
tw,
)
Snackbar.make(
it,
getString(R.string.you_have_just_sent_an_error_with_raygun4android),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonCrash.setOnClickListener {
// A real exception will be thrown here, which will be caught & sent by RaygunClient
val i = 3 / 0
Log.d("Raygun4Android-Sample", "This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i")
Log.d(
"Raygun4Android-Sample",
"This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i",
)
}

buttonHandleException.setOnClickListener {
// Handle an exception yourself - nothing should be sent to Raygun
try {
val i = 3 / 0
Log.d("Raygun4Android-Sample", "This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i")
Log.d(
"Raygun4Android-Sample",
"This is here purely so that our division by zero calculation in i gets used and not optimised away in a release build: $i",
)
} catch (ex: Exception) {
val i = 4
Log.d("Raygun4Android-Sample", "This is here purely so that our alternative value for i gets used and not optimised away in a release build: $i")
Snackbar.make(it, getString(R.string.you_just_created_and_caught_an_exception), Snackbar.LENGTH_SHORT).show()
Log.d(
"Raygun4Android-Sample",
"This is here purely so that our alternative value for i gets used and not optimised away in a release build: $i",
)
Snackbar.make(
it,
getString(R.string.you_just_created_and_caught_an_exception),
Snackbar.LENGTH_SHORT,
)
.show()
}
}

buttonSetUserAnon.setOnClickListener {
val user = RaygunUserInfo()
RaygunClient.setUser(user)
Snackbar.make(it, getString(R.string.user_is_now_set_to_anonymous_for_future_raygun_reports), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
it,
getString(R.string.user_is_now_set_to_anonymous_for_future_raygun_reports),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonSetUserA.setOnClickListener {
Expand All @@ -73,7 +103,12 @@ class SecondActivity : AppCompatActivity() {
user.email = "[email protected]"
RaygunClient.setUser(user)
RaygunClient.recordBreadcrumb("I'm now user A")
Snackbar.make(it, getString(R.string.user_is_now_set_to_user_a_for_future_raygun_reports), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
it,
getString(R.string.user_is_now_set_to_user_a_for_future_raygun_reports),
Snackbar.LENGTH_SHORT,
)
.show()
}

buttonSetUserB.setOnClickListener {
Expand All @@ -83,11 +118,28 @@ class SecondActivity : AppCompatActivity() {
user.email = "[email protected]"
RaygunClient.setUser(user)
RaygunClient.recordBreadcrumb("I'm now user B")
Snackbar.make(it, getString(R.string.user_is_now_set_to_user_b_for_future_raygun_reports), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
it,
getString(R.string.user_is_now_set_to_user_b_for_future_raygun_reports),
Snackbar.LENGTH_SHORT,
)
.show()
}

textViewAppVersion.text = getString(R.string.app_version_text, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE)
textViewProviderVersion.text = getString(R.string.provider_version_text, com.raygun.raygun4android.BuildConfig.VERSION_NAME, com.raygun.raygun4android.BuildConfig.VERSION_CODE, com.raygun.raygun4android.BuildConfig.BUILD_TYPE)
textViewAppVersion.text =
getString(
R.string.app_version_text,
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE,
BuildConfig.BUILD_TYPE,
)
textViewProviderVersion.text =
getString(
R.string.provider_version_text,
com.raygun.raygun4android.BuildConfig.VERSION_NAME,
com.raygun.raygun4android.BuildConfig.VERSION_CODE,
com.raygun.raygun4android.BuildConfig.BUILD_TYPE,
)

// Handle hardware and back presses
onBackPressedDispatcher.addCallback(
Expand All @@ -105,17 +157,23 @@ class SecondActivity : AppCompatActivity() {
customData["someKey"] = "someValue"
customData["someotherkey"] = "someothervalue"

val breadcrumbMessage = RaygunBreadcrumbMessage.Builder("I'm here in SecondActivity")
.level(RaygunBreadcrumbLevel.ERROR)
.category("Launch")
.lineNumber(78)
.methodName("onCreate")
.customData(customData)
.build()
val breadcrumbMessage =
RaygunBreadcrumbMessage.Builder("I'm here in SecondActivity")
.level(RaygunBreadcrumbLevel.ERROR)
.category("Launch")
.lineNumber(78)
.methodName("onCreate")
.customData(customData)
.build()

RaygunClient.recordBreadcrumb(breadcrumbMessage)
val rootView: View = findViewById(android.R.id.content)
Snackbar.make(rootView, getString(R.string.we_re_now_on_the_second_activity_screen), Snackbar.LENGTH_SHORT).show()
Snackbar.make(
rootView,
getString(R.string.we_re_now_on_the_second_activity_screen),
Snackbar.LENGTH_SHORT,
)
.show()
}

// Handle action bar item clicks
Expand Down
9 changes: 4 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
jcenter()
}
dependencies {
classpath 'io.github.http-builder-ng:http-builder-ng-core:1.0.3'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath(libs.github.http.builder.core)
classpath(libs.android.tools.build.gradle)
classpath(libs.kotlin.gradle)
}
}

plugins {
id 'com.diffplug.spotless' version '6.12.1'
alias(libs.plugins.spotless)
}

allprojects {
Expand Down
Loading