Skip to content

Commit

Permalink
[performance-expansion] Add PerformanceCollectionEnabled (#360)
Browse files Browse the repository at this point in the history
* [performance-expansion] Add PerformanceCollectionEnabled

* [performance-expansion] Update version and readme

* [performance-expansion] Revert iOS instrumentation enabled

* [performance-expansion] Update icon for crashlytics
  • Loading branch information
OliverMcB authored Mar 28, 2023
1 parent 288d0e7 commit 249cb19
Show file tree
Hide file tree
Showing 19 changed files with 144 additions and 54 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar

The following libraries are available for the various Firebase products.

| Service or Product | Gradle Dependency | API Coverage |
|---------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.7.2/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.7.2/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.7.2/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.7.2/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.7.2/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.7.2/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.7.2/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.7.2/pom) | ![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square) |
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.7.2/pom) | ![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square) |
| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.7.2`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.7.2/pom) | ![80%](https://img.shields.io/badge/-1%25-orange?style=flat-square) |
| Service or Product | Gradle Dependency | API Coverage |
|---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.7.3/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.7.3/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.7.3/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.7.3/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.7.3/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.7.3/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.7.3/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.7.3/pom) | ![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square) |
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.7.3/pom) | ![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square) |
| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.7.3`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.7.3/pom) | ![80%](https://img.shields.io/badge/-80%25-green?style=flat-square) |



Expand Down Expand Up @@ -203,16 +203,16 @@ If you are building a Kotlin multiplatform library which will be consumed from J

```json
"dependencies": {
"@gitlive/firebase-auth": "1.7.2",
"@gitlive/firebase-config": "1.7.2",
"@gitlive/firebase-database": "1.7.2",
"@gitlive/firebase-firestore": "1.7.2",
"@gitlive/firebase-functions": "1.7.2",
"@gitlive/firebase-installations": "1.7.2",
"@gitlive/firebase-messaging": "1.7.2",
"@gitlive/firebase-storage": "1.7.2"
"@gitlive/firebase-perf": "1.7.2"
"@gitlive/firebase-crashlytics": "1.7.2"
"@gitlive/firebase-auth": "1.7.3",
"@gitlive/firebase-config": "1.7.3",
"@gitlive/firebase-database": "1.7.3",
"@gitlive/firebase-firestore": "1.7.3",
"@gitlive/firebase-functions": "1.7.3",
"@gitlive/firebase-installations": "1.7.3",
"@gitlive/firebase-messaging": "1.7.3",
"@gitlive/firebase-storage": "1.7.3"
"@gitlive/firebase-perf": "1.7.3"
"@gitlive/firebase-crashlytics": "1.7.3"
}
```

Expand Down
4 changes: 2 additions & 2 deletions firebase-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-app",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-app.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-common": "1.7.2",
"@gitlive/firebase-common": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-auth",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-auth.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
2 changes: 1 addition & 1 deletion firebase-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-common",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-common.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,9 @@ external object firebase {

object performance {

var dataCollectionEnabled: Boolean
var instrumentationEnabled: Boolean

fun trace(
name: String
): PerformanceTrace
Expand Down
4 changes: 2 additions & 2 deletions firebase-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-config",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-config.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-crashlytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-crashlytics",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-crashlytics.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-database",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-database.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-firestore/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-firestore",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-firestore.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-functions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-functions",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-functions.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-installations/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-installations",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-installations.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-perf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-perf",
"version": "1.7.2",
"version": "1.7.3",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-perf.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.7.2",
"@gitlive/firebase-app": "1.7.3",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ actual fun Firebase.performance(app: FirebaseApp) =
actual class FirebasePerformance(val android: com.google.firebase.perf.FirebasePerformance){

actual fun newTrace(traceName: String): Trace = Trace(android.newTrace(traceName))

actual fun isPerformanceCollectionEnabled() = android.isPerformanceCollectionEnabled

actual fun setPerformanceCollectionEnabled(enable: Boolean) {
android.isPerformanceCollectionEnabled = enable
}
}

actual open class FirebasePerformanceException(message: String) : FirebaseException(message)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ expect fun Firebase.performance(app: FirebaseApp): FirebasePerformance
expect class FirebasePerformance {

fun newTrace(traceName: String): Trace

fun isPerformanceCollectionEnabled(): Boolean

fun setPerformanceCollectionEnabled(enable: Boolean)
}

expect open class FirebasePerformanceException : FirebaseException
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import dev.gitlive.firebase.FirebaseOptions
import dev.gitlive.firebase.apps
import dev.gitlive.firebase.initialize
import kotlinx.coroutines.CoroutineScope
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.test.assertNotNull
import kotlin.test.*

expect val emulatorHost: String
expect val context: Any
Expand Down Expand Up @@ -47,4 +45,18 @@ class FirebasePerformanceTest {

assertNotNull(trace)
}

@Test
fun testPerformanceCollectionEnabled() = runTest {

val performance = Firebase.performance

performance.setPerformanceCollectionEnabled(false)

assertFalse(performance.isPerformanceCollectionEnabled())

performance.setPerformanceCollectionEnabled(true)

assertTrue(performance.isPerformanceCollectionEnabled())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ actual fun Firebase.performance(app: FirebaseApp) =
actual class FirebasePerformance(val ios: FIRPerformance) {

actual fun newTrace(traceName: String): Trace = Trace(ios.traceWithName(traceName))

actual fun isPerformanceCollectionEnabled(): Boolean = ios.isDataCollectionEnabled()

actual fun setPerformanceCollectionEnabled(enable: Boolean) {
ios.dataCollectionEnabled = enable
}
}

actual open class FirebasePerformanceException(message: String) : FirebaseException(message)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ actual class FirebasePerformance internal constructor(val js: firebase.performan
actual fun newTrace(traceName: String): Trace = rethrow {
Trace(js.trace(traceName))
}

actual fun isPerformanceCollectionEnabled(): Boolean = js.dataCollectionEnabled

actual fun setPerformanceCollectionEnabled(enable: Boolean) {
js.dataCollectionEnabled = enable
}

fun isInstrumentationEnabled(): Boolean = js.instrumentationEnabled

fun setInstrumentationEnabled(enable: Boolean) {
js.instrumentationEnabled = enable
}
}

actual open class FirebasePerformanceException(code: String, cause: Throwable) :
Expand Down
Loading

0 comments on commit 249cb19

Please sign in to comment.