{"id":19220097,"url":"https://github.com/nativescript-community/sentry","last_synced_at":"2025-05-13T01:11:05.153Z","repository":{"id":42988729,"uuid":"236298139","full_name":"nativescript-community/sentry","owner":"nativescript-community","description":"A cross-platform application monitoring tool, with a focus on error reporting.","archived":false,"fork":false,"pushed_at":"2025-04-03T19:40:43.000Z","size":4243,"stargazers_count":18,"open_issues_count":10,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T21:36:05.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nativescript-community.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["farfromrefug"]}},"created_at":"2020-01-26T10:43:02.000Z","updated_at":"2025-04-03T19:40:46.000Z","dependencies_parsed_at":"2023-11-22T16:28:22.965Z","dependency_job_id":"3c93e86c-3245-457d-b487-446c2da23d2c","html_url":"https://github.com/nativescript-community/sentry","commit_stats":{"total_commits":208,"total_committers":6,"mean_commits":"34.666666666666664","dds":0.4423076923076923,"last_synced_commit":"99e2a41dc1dd97ef61ed2129a8ab2a849275abae"},"previous_names":[],"tags_count":71,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fsentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fsentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fsentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nativescript-community%2Fsentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nativescript-community","download_url":"https://codeload.github.com/nativescript-community/sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253851070,"owners_count":21973674,"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":[],"created_at":"2024-11-09T14:33:59.882Z","updated_at":"2025-05-13T01:11:05.118Z","avatar_url":"https://github.com/nativescript-community.png","language":"TypeScript","funding_links":["https://github.com/sponsors/farfromrefug"],"categories":["Plugins"],"sub_categories":["Analytics, Engagement \u0026 Monitoring Plugins"],"readme":"\u003c!-- ⚠️ This README has been generated from the file(s) \"blueprint.md\" ⚠️--\u003e[![npm](https://img.shields.io/npm/v/@nativescript-community/sentry.svg)](https://www.npmjs.com/package/@nativescript-community/sentry)\n[![npm](https://img.shields.io/npm/dt/@nativescript-community/sentry.svg?label=npm%20downloads)](https://www.npmjs.com/package/@nativescript-community/sentry)\n[![GitHub forks](https://img.shields.io/github/forks/nativescript-community/sentry.svg)](https://github.com/nativescript-community/sentry/network)\n[![GitHub stars](https://img.shields.io/github/stars/nativescript-community/sentry.svg)](https://github.com/nativescript-community/sentry/stargazers)\n\n\r\n[](#installation)\r\n\r\n# Installation\n\n* `tns plugin add @nativescript-community/sentry`\n\nBe sure to run a new build after adding plugins to avoid any issues.\n\n\r\n[](#configuration)\r\n\r\n# Configuration\n\n\r\n[](#webpack-)\r\n\r\n## Webpack \n\nYou will need to add something like this to your webpack config so that the source maps gets uploaded. I dont set `auth` or `project` in the options as i use a `.sentryclirc` config file.\n* `SOURCEMAP_REL_DIR`: i almost always set it to `../../sourcemaps`\n* `SENTRY_PREFIX`: the default is `app:///`\n```javascript\nif (!!sentry \u0026\u0026 !!uploadSentry) {\n  config.devtool = false;\n  config.plugins.push(\n      new webpack.SourceMapDevToolPlugin({\n          append: `\\n//# sourceMappingURL=${process.env.SENTRY_PREFIX}[name].js.map`,\n          filename: join(process.env.SOURCEMAP_REL_DIR, '[name].js.map')\n      })\n  );\n  let appVersion;\n  let buildNumber;\n  if (isAndroid) {\n      const gradlePath = `${appResourcesPath}/Android/app.gradle`;\n      const gradleData = readFileSync(gradlePath, 'utf8');\n      appVersion = gradleData.match(/versionName \"((?:[0-9]+\\.?)+)\"/)[1];\n      buildNumber = gradleData.match(/versionCode ([0-9]+)/)[1];\n  } else if (isIOS) {\n      const plistPath = `${appResourcesPath}/iOS/Info.plist`;\n      const plistData = readFileSync(plistPath, 'utf8');\n      appVersion = plistData.match(/\u003ckey\u003eCFBundleShortVersionString\u003c\\/key\u003e[\\s\\n]*\u003cstring\u003e(.*?)\u003c\\/string\u003e/)[1];\n      buildNumber = plistData.match(/\u003ckey\u003eCFBundleVersion\u003c\\/key\u003e[\\s\\n]*\u003cstring\u003e([0-9]*)\u003c\\/string\u003e/)[1];\n  }\n  config.plugins.push(\n      new SentryCliPlugin({\n          release: appVersion,\n          urlPrefix: 'app:///',\n          rewrite: true,\n          release: `${nconfig.id}@${appVersion}+${buildNumber}`,\n          dist: `${buildNumber}.${platform}`,\n          ignoreFile: '.sentrycliignore',\n          include: [join(dist, process.env.SOURCEMAP_REL_DIR)]\n      })\n  );\n}\n```\n\n###debug \n\nFor debug mode to work correctly you will need to add this to your webpack (see demo app)\n\n```js\nnsWebpack.chainWebpack(config=\u003e{\n    config.entry('bundle').prepend('@nativescript-community/sentry/process');\n});\n```\n\n\r\n[](#fastlane)\r\n\r\n## Fastlane\n\nIf you use fastlane you can use it to create release and upload dsyms\nTo do that you need to install it:\n```sh\nfastlane add_plugin sentry\n```\nAlso for now you should install `nativescript-set-version` as it is needed to read app version, build number.\n```sh\nnpm install -D nativescript-set-version\n```\n\nNow you can setup your `Fastfile`\n* create release \n```\nversion = \"\"\nversionCode = \"\"\n\nDir.chdir(\"..\") do\n  version  =  sh(\"./node_modules/.bin/get-version\", platform, \"version\").gsub(/\\n/,'')\n  versionCode  =  sh(\"./node_modules/.bin/get-version\", platform, \"code\").gsub(/\\n/,'')\nend\nsentry_create_release(\n  version: version, # release version to create\n)\n```\n\n* upload dsyms\n```\nsentry_upload_dsym\n```\n\n\r\n[](#usage-in-the-app)\r\n\r\n# Usage in the app\n\n```typescript\nimport * as Sentry from '@nativescript-community/sentry';\n\nconst buildNumber = await getBuildNumber();\nconst versionName = await getVersionName();\nconst buildNumber = await getBuildNumber();\nconst appId = await getAppId();\nSentry.init({\n    dsn: SENTRY_DSN,\n    debug: true,\n    enableAutoPerformanceTracking: true,\n});\n```\n\n\r\n[](#reporting-nativescript-errors)\r\n\r\n## Reporting NativeScript errors\n\nThe `onerror` method ensures all unhandled NativeScript errors will be caught by Sentry in production, using a [custom error handler](https://docs.nativescript.org/core-concepts/error-handling).\n\n\n\r\n[](#reporting-handled-errors)\r\n\r\n## Reporting handled errors\n\nIf you would like to send a handled error to Bugsnag, you can pass any Error object to Sentry notify method:\n```typescript\nimport * as Sentry from '@nativescript-community/sentry';\ntry {\n  // potentially crashy code\n} catch (error) {\n  Sentry.captureException(error);\n}\n```\n\n\r\n[](#reporting-promise-rejections)\r\n\r\n## Reporting promise rejections\n\nTo report a promise rejection, use notify() as a part of the catch block:\n\n```typescript\nimport * as Sentry from '@nativescript-community/sentry';\nnew Promise(function(resolve, reject) {\n  /* potentially failing code */\n})\n.then(function () { /* if the promise is resolved */ })\n.catch(function (error) {\n  Sentry.captureException(error);\n});\n```\n\n\r\n[](#sending-diagnostic-data)\r\n\r\n## Sending diagnostic data\n\n### Automatically captured diagnostics\n\nBugsnag will automatically capture and attach the following diagnostic data:\n\n* A full stacktrace\n* Battery state\n* Device model and OS version\n* Thread state for all threads\n* Release stage (production, debug, etc)\n* App running duration in the foreground and/or background\n* A device- and vendor-specific identifier\n\n\n\r\n[](#identifying-users)\r\n\r\n## Identifying users\n\nIn order to correlate errors with customer reports, or to see a list of users who experienced each error, it is helpful to capture and display user information. Information set on the Bugsnag client is sent with each error report:\n\n```typescript\nSentry.setUser({\"email\": \"john.doe@example.com\"});\n```\n\n\r\n[](#logging-breadcrumbs)\r\n\r\n## Logging breadcrumbs\n\nIn order to understand what happened in your application before each crash, it can be helpful to leave short log statements that we call breadcrumbs. The last several breadcrumbs are attached to a crash to help diagnose what events lead to the error.\n\n### Automatically captured breadcrumbs\n\nBy default, Bugsnag captures common events including:\n\n* Low memory warnings\n* Device rotation (if applicable)\n* Menu presentation\n* Screenshot capture (not the screenshot itself)\n* Undo and redo\n* Table view selection\n*  Window visibility changes\n* Non-fatal errors\n* Log messages (off by default, see configuration options)\n\n### Attaching custom breadcrumbs\n\nTo attach additional breadcrumbs, use the leaveBreadcrumb function:\n\n```typescript\nSentry.addBreadcrumb({\n    category: 'ui',\n    message: 'load main view',\n    level: 'info'\n  });\n```\n\n\r\n[](#demos-and-development)\r\n\r\n## Demos and Development\n\n\n### Repo Setup\n\nThe repo uses submodules. If you did not clone with ` --recursive` then you need to call\n```\ngit submodule update --init\n```\n\nThe package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.\n\nTo develop and test:\nif you use `yarn` then run `yarn`\nif you use `pnpm` then run `pnpm i`\n\n**Interactive Menu:**\n\nTo start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.\n\n### Build\n\n```bash\nnpm run build.all\n```\nWARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`\n\n### Demos\n\n```bash\nnpm run demo.[ng|react|svelte|vue].[ios|android]\n\nnpm run demo.svelte.ios # Example\n```\n\nDemo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`\nInstead you work in `demo-snippets/[ng|react|svelte|vue]`\nYou can start from the `install.ts` of each flavor to see how to register new demos \n\n\r\n[](#contributing)\r\n\r\n## Contributing\n\n### Update repo \n\nYou can update the repo files quite easily\n\nFirst update the submodules\n\n```bash\nnpm run update\n```\n\nThen commit the changes\nThen update common files\n\n```bash\nnpm run sync\n```\nThen you can run `yarn|pnpm`, commit changed files if any\n\n### Update readme \n```bash\nnpm run readme\n```\n\n### Update doc \n```bash\nnpm run doc\n```\n\n### Publish\n\nThe publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)\nSimply run \n```shell\nnpm run publish\n```\n\n### modifying submodules\n\nThe repo uses https:// for submodules which means you won't be able to push directly into the submodules.\nOne easy solution is t modify `~/.gitconfig` and add\n```\n[url \"ssh://git@github.com/\"]\n\tpushInsteadOf = https://github.com/\n```\n\r\n[](#questions)\r\n\r\n## Questions\n\nIf you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript-community%2Fsentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnativescript-community%2Fsentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnativescript-community%2Fsentry/lists"}