-
Notifications
You must be signed in to change notification settings - Fork 237
feat(compass-telemetry): Atlas Skills Banner CLOUDP-349749 #7441
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0e7316e
CLOUDP-349749: reusable skills banner for atlas experiment
carolynmcca 569e1ee
CLOUDP-349749: skills banner updates
carolynmcca d515b45
CLOUDP-349749: useTrackInSample
carolynmcca 583ce1b
CLOUDP-349749: atlas skills comp w helper
carolynmcca ce77366
CLOUDP-349749: telemetry exports
carolynmcca 72eb33f
CLOUDP-349749: awardIcon
carolynmcca 42addf8
CLOUDP-349749: export changes
carolynmcca 5e44e46
CLOUDP-349749: package-lock
carolynmcca b1120a3
CLOUDP-349749: test fix
carolynmcca 7b77931
CLOUDP-349749: update comment
carolynmcca 40b707c
CLOUDP-349749: compass-collection tests
carolynmcca 2be9f3e
Merge branch 'main' into CLOUDP-349749
carolynmcca 0deca62
CLOUDP-349749: removing span
carolynmcca 093a05a
CLOUDP-349749: label update
carolynmcca 401e2dc
Merge branch 'main' into CLOUDP-349749
carolynmcca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
packages/compass-components/src/components/atlas-skills-banner.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React from 'react'; | ||
import { render, screen, userEvent } from '@mongodb-js/testing-library-compass'; | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
|
||
import { AtlasSkillsBanner } from './atlas-skills-banner'; | ||
|
||
describe('AtlasSkillsBanner Component', function () { | ||
const defaultProps = { | ||
ctaText: | ||
'New to MongoDB? Document modeling skills will accelerate your progress.', | ||
skillsUrl: 'https://www.mongodb.com/skills', | ||
onCloseSkillsBanner: sinon.spy(), | ||
showBanner: true, | ||
}; | ||
|
||
it('should render the banner with correct text', function () { | ||
render(<AtlasSkillsBanner {...defaultProps} />); | ||
|
||
expect( | ||
screen.getByText( | ||
'New to MongoDB? Document modeling skills will accelerate your progress.' | ||
) | ||
).to.be.visible; | ||
}); | ||
|
||
it('should render the badge with award icon', function () { | ||
render(<AtlasSkillsBanner {...defaultProps} />); | ||
|
||
// Check for the award icon | ||
const awardIcon = screen.getByLabelText('Award Icon'); | ||
expect(awardIcon).to.be.visible; | ||
}); | ||
|
||
it('should render the "Go to Skills" button with correct href', function () { | ||
render(<AtlasSkillsBanner {...defaultProps} />); | ||
|
||
const goToSkillsButton = screen.getByRole('link', { | ||
name: /go to skills/i, | ||
}); | ||
expect(goToSkillsButton).to.be.visible; | ||
expect(goToSkillsButton.getAttribute('href')).to.equal( | ||
'https://www.mongodb.com/skills' | ||
); | ||
expect(goToSkillsButton.getAttribute('target')).to.equal('_blank'); | ||
}); | ||
|
||
it('should call onCtaClick when "Go to Skills" button is clicked', function () { | ||
const onCtaClick = sinon.spy(); | ||
render(<AtlasSkillsBanner {...defaultProps} onCtaClick={onCtaClick} />); | ||
|
||
const goToSkillsButton = screen.getByRole('link', { | ||
name: /go to skills/i, | ||
}); | ||
|
||
userEvent.click(goToSkillsButton); | ||
expect(onCtaClick).to.have.been.calledOnce; | ||
}); | ||
|
||
it('should render the close button and call onCloseSkillsBanner when clicked', function () { | ||
const onCloseSkillsBanner = sinon.spy(); | ||
render( | ||
<AtlasSkillsBanner | ||
{...defaultProps} | ||
onCloseSkillsBanner={onCloseSkillsBanner} | ||
/> | ||
); | ||
|
||
const closeButton = screen.getByRole('button', { | ||
name: 'Dismiss Skills Banner', | ||
}); | ||
expect(closeButton).to.be.visible; | ||
expect(closeButton.getAttribute('title')).to.equal('Dismiss Skills Banner'); | ||
|
||
userEvent.click(closeButton); | ||
expect(onCloseSkillsBanner).to.have.been.calledOnce; | ||
}); | ||
|
||
it('should not render when showBanner is false', function () { | ||
render(<AtlasSkillsBanner {...defaultProps} showBanner={false} />); | ||
|
||
// Banner should not be visible | ||
expect( | ||
screen.queryByText( | ||
'New to MongoDB? Document modeling skills will accelerate your progress.' | ||
) | ||
).to.not.exist; | ||
expect(screen.queryByLabelText('Award Icon')).to.not.exist; | ||
expect(screen.queryByRole('link', { name: /go to skills/i })).to.not.exist; | ||
}); | ||
}); |
76 changes: 76 additions & 0 deletions
76
packages/compass-components/src/components/atlas-skills-banner.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import { css } from '@leafygreen-ui/emotion'; | ||
import IconButton from '@leafygreen-ui/icon-button'; | ||
import Badge, { Variant as BadgeVariant } from '@leafygreen-ui/badge'; | ||
import Icon from '@leafygreen-ui/icon'; | ||
import { spacing } from '@leafygreen-ui/tokens'; | ||
import Button from '@leafygreen-ui/button'; | ||
import { palette } from '@leafygreen-ui/palette'; | ||
|
||
const skillsCTAContent = css({ | ||
border: `1px ${palette.gray.light1} solid`, | ||
borderRadius: spacing[300], | ||
padding: spacing[300], | ||
paddingLeft: spacing[400], | ||
display: 'flex', | ||
width: '100%', | ||
alignItems: 'center', | ||
}); | ||
|
||
const skillsCTAText = css({ | ||
display: 'flex', | ||
alignSelf: 'center', | ||
paddingLeft: spacing[200], | ||
}); | ||
|
||
const badgeStyles = css({ | ||
padding: '0 10px', | ||
minHeight: spacing[600], | ||
}); | ||
|
||
const learnMoreBtnStyles = css({ | ||
marginLeft: spacing[200], | ||
}); | ||
|
||
const closeButtonStyles = css({ | ||
marginLeft: 'auto', | ||
}); | ||
|
||
// @experiment Skills in Atlas | Jira Epic: CLOUDP-346311 | ||
export const AtlasSkillsBanner: React.FunctionComponent<{ | ||
ctaText: string; | ||
onCloseSkillsBanner: () => void; | ||
onCtaClick?: () => void; | ||
skillsUrl: string; | ||
showBanner: boolean; | ||
}> = ({ ctaText, skillsUrl, onCloseSkillsBanner, onCtaClick, showBanner }) => { | ||
return showBanner ? ( | ||
<div className={skillsCTAContent}> | ||
<Badge variant={BadgeVariant.Green} className={badgeStyles}> | ||
<Icon glyph="Award" /> | ||
</Badge> | ||
<div className={skillsCTAText}>{ctaText}</div> | ||
|
||
<Button | ||
value="Go to Skills" | ||
size="xsmall" | ||
href={skillsUrl} | ||
target="_blank" | ||
onClick={onCtaClick} | ||
leftGlyph={<Icon glyph="OpenNewTab"></Icon>} | ||
title="Go to Skills" | ||
className={learnMoreBtnStyles} | ||
> | ||
Go to Skills | ||
</Button> | ||
<IconButton | ||
className={closeButtonStyles} | ||
title="Dismiss Skills Banner" | ||
aria-label="Dismiss Skills Banner" | ||
onClick={onCloseSkillsBanner} | ||
> | ||
<Icon glyph="X" /> | ||
</IconButton> | ||
</div> | ||
) : null; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ExperimentTestGroup, ExperimentTestName } from './growth-experiments'; | ||
import { useAssignment, useTrackInSample } from './experimentation-provider'; | ||
|
||
export enum SkillsBannerContextEnum { | ||
Documents = 'documents', | ||
Aggregation = 'aggregation', | ||
Indexes = 'indexes', | ||
Schema = 'schema', | ||
} | ||
|
||
// @experiment Skills in Atlas | Jira Epic: CLOUDP-346311 | ||
export const useAtlasSkillsBanner = (context: SkillsBannerContextEnum) => { | ||
const atlasSkillsAssignment = useAssignment( | ||
ExperimentTestName.atlasSkills, | ||
false | ||
); | ||
|
||
const isInSkillsVariant = | ||
atlasSkillsAssignment?.assignment?.assignmentData?.variant === | ||
ExperimentTestGroup.atlasSkillsVariant; | ||
|
||
// Track users who are assigned to the skills experiment (variant or control) | ||
useTrackInSample(ExperimentTestName.atlasSkills, !!atlasSkillsAssignment, { | ||
screen: context, | ||
}); | ||
|
||
return { | ||
shouldShowAtlasSkillsBanner: isInSkillsVariant, | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
export enum ExperimentTestName { | ||
earlyJourneyIndexesGuidance = 'EARLY_JOURNEY_INDEXES_GUIDANCE_20250328', | ||
mockDataGenerator = 'MOCK_DATA_GENERATOR_20251001', | ||
atlasSkills = 'ATLAS_SKILLS_EXPERIMENT_20251007', | ||
} | ||
|
||
export enum ExperimentTestGroup { | ||
mockDataGeneratorVariant = 'mockDataGeneratorVariant', | ||
mockDataGeneratorControl = 'mockDataGeneratorControl', | ||
atlasSkillsVariant = 'atlasSkillsVariant', | ||
atlasSkillsControl = 'atlasSkillsControl', | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally we also track
is in sample
when the user is in the control as well. Is there a reason you're limiting to the variant here?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll fire if they're in variant or control - it won't fire if atlasSkillsAssignment is null or undefined
I'll update comment since it's confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,
and banner would be shown
is incorrect then right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah updated comment!