Skip to content

Draft: AB#274406: Derive the region exclusively from provided credentials#77

Open
graciecooper wants to merge 7 commits intomasterfrom
274406-delayed-credentials
Open

Draft: AB#274406: Derive the region exclusively from provided credentials#77
graciecooper wants to merge 7 commits intomasterfrom
274406-delayed-credentials

Conversation

@graciecooper
Copy link
Contributor

Description of Changes

When using delayed initialisation, Optimobile.urlBuilder was created during the initial Optimobile.initialize() call using the Region enum provided to the Builder. When credentials arrived later via setCredentials(), the config's region and baseUrlMap were updated, but Optimobile.urlBuilder was never rebuilt — meaning all API calls continued using the initial enum-based URLs.

This PR creates a new Builder(FeatureSet) constructor for delayed initialisation that doesn't need region. Region and base URL mapping remain null until credentials are provided via setCredentials(). It also of deprecates the old constructor, sort of...

‼️ Deprecation Note ‼️
our beloved CI runs JDK 8, but we have a transistive dependency (looks like kotlin-stdlib via OkHttp ? ) containing Java 9 module-info classfile attributes. If we add the actual @Deprecated annotation, it triggers the javac type annotation scanner and that hits the MODULE attribute, which causes a pipeline failure as it doesn't recognise it. I've worked around this by adding a deprecated as Javadoc but ideally we'd want this to be communicated via annotations so it shows compiler warnings to clients? Upgrading the CI pipeline would involve a fair wee bit of work though as it involves updating all the mockito tests, not just the .yaml 😔

I think the solution would be to ship this so Bet365 issue is fixed ASAP, then upgrade CI pipeline as tech debt?

Breaking Changes

  • None

Release Checklist

Prepare:

  • Detail any breaking changes. Breaking changes require a new major version number, and a migration guide in wiki / README.md

Bump versions in:

  • [ TO DO ] CHANGELOG.md
  • gradle.properties
  • add links to newly created wiki pages to readme
  • Update major version numbers in wiki (basic integration + push guides)

Integration tests

T&T Only

  • Init SDK with only optimove credentials
  • Associate customer
  • Associate email
  • Track events

Mobile Only

  • Init SDK with all credentials
  • Track events
  • Associate customer (verify both backends)
  • Register for push
  • Opt-in for In-App
  • Send test push
  • Send test In-App
  • Receive / trigger deep link handler (In-App/Push)
  • Receive / trigger the content extension, render image and action buttons for push
  • Verify push opened handler

Deferred Deep Links

  • With app installed, trigger deep link handler
  • With app uninstalled, follow deep link, install test bundle, verify deep link read from Clipboard, trigger deep link handler

Combined

  • Track event for T&T, verify push received
  • Trigger scheduled campaign, verify push received
  • Trigger scheduled campaign, verify In-App received

Release Procedure

  • Squash and merge dev to master
  • Delete branch once merged

@graciecooper graciecooper self-assigned this Feb 27, 2026
@kris-opti
Copy link
Contributor

@graciecooper I agree with your idea of creating a tech debt to deal with the CI pipeline

@graciecooper
Copy link
Contributor Author

@graciecooper I agree with your idea of creating a tech debt to deal with the CI pipeline
Made a ticket for it when I did the Kotlin stuff as was obv running into issues back then. The pipeline itself is from 2019 I think anyway, so could probs do with a proper wee dive :)

@k-antipochkin
Copy link
Collaborator

@graciecooper A couple of questions on potential edge cases on region absence:

  1. What happens when the credentials aren't set yet and there is an in app message?
  2. What happens when the end user opens a deep link and the setCredentials call isn't immediately called? do we have a crash on Optimobile.urlBuilder?

…ntial init

When using Builder(FeatureSet) without a region, urlBuilder stays null
until setCredentials() is called. All 6 direct urlBuilder access sites
could NPE before the existing PartialInitialisationException safety net
was reached. This adds a null-safe accessor (Optimobile.urlForService)
that throws PartialInitialisationException when urlBuilder is null,
channeling the error into existing catch paths so events are persisted
and flushed later, in-app fetch retries, and deep links are cached.

Made-with: Cursor
Move the urlForService call above dialog.show() so that if credentials
aren't available yet, the PartialInitialisationException is thrown
before any UI is displayed. Previously the dialog and spinner were
shown first, leaving the user stuck with a permanent spinner overlay.

Made-with: Cursor
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.

3 participants