{"id":26452956,"url":"https://github.com/youzan/raven-weapp","last_synced_at":"2025-03-18T18:40:29.984Z","repository":{"id":64931342,"uuid":"104310143","full_name":"youzan/raven-weapp","owner":"youzan","description":"Sentry SDK for WeApp","archived":false,"fork":false,"pushed_at":"2019-10-01T03:28:20.000Z","size":162,"stargazers_count":159,"open_issues_count":5,"forks_count":51,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-02-25T15:41:14.153Z","etag":null,"topics":["crash-reporting","error-handling","javascript","javascript-library","raven","sentry","sentry-service","weapp"],"latest_commit_sha":null,"homepage":"","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/youzan.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":"2017-09-21T06:29:33.000Z","updated_at":"2024-02-21T02:58:22.000Z","dependencies_parsed_at":"2022-12-19T13:08:17.888Z","dependency_job_id":null,"html_url":"https://github.com/youzan/raven-weapp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fraven-weapp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fraven-weapp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fraven-weapp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/youzan%2Fraven-weapp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/youzan","download_url":"https://codeload.github.com/youzan/raven-weapp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244282967,"owners_count":20428103,"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","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":["crash-reporting","error-handling","javascript","javascript-library","raven","sentry","sentry-service","weapp"],"created_at":"2025-03-18T18:40:29.220Z","updated_at":"2025-03-18T18:40:29.971Z","avatar_url":"https://github.com/youzan.png","language":"JavaScript","readme":"# Raven-weapp\n\n为方便小程序接入sentry，由raven改写而来的小程序版本。\n\n#### 引入文件\n由于目前小程序不支持从node_modules中引入文件，因此以npm方式安装的话只能手动将raven-weapp/dist目录下需要的文件拷贝到其他文件中，在app.js中引入，例如：\n\n```\nvar Raven = require('./utils/raven-weapp/build/raven')\n```\n或以Bower安装raven-weapp并引入：\n\n```\nvar Raven = require('./bower_components/raven-weapp/build/raven')\n```\n#### 初始化Raven\n\n```\nRaven.config('https://xxx@crash.youzan.com/x', options).install()\n```\n在app的onLaunch中初始化(?)，options为可选配置对象，目前支持：\n```\noptions = {\n    release: '当前小程序版本'，\n    environment: '指定为production才会上报',\n    allowDuplicates: true, // 允许相同错误重复上报\n    sampleRate: 0.5 // 采样率\n}\n```\n#### 收集信息\n收集的信息将在上报时被一起带上\n##### 基本信息\n初始化后raven会默认收集以下信息：\n```\n{\n    SDKversion: '小程序基础库版本',\n    WXversion: '微信版本',\n    device: '设备型号',\n    network: '网络类型',\n    system: '系统信息',\n}\n```\n可以通过[Raven.setUserContext(context)](https://docs.sentry.io/learn/context/#capturing-the-user)或者[Raven.setExtraContext(context)](https://docs.sentry.io/learn/context/#extra-context)添加更多信息（kdtId和userId等）\n##### 用户行为\n###### console\nconsole的行为默认将被自动收集\n###### ajax\nwx.request不可扩展，因此只能手动收集请求的行为：例如在经过封装的请求函数的成功回调内添加：\n```\nRaven.captureBreadcrumb({\n  category: 'ajax',\n  data: {\n    method: 'get',\n    url: 'weapp.showcase.page/1.0.0/get',\n    status_code: 200\n  }\n```\n###### dom\nui操作的记录暂不支持\n###### location\n页面变化的记录暂不支持\n\n#### 信息上报\n分为message和exception的上报\n##### message\n使用[Raven.captureMessage(msg, option)](https://docs.sentry.io/clients/javascript/usage/#capturing-messages)上报需要上报的信息比如ajax的报错等\n##### exception\n所有uncaught exception都会被小程序捕获封装成msg传递到app的onError中，在onError中上报这些信息：\n```\nonError(msg) {\n    Raven.captureException(msg, {\n      level: 'error'\n    })\n  }\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouzan%2Fraven-weapp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyouzan%2Fraven-weapp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyouzan%2Fraven-weapp/lists"}