mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
Log error on web service start when hashedEmailSalt not set
GitOrigin-RevId: 67473de85d869b56aa1321391b03ddcceb95346b
This commit is contained in:
@@ -9,6 +9,15 @@ const { expressify } = require('@overleaf/promise-utils')
|
||||
const logger = require('@overleaf/logger')
|
||||
const { createHash } = require('crypto')
|
||||
|
||||
if (
|
||||
Settings.analytics?.enabled &&
|
||||
process.env.NODE_ENV !== 'test' &&
|
||||
!Settings.analytics?.hashedEmailSalt
|
||||
) {
|
||||
// This isn't important enough to crash the app, but we want to record the error
|
||||
logger.error({}, 'Settings.analytics.hashedEmailSalt should be set')
|
||||
}
|
||||
|
||||
const analyticsEventsQueue = Queues.getQueue('analytics-events')
|
||||
const analyticsEditingSessionsQueue = Queues.getQueue(
|
||||
'analytics-editing-sessions'
|
||||
@@ -218,10 +227,8 @@ function registerEmailChange({
|
||||
}) {
|
||||
Metrics.analyticsQueue.inc({ status: 'adding', event_type: 'email-change' })
|
||||
|
||||
const salt = Settings.analytics?.hashedEmailSalt ?? ''
|
||||
|
||||
const hashedEmail = createHash('sha256')
|
||||
.update(`${email}${salt}`)
|
||||
.update(`${email}${Settings.analytics?.hashedEmailSalt}`)
|
||||
.digest('hex')
|
||||
|
||||
analyticsEmailChangeQueue
|
||||
|
||||
@@ -88,6 +88,7 @@ const overrides = {
|
||||
|
||||
analytics: {
|
||||
enabled: true,
|
||||
hashedEmailSalt: 'acceptance-test-salt',
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,9 @@ describe('AnalyticsManager', function () {
|
||||
this.analyticsId = 'bccd308c-5d72-426e-a106-662e88557795'
|
||||
this.AnalyticsManager = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
'@overleaf/settings': {},
|
||||
'@overleaf/settings': {
|
||||
analytics: { hashedEmailSalt: 'test-salt' },
|
||||
},
|
||||
'../../infrastructure/Queues': {
|
||||
getQueue: queueName => {
|
||||
switch (queueName) {
|
||||
|
||||
Reference in New Issue
Block a user