Skip to content

Commit 5973e4e

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 9a76ead + 17f5cd1 commit 5973e4e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+619
-561
lines changed

examples/nextjs/package-lock.json

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

examples/reactnative/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,4 @@ SPEC CHECKSUMS:
530530

531531
PODFILE CHECKSUM: 0ab57695a801650aa30c7d29aa6c58d97ebd33cf
532532

533-
COCOAPODS: 1.11.2
533+
COCOAPODS: 1.11.3

examples/reactnative/package-lock.json

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

examples/reactnative/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
},
1212
"dependencies": {
1313
"@react-native-async-storage/async-storage": "^1.17.0",
14-
"flagsmith": "2.0.0",
14+
"flagsmith": "3.9.2",
1515
"react": "17.0.2",
1616
"react-native": "0.67.4",
17-
"react-native-flagsmith": "3.8.0"
17+
"react-native-flagsmith": "3.9.2"
1818
},
1919
"devDependencies": {
2020
"@babel/core": "7.17.8",

flagsmith-core.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const initError = function (caller:string) {
2828
return "Attempted to " + caller + " a user before calling flagsmith.init. Call flagsmith.init first, if you wish to prevent it sending a request for flags, call init with preventFetch:true."
2929
}
3030

31-
type Config= {fetch?:LikeFetch, AsyncStorage?:AsyncStorageType, eventSource?:any};
31+
type Config= {browserlessStorage?:boolean, fetch?:LikeFetch, AsyncStorage?:AsyncStorageType, eventSource?:any};
3232

3333
const Flagsmith = class {
3434
eventSource:EventSource|null = null
@@ -38,6 +38,9 @@ const Flagsmith = class {
3838
} else {
3939
_fetch = (typeof fetch !== 'undefined'? fetch : global?.fetch) as LikeFetch;
4040
}
41+
42+
this.canUseStorage = typeof window!=='undefined' || !!props.browserlessStorage;
43+
4144
this.log("Constructing flagsmith instance " + props)
4245
if (props.eventSource) {
4346
eventSource = props.eventSource;
@@ -208,6 +211,7 @@ const Flagsmith = class {
208211
}
209212
};
210213

214+
canUseStorage = false
211215
analyticsInterval: NodeJS.Timer | null= null
212216
api: string|null= null
213217
cacheFlags= false
@@ -278,7 +282,6 @@ const Flagsmith = class {
278282
this.flags = Object.assign({}, defaultFlags) || {};
279283
this.initialised = true;
280284
this.ticks = 10000;
281-
282285
if (realtime && typeof window !== 'undefined') {
283286
const connectionUrl = eventSourceUrl.replace("$ENVIRONMENT", environmentID);
284287
if(!eventSource) {
@@ -374,7 +377,7 @@ const Flagsmith = class {
374377
}
375378
}
376379

377-
if (AsyncStorage && typeof window!=='undefined') {
380+
if (AsyncStorage && this.canUseStorage) {
378381
AsyncStorage.getItem(FLAGSMITH_EVENT)
379382
.then((res)=>{
380383
if (res){
@@ -398,7 +401,7 @@ const Flagsmith = class {
398401
clearInterval(this.analyticsInterval);
399402
}
400403

401-
if (AsyncStorage && typeof window!=='undefined') {
404+
if (AsyncStorage && this.canUseStorage) {
402405
AsyncStorage.getItem(FLAGSMITH_EVENT, (err, res) => {
403406
if (res) {
404407
var json = JSON.parse(res);
@@ -419,7 +422,7 @@ const Flagsmith = class {
419422

420423
//If the user specified default flags emit a changed event immediately
421424
if (cacheFlags) {
422-
if (AsyncStorage && typeof window!=='undefined') {
425+
if (AsyncStorage && this.canUseStorage) {
423426
AsyncStorage.getItem(FLAGSMITH_KEY, (err, res) => {
424427
if (res) {
425428
try {
@@ -718,7 +721,7 @@ const Flagsmith = class {
718721

719722
};
720723

721-
export default function ({ fetch, AsyncStorage, eventSource }:Config):IFlagsmith {
724+
export default function ({ fetch, browserlessStorage, AsyncStorage, eventSource }:Config):IFlagsmith {
722725
return new Flagsmith({ fetch, AsyncStorage, eventSource }) as IFlagsmith;
723726
};
724727

flagsmith-es/flagsmith-core.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)