-
Notifications
You must be signed in to change notification settings - Fork 32
Enable manual creation of screen view spans #851
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
Merged
breedx-splk
merged 8 commits into
signalfx:main
from
jtmalinowski:jetpack-compose-support
Jun 17, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
053e0ec
Enable manual creation of screen view spans
jtmalinowski 338eeee
code formatting
jtmalinowski e2fbe71
jetpack compose basic view
jtmalinowski 3529bd3
jetpack compose navigation
jtmalinowski 0e9043e
move to a span processor
jtmalinowski 99d3a88
override both noops
jtmalinowski a4b54d1
PR feedback
jtmalinowski 807f881
Merge remote-tracking branch 'origin/main' into jetpack-compose-support
jtmalinowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,34 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
|
||
<!-- for location tracking --> | ||
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- for location tracking --> | ||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> | ||
|
||
<application | ||
android:name=".SampleApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:name="com.splunk.android.sample.SampleApplication" | ||
android:theme="@style/Theme.SplunkRUMSampleApp"> | ||
<activity | ||
android:name=".JetpackComposeActivity" | ||
android:exported="false" | ||
android:label="@string/title_activity_jetpack_compose" | ||
android:theme="@style/Theme.SplunkRUMSampleApp" /> | ||
<activity | ||
android:name=".MainActivity" | ||
android:theme="@style/Theme.SplunkRUMSampleApp.NoActionBar" | ||
android:exported="true"> | ||
android:exported="true" | ||
android:theme="@style/Theme.SplunkRUMSampleApp.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<service | ||
android:name=".SplunkBackgroundService" | ||
android:exported="false" | ||
android:process=":my_service_process"/> | ||
android:process=":my_service_process" /> | ||
</application> | ||
|
||
</manifest> |
This file contains hidden or 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
88 changes: 88 additions & 0 deletions
88
sample-app/src/main/java/com/splunk/android/sample/JetpackComposeActivity.kt
This file contains hidden or 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,88 @@ | ||
package com.splunk.android.sample | ||
|
||
import android.os.Bundle | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.enableEdgeToEdge | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.navigation.compose.NavHost | ||
import androidx.navigation.compose.composable | ||
import androidx.navigation.compose.currentBackStackEntryAsState | ||
import androidx.navigation.compose.rememberNavController | ||
import com.splunk.rum.SplunkRum | ||
|
||
class JetpackComposeActivity : ComponentActivity() { | ||
private var lastRoute: String? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
enableEdgeToEdge() | ||
setContent { | ||
val navController = rememberNavController() | ||
val currentBackEntry by navController.currentBackStackEntryAsState() | ||
val currentRoute = currentBackEntry?.destination?.route | ||
|
||
LaunchedEffect(currentRoute) { | ||
if (currentRoute != null) { | ||
lastRoute = currentRoute | ||
SplunkRum.getInstance().experimentalSetScreenName(currentRoute) | ||
} | ||
} | ||
|
||
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> | ||
Column( | ||
modifier = Modifier.padding(innerPadding) | ||
) { | ||
NavHost(navController = navController, startDestination = "view-a") { | ||
composable("view-a") { ViewA(onNavigation = { path -> navController.navigate(path) }) } | ||
composable("view-b") { ViewB(onNavigation = { path -> navController.navigate(path) }) } | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
|
||
// doubled to clear both the last view and the previous last view | ||
SplunkRum.getInstance().experimentalSetScreenName(null) | ||
SplunkRum.getInstance().experimentalSetScreenName(null) | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
if (lastRoute != null) { | ||
SplunkRum.getInstance().experimentalSetScreenName(lastRoute, "Resumed") | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun ViewA(onNavigation: (String) -> Unit) { | ||
Column { | ||
Text("View A") | ||
Button(onClick = { onNavigation("view-b")}) { | ||
Text("Go to B") | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun ViewB(onNavigation: (String) -> Unit) { | ||
Column { | ||
Text("View B") | ||
Button(onClick = { onNavigation("view-a")}) { | ||
Text("Go to A") | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.