Skip to content

fix(docs): correct handleLog signature in iOS and Android SuperwallDelegate - #265

Open
0xwurdig wants to merge 1 commit into
superwall:mainfrom
0xwurdig:fix/handlelog-signature-ios-android
Open

fix(docs): correct handleLog signature in iOS and Android SuperwallDelegate#265
0xwurdig wants to merge 1 commit into
superwall:mainfrom
0xwurdig:fix/handlelog-signature-ios-android

Conversation

@0xwurdig

Copy link
Copy Markdown

What changed and why

The SuperwallDelegate reference on iOS and Android documents handleLog as:

func handleLog(level: LogLevel, scope: LogScope, message: String, ...)

Both SDKs actually declare level and scope as String, and message as optional:

  • iOS — Sources/SuperwallKit/Delegate/SuperwallDelegate.swift:102
  • Android — superwall/src/main/java/com/superwall/sdk/delegate/SuperwallDelegate.kt:34 (and SuperwallDelegateJava.kt:38)

This isn't drift from an older API. handleLog has taken String at every v4 tag I checked — 4.0.0, 4.5.0, 4.10.0, 4.16.1 — so the documented signature has never matched a shipped SDK.

Why it's worth fixing rather than just wrong

It fails silently. Three things line up:

  1. LogLevel and LogScope are real public types, so the documented signature compiles.
  2. Every delegate member has a default empty implementation — a Swift protocol extension, Kotlin interface default bodies — so the wrong signature is not a conformance error. You've declared an unrelated method.
  3. The SDK's own doc comment reads "Can be either DEBUG, INFO, WARN, or ERROR, as defined by LogLevel", which describes the string's contents in a way that sounds like the parameter's type.

Net result: the delegate keeps calling its own empty default, handleLog never fires, and there is no warning anywhere. I hit this while wiring the iOS SDK into a test app and only found it by reading the SDK source.

Corroboration that String is intended

  • The React Native reference already documents it correctly — content/docs/react-native/sdk-reference/SuperwallDelegate.mdx:75 declares level: string, scope: string, message?: string.

  • Superwall's own Android sample app overrides it with String and compares against the stringified enum — app/src/main/java/com/superwall/superapp/MainApplication.kt:137:

    override fun handleLog(level: String, scope: String, message: String?, …) {
        if (level == LogLevel.error.toString() &&
            scope == LogScope.productsManager.toString()) { … }

So the iOS and Android reference pages are the outliers, not the SDKs.

The change

  • Corrects the Swift, Kotlin and Java signature blocks on both pages.
  • Adds a <Note> on each explaining that level and scope are the string forms, since otherwise the fix reads as a mistake. The exact values are verified from the call sites: iOS Logger.swift:78 passes logLevel.description, Android Logger.kt:51 passes logLevel.toString(), both yielding "DEBUG" / "INFO" / "WARN" / "ERROR" / "NONE".
  • Adds a handleLog row to each page's existing TypeTable, per the TypeTable convention in AGENTS.md.

Scope kept to handleLog. I found some other gaps while auditing and will raise those separately rather than bundle them here.

Testing performed

  • bun install --frozen-lockfile
  • bun run build — succeeds, 602 pages prerendered
  • bun run build:cf — succeeds, search index generated
  • bun test — 64 pass, 0 fail
  • Swept content/ for any other page documenting handleLog with the enum types: none. React Native was already correct; changelog entries are historical and left alone.

Only content/docs/** touched. Nothing under public/. Not deployed.

…legate

The SuperwallDelegate reference documents handleLog as taking LogLevel and
LogScope, but both SDKs declare level and scope as String, and message as
optional. This has been the case since 4.0.0 on iOS and across the current
Android line.

Because LogLevel and LogScope are real public types, the documented signature
compiles. And because every delegate method has a default empty implementation,
there is no conformance error either — you have simply declared an unrelated
method, so the callback never fires and the build stays clean.

Corrects the Swift, Kotlin and Java blocks, and adds a note plus a TypeTable
row explaining that level and scope are the string forms of the enums.
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