Skip to content

Commit 7ad29c8

Browse files
Merge branch 'master' into junaed/fssdk-10121-expo-poc-doc
2 parents b626dda + 068382a commit 7ad29c8

File tree

7 files changed

+34
-17
lines changed

7 files changed

+34
-17
lines changed

.github/workflows/integration_test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Checkout branch
1515
uses: actions/checkout@v3
1616
with:
17-
token: ${{ secrets.CI_USER_TOKEN }}
17+
token: ${{ secrets.CI_USER_TOKEN || secrets.GITHUB_TOKEN }}
1818
repository: 'optimizely/travisci-tools'
1919
path: 'home/runner/travisci-tools'
2020
ref: 'master'

README.md

-4
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,6 @@ Copyright © 2014 Taylor Hakes
525525
Copyright © 2014 Forbes Lindesay
526526
License: [MIT](https://github.com/taylorhakes/promise-polyfill/blob/master/LICENSE)
527527

528-
[**prop-types**](https://github.com/facebook/prop-types)
529-
Copyright © 2013-present, Facebook, Inc.
530-
License: [MIT](https://github.com/facebook/prop-types/blob/master/LICENSE)
531-
532528
[**react-is**](https://github.com/facebook/react)
533529
Copyright © Facebook, Inc. and its affiliates.
534530
License: [MIT](https://github.com/facebook/react/blob/master/LICENSE)

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"dependencies": {
4444
"@optimizely/optimizely-sdk": "^5.3.4",
4545
"hoist-non-react-statics": "^3.3.2",
46-
"prop-types": "^15.8.1",
4746
"utility-types": "^2.1.0 || ^3.0.0"
4847
},
4948
"peerDependencies": {
@@ -58,7 +57,6 @@
5857
"@testing-library/react": "^14.3.0",
5958
"@types/hoist-non-react-statics": "^3.3.5",
6059
"@types/jest": "^29.5.12",
61-
"@types/prop-types": "^15.7.12",
6260
"@types/react": "^18.0.15",
6361
"@types/react-dom": "^18.0.6",
6462
"@typescript-eslint/eslint-plugin": "^5.6.2",
@@ -78,7 +76,6 @@
7876
"rollup": "^3.29.4",
7977
"rollup-plugin-typescript2": "^0.36.0",
8078
"ts-jest": "^29.2.3",
81-
"tslib": "^2.6.3",
8279
"typescript": "^5.5.4"
8380
}
8481
}

src/Provider.spec.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ describe('OptimizelyProvider', () => {
8383
});
8484

8585
it('should render successfully without user or userId provided', () => {
86+
// @ts-ignore
87+
mockReactClient.user = undefined;
8688
render(<OptimizelyProvider optimizely={mockReactClient} />);
8789

8890
expect(mockReactClient.setUser).toHaveBeenCalledWith(DefaultUser);
@@ -95,6 +97,8 @@ describe('OptimizelyProvider', () => {
9597
});
9698

9799
it('should succeed just userAttributes provided', () => {
100+
// @ts-ignore
101+
mockReactClient.user = undefined;
98102
render(<OptimizelyProvider optimizely={mockReactClient} userAttributes={{ attr1: 'value1' }} />);
99103

100104
expect(mockReactClient.setUser).toHaveBeenCalledWith({
@@ -103,6 +107,21 @@ describe('OptimizelyProvider', () => {
103107
});
104108
});
105109

110+
it('should succeed with the initial user available in client', () => {
111+
render(<OptimizelyProvider optimizely={mockReactClient} />);
112+
113+
expect(mockReactClient.setUser).toHaveBeenCalledWith(user1);
114+
});
115+
116+
it('should succeed with the initial user id and newly passed attributes', () => {
117+
render(<OptimizelyProvider optimizely={mockReactClient} userAttributes={{ attr1: 'value2' }} />);
118+
119+
expect(mockReactClient.setUser).toHaveBeenCalledWith({
120+
id: user1.id,
121+
attributes: { attr1: 'value2' },
122+
});
123+
});
124+
106125
it('should not update when isServerSide is true', () => {
107126
// Initial render
108127
const { rerender } = render(<OptimizelyProvider optimizely={mockReactClient} isServerSide={true} user={user1} />);

src/Provider.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ export class OptimizelyProvider extends React.Component<OptimizelyProviderProps,
7373
};
7474
// deprecation warning
7575
logger.warn('Passing userId and userAttributes as props is deprecated, please switch to using `user` prop');
76+
} else if (optimizely.user) {
77+
const { id, attributes } = optimizely.user;
78+
finalUser = {
79+
id,
80+
attributes: userAttributes || attributes || {},
81+
};
7682
} else {
7783
finalUser = {
7884
id: DefaultUser.id,

tsconfig.json

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"noImplicitReturns": true,
99
"noImplicitThis": true,
1010
"noImplicitAny": true,
11-
"importHelpers": false,
1211
"strictNullChecks": true,
1312
"noLib": false,
1413
"emitDecoratorMetadata": true,

yarn.lock

+8-8
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@
860860
dependencies:
861861
undici-types "~6.13.0"
862862

863-
"@types/prop-types@*", "@types/prop-types@^15.7.12":
863+
"@types/prop-types@*":
864864
version "15.7.12"
865865
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
866866
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==
@@ -3596,9 +3596,9 @@ merge2@^1.3.0, merge2@^1.4.1:
35963596
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
35973597

35983598
micromatch@^4.0.4, micromatch@^4.0.5:
3599-
version "4.0.7"
3600-
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.7.tgz#33e8190d9fe474a9895525f5618eee136d46c2e5"
3601-
integrity sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==
3599+
version "4.0.8"
3600+
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
3601+
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
36023602
dependencies:
36033603
braces "^3.0.3"
36043604
picomatch "^2.3.1"
@@ -4185,9 +4185,9 @@ rollup-plugin-typescript2@^0.36.0:
41854185
tslib "^2.6.2"
41864186

41874187
rollup@^3.29.4:
4188-
version "3.29.4"
4189-
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.4.tgz#4d70c0f9834146df8705bfb69a9a19c9e1109981"
4190-
integrity sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==
4188+
version "3.29.5"
4189+
resolved "https://registry.yarnpkg.com/rollup/-/rollup-3.29.5.tgz#8a2e477a758b520fb78daf04bca4c522c1da8a54"
4190+
integrity sha512-GVsDdsbJzzy4S/v3dqWPJ7EfvZJfCHiDqe80IyrF59LYuP+e6U1LJoUqeuqRbwAWoMNoXivMNeNAOf5E22VA1w==
41914191
optionalDependencies:
41924192
fsevents "~2.3.2"
41934193

@@ -4664,7 +4664,7 @@ tslib@^1.8.1:
46644664
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
46654665
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
46664666

4667-
tslib@^2.1.0, tslib@^2.6.2, tslib@^2.6.3:
4667+
tslib@^2.1.0, tslib@^2.6.2:
46684668
version "2.6.3"
46694669
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0"
46704670
integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==

0 commit comments

Comments
 (0)