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

In-app Announcement popup #2318

Merged
merged 16 commits into from Oct 31, 2023
Merged

In-app Announcement popup #2318

merged 16 commits into from Oct 31, 2023

Conversation

finnar-bin
Copy link
Contributor

Closes #2306

Preview

announcement

@finnar-bin finnar-bin added the enhancement Improvement to an existing feature label Oct 31, 2023
@finnar-bin finnar-bin self-assigned this Oct 31, 2023

export const announcementsApi = createApi({
reducerPath: "announcementsApi",
baseQuery: fetchBaseQuery({ baseUrl: "https://www.zesty.io/-/instant/" }),
Copy link
Contributor

Choose a reason for hiding this comment

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

This base url seems very generic yet it is supporting a specific service.

Let's make this a more general service and tie this less with announcements.

If we want we can keep the getAnouncment query to maintain response structure but it should have hard coded values to announcement model

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Renamed service to marketingApi so that it's more generic towards any marketing-related queries. Also made the query have the model zuid by default instead of passing it as a prop

justifyContent="center"
boxSizing="border-box"
>
<Box
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not have this be an a tag and avoid the onClick handler?

@@ -44,3 +44,12 @@ Cypress.Commands.add("assertClipboardValue", (value) => {
Cypress.Commands.add("getBySelector", (selector, ...args) => {
return cy.get(`[data-cy=${selector}]`, ...args);
});

Cypress.Commands.add("blockAnnouncements", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it would need to be applied to every test in order to avoid it interrupting them. Can we apply it by default and then manual exclude if needing to test the announcement behavior? This way we don't have to remember to add it for every new test.

<Box
component="img"
alt="announcement-banner-image"
src={announcementData?.feature_image?.data[0]?.url ?? ""}
Copy link
Contributor

Choose a reason for hiding this comment

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

This URL should contain width and height parameters that match the rendered size.

boxSizing="border-box"
>
<Box
component="img"
Copy link
Contributor

Choose a reason for hiding this comment

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

This element should contain width and height attributes that match the image dimensions

Copy link

Choose a reason for hiding this comment

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

Not sure if this comment may help and I could be wrong. The way we have configured it, all aspect ratios and sizes will always be respected no matter what image resolution is uploaded. I have already tested it for the same. We are using image contain fit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its not a concern of ratio but of performance


export const marketingApi = createApi({
reducerPath: "marketingApi",
baseQuery: fetchBaseQuery({ baseUrl: "https://www.zesty.io/" }),
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a configuration value that can be different within different environments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shrunyan are you suggesting that this should be pointing to the dev env of the marketing instance if manager-ui is being ran on the dev env, same for stage?

endpoints: (builder) => ({
// Get announcements via instant api from the marketing instance
getAnnouncements: builder.query<Announcement[], void>({
query: () => "/-/instant/6-90fbdcadfc-4lc0s5.json",
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be a configuration value that can be different within different environments

Copy link
Contributor

Choose a reason for hiding this comment

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

This ones debatable on whether it should be a config value

@shrunyan shrunyan merged commit 8df190e into master Oct 31, 2023
1 check failed
@shrunyan shrunyan deleted the feature/in-app-announcement branch October 31, 2023 22:33

const unreadAnnouncements = useMemo(() => {
if (announcements?.length) {
return announcements
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently if there are multiple announcements in the publish range the pop-up will cycle through them as you ignore them. It should only show the single latest announcement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shrunyan oohh, I thought it was supposed to show everything starting from the latest announcement first.


export const InAppAnnouncement = () => {
const [activeAnnouncementIndex, setActiveAnnouncementIndex] = useState(0);
const [readAnnouncements, setReadAnnouncements] = useLocalStorage(
Copy link
Contributor

Choose a reason for hiding this comment

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

Local storage isolates data by origin. This is causing the pop-up to show on ever instance a user visits. We want to avoid that and only show the announcement once per user. 2 alternatives I can think of are using a cookie or storing it to the users account

Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In-App Product Onboarding Announcement Pop Up
4 participants