Skip to content

Diagnostics: Diagnostics split manager into tracker and synchronizer#795

Merged
tonidero merged 5 commits into
diagnosticsfrom
diagnostics-split-manager-tracker-synchronizer
Feb 17, 2023
Merged

Diagnostics: Diagnostics split manager into tracker and synchronizer#795
tonidero merged 5 commits into
diagnosticsfrom
diagnostics-split-manager-tracker-synchronizer

Conversation

@tonidero

@tonidero tonidero commented Feb 14, 2023

Copy link
Copy Markdown
Contributor

Description

Based on #793
This PR refactors previous code to split the DiagnosticsManager into DiagnosticsTracker and DiagnosticsSynchronizer. This is a prerequisite to avoid circular dependencies when tracking request data.

  • Before: DiagnosticsManager->Backend->HttpClient->DiagnosticsManager.
  • After: DiagnosticsSynchronizer->Backend for syncing and HttpClient->DiagnosticsTracker for tracking requests

I could have tried to extract this logic from the HttpClient, but that would be a bigger refactor. This was the simplest solution I thought for this problem. Also, sorry I didn't see that issue before. I didn't modify the #785 PR directly to try to avoid some conflicts that would happen if I did it there directly.

@tonidero tonidero changed the title Diagnostics: Diagnostics split manager tracker synchronizer Diagnostics: Diagnostics split manager into tracker and synchronizer Feb 14, 2023
@tonidero tonidero marked this pull request as ready for review February 14, 2023 16:56
@tonidero tonidero requested a review from a team February 14, 2023 16:56
@codecov

codecov Bot commented Feb 14, 2023

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (diagnostics@b8e819a). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 294397f differs from pull request most recent head 6d71ce8. Consider uploading reports for the commit 6d71ce8 to get more accurate results

@@              Coverage Diff               @@
##             diagnostics     #795   +/-   ##
==============================================
  Coverage               ?   82.07%           
==============================================
  Files                  ?      129           
  Lines                  ?     4250           
  Branches               ?      538           
==============================================
  Hits                   ?     3488           
  Misses                 ?      549           
  Partials               ?      213           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@tonidero tonidero force-pushed the diagnostics-limit-events-sent branch 2 times, most recently from de85a24 to a5f1219 Compare February 16, 2023 09:31
Base automatically changed from diagnostics-limit-events-sent to diagnostics February 16, 2023 09:32
@tonidero tonidero force-pushed the diagnostics-split-manager-tracker-synchronizer branch from 193d5d3 to 55865b4 Compare February 16, 2023 10:07
import com.revenuecat.purchases.common.verboseLog
import java.io.IOException

class DiagnosticsTracker(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would help to have a docstring here too, otherwise I'd be wondering what the difference between this and DiagnosticsManager is.

@tonidero tonidero merged commit bcef86f into diagnostics Feb 17, 2023
@tonidero tonidero deleted the diagnostics-split-manager-tracker-synchronizer branch February 17, 2023 08:01
tonidero added a commit that referenced this pull request Feb 22, 2023
### Description
Based on #795 
Deals with [CSDK-655](https://revenuecats.atlassian.net/browse/CSDK-655)

### Changes
- Adds functionality to send an `endpoint_hit` event to the diagnostics
endpoint on every request
- Adds the `Endpoint` class with the enpoints we support, instead of
hardcoding the path on each method.
- Adds functionality to detect whether a response comes from the backend
or the cache.

[CSDK-655]:
https://revenuecats.atlassian.net/browse/CSDK-655?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
tonidero added a commit that referenced this pull request Feb 22, 2023
…795)

### Description
Based on #793 
This PR refactors previous code to split the `DiagnosticsManager` into
`DiagnosticsTracker` and `DiagnosticsSynchronizer`. This is a
prerequisite to avoid circular dependencies when tracking request data.
- Before:
`DiagnosticsManager`->`Backend`->`HttpClient`->`DiagnosticsManager`.
- After: `DiagnosticsSynchronizer`->`Backend` for syncing and
`HttpClient`->`DiagnosticsTracker` for tracking requests

I could have tried to extract this logic from the HttpClient, but that
would be a bigger refactor. This was the simplest solution I thought for
this problem. Also, sorry I didn't see that issue before. I didn't
modify the #785 PR directly to try to avoid some conflicts that would
happen if I did it there directly.
tonidero added a commit that referenced this pull request Feb 22, 2023
### Description
Based on #795 
Deals with [CSDK-655](https://revenuecats.atlassian.net/browse/CSDK-655)

### Changes
- Adds functionality to send an `endpoint_hit` event to the diagnostics
endpoint on every request
- Adds the `Endpoint` class with the enpoints we support, instead of
hardcoding the path on each method.
- Adds functionality to detect whether a response comes from the backend
or the cache.

[CSDK-655]:
https://revenuecats.atlassian.net/browse/CSDK-655?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
tonidero added a commit that referenced this pull request Feb 28, 2023
…795)

### Description
Based on #793 
This PR refactors previous code to split the `DiagnosticsManager` into
`DiagnosticsTracker` and `DiagnosticsSynchronizer`. This is a
prerequisite to avoid circular dependencies when tracking request data.
- Before:
`DiagnosticsManager`->`Backend`->`HttpClient`->`DiagnosticsManager`.
- After: `DiagnosticsSynchronizer`->`Backend` for syncing and
`HttpClient`->`DiagnosticsTracker` for tracking requests

I could have tried to extract this logic from the HttpClient, but that
would be a bigger refactor. This was the simplest solution I thought for
this problem. Also, sorry I didn't see that issue before. I didn't
modify the #785 PR directly to try to avoid some conflicts that would
happen if I did it there directly.
tonidero added a commit that referenced this pull request Feb 28, 2023
### Description
Based on #795 
Deals with [CSDK-655](https://revenuecats.atlassian.net/browse/CSDK-655)

### Changes
- Adds functionality to send an `endpoint_hit` event to the diagnostics
endpoint on every request
- Adds the `Endpoint` class with the enpoints we support, instead of
hardcoding the path on each method.
- Adds functionality to detect whether a response comes from the backend
or the cache.

[CSDK-655]:
https://revenuecats.atlassian.net/browse/CSDK-655?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
tonidero added a commit that referenced this pull request Feb 28, 2023
…795)

### Description
Based on #793 
This PR refactors previous code to split the `DiagnosticsManager` into
`DiagnosticsTracker` and `DiagnosticsSynchronizer`. This is a
prerequisite to avoid circular dependencies when tracking request data.
- Before:
`DiagnosticsManager`->`Backend`->`HttpClient`->`DiagnosticsManager`.
- After: `DiagnosticsSynchronizer`->`Backend` for syncing and
`HttpClient`->`DiagnosticsTracker` for tracking requests

I could have tried to extract this logic from the HttpClient, but that
would be a bigger refactor. This was the simplest solution I thought for
this problem. Also, sorry I didn't see that issue before. I didn't
modify the #785 PR directly to try to avoid some conflicts that would
happen if I did it there directly.
tonidero added a commit that referenced this pull request Feb 28, 2023
### Description
Based on #795 
Deals with [CSDK-655](https://revenuecats.atlassian.net/browse/CSDK-655)

### Changes
- Adds functionality to send an `endpoint_hit` event to the diagnostics
endpoint on every request
- Adds the `Endpoint` class with the enpoints we support, instead of
hardcoding the path on each method.
- Adds functionality to detect whether a response comes from the backend
or the cache.

[CSDK-655]:
https://revenuecats.atlassian.net/browse/CSDK-655?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
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.

2 participants