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

fix: ensure activity name is used when activity label is not defined #153

Merged
merged 9 commits into from
Aug 8, 2024

Conversation

thisames
Copy link
Contributor

@thisames thisames commented Aug 7, 2024

💡 Motivation and Context

The loadLabel method was loading the application label when an activity label was not defined. This change ensures that when an activity label is not defined, it defaults to the activity name instead of the application label. This improves the accuracy of screen name logging.

fix #150

💚 How did you test it?

  • Unit tests were updated and run to verify the behavior of the new activityLabelOrName method.
  • Additional test scenarios were added to ensure that the correct labels are returned when activity and application labels are the same or empty.
  • Verified that existing tests pass without any issues.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

Modified the activityLabel method to check if the label is explicitly set for the Activity. If not, it will return null instead of the application label.

Added activityName to return activityName class

Updated onActivityStarted to use activityName as a fallback if activityLabel is null.
- Combined activityLabel and activityName methods into a single method activityLabelOrName.
- The new method retrieves the activity label if it differs from the application label.
- If the labels are identical or the activity label is empty, it falls back to the activity's class name.
… method

- Replaced the separate calls to activityLabel and activityName with a single call to activityLabelOrName.
…tion label

- Added parameters for activity name and application label to the mockScreenTitle function.
- Updated tests in PostHogActivityLifecycleCallbackIntegrationTest to verify activity label and application label handling.
- Added scenarios to ensure the correct behavior when labels are the same or empty.
@thisames thisames requested a review from marandaneto as a code owner August 7, 2024 15:07
Copy link
Member

@marandaneto marandaneto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thisames

@marandaneto
Copy link
Member

it does not fix #150 but addresses another issue.

@marandaneto
Copy link
Member

@thisames would add a new item to the changelog file https://github.com/PostHog/posthog-android/blob/main/CHANGELOG.md ?

@thisames
Copy link
Contributor Author

thisames commented Aug 7, 2024

@thisames would add a new item to the changelog file https://github.com/PostHog/posthog-android/blob/main/CHANGELOG.md ?

for sure =)

@marandaneto
Copy link
Member

@thisames type make format and commit to fix the lint issues

@marandaneto marandaneto merged commit c267815 into PostHog:main Aug 8, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

screen_name is not set on $screen events - Using compose
2 participants