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

New PushNotificationDataSource #688

Merged
merged 10 commits into from
Apr 16, 2024

Conversation

nelsitoPuglisi
Copy link
Contributor

@nelsitoPuglisi nelsitoPuglisi commented Apr 10, 2024

Goal

Log push notifications as span events in the session span instead of breadcrumbs

Testing

Integration and manual tests

Copy link
Contributor Author

nelsitoPuglisi commented Apr 10, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @nelsitoPuglisi and the rest of your teammates on Graphite Graphite

@nelsitoPuglisi nelsitoPuglisi changed the title PushNotificationDataSource New PushNotificationDataSource Apr 10, 2024
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/push-notification-data-source branch 4 times, most recently from 2a9464e to eace200 Compare April 13, 2024 19:10
@nelsitoPuglisi nelsitoPuglisi changed the base branch from master to nelson/web-view-data-source-prod April 13, 2024 19:10
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/web-view-data-source-prod branch from be4eb50 to 5edc7f6 Compare April 15, 2024 12:38
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/push-notification-data-source branch from 4117a92 to 504be70 Compare April 15, 2024 12:38
@nelsitoPuglisi nelsitoPuglisi marked this pull request as ready for review April 15, 2024 12:41
@nelsitoPuglisi nelsitoPuglisi requested a review from a team as a code owner April 15, 2024 12:41
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/web-view-data-source-prod branch from 5edc7f6 to f4b7b57 Compare April 15, 2024 13:04
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/push-notification-data-source branch from 504be70 to db6a928 Compare April 15, 2024 13:04
Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

I had one query about some assertions in the test cases, otherwise this looks good

Comment on lines 7 to 16
import io.embrace.android.embracesdk.arch.schema.EmbType
import io.embrace.android.embracesdk.findEventOfType
import io.embrace.android.embracesdk.findSessionSpan
import io.embrace.android.embracesdk.getSentSessionMessages
import io.embrace.android.embracesdk.hasEventOfType
import io.embrace.android.embracesdk.internal.ApkToolsConfig
import io.embrace.android.embracesdk.internal.IdGeneratorTest.Companion.validPattern
import io.embrace.android.embracesdk.internal.clock.millisToNanos
import io.embrace.android.embracesdk.recordSession
import org.junit.Assert
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd assume these are all unused imports?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦

* List of captured push notifications
*/
@Json(name = "pn")
val pushNotifications: List<PushNotificationBreadcrumb>? = null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the LegacyPushNotificationDataSource be deleted if we're getting rid of payload fields in the same changeset?

@@ -69,6 +71,19 @@ internal class DataSourceModuleImpl(
)
}

override val pushNotificationDataSource: DataSourceState<PushNotificationDataSource> by dataSourceState {
DataSourceState(
Copy link
Contributor

Choose a reason for hiding this comment

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

How do users enable this feature in their apps? I'm a little surprised that there isn't any parameter supplied for configGate although if that's existing behavior that's ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is used by manually calling our public api, and automacally if the feature is enabled with this guide: https://embrace.io/docs/android/features/push-notifications/

type
)
) {
dataSourceModuleProvider()?.pushNotificationDataSource?.dataSource?.apply {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could remove the apply here as there's only one statement inside

Comment on lines +99 to +96
"notification.title" to "",
"notification.type" to type,
"notification.body" to "",
"notification.id" to "id",
"notification.from" to "",
Copy link
Contributor

Choose a reason for hiding this comment

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

These empty string assertions don't look right - if "title" and "body" are being supplied as parameters in the test invocation then I'd expect them to show up in the attrs map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They shouldn't be sent because the default setting for PII capture is FALSE. A specific test captures that data when the setting is overridden to true.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. This is fine then

@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/web-view-data-source-prod branch from f4b7b57 to e384707 Compare April 15, 2024 17:23
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/push-notification-data-source branch from db6a928 to 251548a Compare April 15, 2024 17:23
Base automatically changed from nelson/web-view-data-source-prod to master April 15, 2024 21:20
@nelsitoPuglisi nelsitoPuglisi force-pushed the nelson/push-notification-data-source branch from aee3ba3 to 83a4109 Compare April 15, 2024 21:24
Copy link

codecov bot commented Apr 15, 2024

Codecov Report

Attention: Patch coverage is 89.23077% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 80.21%. Comparing base (5438954) to head (3c731ff).
Report is 11 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #688      +/-   ##
==========================================
+ Coverage   79.83%   80.21%   +0.38%     
==========================================
  Files         429      429              
  Lines       11330    11374      +44     
  Branches     1720     1725       +5     
==========================================
+ Hits         9045     9124      +79     
+ Misses       1558     1532      -26     
+ Partials      727      718       -9     
Files Coverage Δ
.../embrace/android/embracesdk/arch/schema/EmbType.kt 56.25% <100.00%> (+1.41%) ⬆️
...brace/android/embracesdk/arch/schema/SchemaType.kt 70.23% <100.00%> (+4.96%) ⬆️
...e/android/embracesdk/injection/DataSourceModule.kt 100.00% <100.00%> (ø)
.../embrace/android/embracesdk/payload/Breadcrumbs.kt 100.00% <100.00%> (ø)
...racesdk/capture/crumbs/EmbraceBreadcrumbService.kt 80.00% <87.50%> (-2.98%) ⬇️
...d/embracesdk/config/behavior/BreadcrumbBehavior.kt 45.00% <50.00%> (-2.06%) ⬇️
...cesdk/capture/crumbs/PushNotificationDataSource.kt 87.09% <87.09%> (ø)

... and 35 files with indirect coverage changes

Copy link
Contributor

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

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

LGTM

override val pushNotificationDataSource: DataSourceState<PushNotificationDataSource> by dataSourceState {
DataSourceState(
factory = {
System.out.println("DataSourceModuleImpl ${essentialServiceModule.configService}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Would suggest removing this println statement

@nelsitoPuglisi nelsitoPuglisi merged commit b09b5ea into master Apr 16, 2024
6 checks passed
@nelsitoPuglisi nelsitoPuglisi deleted the nelson/push-notification-data-source branch April 16, 2024 12:49
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.

None yet

2 participants