Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit c0a32e5

Browse files
committed
Adding section on dynamic deployments
1 parent 77c235e commit c0a32e5

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ This plugin provides client-side integration for the [CodePush service](http://c
1111
* [Windows Setup](#windows-setup)
1212
* [Plugin Usage](#plugin-usage)
1313
* [Releasing Updates](#releasing-updates)
14-
* [Multi-Deployment Releases](#multi-deployment-releases)
14+
* [Multi-Deployment Testing](#multi-deployment-testing)
15+
* [Dynamic Deployment Assignment](#dynamic-deployment-assignment)
1516
* [API Reference](#api-reference)
1617
* [JavaScript API](#javascript-api-reference)
1718
* [Objective-C API Reference (iOS)](#objective-c-api-reference-ios)
@@ -441,7 +442,7 @@ For more details about how the `release-react` command works, as well as the var
441442
If you run into any issues, or have any questions/comments/feedback, you can ping us within the [#code-push](https://discord.gg/0ZcbPKXt5bWxFdFu) channel on Reactiflux, [e-mail us](mailto:codepushfeed@microsoft.com) and/or check out the [troubleshooting](#debugging--troubleshooting) details below.
442443

443444

444-
## Multi-Deployment Releases
445+
## Multi-Deployment Testing
445446

446447
In our [getting started](#getting-started) docs, we illustrated how to configure the CodePush plugin using a specific deployment key. However, in order to effectively test your releases, it is critical that you leverage the `Staging` and `Production` deployments that are auto-generated when you first created your CodePush app (or any custom deployments you may have created). This way, you never release an update to your end users that you haven't been able to validate yourself.
447448
@@ -557,6 +558,26 @@ Additionally, if you want to give them seperate names and/or icons, you can modi
557558
558559
![Product name](https://cloud.githubusercontent.com/assets/116461/15764314/b3a4cfac-28de-11e6-9e8c-b1cbd8ac7c6c.png)
559560
561+
## Dynamic Deployment Assignment
562+
563+
The above section illustrated how you can leverage multiple CodePush deployments in order to effectively test your updates before broadly releasing them to your end users. However, since that workflow statically embeds the deployment assignment into the actual binary, a staging or production build will only ever sync updates from that deployment. In many cases, this is sufficient, since you only want your team, customers, stakeholders, etc. to sync with your pre-production releases, and therefore, only they need a build that knows how to sync with staging. However, if you want to be able to perform A/B tests, or provide early access of your app to certain users, it can prove very useful to be able to dynamically place specific users (or audiences) into specific deployments at runtime.
564+
565+
In order to achieve this kind of workflow, all you need to do is specify the deployment key you want the current user to syncronize with when calling the `checkForUpdate` or `sync` methods. When specified, this key will override the "default" one that was provided in your app's `Info.plist` (iOS) or `MainActivity.java` (Android) files. This allows you to produce a build for staging or production, that is also capabable of being dynamically "redirected" as needed.
566+
567+
```javascript
568+
// Imagine that "userProfile" is a prop that this component received
569+
// which includes the deployment key that the current user should use.
570+
codePush.sync({ deploymentKey: userProfile.CODEPUSH_KEY });
571+
```
572+
573+
With that change in place, now it's just a matter of choosing how your app determines the right deployment key for the current user. In practice, there are typically two solutions for this:
574+
575+
1. Expose a user-visible mechanism for changing deployments at any time. For example, your settings page could have a toggle for enabling "beta" access. This model works well if you're not concerned with the privacy of your pre-production updates, and you have power users that may want to opt-in to earlier (and potentially buggy) updates at their own will (kind of like Chrome channels). However, this solution puts the decision in the hands of your users, which doesn't help you perform A/B tests.
576+
577+
2. Annotate the profile's of your users with an additional piece of metadata which indicates the deployment they should sync with. By default, your app could just use the embedded key, but after a user has authenticated, your server can choose to "redirect" them to a different deployment, which allows you to incrementally place certain users or groups in different deployments as needed. You could even choose to store the server-response in local storage so that it becomes the new defaul. How you store the key alongside your user's profiles is entirely up to your authentication solution (e.g. Auth0, Firebase, custom DB + REST API), but is generally pretty trivial to do.
578+
579+
*NOTE: If needed, you could also implement a hybrid solution that allowed your end-users to toggle between different deployments, while also allowing your server to override that decision. This way, you have a hierarchy of "deployment resolution" that ensures your app has the ability to update itself out-of-the-box, your end users can feel rewarded by getting early access to bits, but you also have the ability to run A/B tests on your users as needed.
580+
560581
---
561582
562583
## API Reference

0 commit comments

Comments
 (0)