Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(branch): add support for test environments #229

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rodperottoni
Copy link

@rodperottoni rodperottoni commented Apr 9, 2024

Why

Branch has a handy test mode that lets developers test their implementation in a sandbox, preventing data pollution in the live environment. At the moment this config plugin does not support the test environment feature.

iOS docs
Android docs

How

I introduced this feature into the config plugin by expanding the config plugin parameters to accept some new values:

  • testApiKey (string): the test API key to be used when the test environment is enabled
  • enableTestEnvironment (boolean): setting this to true will enable the usage of the test environment.

Enabling the test environment varies between platforms:

  • iOS: By injecting a branch_test_environment value into the generated info.plist, we can assert whether this value is true from the applicationDidFinishLaunchWithOptions (inside our Swift delegate) and call the appropriate SDK's mechanism to enable the test environment: RNBranch.useTestInstance()
  • Android: The native Branch module supports enabling the test environment by adding a metadata item to the AndroidManifest: io.branch.sdk.TestMode.

Considerations / Help Needed

Part of this PR depends on some updated types in the official expo/config-types. Specifically, the ExpoConfig type supports a branch.apiKey field underneath the config.ios and config.android, and this config-plugin currently makes use of those values.

In an ideal world, I think the global ExpoConfig should have nothing that deals with Branch. It just... doesn't make sense? If this sentiment is shared between other maintainers, I'd be happy to completely kill those values from ExpoConfig and make the necessary changes in this PR to only take in options from the config-plugin itself.

Regardless, I have opened a PR in the expo repo to update the ExpoConfig type to accept the testApiKey and enableTestEnvironment parameters: expo/expo#28084

What I'm confused about is how would these PRs be orchestrated to work together? Would we have to first merge the main repo PR and only then update the config plugin here? I'll wait for someone to chime in on this, as I'm a beginner in multi-repo contributions 😂

Test Plan

  • I updated the existing suite to include tests for the new enableBranchTestEnvironment functions.
  • I unfortunately don't know how to test the native layer for this. I don't think this is required, however, as we currently don't have native tests for each platforms.

@rodperottoni rodperottoni changed the title feat(branch): add support for test environment usage feat(branch): add support for test environments Apr 9, 2024
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