Skip to content

Refactor apphud internal#147

Open
aaudin90 wants to merge 3 commits intomasterfrom
Refactor-ApphudInternal
Open

Refactor apphud internal#147
aaudin90 wants to merge 3 commits intomasterfrom
Refactor-ApphudInternal

Conversation

@aaudin90
Copy link
Collaborator

No description provided.

aaudin90 and others added 3 commits March 13, 2026 21:29
Added code style guideline requiring mutable state (var) in classes
to be private, with dedicated methods or read-only getters for
external access.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…erPropertiesManager, OfferingsCallbackManager

Extracted three classes from ApphudInternal into dedicated components:
- AnalyticsTracker: SDK timing/benchmarks with injectable timeProvider
- UserPropertiesManager: property batching, debounce, flush logic
- OfferingsCallbackManager: callback lifecycle and notification state

Applied encapsulation: all mutable state is private with read-only
getters or dedicated methods. AnalyticsTracker.sdkLaunchedAt replaced
with sdkLaunchTimeMs() method. RegistrationProvider now depends on
AnalyticsTracker directly instead of a lambda.

ServiceLocator wires all new dependencies. Tests use constructor
injection and fake timeProvider for deterministic behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
- Use named arguments in all notifyLoadingCompleted call sites to
  prevent silent parameter mismatch after fromCache removal
- Add @volatile to customProductsFetchedBlock for thread safety
- Replace toJSON()!! with safe ?: return@forEach in UserPropertiesManager
- Remove unused productDetails param from isErrorOccurred/hasDataLoadFailed
- Wrap setUserProperty, incrementUserProperty, productsFetchCallback
  in Apphud.kt with runCatching for uninitialized SDK safety
- Remove trailing semicolon from RegistrationProvider package declaration
- Fix _firstCustomerLoadedTime force-unwrap with local val snapshot
- Rewrite UserPropertiesManagerTest to use CompletableDeferred instead
  of reflection for _isUpdatingProperties

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

1 participant