Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ class SuperwallExpoModule : Module() {
}
}

Function("setLocaleIdentifier") { localeIdentifier: String? ->
Superwall.instance.localeIdentifier = localeIdentifier
}

AsyncFunction("setIntegrationAttributes") { attributes: Map<String, String>, promise: Promise ->
scope.launch {
try {
Expand Down
4 changes: 4 additions & 0 deletions ios/SuperwallExpoModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ public class SuperwallExpoModule: Module {
}
}

Function("setLocaleIdentifier") { (localeIdentifier: String?) in
Superwall.shared.localeIdentifier = localeIdentifier
}

AsyncFunction("setIntegrationAttributes") { (attributes: [String: String], promise: Promise) in
var converted: [IntegrationAttribute: String] = [:]

Expand Down
1 change: 1 addition & 0 deletions src/SuperwallExpoModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ declare class SuperwallExpoModule extends NativeModule<SuperwallExpoModuleEvents
preloadAllPaywalls(): void

setLogLevel(level: string): void
setLocaleIdentifier(localeIdentifier: string | null): void

setIntegrationAttributes(attributes: IntegrationAttributes): Promise<void>
getIntegrationAttributes(): Promise<Record<string, string>>
Expand Down
11 changes: 11 additions & 0 deletions src/compat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,17 @@ export default class Superwall {
await SuperwallExpoModule.setLogLevel(level.toString())
}

/**
* Sets the locale identifier for the Superwall SDK.
* This determines the language used when presenting paywalls.
* Can be changed at runtime without needing to reconfigure.
*
* @param localeIdentifier - The locale identifier (e.g., "en_US", "es_ES"), or `null` to reset to the device locale.
*/
async setLocaleIdentifier(localeIdentifier: string | null): Promise<void> {
SuperwallExpoModule.setLocaleIdentifier(localeIdentifier)
}
Comment on lines +730 to +732
Copy link
Contributor

Choose a reason for hiding this comment

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

Swallowed native errors

setLocaleIdentifier is async but doesn't await/return the underlying SuperwallExpoModule.setLocaleIdentifier(...) call. If the native module throws synchronously (e.g., module unavailable), this method will still resolve successfully and hide the failure. Consider return await SuperwallExpoModule.setLocaleIdentifier(localeIdentifier) for parity with other wrappers here.

Also appears in src/useSuperwall.ts:332-334.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/compat/index.ts
Line: 730:732

Comment:
**Swallowed native errors**

`setLocaleIdentifier` is `async` but doesn't `await`/`return` the underlying `SuperwallExpoModule.setLocaleIdentifier(...)` call. If the native module throws synchronously (e.g., module unavailable), this method will still resolve successfully and hide the failure. Consider `return await SuperwallExpoModule.setLocaleIdentifier(localeIdentifier)` for parity with other wrappers here.

Also appears in `src/useSuperwall.ts:332-334`.

How can I resolve this? If you propose a fix, please make it concise.


/**
* Sets attributes for third-party integrations.
* @param attributes - Object mapping IntegrationAttribute string values to their IDs
Expand Down
12 changes: 12 additions & 0 deletions src/useSuperwall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ export interface SuperwallStore {
*/
setLogLevel: (level: string) => Promise<void>

/**
* Sets the locale identifier for the Superwall SDK.
* This determines the language used when presenting paywalls.
* Can be changed at runtime without needing to reconfigure.
* @param localeIdentifier - The locale identifier (e.g., "en", "es", "fr"), or `null` to reset to the device locale.
* @returns A promise that resolves when the locale identifier is set.
*/
setLocaleIdentifier: (localeIdentifier: string | null) => Promise<void>

/**
* Sets attributes for third-party integrations.
* @param attributes - Object mapping IntegrationAttribute string values to their IDs
Expand Down Expand Up @@ -320,6 +329,9 @@ export const useSuperwallStore = create<SuperwallStore>((set, get) => ({
setLogLevel: async (level) => {
SuperwallExpoModule.setLogLevel(level)
},
setLocaleIdentifier: async (localeIdentifier) => {
SuperwallExpoModule.setLocaleIdentifier(localeIdentifier)
},
Comment on lines +332 to +334
Copy link
Contributor

Choose a reason for hiding this comment

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

Async call not awaited

This store action is async but doesn't await/return SuperwallExpoModule.setLocaleIdentifier(...). If the native module call throws synchronously, the returned Promise resolves and the error is swallowed. Returning/awaiting the call will preserve failures for callers.

(Compat layer has the same issue in src/compat/index.ts:730-732.)

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/useSuperwall.ts
Line: 332:334

Comment:
**Async call not awaited**

This store action is `async` but doesn't `await`/`return` `SuperwallExpoModule.setLocaleIdentifier(...)`. If the native module call throws synchronously, the returned Promise resolves and the error is swallowed. Returning/awaiting the call will preserve failures for callers.

(Compat layer has the same issue in `src/compat/index.ts:730-732`.)

How can I resolve this? If you propose a fix, please make it concise.


setIntegrationAttributes: async (attributes) => {
await SuperwallExpoModule.setIntegrationAttributes(attributes)
Expand Down