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

feature: add new survey notification to design page #8155

Merged
merged 32 commits into from
Jun 24, 2021

Conversation

beyackle
Copy link
Contributor

@beyackle beyackle commented Jun 21, 2021

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

image

@beyackle beyackle changed the title Beyackle/hats usage feature: add new survey notification to design page Jun 21, 2021
@cypress
Copy link

cypress bot commented Jun 21, 2021



Test summary

16 0 1 0Flakiness 0


Run details

Project Composer
Status Passed
Commit f062b3f
Started Jun 24, 2021 5:12 PM
Ended Jun 24, 2021 5:17 PM
Duration 05:29 💡
OS Linux Ubuntu - 20.04
Browser Electron 89

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}`);
Copy link
Contributor

@srinaath srinaath Jun 22, 2021

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Collaborator

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?

mainWindow?.webContents.send('session-update', 'session-started');

if (process.env.COMPOSER_DEV_TOOLS) {
mainWindow?.webContents.openDevTools();
}

log(`Machine ID is ${machineId}`);
Copy link
Collaborator

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/types/src/shell.ts 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);
Copy link
Collaborator

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?

@@ -13,17 +13,20 @@ import { readTextFileSync, writeJsonFileSync } from './fs';

export const persistedFilePath = path.join(app.getPath('userData'), 'persisted.json');

function truncate(str: string): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Arrow function

Copy link
Contributor Author

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.

Copy link
Collaborator

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: {
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@beyackle beyackle merged commit 587700b into feature/hats-survey Jun 24, 2021
@beyackle beyackle deleted the beyackle/hatsUsage branch June 24, 2021 19:13
beyackle added a commit that referenced this pull request Jun 29, 2021
* 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
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.

None yet

3 participants