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: Integrated Optimizely Prompt Experiment #52

Merged
merged 13 commits into from
Jul 11, 2024

Conversation

rijuma
Copy link
Member

@rijuma rijuma commented Jun 26, 2024

This integrates Optimizely's hooks for the new XPert prompt experiment.

@rijuma rijuma force-pushed the rijuma/optimizely-prompt-experiment branch from 10c5989 to 6c5aeb1 Compare June 27, 2024 14:56
@rijuma rijuma force-pushed the rijuma/optimizely-prompt-experiment branch from 6c5aeb1 to 2fb1862 Compare June 27, 2024 14:57
Copy link
Member

@varshamenon4 varshamenon4 left a comment

Choose a reason for hiding this comment

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

Nice! Just a few questions.

@@ -0,0 +1,7 @@
const PROMPT_EXPERIMENT_FLAG = '_cosmo__xpert_gpt_4_0_prompt';
Copy link
Member

Choose a reason for hiding this comment

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

Question: sorry if this is captured somewhere else already but is the naming of this flag based on what is set in optimizely?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. It's taken from here:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

that looks like the correct value to use

unitId,
...customQueryParams,
};

Copy link
Member

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

Choose a reason for hiding this comment

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

Question: Should this file exist or was it deleted?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was empty. I don't think it should be here.

rijuma and others added 5 commits July 1, 2024 18:07
* feat: trigger survey monkey on chat close

* fix: Fixed useOptimizelyExperiment() infinite updates

* fix: read experiment state correctly

* feat: add tests

* fix: fix lint errors

* fix: remove flaky test

---------

Co-authored-by: Marcos <[email protected]>
@@ -19,7 +19,8 @@
"lint:fix": "fedx-scripts eslint --fix --ext .js --ext .jsx .",
"snapshot": "fedx-scripts jest --updateSnapshot",
"start": "fedx-scripts webpack-dev-server --progress",
"test": "fedx-scripts jest --coverage --passWithNoTests"
"test": "fedx-scripts jest --coverage --passWithNoTests",
"test:ci": "fedx-scripts jest --silent --coverage --passWithNoTests"
Copy link
Member Author

Choose a reason for hiding this comment

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

This reduces CI checks log file size from 30KB to 8KB by silencing warnings.
At some point warnings should be reduced, but we are not taking them into account on the CI, so we just might just remove them.

Copy link
Member Author

@rijuma rijuma Jul 11, 2024

Choose a reason for hiding this comment

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

Also, some warnings are caused by external libraries, like @openedx/paragon icons for example. When testing, the library renders the icons as <IconMock /> by the use of a string reference rather than a component causing the following warning:

    Warning: <IconMock /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
        at IconMock
        at button
        at /Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/react-bootstrap/cjs/Button.js:28:23
        at children (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/@openedx/paragon/src/Button/index.jsx:12:3)
        at div
        at isOpen (/Users/marcos/edx/src/frontend-lib-learning-assistant/src/components/ToggleXpertButton/index.jsx:20:3)
        at Provider (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/react-redux/lib/components/Provider.js:21:20)
        at IntlProvider (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/react-intl/src/components/provider.js:33:47)
        at children (/Users/marcos/edx/src/frontend-lib-learning-assistant/src/utils/utils.test.jsx:19:22)

This warning stacks up for every render.

@rijuma rijuma force-pushed the rijuma/optimizely-prompt-experiment branch from f4da8a6 to 8d96749 Compare July 11, 2024 14:04
Comment on lines 33 to 47
{getConfig().PRIVACY_POLICY_URL ? (
<p className="disclaimer text-light-100 py-3">
<strong>Note: </strong>
This chat is AI generated (powered by ChatGPT). Mistakes are possible.
By using it you agree that edX may create a record of this chat.
Your personal data will be used as described in our&nbsp;
<Hyperlink
className="privacy-policy-link text-light-100"
destination={getConfig().PRIVACY_POLICY_URL}
>
privacy policy
</Hyperlink>
.
</p>
) : null }
Copy link
Member Author

@rijuma rijuma Jul 11, 2024

Choose a reason for hiding this comment

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

This solves a warning in the tests. Since getConfig().PRIVACY_POLICY_URL is undefined on the test environment, it throws a warning since destination is a required prop for <Hyperlink>.

The full warning was:

Warning: Failed prop type: The prop `destination` is marked as required in `ForwardRef`, but its value is `undefined`.
        at className (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/@openedx/paragon/src/Hyperlink/index.jsx:15:5)
        at _classCallCheck (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/@openedx/paragon/src/withDeprecatedProps.tsx:28:27)
        at p
        at div
        at children (/Users/marcos/edx/src/frontend-lib-learning-assistant/src/components/Disclosure/index.jsx:10:23)
        at div
        at courseId (/Users/marcos/edx/src/frontend-lib-learning-assistant/src/components/Sidebar/index.jsx:23:3)
        at Provider (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/react-redux/lib/components/Provider.js:21:20)
        at IntlProvider (/Users/marcos/edx/src/frontend-lib-learning-assistant/node_modules/react-intl/src/components/provider.js:33:47)
        at children (/Users/marcos/edx/src/frontend-lib-learning-assistant/src/utils/utils.test.jsx:19:22)

Copy link
Contributor

Choose a reason for hiding this comment

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

since it seems like this config value is effectively required for this component maybe we want to make use of ensureConfig()? https://github.com/openedx/frontend-platform/blob/b0ac45329f0ed9022541abea4fe30abf49fde0b1/src/config.js#L264

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. I wasn't familiar with all the config options. Updated and it's much cleaner now. Thanks for the suggestion.

@rijuma rijuma marked this pull request as ready for review July 11, 2024 17:12
@@ -0,0 +1,160 @@
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

this is great! Thanks for improving our test coverage on this

src/utils/index.jsx Outdated Show resolved Hide resolved
@rijuma rijuma merged commit e9791c8 into main Jul 11, 2024
5 checks passed
@rijuma rijuma deleted the rijuma/optimizely-prompt-experiment branch July 11, 2024 19:04
rijuma added a commit that referenced this pull request Jul 15, 2024
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.

4 participants