mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #2884 from overleaf/as-remove-dead-code
Remove some dead code GitOrigin-RevId: f861b0a4071f5f66a1f1052caa681799bad17153
This commit is contained in:
parent
1e4b7aeace
commit
d536e57ed8
6 changed files with 27 additions and 142 deletions
|
@ -99,7 +99,6 @@ html(
|
|||
|
||||
block content
|
||||
|
||||
div(ng-controller="AbTestController")
|
||||
- if(typeof(suppressFooter) == "undefined")
|
||||
include layout/footer
|
||||
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS103: Rewrite code to no longer use __guard__
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../base'
|
||||
import CryptoJS from 'crypto-js/md5'
|
||||
const oldKeys = [
|
||||
'sl_abt_multi_currency_editor_eu-eu',
|
||||
'sl_abt_multi_currency_eu-eu',
|
||||
'sl_abt_multi_currency_editor_eu-usd',
|
||||
'sl_abt_multi_currency_eu-usd',
|
||||
'sl_abt_trial_len_14d',
|
||||
'sl_abt_trial_len_7d',
|
||||
'sl_abt_trial_len_30d',
|
||||
'sl_utt',
|
||||
'sl_utt_trial_len',
|
||||
'sl_utt_multi_currency'
|
||||
]
|
||||
|
||||
App.factory('abTestManager', function($http, ipCookie) {
|
||||
let getABTestBucket, processTestWithStep
|
||||
_.each(oldKeys, oldKey => ipCookie.remove(oldKey))
|
||||
|
||||
const _buildCookieKey = function(testName, bucket) {
|
||||
const key = `sl_abt_${testName}_${bucket}`
|
||||
return key
|
||||
}
|
||||
|
||||
const _getTestCookie = function(testName, bucket) {
|
||||
const cookieKey = _buildCookieKey(testName, bucket)
|
||||
const cookie = ipCookie(cookieKey)
|
||||
return cookie
|
||||
}
|
||||
|
||||
const _persistCookieStep = function(testName, bucket, newStep) {
|
||||
const cookieKey = _buildCookieKey(testName, bucket)
|
||||
ipCookie(cookieKey, { step: newStep }, { expires: 100, path: '/' })
|
||||
return ga(
|
||||
'send',
|
||||
'event',
|
||||
'ab_tests',
|
||||
`${testName}:${bucket}`,
|
||||
`step-${newStep}`
|
||||
)
|
||||
}
|
||||
|
||||
const _checkIfStepIsNext = function(cookieStep, newStep) {
|
||||
if (cookieStep == null && newStep !== 0) {
|
||||
return false
|
||||
} else if (newStep === 0) {
|
||||
return true
|
||||
} else if (cookieStep + 1 === newStep) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const _getUsersHash = function(testName) {
|
||||
const sl_user_test_token = `sl_utt_${testName}`
|
||||
let user_uuid = ipCookie(sl_user_test_token)
|
||||
if (user_uuid == null) {
|
||||
user_uuid = Math.random()
|
||||
ipCookie(sl_user_test_token, user_uuid, { expires: 365, path: '/' })
|
||||
}
|
||||
const hash = CryptoJS(`${user_uuid}:${testName}`)
|
||||
return hash
|
||||
}
|
||||
|
||||
return {
|
||||
processTestWithStep: (processTestWithStep = function(
|
||||
testName,
|
||||
bucket,
|
||||
newStep
|
||||
) {
|
||||
const currentCookieStep = __guard__(
|
||||
_getTestCookie(testName, bucket),
|
||||
x => x.step
|
||||
)
|
||||
if (_checkIfStepIsNext(currentCookieStep, newStep)) {
|
||||
return _persistCookieStep(testName, bucket, newStep)
|
||||
}
|
||||
}),
|
||||
|
||||
getABTestBucket: (getABTestBucket = function(test_name, buckets) {
|
||||
const hash = _getUsersHash(test_name)
|
||||
const bucketIndex =
|
||||
parseInt(hash.toString().slice(0, 2), 16) %
|
||||
((buckets != null ? buckets.length : undefined) || 2)
|
||||
return buckets[bucketIndex]
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export default App.controller('AbTestController', function(
|
||||
$scope,
|
||||
abTestManager
|
||||
) {
|
||||
const testKeys = _.keys(window.ab)
|
||||
|
||||
return _.each(window.ab, event =>
|
||||
abTestManager.processTestWithStep(event.testName, event.bucket, event.step)
|
||||
)
|
||||
})
|
||||
|
||||
function __guard__(value, transform) {
|
||||
return typeof value !== 'undefined' && value !== null
|
||||
? transform(value)
|
||||
: undefined
|
||||
}
|
|
@ -40,7 +40,6 @@ import './ide/wordcount/index'
|
|||
import './ide/directives/layout'
|
||||
import './ide/directives/validFile'
|
||||
import './ide/services/ide'
|
||||
import './analytics/AbTestingManager'
|
||||
import './directives/focus'
|
||||
import './directives/fineUpload'
|
||||
import './directives/scroll'
|
||||
|
|
|
@ -35,7 +35,6 @@ import './main/affiliations/factories/UserAffiliationsDataService'
|
|||
import './main/oauth/controllers/UserOauthController'
|
||||
import './main/keys'
|
||||
import './main/importing'
|
||||
import './analytics/AbTestingManager'
|
||||
import './directives/autoSubmitForm'
|
||||
import './directives/asyncForm'
|
||||
import './directives/complexPassword'
|
||||
|
|
|
@ -195,7 +195,6 @@ App.controller('PlansController', function(
|
|||
MultiCurrencyPricing,
|
||||
$http,
|
||||
$filter,
|
||||
ipCookie,
|
||||
$location
|
||||
) {
|
||||
let switchEvent
|
||||
|
|
|
@ -1,24 +1,33 @@
|
|||
/* eslint-disable
|
||||
max-len,
|
||||
no-return-assign,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
import App from '../base'
|
||||
|
||||
export default App.controller('TranslationsPopupController', function(
|
||||
App.controller('TranslationsPopupController', function(
|
||||
$scope,
|
||||
ipCookie
|
||||
ipCookie,
|
||||
localStorage
|
||||
) {
|
||||
$scope.hidei18nNotification = ipCookie('hidei18nNotification')
|
||||
function getStoredDismissal() {
|
||||
let localStore = localStorage('hide-i18n-notification')
|
||||
|
||||
return ($scope.dismiss = function() {
|
||||
ipCookie('hidei18nNotification', true, { expires: 180 })
|
||||
return ($scope.hidei18nNotification = ipCookie('hidei18nNotification'))
|
||||
})
|
||||
if (localStore === null) {
|
||||
// Not stored in localStorage, check cookie
|
||||
let cookieStore = ipCookie('hidei18nNotification')
|
||||
|
||||
// If stored in cookie, set on localStorage for forwards compat
|
||||
if (cookieStore) {
|
||||
localStorage('hide-i18n-notification', cookieStore)
|
||||
ipCookie.remove('hidei18nNotification')
|
||||
}
|
||||
|
||||
return cookieStore
|
||||
}
|
||||
|
||||
return localStore
|
||||
}
|
||||
|
||||
$scope.hidei18nNotification = getStoredDismissal()
|
||||
|
||||
$scope.dismiss = function() {
|
||||
localStorage('hide-i18n-notification', true)
|
||||
$scope.hidei18nNotification = true
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue