Log: fix log event POST format

This commit is contained in:
Andrew Head 2019-02-23 09:29:41 -08:00
Родитель ac5048ac60
Коммит b076913b10
2 изменённых файлов: 10 добавлений и 7 удалений

Просмотреть файл

@ -1,6 +1,6 @@
{ {
"name": "@andrewhead/gather", "name": "gather",
"version": "0.2.0", "version": "0.2.1",
"description": "Tools for cleaning and recovering code in Jupyter Lab", "description": "Tools for cleaning and recovering code in Jupyter Lab",
"author": "", "author": "",
"main": "lib/lab/index.js", "main": "lib/lab/index.js",

Просмотреть файл

@ -95,13 +95,16 @@ export function log(eventName: string, data?: any) {
} }
} }
// If there is any sensitive data to be logged, it should first be cleaned through a
// `toJSON` method defined on a class, or manually before passing it into this method.
// Earlier, we used the replacer argument to JSON.stringify, but it takes too much time
// to apply replacers to every value in the resulting JSON.
postData.data = JSON.stringify(postData.data);
// Submit data to logger endpoint. // Submit data to logger endpoint.
_ajaxCaller.ajax(LOG_ENDPOINT + "/save", { _ajaxCaller.ajax(LOG_ENDPOINT + "/save", {
// If there is any sensitive data to be logged, it should first be cleaned through a
// `toJSON` method defined on a class, or manually before passing it into this method. data: JSON.parse(JSON.stringify(postData)),
// Earlier, we used the replacer argument to JSON.stringify, but it takes too much time
// to apply replacers to every value in the resulting JSON.
data: JSON.stringify(postData),
method: "POST", method: "POST",
error: (_: any, textStatus: string, errorThrown: string) => { error: (_: any, textStatus: string, errorThrown: string) => {
console.error("Failed to log", textStatus, errorThrown); console.error("Failed to log", textStatus, errorThrown);