Skip to content

Commit

Permalink
[FSSDK-9913] chore: update dependencies & fixes from testing (#230)
Browse files Browse the repository at this point in the history
* chore: add conventional commits ext to dev container

* chore: upgrade to js sdk 5.0.0

* fix: use FeatureVariableValue for getFeatureVariable

* fix: add `as UserAttributes` for better TS coercion
  • Loading branch information
mikechu-optimizely authored Jan 23, 2024
1 parent 43613fc commit a441b07
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"github.vscode-github-actions",
"Orta.vscode-jest",
"ms-vscode.test-adapter-converter",
"GitHub.copilot-chat"
"GitHub.copilot-chat",
"vivaxy.vscode-conventional-commits"
],
"settings": {
"files.eol": "\n"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"access": "public"
},
"dependencies": {
"@optimizely/optimizely-sdk": "^5.0.0-beta5",
"@optimizely/optimizely-sdk": "^5.0.0",
"hoist-non-react-statics": "^3.3.0",
"prop-types": "^15.6.2",
"utility-types": "^2.1.0 || ^3.0.0"
Expand Down
7 changes: 4 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as optimizely from '@optimizely/optimizely-sdk';
import { OptimizelyDecision, UserInfo, createFailedDecision, areUsersEqual } from './utils';
import { notifier } from './notifier';
import { logger } from './logger';
import { FeatureVariableValue } from '@optimizely/optimizely-sdk';

export type VariableValuesObject = {
[key: string]: any;
Expand Down Expand Up @@ -117,7 +118,7 @@ export interface ReactSDKClient extends Omit<optimizely.Client, 'createUserConte
variableKey: string,
overrideUserId: string,
overrideAttributes?: optimizely.UserAttributes
): unknown;
): FeatureVariableValue;

getAllFeatureVariables(
featureKey: string,
Expand Down Expand Up @@ -952,15 +953,15 @@ class OptimizelyReactSDKClient implements ReactSDKClient {
* @param {string} variableKey
* @param {string} [overrideUserId]
* @param {optimizely.UserAttributes} [overrideAttributes]
* @returns {(unknown | null)}
* @returns {(FeatureVariableValue | null)}
* @memberof OptimizelyReactSDKClient
*/
public getFeatureVariable(
featureKey: string,
variableKey: string,
overrideUserId: string,
overrideAttributes?: optimizely.UserAttributes
): unknown {
): FeatureVariableValue | null {
if (!this._client) {
logger.warn(
'Unable to get feature variable from feature "%s" because Optimizely client failed to initialize.',
Expand Down
4 changes: 2 additions & 2 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export function hoistStaticsAndForwardRefs<R, P extends AcceptsForwardedRef<R>>(

function coerceUnknownAttrsValueForComparison(maybeAttrs: unknown): optimizely.UserAttributes {
if (typeof maybeAttrs === 'object' && maybeAttrs !== null) {
return maybeAttrs;
return maybeAttrs as optimizely.UserAttributes;
}
return {};
return {} as optimizely.UserAttributes;
}

/**
Expand Down
27 changes: 16 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -535,16 +535,16 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"

"@optimizely/optimizely-sdk@^5.0.0-beta5":
version "5.0.0-beta5"
resolved "https://registry.yarnpkg.com/@optimizely/optimizely-sdk/-/optimizely-sdk-5.0.0-beta5.tgz#67ac961be3d1269d2774ec758659d42a3e763e38"
integrity sha512-xQ1Lv306d9xQoK/vr0o4Wpn53gJNVUeJVi8N90NinDYjtFPsXasdWEFNXNN+qH678VmdpBsPPKLg/5olLoFrKg==
"@optimizely/optimizely-sdk@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@optimizely/optimizely-sdk/-/optimizely-sdk-5.0.0.tgz#9dc06e6aa05fafa5a0a689cf986f5198deb93786"
integrity sha512-qOJhCa/q/GXcuHSjbuDVB7kepo1GzLs2dS9iwZBD2Auupy/XjCh77cAuMQpqCbeNlQJsqr5meqxHeN+HGKqzAA==
dependencies:
decompress-response "^4.2.1"
json-schema "^0.4.0"
murmurhash "^2.0.1"
ua-parser-js "^1.0.35"
uuid "^8.3.2"
ua-parser-js "^1.0.37"
uuid "^9.0.1"

"@rollup/plugin-commonjs@^16.0.0":
version "16.0.0"
Expand Down Expand Up @@ -4652,10 +4652,10 @@ typescript@^4.7.4:
resolved "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz"
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==

ua-parser-js@^1.0.35:
version "1.0.36"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.36.tgz#a9ab6b9bd3a8efb90bb0816674b412717b7c428c"
integrity sha512-znuyCIXzl8ciS3+y3fHJI/2OhQIXbXw9MWC/o3qwyR+RGppjZHrM27CGFSKCJXi2Kctiz537iOu2KnXs1lMQhw==
ua-parser-js@^1.0.37:
version "1.0.37"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.37.tgz#b5dc7b163a5c1f0c510b08446aed4da92c46373f"
integrity sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==

uglify-js@^3.4.9:
version "3.16.3"
Expand Down Expand Up @@ -4725,11 +4725,16 @@ use@^3.1.0:
resolved "https://registry.npmjs.org/utility-types/-/utility-types-3.10.0.tgz"
integrity sha512-O11mqxmi7wMKCo6HKFt5AhO4BwY3VV68YU07tgxfz8zJTIxr4BpsezN49Ffwy9j3ZpwwJp4fkRwjRzq3uWE6Rg==

uuid@^8.3.0, uuid@^8.3.2:
uuid@^8.3.0:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

uuid@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==

v8-compile-cache@^2.0.3:
version "2.3.0"
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz"
Expand Down

0 comments on commit a441b07

Please sign in to comment.