Skip to content

feat(logger): [SDK-4835] gate otel-vs-logger switch on SDK_CUSTOM_LOGGING flag#2688

Merged
abdulraqeeb33 merged 1 commit into
mainfrom
feat/SDK-4835-custom-logging-feature-flag
Jul 24, 2026
Merged

feat(logger): [SDK-4835] gate otel-vs-logger switch on SDK_CUSTOM_LOGGING flag#2688
abdulraqeeb33 merged 1 commit into
mainfrom
feat/SDK-4835-custom-logging-feature-flag

Conversation

@abdulraqeeb33

Copy link
Copy Markdown
Contributor

Summary

Replaces the hardcoded LoggerModuleSwitch.USE_LOGGER_MODULE boolean with a remote-config-driven decision so the new multiplatform logger module can be enabled/disabled from the backend instead of via a code change.

  • Adds the SDK_CUSTOM_LOGGING feature flag (sdk_custom_logging, FeatureActivationMode.APP_STARTUP).
  • LoggerModuleSwitch.useLoggerModule(context) now resolves the flag during early init by reading the cached config straight from SharedPreferences via OtelIdResolver.resolveCustomLoggingEnabled() — before service bootstrap / FeatureManager exist.
  • Because the value comes from the config the previous session persisted, toggling the flag remotely takes effect on the next app start, never mid-session (switching observability pipelines mid-run is unsafe).
  • Wires the resolver into both call sites: OneSignalImp (lifecycle manager selection) and OneSignalCrashUploaderWrapper (crash uploader selection).

Why read from prefs directly?

The otel-vs-logger choice is made at the very start of init, before the IoC container and FeatureManager are ready. OtelIdResolver already reads other cached values (appId, log level, ids) from prefs on this cold-start path, so the flag resolution follows the same pattern. Matching is case-insensitive to mirror FeatureManager's canonical keys.

Tests

New/updated unit tests (all passing via :OneSignal:core:testDebugUnitTest):

  • OtelIdResolverTestresolveCustomLoggingEnabled(): flag present, case-insensitive, present-among-others, absent, empty array, missing field, no config, null context, invalid JSON.
  • LoggerModuleSwitchTest (new) — useLoggerModule() end-to-end: reads cached flag from prefs → true/false, and false when no config.
  • FeatureFlagTests — asserts SDK_CUSTOM_LOGGING key + APP_STARTUP activation mode.

Notes

  • Base branch is feat/SDK-4835-kmp-logger-module (this stacks on the logger module work).
  • An unrelated local gradle.properties publish toggle was intentionally left out of this PR.

Test plan

  • CI green (unit tests, detekt, spotless)
  • Manually verify enabling sdk_custom_logging remotely routes observability through the logger module on next launch
  • Verify default (flag absent) still uses the otel module

Made with Cursor

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff Coverage Report (Changed Lines Only)

Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff).

Changed Files Coverage

  • FeatureFlag.kt: 3/3 touched executable lines (100.0%) (12 touched lines in diff)
  • OneSignalCrashUploaderWrapper.kt: 0/1 touched executable lines (0.0%) (1 touched lines in diff)
    • 1 uncovered touched lines in this file
  • LoggerModuleSwitch.kt: 0/1 touched executable lines (0.0%) (18 touched lines in diff)
    • 1 uncovered touched lines in this file
  • OtelIdResolver.kt: 0/3 touched executable lines (0.0%) (17 touched lines in diff)
    • 3 uncovered touched lines in this file
  • OneSignalImp.kt: 0/1 touched executable lines (0.0%) (1 touched lines in diff)
    • 1 uncovered touched lines in this file

Overall (aggregate gate)

3/9 touched executable lines covered (33.3% — requires ≥ 80%)

Per-file detail (informational; gate is aggregate above):

  • OneSignalCrashUploaderWrapper.kt: 0.0% (1 uncovered touched lines)

  • LoggerModuleSwitch.kt: 0.0% (1 uncovered touched lines)

  • OtelIdResolver.kt: 0.0% (3 uncovered touched lines)

  • OneSignalImp.kt: 0.0% (1 uncovered touched lines)

❌ Coverage Check Failed

Aggregate coverage on touched lines is 33.3% (minimum 80%).

📥 View workflow run

@abdulraqeeb33
abdulraqeeb33 force-pushed the feat/SDK-4835-custom-logging-feature-flag branch 2 times, most recently from 38d85c3 to 4c503a1 Compare July 23, 2026 20:17
Base automatically changed from feat/SDK-4835-kmp-logger-module to main July 24, 2026 05:33
…GING flag

Replace the hardcoded LoggerModuleSwitch.USE_LOGGER_MODULE boolean with a
remote-config-driven decision. Add the SDK_CUSTOM_LOGGING feature flag
(APP_STARTUP activation) and resolve it during early init directly from the
cached config in SharedPreferences via OtelIdResolver.resolveCustomLoggingEnabled(),
so toggling the flag takes effect on the next app start rather than mid-session.

Add unit tests covering resolveCustomLoggingEnabled() (present/absent,
case-insensitive, empty/missing flags, no config, null context, invalid JSON),
the LoggerModuleSwitch.useLoggerModule() end-to-end read, and the
SDK_CUSTOM_LOGGING enum key + activation mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
@abdulraqeeb33
abdulraqeeb33 force-pushed the feat/SDK-4835-custom-logging-feature-flag branch from 4c503a1 to f791338 Compare July 24, 2026 05:39
@abdulraqeeb33
abdulraqeeb33 merged commit cd4231b into main Jul 24, 2026
4 of 5 checks passed
@abdulraqeeb33
abdulraqeeb33 deleted the feat/SDK-4835-custom-logging-feature-flag branch July 24, 2026 06:06
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