-
Notifications
You must be signed in to change notification settings - Fork 366
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
feature: add new survey notification to design page #8155
Conversation
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
mainWindow?.webContents.send('session-update', 'session-started'); | ||
|
||
if (process.env.COMPOSER_DEV_TOOLS) { | ||
mainWindow?.webContents.openDevTools(); | ||
} | ||
|
||
log(`Machine ID is ${machineId}`); |
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.
Is this log required? Maybe only in dev env.
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's not required, but it's useful - this goes into the debug log which users won't see unless they're running via the console anyway.
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.
Logs are only visible from the terminal, so I think it's fine.
Composer/packages/client/src/components/Notifications/useSurveyNotification.tsx
Outdated
Show resolved
Hide resolved
Composer/packages/client/src/components/Notifications/useSurveyNotification.tsx
Outdated
Show resolved
Hide resolved
@@ -42,6 +43,10 @@ export const App: React.FC = () => { | |||
ipcRenderer?.on('cleanup', (_event) => { | |||
performAppCleanupOnQuit(); | |||
}); | |||
|
|||
ipcRenderer?.on('machine-info', (_event, info) => { | |||
setMachineInfo(info); |
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 looks like you are using the machine info only inside the useSurveyNotification hook. If so, why do we need to create a recoil state for it. You can just use the ipcRenderer.on
inside the hook. Ex useInitializeLoger.ts
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.
I was trying to make this work last week, but it runs into annoying race conditions where the message handler isn't initialized before the message gets sent and so nothing gets through. Using the Recoil store lets us put the machine info down somewhere whenever we receive it and then count on it being available when we need it.
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.
Makes sense to usethe recoil state unless the hook can be registered in app.tsx
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.
Can you explain the race condition a bit more. I'm also confused why we can't just initialize the survey here when the event is received? If the message handler doesn't get initialized before the message is sent, we would never get the message, right?
Composer/packages/client/src/components/Notifications/NotificationCard.tsx
Show resolved
Hide resolved
Composer/packages/client/src/components/Notifications/NotificationCard.tsx
Show resolved
Hide resolved
Composer/packages/client/src/components/Notifications/NotificationCard.tsx
Show resolved
Hide resolved
mainWindow?.webContents.send('session-update', 'session-started'); | ||
|
||
if (process.env.COMPOSER_DEV_TOOLS) { | ||
mainWindow?.webContents.openDevTools(); | ||
} | ||
|
||
log(`Machine ID is ${machineId}`); |
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.
Logs are only visible from the terminal, so I think it's fine.
@@ -42,6 +43,10 @@ export const App: React.FC = () => { | |||
ipcRenderer?.on('cleanup', (_event) => { | |||
performAppCleanupOnQuit(); | |||
}); | |||
|
|||
ipcRenderer?.on('machine-info', (_event, info) => { | |||
setMachineInfo(info); |
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.
Can you explain the race condition a bit more. I'm also confused why we can't just initialize the survey here when the event is received? If the message handler doesn't get initialized before the message is sent, we would never get the message, right?
Composer/packages/client/src/components/Notifications/useSurveyNotification.tsx
Outdated
Show resolved
Hide resolved
Composer/packages/client/src/components/Notifications/useSurveyNotification.tsx
Outdated
Show resolved
Hide resolved
@@ -13,17 +13,20 @@ import { readTextFileSync, writeJsonFileSync } from './fs'; | |||
|
|||
export const persistedFilePath = path.join(app.getPath('userData'), 'persisted.json'); | |||
|
|||
function truncate(str: string): string { |
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.
Arrow function
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.
I don't see what that would get us here. This isn't inside a component that gets re-rendered, this isn't exported anywhere, it's just a simple utility function that belongs to this one file.
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.
The other functions in this file use arrow functions. Best to be consistent. More of a nit.
@@ -35,7 +35,7 @@ const templatePayload: TemplateRefPayload = { | |||
const propertiesPayload: PropertyRefPayload = { | |||
kind: 'property', | |||
data: { |
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.
Why are these tests being changed? They're not related to this work at all.
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.
They're being changed because they were failing mysteriously. I feel like the word "this" is too common to be used as a name and search target in tests like this without false positives happening.
* feature: add HaTS stuff to localStorage (#8040) * add stuff to localStorage * add stuff to localStorage * move logic and add more checks * Update constants.tsx * create prototype card * add congratulation notification * feature: show survey card on Home page (#8078) * add custom style * Update Publish.tsx * display card on Home page * Update constants.tsx * Update shell.ts * Update Home.tsx * move survey into separate component * get more info automatically * move URL into constant * move more props around * Update constants.tsx * turn non-rendering component into hook * move card to design page * start adding ipcRenderer stuff * update card design * get machineID and stash in Recoil * read OS and place in URL * add spacer to notification card * better notification styling * fix constants and typercheck error * Revert "feature: show survey card on Home page (#8078)" (#8149) This reverts commit 5b9f164. * feature: add new survey notification to design page (#8155) * add custom style * Update Publish.tsx * display card on Home page * Update constants.tsx * Update shell.ts * Update Home.tsx * move survey into separate component * get more info automatically * move URL into constant * move more props around * Update constants.tsx * turn non-rendering component into hook * move card to design page * start adding ipcRenderer stuff * update card design * get machineID and stash in Recoil * read OS and place in URL * add spacer to notification card * better notification styling * fix constants and typercheck error * fixes from PR * fix card alignment and make aka.ms URL * remove redundant prop * use query-string package to generate link * move MAC truncation to electron server * add fixes from CR and machineID truncation * fix typechecking * Update ToolbarButtonMenu.test.tsx * Update App.tsx * add custom onDismiss to cards * restore delete-on-click for links * Update NotificationCard.tsx * add comments from PR * revert ToolbarButtonMenu test * Update NotificationCard.tsx * add comment about truncation
Description
[This is a redo of #8078, which was closed by mistake]
This adds the logic to show a notification on the home screen prompting the user to take a survey. This also adds some new notification types and a fairly generic way to track a user's usage of various features inside the browser's own local storage, which will be useful for other possible business cases (like extending the conditions surveys pop up in, or cosmetic things like Achievements).
Task Item
refs #8029
[will close when this merges into main]
Screenshots