{"id":19936749,"url":"https://github.com/donkeycode/frontendlogger","last_synced_at":"2025-07-30T12:05:25.037Z","repository":{"id":57242031,"uuid":"59677367","full_name":"donkeycode/frontendlogger","owner":"donkeycode","description":null,"archived":false,"fork":false,"pushed_at":"2016-05-31T15:09:37.000Z","size":13,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"dev","last_synced_at":"2025-05-03T13:40:59.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/donkeycode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-25T15:58:44.000Z","updated_at":"2019-08-17T16:49:27.000Z","dependencies_parsed_at":"2022-09-04T20:13:12.836Z","dependency_job_id":null,"html_url":"https://github.com/donkeycode/frontendlogger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/donkeycode/frontendlogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donkeycode%2Ffrontendlogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donkeycode%2Ffrontendlogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donkeycode%2Ffrontendlogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donkeycode%2Ffrontendlogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donkeycode","download_url":"https://codeload.github.com/donkeycode/frontendlogger/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donkeycode%2Ffrontendlogger/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267865838,"owners_count":24157343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T23:28:43.109Z","updated_at":"2025-07-30T12:05:24.999Z","avatar_url":"https://github.com/donkeycode.png","language":"JavaScript","readme":"# frontendlogger\n\nfrontendlogger is a JavaScript library for sending logs of front events and errors to a server.\n\nThis library sends logs to the server only when it catches a warning or a critical event. \nLogs sent to the server are composed of the last events logs.\n\nIt integrates easily with an ELK (Elasticsearch-Logstash-Kibana) stack.\n\n## Installing\n\nThe simplest way to install frontendlogger is to use npm:\n\n```\nnpm install frontendlogger\n```\n\nor bower:\n\n```\nbower install frontendlogger\n```\n\nAfter that, you have to include it with a script tag in your HTML file:\n\n```html\n\u003cscript src=\"path_to_bower_components/frontendlogger/frontendlogger.js\"\u003e\u003c/script\u003e\n```\n\n## Configuration\n\n### setServerUrl (default: \"http://10.10.10.10:8080\")\n\nTo use this library, you have to set the URL of the server to which you want to send your application logs. \nTo do that, simply use the setServerUrl command; for example:\n\n```javascript\nfrontendlogger.setServerUrl(\"http://localhost:8080\");\n```\n\n### setUser (default: {})\n\nYou can also add current user information with the setUser command, for example:\n\n```javascript\nfrontendlogger.setUser(user);\n```\n\n### setMaxLengthLog (default: 30)\n\nYou can also change the default length of the stack trace with the setMaxLengthLog command, for example:\n\n```javascript\nfrontendlogger.setMaxLengthLog(100);\n```\n\n### addEvent\n\nYou can also add your custom event with the addEvent command, for example:\n\n```javascript\nvar event = {\n  message = \"This is a critical event!\",\n  eventLevel = 2, // 0 for debug events, 1 for warning events, 2 for critical events\n  eventType = \"myCriticalEvent\"\n};\nfrontendlogger.addEvent(event);\n```\n\nfrontendlogger adds automagically the current user page URL, a datetime string and the user (if defined) to your custom event.\n\n### Logstash configuration\n\nIf you want to send your application logs to Logstash, you have to use the [input http plugin](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-http.html).\n\nAn example of Logstash configuration is the following one:\n\n```\ninput {\n  http {\n    response_headers =\u003e {\n      \"Access-Control-Allow-Origin\" =\u003e \"*\"\n      \"Access-Control-Allow-Headers\" =\u003e \"Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With\"\n      \"Access-Control-Allow-Methods\" =\u003e \"*\"\n      \"Access-Control-Allow-Credentials\" =\u003e \"*\"\n    }\n    host =\u003e \"10.10.10.10\"\n    port =\u003e 8080\n  }\n}\nfilter {\n    if [logType] == \"frontendlogger\" {\n      useragent {\n          source =\u003e \"userAgentUA\"\n          target =\u003e \"UA\"\n      }\n    }\n}\noutput {\n  elasticsearch {}\n}\n```\n\nWith this configuration, Logstash creates an HTTP server that will listen on 10.10.10.10:8080 with some custom response headers.\nLogstash allows you to parse the userAgent string to get information about the user browser and OS (you can find this data in the output UA object).\nFinally, Logstash sends logs to Elasticsearch and you can visualize this data in the Kibana platform.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonkeycode%2Ffrontendlogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonkeycode%2Ffrontendlogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonkeycode%2Ffrontendlogger/lists"}