Skip to content
This repository was archived by the owner on Jun 10, 2021. It is now read-only.

Commit bc2fb88

Browse files
committed
Merge branch 'feature/ch310/kill-switch-for-flags_2' into 'master'
Kill Switch for Flags See merge request bullet-train/bullet-train-frontend!96
2 parents 5bb12b5 + 4923905 commit bc2fb88

File tree

13 files changed

+89
-45
lines changed

13 files changed

+89
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ If you have any questions about our projects you can email <a href="mailto:proje
9494

9595
## Running locally against your own Flagsmith API instance
9696

97-
We use Flagsmith to manage features we rollout, if you are using your own Flagsmith environment (i.e. by editing project_x.js-> bulletTrain) then you will need to have a replica of our flags.
97+
We use Flagsmith to manage features we rollout, if you are using your own Flagsmith environment (i.e. by editing project_x.js-> flagsmith) then you will need to have a replica of our flags.
9898

9999
A list of the flags and remote config we're currently using in production can be found here https://gist.github.com/kyle-ssg/55f3b869c28bdd13c02c6688bc76c67f.
100100

common/dispatcher/action-constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const Actions = Object.assign({}, require('./base/_action-constants'), {
22
'ACCEPT_INVITE': 'ACCEPT_INVITE',
3+
'CHANGE_USER_FLAG': 'CHANGE_USER_FLAG',
34
'CREATE_ENV': 'CREATE_ENV',
45
'CREATE_FLAG': 'CREATE_FLAG',
56
'CREATE_ORGANISATION': 'CREATE_ORGANISATION',

common/dispatcher/app-actions.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,10 @@ const AppActions = Object.assign({}, require('./base/_app-actions'), {
238238
...params,
239239
});
240240
},
241-
changeUserFlag(identity, identityFlag, environmentId, payload) {
241+
changeUserFlag(identity) {
242242
Dispatcher.handleViewAction({
243243
actionType: Actions.CHANGE_USER_FLAG,
244244
identity,
245-
identityFlag,
246-
environmentId,
247-
payload,
248245
});
249246
},
250247
selectOrganisation(id) {

common/project.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
module.exports = global.Project = {
2-
api: 'https://api-staging.flagsmith.com/api/v1/',
2+
api: 'https://api-dev.flagsmith.com/api/v1/',
33
flagsmithClientAPI: 'https://api.flagsmith.com/api/v1/',
4-
flagsmith: 'ENktaJnfLVbLifybz34JmX', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
5-
env: 'staging', // This is used for Sentry tracking
6-
ga: 'UA-120237963-7', // This is our Google Analytics key
7-
maintenance: false, // trigger maintenance mode
4+
flagsmith: '8KzETdDeMY7xkqkSkY3Gsg', // This is our Bullet Train API key - Bullet Train runs on Bullet Train!
5+
debug: false,
86
delighted: true, // determines whether to shw delighted feedback widget
7+
env: 'dev', // This is used for Sentry tracking
8+
ga: 'UA-120237963-3', // This is our Google Analytics key
9+
maintenance: false, // trigger maintenance mode
910
demoAccount: {
1011
1112
password: 'demo_account',

common/providers/ConfigProvider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react';
2-
import bulletTrain from 'bullet-train-client';
2+
import flagsmith from 'flagsmith';
33
import ConfigStore from '../stores/config-store';
44

55
module.exports = (WrappedComponent) => {
@@ -24,7 +24,7 @@ module.exports = (WrappedComponent) => {
2424

2525
render() {
2626
const { isLoading,error } = this.state;
27-
const { getValue, hasFeature } = bulletTrain;
27+
const { getValue, hasFeature } = flagsmith;
2828

2929
return (
3030
<WrappedComponent

common/stores/config-store.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const controller = {
1414
} else {
1515
store.changed();
1616
}
17-
store.model = bulletTrain.getAllFlags();
17+
store.model = flagsmith.getAllFlags();
1818
},
1919
};
2020

@@ -36,10 +36,11 @@ store.dispatcherIndex = Dispatcher.register(store, (payload) => {
3636
}
3737
});
3838

39-
bulletTrain.init({
39+
flagsmith.init({
4040
environmentID: Project.flagsmith,
4141
onChange: controller.loaded,
4242
api: Project.flagsmithClientAPI,
43+
enableAnalytics: true,
4344
}).catch(() => {
4445
controller.onError();
4546
});

common/stores/identity-store.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ const controller = {
4343
store.saved();
4444
});
4545
},
46-
changeUserFlag({identity, identityFlag, environmentId, payload}) {
46+
changeUserFlag({ identity, identityFlag, environmentId, payload, onSuccess }) {
4747
store.saving();
4848
API.trackEvent(Constants.events.TOGGLE_USER_FEATURE);
4949

50-
const prom = data.put(`${Project.api}environments/${environmentId}/identities/${identity}/featurestates/${identityFlag}/`, Object.assign({}, payload))
50+
const prom = data.put(`${Project.api}environments/${environmentId}/identities/${identity}/featurestates/${identityFlag}/`, Object.assign({}, payload));
5151
prom.then((res) => {
52+
if (onSuccess) onSuccess();
5253
store.saved();
5354
});
5455
},
@@ -141,7 +142,7 @@ store.dispatcherIndex = Dispatcher.register(store, (payload) => {
141142
controller.deleteIdentityTrait(action.envId, action.identity, action.id);
142143
break;
143144
case Actions.CHANGE_USER_FLAG:
144-
controller.changeUserFlag(action.identity, action.identityFlag, action.environmentId, action.payload);
145+
controller.changeUserFlag(action.identity);
145146
break;
146147
default:
147148
}

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"babel-plugin-transform-react-remove-prop-types": "0.4.18",
3939
"babel-runtime": "6.26.0",
4040
"bootstrap": "4.0.0-alpha.3",
41-
"bullet-train-client": "0.0.83",
41+
"flagsmith": "1.1.0",
4242
"bullet-train-rules-engine": "0.0.7",
4343
"chai": "4.2.0",
4444
"classnames": "2.2.6",

tests/index.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const clearDown = function (browser, done) {
4646
}
4747
}
4848
if (token) {
49-
console.log(`${Project.api}e2etests/teardown/`, token.trim());
5049
fetch(`${Project.api}e2etests/teardown/`, {
5150
method: 'POST',
5251
headers: {

0 commit comments

Comments
 (0)