KeiserCorp / Keiser.Metrics.SDK

Keiser Metrics SDK
MIT License
3 stars 0 forks source link

Add handling for unknown errors from the server #99

Closed nerdoza closed 3 years ago

nerdoza commented 3 years ago

@ish2028, can you please provide the stack trace from Sentry that you believed was caused by this issue?

ish2028 commented 3 years ago

This is the error that appears and it's caused by a 504 from the API

{
    "event_id": "e745b98dad6d408b8c4c3bb7a448c053",
    "project": 1479867,
    "release": "keiser.metrics.facility.web@1.17.2",
    "dist": null,
    "platform": "javascript",
    "message": "",
    "datetime": "2021-06-22T09:11:32.534000Z",
    "tags": [["browser", "Chrome 91.0.4472"], ["browser.name", "Chrome"], ["environment", "production"], ["handled", "no"], ["level", "error"], ["mechanism", "onunhandledrejection"], ["os", "Windows 10"], ["os.name", "Windows"], ["release", "keiser.metrics.facility.web@1.17.2"], ["user", "ip:105.224.239.187"], ["url", "https://metrics.keiser.com/facility/app/account/dashboard/members"]],
    "_metrics": {
        "bytes.ingested.event": 3989,
        "bytes.stored.event": 10887
    },
    "breadcrumbs": {
        "values": [{
                "timestamp": 1624352460.576,
                "type": "http",
                "category": "xhr",
                "level": "info",
                "data": {
                    "method": "GET",
                    "status_code": 200,
                    "url": "assets/i18n/en.json"
                }
            }, {
                "timestamp": 1624352462.507,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/#/app/account/1/dashboard/session-plan-template/list",
                    "to": "/facility/"
                }
            }, {
                "timestamp": 1624352462.511,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/",
                    "to": "/facility/facility-selection"
                }
            }, {
                "timestamp": 1624352462.513,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/facility-selection",
                    "to": "/facility/facility-selection"
                }
            }, {
                "timestamp": 1624352462.515,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/facility-selection",
                    "to": "/facility/"
                }
            }, {
                "timestamp": 1624352462.517,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/",
                    "to": "/facility/"
                }
            }, {
                "timestamp": 1624352462.533,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/",
                    "to": "/facility/app/facility-selection"
                }
            }, {
                "timestamp": 1624352465.571,
                "type": "default",
                "category": "ui.click",
                "level": "info",
                "message": "div.p-20 > div.km-select > select.ng-untouched.ng-pristine.ng-valid"
            }, {
                "timestamp": 1624352466.939,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/app/facility-selection",
                    "to": "/facility/app/account/dashboard/facility-check-in-out"
                }
            }, {
                "timestamp": 1624352472.435,
                "type": "default",
                "category": "ui.click",
                "level": "info",
                "message": "li.ng-tns-c77-0 > div.side-bar-link.ng-tns-c77-0 > span.ng-tns-c77-0"
            }, {
                "timestamp": 1624352472.457,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/app/account/dashboard/facility-check-in-out",
                    "to": "/facility/app/account/dashboard/help"
                }
            }, {
                "timestamp": 1624352991.895,
                "type": "default",
                "category": "ui.click",
                "level": "info",
                "message": "div.side-bar-link.ng-tns-c77-0 > span.ng-tns-c77-0"
            }, {
                "timestamp": 1624352991.909,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/app/account/dashboard/help",
                    "to": "/facility/app/account/dashboard/equipment"
                }
            }, {
                "timestamp": 1624353091.399,
                "type": "default",
                "category": "ui.click",
                "level": "info",
                "message": "li.ng-tns-c77-0 > div.side-bar-link.ng-tns-c77-0 > span.ng-tns-c77-0"
            }, {
                "timestamp": 1624353091.405,
                "type": "default",
                "category": "navigation",
                "level": "info",
                "data": {
                    "from": "/facility/app/account/dashboard/equipment",
                    "to": "/facility/app/account/dashboard/members"
                }
            }, {
                "timestamp": 1624353092.523,
                "type": "http",
                "category": "xhr",
                "level": "info",
                "data": {
                    "method": "POST",
                    "status_code": 504,
                    "url": "https://metrics-api.keiser.com/api?action=facilityConfiguration:show"
                }
            }, {
                "timestamp": 1624353092.525,
                "type": "http",
                "category": "xhr",
                "level": "info",
                "data": {
                    "method": "POST",
                    "status_code": 504,
                    "url": "https://metrics-api.keiser.com/api?action=facilityRelationship:facilityList"
                }
            }, {
                "timestamp": 1624353092.533,
                "type": "default",
                "category": "sentry.event",
                "level": "error",
                "message": "TypeError: Cannot read property 'code' of undefined",
                "event_id": "89a65fcba08047058edbba4fde8d43b2"
            }
        ]
    },
    "contexts": {
        "browser": {
            "name": "Chrome",
            "version": "91.0.4472",
            "type": "browser"
        },
        "os": {
            "name": "Windows",
            "version": "10",
            "type": "os"
        }
    },
    "culprit": "Array.find(<anonymous>)",
    "environment": "production",
    "exception": {
        "values": [{
                "type": "TypeError",
                "value": "Cannot read property 'code' of undefined",
                "stacktrace": {
                    "frames": [{
                            "function": "t.MetricsConnection.actionRest",
                            "module": "@keiser/metrics-sdk/index.browser",
                            "filename": "webpack:/node_modules/@keiser/metrics-sdk/index.browser.js",
                            "abs_path": "webpack:/node_modules/@keiser/metrics-sdk/index.browser.js",
                            "lineno": 2,
                            "colno": 113965,
                            "pre_context": ["/*! For license information please see index.browser.js.LICENSE.txt */"],
                            "context_line": "{snip} e?void 0:e.response)||void 0===i?void 0:i.data)){const t=c.GetErrorInstance(e.response.data.error);t instanceof c.RequestError||t instanceof {snip}",
                            "in_app": false,
                            "data": {
                                "sourcemap": "https://metrics.keiser.com/facility/main-es2018.4f9c7bdb70ff73334193.js.map"
                            }
                        }, {
                            "function": "GetErrorInstance",
                            "module": "@keiser/metrics-sdk/index.browser",
                            "filename": "webpack:/node_modules/@keiser/metrics-sdk/index.browser.js",
                            "abs_path": "webpack:/node_modules/@keiser/metrics-sdk/index.browser.js",
                            "lineno": 2,
                            "colno": 116141,
                            "pre_context": ["/*! For license information please see index.browser.js.LICENSE.txt */"],
                            "context_line": "{snip} st t=[o,c,h,l,u,d,g,f,p,y,_,m,w,x,S,b,D,E,v,M,A,k,O,R,C,P].find((t=>t.code===e.code));return void 0!==t?new t(e):new n(e)};class i extends s {snip}",
                            "in_app": false,
                            "data": {
                                "sourcemap": "https://metrics.keiser.com/facility/main-es2018.4f9c7bdb70ff73334193.js.map"
                            }
                        }, {
                            "function": "Array.find",
                            "filename": "<anonymous>",
                            "abs_path": "<anonymous>",
                            "in_app": true
                        }, {
                            "module": "@keiser/metrics-sdk/index.browser",
                            "filename": "webpack:/node_modules/@keiser/metrics-sdk/index.browser.js",
                            "abs_path": "webpack:/node_modules/@keiser/metrics-sdk/index.browser.js",
                            "lineno": 2,
                            "colno": 116161,
                            "pre_context": ["/*! For license information please see index.browser.js.LICENSE.txt */"],
                            "context_line": "{snip} f,p,y,_,m,w,x,S,b,D,E,v,M,A,k,O,R,C,P].find((t=>t.code===e.code));return void 0!==t?new t(e):new n(e)};class i extends s{}t.RequestError=i;c {snip}",
                            "in_app": false,
                            "data": {
                                "sourcemap": "https://metrics.keiser.com/facility/main-es2018.4f9c7bdb70ff73334193.js.map"
                            }
                        }
                    ]
                },
                "raw_stacktrace": {
                    "frames": [{
                            "function": "t.MetricsConnection.actionRest",
                            "filename": "/facility/main-es2018.4f9c7bdb70ff73334193.js",
                            "abs_path": "https://metrics.keiser.com/facility/main-es2018.4f9c7bdb70ff73334193.js",
                            "lineno": 1,
                            "colno": 723320,
                            "context_line": "{snip} e?void 0:e.response)||void 0===i?void 0:i.data)){const t=c.GetErrorInstance(e.response.data.error);t instanceof c.RequestError||t instanceof {snip}",
                            "post_context": ["//# sourceMappingURL=main-es2018.4f9c7bdb70ff73334193.js.map"],
                            "in_app": false
                        }, {
                            "function": "Object.t.GetErrorInstance",
                            "filename": "/facility/main-es2018.4f9c7bdb70ff73334193.js",
                            "abs_path": "https://metrics.keiser.com/facility/main-es2018.4f9c7bdb70ff73334193.js",
                            "lineno": 1,
                            "colno": 725496,
                            "context_line": "{snip} st t=[o,c,l,u,h,d,f,p,g,m,y,_,b,v,w,S,E,x,D,O,C,M,A,P,k,T].find(t=>t.code===e.code);return void 0!==t?new t(e):new a(e)};class i extends n{} {snip}",
                            "post_context": ["//# sourceMappingURL=main-es2018.4f9c7bdb70ff73334193.js.map"],
                            "in_app": false
                        }, {
                            "function": "Array.find",
                            "filename": "<anonymous>",
                            "abs_path": "<anonymous>",
                            "in_app": true
                        }, {
                            "filename": "/facility/main-es2018.4f9c7bdb70ff73334193.js",
                            "abs_path": "https://metrics.keiser.com/facility/main-es2018.4f9c7bdb70ff73334193.js",
                            "lineno": 1,
                            "colno": 725515,
                            "context_line": "{snip} ,p,g,m,y,_,b,v,w,S,E,x,D,O,C,M,A,P,k,T].find(t=>t.code===e.code);return void 0!==t?new t(e):new a(e)};class i extends n{}t.RequestError=i;cl {snip}",
                            "post_context": ["//# sourceMappingURL=main-es2018.4f9c7bdb70ff73334193.js.map"],
                            "in_app": false
                        }
                    ]
                },
                "mechanism": {
                    "type": "onunhandledrejection",
                    "handled": false
                }
            }
        ]
    },
    "fingerprint": ["{{ default }}"],
    "grouping_config": {
        "enhancements": "eJybzDRxY05qemJypZWRgaGlroGxrqHRBABbKAcD",
        "id": "legacy:2019-03-12"
    },
    "hashes": ["db8266d9c28cb295f491c295b6956f0c"],
    "key_id": "858212",
    "level": "error",
    "location": "<anonymous>",
    "logger": "",
    "metadata": {
        "filename": "<anonymous>",
        "function": "Array.find",
        "type": "TypeError",
        "value": "Cannot read property 'code' of undefined"
    },
    "received": 1624353092.880818,
    "request": {
        "url": "https://metrics.keiser.com/facility/app/account/dashboard/members",
        "headers": [["User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36"]]
    },
    "sdk": {
        "name": "sentry.javascript.angular",
        "version": "6.3.6",
        "integrations": ["InboundFilters", "FunctionToString", "TryCatch", "Breadcrumbs", "GlobalHandlers", "LinkedErrors", "UserAgent"],
        "packages": [{
                "name": "npm:@sentry/angular",
                "version": "6.3.6"
            }
        ]
    },
    "timestamp": 1624353092.534,
    "title": "TypeError: Cannot read property 'code' of undefined",
    "type": "error",
    "user": {
        "ip_address": "105.224.239.187",
        "geo": {
            "country_code": "ZA",
            "city": "Durban",
            "region": "South Africa"
        }
    },
    "version": "7"
}