Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Opticks to support Optimizely's JS SDK v5.3.2 #81

Merged

Conversation

vlacerda
Copy link
Contributor

@vlacerda vlacerda commented Jun 5, 2024

@vlacerda vlacerda force-pushed the sc-119714-upgrade-optimizely-sdk-and-opticks-to-latest branch from 3c7851c to 8c7dd43 Compare June 5, 2024 15:11
Copy link
Contributor

@Gerrit88 Gerrit88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Vini!

I left a few suggestions.

I also did some QA and everything seems to work as expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still see some references to booleanToggle:

  • Documentation: docs/booleanToggles.md and docs/dead-code-removal.md
  • Logic: packages/lib/src/integrations/simple.ts
  • Type: BooleanToggleType

Can we clean this up as well? If not, let's mark them as deprecated and create a follow-up story.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Good catch. I cleaned them up. I think I managed to do so .

README.md Outdated Show resolved Hide resolved
toggle,
forceToggles,
getEnabledFeatures
} from './optimizely'

// During the tests:
// for booleanToggle 'foo' yields true and 'bar' yields false, unless forced
// for toggle 'foo' yields 'b' and 'bar' yields 'a', unless forced
import datafile from './__fixtures__/dataFile'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to update this datafile to match the new configuration format?

@@ -26,7 +24,11 @@ import Optimizely, {
// @ts-expect-error
getEnabledFeaturesMock,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this mock is not used so we can remove the import (and maybe even the mock declaration).

packages/lib/src/integrations/optimizely.test.ts Outdated Show resolved Hide resolved
) =>
optimizelyClient.notificationCenter.addNotificationListener(
NOTIFICATION_TYPES.DECISION,
OptimizelyLib.enums.NOTIFICATION_TYPES.DECISION,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, we don't need the NOTIFICATION_TYPES declaration on line 19 anymore, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to bump the version of the opticks package here.

Copy link
Collaborator

@dale-french dale-french Jun 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this manually - you can run npx changeset from the root dir which will generate the changeset. Once this PR is merged, another PR will be opened automatically with the version bump + changelog

Example

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vlacerda let me know if you face any issues generating the changeset

Copy link
Contributor

@luisfmsouza luisfmsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to run this new version on the mobile app, but found something weird. Will comment here in case someoneelse also found and fixed it.

On the package/mobile-app/package.json file, I added the line below:

"opticks": "github:viodotcom/opticks#sc-119714-upgrade-optimizely-sdk-and-opticks-to-latest",

After running the install command, this is how the opticks package folder looked like (without the code). Maybe this type of install is not supported?

image

How do you suggest I install this branch version into the app to test it out?

@Gerrit88
Copy link
Contributor

Gerrit88 commented Jun 6, 2024

@luisfmsouza, I'm not sure the best way to run from GitHub.

But I QA'ed by pointing to the repo on my local machine:

"opticks": "../../../opticks/packages/lib",

vlacerda and others added 3 commits June 6, 2024 12:38
@vlacerda
Copy link
Contributor Author

vlacerda commented Jun 6, 2024

I was trying to run this new version on the mobile app, but found something weird. Will comment here in case someoneelse also found and fixed it.

On the package/mobile-app/package.json file, I added the line below:

"opticks": "github:viodotcom/opticks#sc-119714-upgrade-optimizely-sdk-and-opticks-to-latest",

After running the install command, this is how the opticks package folder looked like (without the code). Maybe this type of install is not supported?

image How do you suggest I install this branch version into the app to test it out?

@luisfmsouza I tested with Opticks locally. The steps are roughly:

  • Clone opticks
  • Go to opticks/packages/lib folder and run yarn link
  • Go to the root of daedalus and run yarn link {../relative-path-to-opticks/packages/lib}
    • This will add the link you added yourself but with the local version
  • On the webpack.config of the package you want to test you then need to include opticks to be compiled as well by babel.
    In the property include here add path.resolve(__dirname, '../../../../opticks/packages/lib')

@vlacerda vlacerda force-pushed the sc-119714-upgrade-optimizely-sdk-and-opticks-to-latest branch from f560af7 to d750ed2 Compare June 6, 2024 11:26
@vlacerda vlacerda requested a review from Gerrit88 June 6, 2024 11:32
Copy link
Contributor

@Gerrit88 Gerrit88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for those changes, Vini!

It's probably best to do the fix I mentioned here in this PR as well.

return [`${userId}-test-1`, `${userId}-test-2`]
}
export const decideMock = jest.fn((toggleKey) => ({
enabled: toggleKey === "foo"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
enabled: toggleKey === "foo"
enabled: toggleKey === 'foo'

README.md Outdated
as with `booleanToggle`, we specify multiple variants of which one is active at
any time. By convention the variants are named `a` (control), `b`, `c` etc.
Toggles can be used to implement a/b/c style testing and on/off values as well.
We specify multiple variants of which one is active at any time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We specify multiple variants of which one is active at any time.
We specify multiple variants of which only one is active at any time.

README.md Outdated
Toggles can be used to implement a/b/c style testing, instead of on/off values
as with `booleanToggle`, we specify multiple variants of which one is active at
any time. By convention the variants are named `a` (control), `b`, `c` etc.
Toggles can be used to implement a/b/c style testing and on/off values as well.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Toggles can be used to implement a/b/c style testing and on/off values as well.
Toggles can be used to implement a/b/c style MVT testing and on/off feature flags as well.

)

return isInAnyAudience || !isEveryoneElseRulePaused
return isInAnyAudience
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're not explicitly checking the last fallback rule as "everyone else", does this construct rely on the fact we always have our own explicit "everyone else" audience rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's supposed to stand on its own. If we don't have any audience rule set this means isInAnyAudience will be false. Which matches our expectations. If you don't have any rule set your experiment is always turned off.

@vlacerda vlacerda force-pushed the sc-119714-upgrade-optimizely-sdk-and-opticks-to-latest branch from 927c403 to 9b32a6a Compare June 6, 2024 14:31
Copy link
Contributor

@Gerrit88 Gerrit88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Vini! 🚀

@vlacerda vlacerda merged commit d73f8eb into master Jun 7, 2024
1 check passed
@vlacerda vlacerda deleted the sc-119714-upgrade-optimizely-sdk-and-opticks-to-latest branch June 7, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants