{"id":26452954,"url":"https://github.com/diederikvandenb/apollo-link-sentry","last_synced_at":"2025-05-15T13:08:44.191Z","repository":{"id":38113094,"uuid":"242167042","full_name":"DiederikvandenB/apollo-link-sentry","owner":"DiederikvandenB","description":"Apollo Link middleware which enriches SentryJS with GraphQL data","archived":false,"fork":false,"pushed_at":"2025-05-09T11:58:37.000Z","size":2030,"stargazers_count":125,"open_issues_count":9,"forks_count":41,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-15T13:08:43.412Z","etag":null,"topics":["apollo","error-reporting","graphql","sentry"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DiederikvandenB.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2020-02-21T15:11:03.000Z","updated_at":"2025-05-09T11:58:40.000Z","dependencies_parsed_at":"2024-03-28T19:33:28.653Z","dependency_job_id":"fc375859-baf0-451d-9a26-a197e359bee2","html_url":"https://github.com/DiederikvandenB/apollo-link-sentry","commit_stats":{"total_commits":214,"total_committers":16,"mean_commits":13.375,"dds":0.5794392523364487,"last_synced_commit":"87c91fb93bdc9053a5ed9851b3e40d15668e0169"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiederikvandenB%2Fapollo-link-sentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiederikvandenB%2Fapollo-link-sentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiederikvandenB%2Fapollo-link-sentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiederikvandenB%2Fapollo-link-sentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiederikvandenB","download_url":"https://codeload.github.com/DiederikvandenB/apollo-link-sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"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":["apollo","error-reporting","graphql","sentry"],"created_at":"2025-03-18T18:40:26.884Z","updated_at":"2025-05-15T13:08:44.119Z","avatar_url":"https://github.com/DiederikvandenB.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo Link Sentry\n\n[Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction) to enrich [Sentry](https://sentry.io) events with [GraphQL](https://graphql.org) data\n\n[![Code Coverage](https://img.shields.io/coveralls/github/DiederikvandenB/apollo-link-sentry/master)](https://coveralls.io/github/DiederikvandenB/apollo-link-sentry?branch=master)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n[![npm-version](https://img.shields.io/npm/v/apollo-link-sentry)](https://www.npmjs.com/package/apollo-link-sentry)\n[![npm-downloads](https://img.shields.io/npm/dt/apollo-link-sentry)](https://www.npmjs.com/package/apollo-link-sentry)\n\n## Installation\n\n```\nyarn add apollo-link-sentry\n```\n\n**Note**: Due to a release issue, v3.0.0 of this package has been unpublished. Please use v3.0.1\n**Note**: starting from v2.0.0 of this package we support `@apollo/client` v3.0.\n\n## Features\n\nTurn this:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/DiederikvandenB/apollo-link-sentry/master/screenshots/before.png\" alt=\"Before\" width=\"auto\" /\u003e\n\u003c/p\u003e\n\nInto this:\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/DiederikvandenB/apollo-link-sentry/master/screenshots/after.png\" alt=\"After\" width=\"auto\" /\u003e\n\u003c/p\u003e\n\n## Basic setup\n\nInitialize Sentry as you would normally. Then, add `apollo-link-sentry` to your Apollo Client's `link` array:\n\n```js\nimport { SentryLink } from 'apollo-link-sentry';\n\nconst client = new ApolloClient({\n  link: ApolloLink.from([\n    new SentryLink(/* See options */),\n    new HttpLink({ uri: 'http://localhost:4000' }),\n  ]),\n  cache: new InMemoryCache(),\n});\n```\n\n## Options\n\nSee [src/options.ts](src/options.ts).\n\n### Compatibility with other Apollo Links\n\n`apollo-link-sentry` aims to be friendly with other `apollo-link` packages,\nin the sense that we would like for you to be able to attach as much data as you want.\nFor example, if you would like to add the HTTP headers you set with `apollo-link-context`,\nyou can do that by setting `includeContextKeys: ['headers']`.\n\nIn case you find that there's a piece of data you're missing, feel free to open an issue.\n\n### Be careful what you include\n\nPlease note that Sentry sets some limits to how big events can be.\nFor instance, **events greater than 200KiB are immediately dropped (pre decompression)**.\nMore information on that [here](https://docs.sentry.io/accounts/quotas/#attributes-limits).\nBe especially careful with the `includeCache` option, as caches can become quite large.\n\nFurthermore, much of the data you are sending to Sentry can include (sensitive) personal information.\nThis might lead you to violating the terms of the GDPR.\nUse Sentry's `beforeBreadcrumb` function to filter out all sensitive data.\n\n## Exclude redundant `fetch` breadcrumbs\n\nBy default, Sentry attaches all fetch events as breadcrumbs.\nSince this package tracks GraphQL requests as breadcrumbs,\nthey would show up duplicated in Sentry.\n\nYou can use either one of the following options to exclude\nredundant `fetch` breadcrumbs:\n\n1. Disable the default integration for fetch requests entirely.\n   Note that this is only recommended if you **only** use GraphQL requests in your application.\n   The default integration can be disabled like this:\n\n   ```js\n   Sentry.init({\n     ...,\n     defaultIntegrations: [\n       new Sentry.BrowserTracing({ traceFetch: false }),\n     ],\n   });\n   ```\n\n2. Use the `beforeBreadcrumb` option of Sentry to filter out the duplicates.\n   The helpers in this package recognize every breadcrumb of category `fetch`\n   where the URL contains `/graphql` as a GraphQL request.\n\n   ```js\n   import { excludeGraphQLFetch } from 'apollo-link-sentry';\n\n   Sentry.init({\n     ...,\n     beforeBreadcrumb: excludeGraphQLFetch,\n   })\n   ```\n\n   If you have a custom wrapper, use the higher order function:\n\n   ```js\n   import { withoutGraphQLFetch } from 'apollo-link-sentry';\n\n   Sentry.init({\n     ...,\n     beforeBreadcrumb: withoutGraphQLFetch((breadcrumb, hint) =\u003e { ... }),\n   })\n   ```\n\n## FAQ\n\n### I don't see any events appearing in my Sentry stream\n\nThis package only adds breadcrumbs, you are still responsible for reporting errors to Sentry.\nYou can do this by calling `Sentry.captureException()`:\n\n```jsx\n\u003cMutation mutation={MUTATION_THAT_MIGHT_FAIL}\u003e\n  {(mutate, { data, error, loading }) =\u003e {\n    if (loading) return \u003cdiv\u003eloading\u003c/div\u003e;\n    if (error) return \u003cdiv\u003e{error.toString()}\u003c/div\u003e;\n\n    const onClick = () =\u003e\n      mutate().catch((error) =\u003e {\n        Sentry.captureException(error);\n      });\n\n    return (\n      \u003cdiv\u003e\n        \u003cbutton type=\"button\" onClick={() =\u003e onClick()}\u003e\n          Mutate\n        \u003c/button\u003e\n        {JSON.stringify(data)}\n      \u003c/div\u003e\n    );\n  }}\n\u003c/Mutation\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiederikvandenb%2Fapollo-link-sentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiederikvandenb%2Fapollo-link-sentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiederikvandenb%2Fapollo-link-sentry/lists"}