Skip to content

Commit 8b55526

Browse files
author
Matt Carroll
committed
Merge branch 'master' into mcarroll/optimizely-sdk-typescript
2 parents b9a4210 + 0427cdd commit 8b55526

Some content is hidden

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

50 files changed

+3819
-2366
lines changed

.travis.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ after_success: npm run coveralls
2424

2525
# Integration tests need to run first to reset the PR build status to pending
2626
stages:
27-
- name: 'Lint markdown files'
27+
- 'Source Clear'
28+
- 'Lint markdown files'
2829
- 'Lint'
2930
- 'Integration tests'
31+
- 'Full stack production tests'
3032
- 'Cross-browser and umd unit tests'
3133
- 'Test'
3234
- 'Test sub packages'
@@ -45,10 +47,9 @@ jobs:
4547
- stage: 'Lint'
4648
node_js: '12'
4749
script: npm run lint
50+
4851
- &integrationtest
4952
stage: 'Integration tests'
50-
addons:
51-
srcclr: true
5253
merge_mode: replace
5354
cache: false
5455
language: minimal
@@ -60,6 +61,15 @@ jobs:
6061
- CLIENT=node $HOME/travisci-tools/trigger-script-with-status-update.sh
6162
- CLIENT=browser $HOME/travisci-tools/trigger-script-with-status-update.sh
6263
after_success: travis_terminate 0
64+
65+
- <<: *integrationtest
66+
stage: 'Full stack production tests'
67+
env:
68+
SDK=javascript
69+
SDK_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
70+
FULLSTACK_TEST_REPO=ProdTesting
71+
script: $HOME/travisci-tools/trigger-script-with-status-update.sh
72+
6373
- stage: Cross-browser and umd unit tests
6474
node_js: '8'
6575
script: npm run test-ci
@@ -74,3 +84,14 @@ jobs:
7484
- <<: *packagetest
7585
before_script: npm install "@react-native-community/async-storage"
7686
before_install: cd packages/datafile-manager
87+
88+
- stage: 'Source Clear'
89+
if: type = cron
90+
addons:
91+
srcclr: true
92+
before_install: skip
93+
install: skip
94+
before_script: skip
95+
script: skip
96+
after_script: skip
97+
after_success: skip

packages/datafile-manager/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## [Unreleased]
88
Changes that have landed but are not yet released.
99

10+
## [0.7.0] - July 28, 2020
11+
12+
### Changed
13+
14+
- Move React Native async storage implementation to datafile manager
15+
1016
## [0.6.0] - June 8, 2020
1117

1218
### New Features

packages/datafile-manager/__test__/httpPollingDatafileManager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import HttpPollingDatafileManager from '../src/httpPollingDatafileManager';
1818
import { Headers, AbortableRequest, Response } from '../src/http';
1919
import { DatafileManagerConfig } from '../src/datafileManager';
2020
import { advanceTimersByTime, getTimerCount } from './testUtils';
21-
import { PersistentKeyValueCache } from '@optimizely/js-sdk-utils';
21+
import PersistentKeyValueCache from '../src/persistentKeyValueCache';
2222

2323
jest.mock('../src/backoffController', () => {
2424
return jest.fn().mockImplementation(() => {

packages/datafile-manager/package-lock.json

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

packages/datafile-manager/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@optimizely/js-sdk-datafile-manager",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Optimizely Full Stack Datafile Manager",
55
"repository": {
66
"type": "git",
@@ -13,6 +13,7 @@
1313
},
1414
"main": "lib/index.node.js",
1515
"browser": "lib/index.browser.js",
16+
"react-native": "lib/index.react_native.js",
1617
"types": "lib/index.d.ts",
1718
"directories": {
1819
"lib": "lib",
@@ -48,7 +49,7 @@
4849
},
4950
"dependencies": {
5051
"@optimizely/js-sdk-logging": "^0.1.0",
51-
"@optimizely/js-sdk-utils": "^0.3.2",
52+
"@optimizely/js-sdk-utils": "^0.4.0",
5253
"decompress-response": "^4.2.1"
5354
},
5455
"peerDependencies": {

packages/datafile-manager/src/datafileManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { PersistentKeyValueCache } from '@optimizely/js-sdk-utils';
16+
import PersistentKeyValueCache from './persistentKeyValueCache';
1717

1818
export interface DatafileUpdate {
1919
datafile: object;

packages/datafile-manager/src/httpPollingDatafileManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
*/
1616

1717
import { getLogger } from '@optimizely/js-sdk-logging';
18-
import { sprintf, PersistentKeyValueCache } from '@optimizely/js-sdk-utils';
18+
import { sprintf } from '@optimizely/js-sdk-utils';
1919
import { DatafileManager, DatafileManagerConfig, DatafileUpdate } from './datafileManager';
2020
import EventEmitter, { Disposer } from './eventEmitter';
2121
import { AbortableRequest, Response, Headers } from './http';
2222
import { DEFAULT_UPDATE_INTERVAL, MIN_UPDATE_INTERVAL, DEFAULT_URL_TEMPLATE } from './config';
2323
import BackoffController from './backoffController';
24+
import PersistentKeyValueCache from './persistentKeyValueCache';
2425

2526
const logger = getLogger('DatafileManager');
2627

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Copyright 2020, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { getLogger } from '@optimizely/js-sdk-logging';
18+
import AsyncStorage from '@react-native-community/async-storage';
19+
20+
import PersistentKeyValueCache from './persistentKeyValueCache';
21+
22+
const logger = getLogger('DatafileManager');
23+
24+
export default class ReactNativeAsyncStorageCache implements PersistentKeyValueCache {
25+
get(key: string): Promise<any | null> {
26+
return AsyncStorage.getItem(key).then((val: string | null) => {
27+
if (!val) {
28+
return null;
29+
}
30+
try {
31+
return JSON.parse(val);
32+
} catch (ex) {
33+
logger.error('Error Parsing Object from cache - %s', ex);
34+
throw ex;
35+
}
36+
});
37+
}
38+
39+
set(key: string, val: any): Promise<void> {
40+
try {
41+
return AsyncStorage.setItem(key, JSON.stringify(val));
42+
} catch (ex) {
43+
logger.error('Error stringifying Object to Json - %s', ex);
44+
return Promise.reject(ex);
45+
}
46+
}
47+
48+
contains(key: string): Promise<boolean> {
49+
return AsyncStorage.getItem(key).then((val: string | null) => val !== null);
50+
}
51+
52+
remove(key: string): Promise<void> {
53+
return AsyncStorage.removeItem(key);
54+
}
55+
}

0 commit comments

Comments
 (0)