nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

refactor: On ui layer analytics injected by entrypoint

Open rhkrwngud445 opened this issue 1 year ago • 5 comments

Issue: #1471

Suggest changing the UI layer injection method of Analytics Instance in Analytics Module.

Instead of using CompositionLocal, how about using Hilt's EntryPoint?

It has these advantages.

  1. It has the advantage of reducing MainActivity injection code.
  2. Management outside HiltScope can be reduced.
  3. Analytics can eliminate compose dependency.

Additionally, in analytics/AnalyticsModule, how about creating an instance as a singleton?

rhkrwngud445 avatar May 26 '24 08:05 rhkrwngud445

This is just a chat, but if a Composable that calls analyticsInstance() leaves the Composition and later AnalyticsHelper is needed again, it seems necessary to fetch the object from the dependency graph again. In the existing implementation, it is managed by the Activity Lifecycle, so I think there wouldn't be such unnecessary overhead. What do you think?

Additionally, according to the comments in the existing code, NoOpAnalyticsHelper() is used to run the Preview. Do you think the modified code can replace it?

yongsuk44 avatar May 27 '24 06:05 yongsuk44

@yongsuk44 Thanks for your feedback

Additionally, according to the comments in the existing code, NoOpAnalyticsHelper() is used to run the Preview. Do you think the modified code can replace it?

I think it is changed by the lambda code so that preview will be OK

example commit

This is just a chat, but if a Composable that calls analyticsInstance() leaves the Composition and later AnalyticsHelper is needed again, it seems necessary to fetch the object from the dependency graph again. In the existing implementation, it is managed by the Activity Lifecycle, so I think there wouldn't be such unnecessary overhead. What do you think?

I also agree that cost existed. It was confirmed that there was a difference of more than 5000 NanoTime. I think that it seems to be a trade-off area with the advantages I suggested.

rhkrwngud445 avatar May 27 '24 12:05 rhkrwngud445

  1. I think it would be simpler to write TrackScreenViewEvent in the InterestsRoute rather than hoisting. I'm curious if it's possible to replace the previews of components like userNewsResourceCardItems and newsFeed.

  2. It seems to me that comparing how much the frame changes through ScrollForYouFeedBenchmark would make things clearer. What do you think?

yongsuk44 avatar May 28 '24 06:05 yongsuk44

@yongsuk44 I think improvements can be made with a nested callback structure, but I don't think it's a good structure.

I suggested CompositionLocal because I was wondering why, and I found the answer. Your suggestions and questions were helpful. Thank you.

rhkrwngud445 avatar May 28 '24 07:05 rhkrwngud445

We cannot merge this PR unless the Build workflow completes successfully. Additionally, you have not enabled contributions from maintainers on your branch so I cannot do this manually.

Please run the following commands:

git commit --allow-empty -m "Retrigger Build workflow"
git push

If we don't hear back from you within 1 week this PR will be closed.

dturner avatar Dec 18 '24 17:12 dturner