Skip to content

Commit

Permalink
EDD-47: Users should be prompted about submitting their usage metrics (
Browse files Browse the repository at this point in the history
…#35)

* EDD-47 Adding Metrics prompt

* EDD-47 Updating tests

* EDD-47 Preventing users from setting their preference to Select Option

* EDD-47 Test fix

* EDD-47 styling

* EDD-47 Styling

* EDD-47 Adding Settings tests

* EDD-47 Adjusting migration script

* EDD-47 Toast adjustments

* EDD-47 Moving toast initializer

* EDD-47: Add some tests to layout.jsx for metrics

* EDD-47: fix test needs await call

* EDD-47: Adding test assertions for metrics toast options

* EDD-47 Changing allowedMetrics from string to bool

* EDD-47 Updating tests

* EDD-47 syntax change

* Update src/app/dialogs/Settings/Settings.jsx

Co-authored-by: Ed Olivares <[email protected]>

* EDD-47 Cleaning up method names

* EDD-47: Consolidate db migrations

* EDD-47: fix setting types to be consistent

* EDD-47: Settings shows the current value for whether user has accepted metrics or not

* EDD-47 Updating test for consistency

* EDD-47 Updating test

---------

Co-authored-by: drewpesall <[email protected]>
Co-authored-by: Ed Olivares <[email protected]>
  • Loading branch information
3 people authored Jan 3, 2024
1 parent bb7484c commit abf1d61
Show file tree
Hide file tree
Showing 37 changed files with 671 additions and 86 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports.up = (knex) => knex.schema.table('preferences', (table) => {
table.boolean('allowMetrics').defaultTo(false)
table.boolean('hasMetricsPreferenceBeenSet').defaultTo(false)
})

exports.down = (knex) => knex.schema.table('preferences', (table) => {
table.dropColumn('allowMetrics')
table.dropColumn('hasMetricsPreferenceBeenSet')
})
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "earthdata-download",
"version": "0.1.2",
"version": "0.1.3",
"description": "Earthdata Download is a cross-platform download manager designed to improve how users download Earth Science data. It accepts lists of files from applications like Earthdata Search (https://search.earthdata.nasa.gov/) and enables clients to offer users a streamlined experience when downloading files from their browser.",
"repository": "nasa/earthdata-download",
"homepage": "https://github.com/nasa/earthdata-download#readme",
Expand Down
71 changes: 69 additions & 2 deletions src/app/components/Layout/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
FaCog,
FaDownload,
FaExclamationCircle,
FaSignInAlt
FaSignInAlt,
FaCheck,
FaBan
} from 'react-icons/fa'
import {
VscChromeRestore,
Expand Down Expand Up @@ -62,6 +64,8 @@ const Layout = () => {
maximizeWindow,
minimizeWindow,
setDownloadLocation,
setPreferenceFieldValue,
getPreferenceFieldValue,
showWaitingForEulaDialog,
showWaitingForLoginDialog,
windowsLinuxTitleBar
Expand Down Expand Up @@ -158,13 +162,76 @@ const Layout = () => {
}
}

const onInitializeDownload = (event, info) => {
const metricsToastResponder = async (selection) => {
onDismissToast('allow-metrics-id')

if (selection === 'Settings') {
setSettingsDialogIsOpen(true)

return
}

setPreferenceFieldValue({
field: 'hasMetricsPreferenceBeenSet',
value: true
})

setPreferenceFieldValue({
field: 'allowMetrics',
value: selection
})
}

const isMetricsPreferenceSet = async () => {
const hasMetricsPreferenceBeenSet = await getPreferenceFieldValue('hasMetricsPreferenceBeenSet')

return hasMetricsPreferenceBeenSet
}

const onInitializeDownload = async (event, info) => {
const {
downloadIds: newDownloadIds,
downloadLocation: newDownloadLocation,
shouldUseDefaultLocation
} = info

// Displaying Allow Metrics prompt if the user hasn't set a value
const hasMetricsPreferenceBeenSet = await isMetricsPreferenceSet()
if (!hasMetricsPreferenceBeenSet) {
addToast({
showCloseButton: false,
id: 'allow-metrics-id',
message: 'Send Anonymous Usage Data?',
variant: 'none',
actions: [
{
altText: 'Allow',
buttonText: 'Yes',
buttonProps: {
Icon: FaCheck,
onClick: () => metricsToastResponder(true)
}
},
{
altText: 'Opt-Out',
buttonText: 'No',
buttonProps: {
Icon: FaBan,
onClick: () => metricsToastResponder(false)
}
},
{
altText: 'Settings',
buttonText: 'Settings',
buttonProps: {
Icon: FaCog,
onClick: () => metricsToastResponder('Settings')
}
}
]
})
}

setDownloadIds(newDownloadIds)
setSelectedDownloadLocation(newDownloadLocation)
setUseDefaultLocation(shouldUseDefaultLocation)
Expand Down
Loading

0 comments on commit abf1d61

Please sign in to comment.