slanatech/swagger-stats

Cannot upload to elk and Built-In API Telemetry

Closed this issue · 0 comments

request example:

{
    
    "type": "pushQuestionnaire",
    "session_user_id": "153xxxx",
    "page_id": "62435xxxx",
    "email": "1dds@qq.com",
    "skillId": "5a45998cxxx0",
    "access_token": "eyJhbGciOiJIUzI1Nixxxx",
    "prechat_survey": [
        "New question|",
        "How can we help you?|Versandinformationen (Vorverkauf)",
        "Email Address*|sdf@qq.com",
        "What is your name?*|士大夫"
    ],
    "plat":{
    	"handler":"ac936992-2cc1-429c-bd4f-ad0d1846db55",
    	"msgid":"3629"
    }
}

Cannot upload to elk and Built-In API Telemetry

TypeError: Cannot read property 'handler' of undefined
swsInterface.js:99
message:"Cannot read property 'handler' of undefined"
stack:"TypeError: Cannot read property 'handler' of undefined\n    at Object.module.exports.swsStringRecursive (F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsUtil.js:217:57)\n    at Object.module.exports.swsStringRecursive (F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsUtil.js:217:32)\n    at swsProcessor.collectRequestResponseData (F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsProcessor.js:264:17)\n    at swsProcessor.processResponse (F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsProcessor.js:372:20)\n    at handleResponseFinished (F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsInterface.js:97:19)\n    at ServerResponse.<anonymous> (F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsInterface.js:90:9)\n    at emitNone (events.js:111:20)\n    at ServerResponse.emit (events.js:208:7)\n    at onFinish (_http_outgoing.js:720:10)\n    at _combinedTickCallback (internal/process/next_tick.js:131:7)\n    at process._tickCallback (internal/process/next_tick.js:180:9)"
__proto__:Error {constructor: , name: "TypeError", message: "", …}

I found that a place needs to be changed to solve it.
F:\SVN\即时通讯\zc\share2.0\node_modules\swagger-stats\lib\swsUtil.js


// returns object key values as string recursively
module.exports.swsStringRecursive = function(output, val) {
    if (typeof val === "object" && !Array.isArray(val)) {
        for (var key in val) {
            // output[key] = this.swsStringRecursive(output[key], val[key]);
            // output[key] = this.swsStringRecursive(output[key] || val[key], val[key]);
            output[key] = JSON.stringify(val[key]);
        }
    } else {
        output = this.swsStringValue(val);
    }

    return output;
}