-
Notifications
You must be signed in to change notification settings - Fork 789
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
Make data limits a permanent feature #698
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a7fd50c
Move data limits endpoints to /server; redirect experimental endpoints
alalamav 6ad2e2c
Increase shadowbox version
alalamav 64caffc
Move data limits UI out of experiments section
alalamav 654547e
Configure data limits path based on shadowbox version
alalamav d379d31
Remove data limits availability date and associated surveys
alalamav cb67732
Redirect with 308
alalamav 40b529b
Merge branch 'master' into alalama-permanent-data-limits
alalamav f1c5e8d
Lint
alalamav b89ca61
Update permanent data limits version to v1.4.0
alalamav 482152e
Display feature metrics disclaimer when enabling data limits
alalamav 66da29b
Fix typo
alalamav 1397e50
Display disclaimer if user has not seen the data limits help bubble
alalamav f84e99c
Improve disclaimer language
alalamav 765268e
Address review comments
alalamav ae906a3
Feature metrics: s/consent/notification
alalamav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import * as digitalocean_api from '../cloud/digitalocean_api'; | |
import * as errors from '../infrastructure/errors'; | ||
import {sleep} from '../infrastructure/sleep'; | ||
import * as server from '../model/server'; | ||
import {Surveys} from '../model/survey'; | ||
|
||
import {TokenManager} from './digitalocean_oauth'; | ||
import * as digitalocean_server from './digitalocean_server'; | ||
|
@@ -37,8 +36,6 @@ const UNUSED_DIGITALOCEAN_REFERRAL_CODE = '5ddb4219b716'; | |
const CHANGE_KEYS_PORT_VERSION = '1.0.0'; | ||
const DATA_LIMITS_VERSION = '1.1.0'; | ||
const CHANGE_HOSTNAME_VERSION = '1.2.0'; | ||
// Date by which the data limits feature experiment will be permanently added or removed. | ||
export const DATA_LIMITS_AVAILABILITY_DATE = new Date('2020-06-02'); | ||
const MAX_ACCESS_KEY_DATA_LIMIT_BYTES = 50 * (10 ** 9); // 50GB | ||
|
||
function dataLimitToDisplayDataAmount(limit: server.DataLimit): DisplayDataAmount|null { | ||
|
@@ -88,6 +85,18 @@ async function computeDefaultAccessKeyDataLimit( | |
} | ||
} | ||
|
||
// Returns whether we should display a disclaimer for the updated feature metrics data collection | ||
// policy. We only show it if all the following conditions are true: | ||
// - data limits feature is not already enabled | ||
// - opt-in metrics are enabled | ||
// - user has not previously seen the data limits help bubble | ||
// - user has not previously seen this disclaimer | ||
function shouldShowFeatureMetricsDisclaimer(server: server.Server): boolean { | ||
return !server.getAccessKeyDataLimit() && server.getMetricsEnabled() && | ||
!window.localStorage.getItem('dataLimitsHelpBubble-dismissed') && | ||
!window.localStorage.getItem('dataLimits-feature-collection-disclaimer'); | ||
} | ||
|
||
async function showHelpBubblesOnce(serverView: ServerView) { | ||
if (!window.localStorage.getItem('addAccessKeyHelpBubble-dismissed')) { | ||
await serverView.showAddAccessKeyHelpBubble(); | ||
|
@@ -131,7 +140,7 @@ export class App { | |
private createDigitalOceanServerRepository: DigitalOceanServerRepositoryFactory, | ||
private manualServerRepository: server.ManualServerRepository, | ||
private displayServerRepository: DisplayServerRepository, | ||
private digitalOceanTokenManager: TokenManager, private surveys: Surveys) { | ||
private digitalOceanTokenManager: TokenManager) { | ||
appRoot.setAttribute('outline-version', this.version); | ||
|
||
appRoot.addEventListener('ConnectToDigitalOcean', (event: CustomEvent) => { | ||
|
@@ -838,10 +847,9 @@ export class App { | |
view.serverPortForNewAccessKeys = selectedServer.getPortForNewAccessKeys(); | ||
view.serverCreationDate = localizeDate(selectedServer.getCreatedDate(), this.appRoot.language); | ||
view.serverVersion = selectedServer.getVersion(); | ||
view.dataLimitsAvailabilityDate = | ||
localizeDate(DATA_LIMITS_AVAILABILITY_DATE, this.appRoot.language); | ||
view.accessKeyDataLimit = dataLimitToDisplayDataAmount(selectedServer.getAccessKeyDataLimit()); | ||
view.isAccessKeyDataLimitEnabled = !!view.accessKeyDataLimit; | ||
view.shouldShowFeatureMetricsDisclaimer = shouldShowFeatureMetricsDisclaimer(selectedServer); | ||
|
||
const version = this.selectedServer.getVersion(); | ||
if (version) { | ||
|
@@ -1029,7 +1037,9 @@ export class App { | |
this.appRoot.showNotification(this.appRoot.localize('saved')); | ||
serverView.accessKeyDataLimit = dataLimitToDisplayDataAmount(limit); | ||
this.refreshTransferStats(this.selectedServer, serverView); | ||
this.surveys.presentDataLimitsEnabledSurvey(); | ||
// Don't display the feature collection disclaimer anymore. | ||
serverView.shouldShowFeatureMetricsDisclaimer = false; | ||
window.localStorage.setItem('dataLimits-feature-collection-disclaimer', 'true'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} catch (error) { | ||
console.error(`Failed to set access key data limit: ${error}`); | ||
this.appRoot.showError(this.appRoot.localize('error-set-data-limit')); | ||
|
@@ -1045,7 +1055,6 @@ export class App { | |
await this.selectedServer.removeAccessKeyDataLimit(); | ||
this.appRoot.showNotification(this.appRoot.localize('saved')); | ||
this.refreshTransferStats(this.selectedServer, serverView); | ||
this.surveys.presentDataLimitsDisabledSurvey(); | ||
} catch (error) { | ||
console.error(`Failed to remove access key data limit: ${error}`); | ||
this.appRoot.showError(this.appRoot.localize('error-remove-data-limit')); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Let's have a
hasConsentForFeatureMetrics
or something along those lines. I think it's easier to reason about than having to understand the flows.It should return
dataLimits-feature-collection-consent
||dataLimitsHelpBubble-dismissed
. Notice it's independent of the server.Then you can have
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.
Done.