Skip to content

Removed deprecated public constructor KeyValueBuilder #6924

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion firebase-crashlytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Unreleased

[changed] **Breaking Change**: Removed deprecated public constructor `KeyValueBuilder(crashlytics: FirebaseCrashlytics)`

# 19.4.2
* [changed] Internal changes to read version control info more efficiently [#6754]
Expand Down
1 change: 0 additions & 1 deletion firebase-crashlytics/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ package com.google.firebase.crashlytics {
}

public final class KeyValueBuilder {
ctor @Deprecated public KeyValueBuilder(com.google.firebase.crashlytics.FirebaseCrashlytics crashlytics);
method public void key(String key, boolean value);
method public void key(String key, double value);
method public void key(String key, float value);
Expand Down
2 changes: 1 addition & 1 deletion firebase-crashlytics/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=19.4.3
version=20.0.0
latestReleasedVersion=19.4.2
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,6 @@ class CrashlyticsTests {
assertThat(result).isEqualTo(expectedKeys)
}

@Test
fun keyValueBuilder_withCrashlyticsInstance() {
@Suppress("DEPRECATION") val keyValueBuilder = KeyValueBuilder(Firebase.crashlytics)
keyValueBuilder.key("string", "world")
keyValueBuilder.key("int", Int.MAX_VALUE)
keyValueBuilder.key("float", Float.MAX_VALUE)
keyValueBuilder.key("boolean", true)
keyValueBuilder.key("double", Double.MAX_VALUE)
keyValueBuilder.key("long", Long.MAX_VALUE)

val result: Map<String, String> = keyValueBuilder.build().keysAndValues

// The result is empty because it called crashlytics.setCustomKey for every key.
assertThat(result).isEmpty()
}

companion object {
private const val APP_ID = "1:1:android:1a"
private const val API_KEY = "API-KEY-API-KEY-API-KEY-API-KEY-API-KEY"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,39 @@ package com.google.firebase.crashlytics
/** Helper class to enable convenient syntax in [setCustomKeys] and [recordException] */
class KeyValueBuilder
private constructor(
private val crashlytics: FirebaseCrashlytics?,
private val builder: CustomKeysAndValues.Builder,
) {
@Deprecated(
"Do not construct this directly. Use `setCustomKeys` instead. To be removed in the next major release."
)
constructor(crashlytics: FirebaseCrashlytics) : this(crashlytics, CustomKeysAndValues.Builder())

internal constructor() : this(crashlytics = null, CustomKeysAndValues.Builder())
internal constructor() : this(CustomKeysAndValues.Builder())

internal fun build(): CustomKeysAndValues = builder.build()

/** Sets a custom key and value that are associated with reports. */
fun key(key: String, value: Boolean) {
crashlytics?.setCustomKey(key, value) ?: builder.putBoolean(key, value)
builder.putBoolean(key, value)
}

/** Sets a custom key and value that are associated with reports. */
fun key(key: String, value: Double) {
crashlytics?.setCustomKey(key, value) ?: builder.putDouble(key, value)
builder.putDouble(key, value)
}

/** Sets a custom key and value that are associated with reports. */
fun key(key: String, value: Float) {
crashlytics?.setCustomKey(key, value) ?: builder.putFloat(key, value)
builder.putFloat(key, value)
}

/** Sets a custom key and value that are associated with reports. */
fun key(key: String, value: Int) {
crashlytics?.setCustomKey(key, value) ?: builder.putInt(key, value)
builder.putInt(key, value)
}

/** Sets a custom key and value that are associated with reports. */
fun key(key: String, value: Long) {
crashlytics?.setCustomKey(key, value) ?: builder.putLong(key, value)
builder.putLong(key, value)
}

/** Sets a custom key and value that are associated with reports. */
fun key(key: String, value: String) {
crashlytics?.setCustomKey(key, value) ?: builder.putString(key, value)
builder.putString(key, value)
}
}
Loading