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

feat(packages/sui-pde): upgrade optimizely version and add use-decisi… #1824

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

andresz1
Copy link
Member

@andresz1 andresz1 commented Sep 26, 2024

Description

This PR introduces Feature Tests.

Feature tests are similar to A/B/n tests that allow you to control whether for each variation the associated feature is on or off via feature flags (aka feature toggles). It also allows you to control the feature variable values for the various variables associated with the feature.

The useDecision hook retrieves the result for a given decision, based on logic from the decision-making tool you are using (e.g., Optimizely).

import {useDecision} from '@s-ui/pde'

function Component() {
  const decision = useDecision('feature_test', {})

  return (
    <>
      {decision.enabled && <p>My feature is enabled</p>}
      {!decision.enabled && <p>My feature is disabled</p>}
      {decision.variationKey === 'variantion_a' && <p>Current Variation</p>}
      {decision.variationKey === 'variantion_b' && <p>Better Variation</p>}
    </>
  );
}

You can also use the Decision component:

import {Decision} from '@s-ui/pde'

const MyComponent = () => {
  return (
    <Decision name="feature_test">
      {({enabled}) => enabled ? <p>My feature is enabled</p> : <p>My feature is disabled</p>}
    </Decision>
  )
}

/**
* @param {object} param
* @param {string} param.name
* @param {object} param.attributes
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {object} param.attributes
* @param {object} param.attributes
* @param {string} param.adapterId

@andresz1 andresz1 marked this pull request as ready for review October 2, 2024 10:13
@@ -1,3 +1,3 @@
import './pdeSpec.js'
import './useExperimentSpec' // This file has no extension due to sui-test server problem
import './useExperimentSpec.js' // This file has no extension due to sui-test server problem
Copy link
Contributor

Choose a reason for hiding this comment

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

Now seems that the comment could be removed

@andresz1 andresz1 merged commit 6131d4b into master Oct 3, 2024
2 checks passed
@andresz1 andresz1 deleted the feat/upgrade-optimizely-pde branch October 3, 2024 07:25
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