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 HaTS stuff to localStorage #8040

Merged
merged 6 commits into from
Jun 10, 2021

Conversation

beyackle
Copy link
Contributor

@beyackle beyackle commented Jun 9, 2021

Description

This addresses the issue of storing things on the client so we know when to display the HaTS survey; it will keep track, in local storage, of the number of unique calendar days that a user uses Composer. If this exceeds 5, it sets a flag in the Recoil store that can be read in a later step (to be written) to see if we should display the survey. Once the survey has been taken, we can use a similar mechanism to store the latest date the survey was taken and make sure we aren't showing the link to a user who's taken it in the last 90 days.

Task Item

refs #8029

Screenshots

Not really a UI change, but here are the (currently) two new values in localStorage.
image

@@ -38,6 +45,19 @@ export const App: React.FC = () => {
ipcRenderer?.on('cleanup', (_event) => {
performAppCleanupOnQuit();
});

let days = surveyStorage.get('days', 0);
Copy link
Collaborator

@tdurnford tdurnford Jun 9, 2021

Choose a reason for hiding this comment

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

All of this logic should be handled in the setSurveyEligibility dispatcher. You should just call the dispatcher on mount and let it determine how and if it should update the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. I'll fix that.

@@ -20,7 +20,9 @@
"url-parse": "^1.5.1",
"underscore": "^1.12.1",
"dns-packet": "^1.3.4",
"json-ptr": "^2.1"
"json-ptr": "^2.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are these dependencies necessary? They seem out of scope for this PR.

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 were causing a security alert, but I've now handled that in a separate PR which has merged already (so these can/will go away on a rebase).

@@ -525,3 +525,11 @@ export const defaultTeamsManifest: TeamsManifest = {

export const defaultBotPort = 3979;
export const defaultBotEndpoint = `http://localhost:${defaultBotPort}/api/messages`;

const DAYS = 1000 * 60 * 60 * 24; // ms per day
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const DAYS = 1000 * 60 * 60 * 24; // ms per day
const MS_PER_DAY = 1000 * 60 * 60 * 24;

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 thought about that, but I like the way it makes "90 * DAYS" legible a few lines farther down.

@beyackle beyackle merged this pull request into feature/hats-survey Jun 10, 2021
@beyackle beyackle deleted the beyackle/hatsData branch June 10, 2021 17:27
benbrown pushed a commit that referenced this pull request Jun 11, 2021
* add stuff to localStorage

* add stuff to localStorage

* move logic and add more checks

* Update constants.tsx
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

2 participants