record both project-created and project-imported events

This commit is contained in:
Tim Alby 2018-03-06 18:26:25 -05:00
parent 4b291fab2a
commit d5109d22d2

View file

@ -26,11 +26,21 @@ module.exports = ProjectCreationHandler =
return callback(error) if error? return callback(error) if error?
logger.log owner_id:owner_id, projectName:projectName, "creating blank project" logger.log owner_id:owner_id, projectName:projectName, "creating blank project"
if projectHistoryId? if projectHistoryId?
ProjectCreationHandler._createBlankProject owner_id, projectName, projectHistoryId, callback ProjectCreationHandler._createBlankProject owner_id, projectName, projectHistoryId, (error, project) ->
return callback(error) if error?
AnalyticsManger.recordEvent(
owner_id, 'project-imported', { projectId: project._id, projectHistoryId: projectHistoryId }
)
callback(error, project)
else else
HistoryManager.initializeProject (error, history) -> HistoryManager.initializeProject (error, history) ->
return callback(error) if error? return callback(error) if error?
ProjectCreationHandler._createBlankProject owner_id, projectName, history?.overleaf_id, callback ProjectCreationHandler._createBlankProject owner_id, projectName, history?.overleaf_id, (error, project) ->
return callback(error) if error?
AnalyticsManger.recordEvent(
owner_id, 'project-created', { projectId: project._id }
)
callback(error, project)
_createBlankProject : (owner_id, projectName, projectHistoryId, callback = (error, project) ->)-> _createBlankProject : (owner_id, projectName, projectHistoryId, callback = (error, project) ->)->
rootFolder = new Folder {'name':'rootFolder'} rootFolder = new Folder {'name':'rootFolder'}
@ -47,9 +57,6 @@ module.exports = ProjectCreationHandler =
project.spellCheckLanguage = user.ace.spellCheckLanguage project.spellCheckLanguage = user.ace.spellCheckLanguage
project.save (err)-> project.save (err)->
return callback(err) if err? return callback(err) if err?
AnalyticsManger.recordEvent(
owner_id, 'project-created', { projectId: project._id }
)
callback err, project callback err, project
createBasicProject : (owner_id, projectName, callback = (error, project) ->)-> createBasicProject : (owner_id, projectName, callback = (error, project) ->)->