diff --git a/package.json b/package.json
index 69935f2abd94..79b315b23bca 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"packages/apm",
"packages/browser",
"packages/core",
+ "packages/gatsby",
"packages/hub",
"packages/integrations",
"packages/minimal",
diff --git a/packages/gatsby/.npmignore b/packages/gatsby/.npmignore
new file mode 100644
index 000000000000..14e80551ae7c
--- /dev/null
+++ b/packages/gatsby/.npmignore
@@ -0,0 +1,4 @@
+*
+!/dist/**/*
+!/esm/**/*
+*.tsbuildinfo
diff --git a/packages/gatsby/LICENSE b/packages/gatsby/LICENSE
new file mode 100644
index 000000000000..dcd01a73ad2d
--- /dev/null
+++ b/packages/gatsby/LICENSE
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2020, Sentry
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/packages/gatsby/README.md b/packages/gatsby/README.md
new file mode 100644
index 000000000000..55d7509d661e
--- /dev/null
+++ b/packages/gatsby/README.md
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+# Official Sentry SDK for GatsbyJS
+
+Register the package as a plugin in `gastby-config.js`:
+
+```javascript
+{
+ // ...
+ plugins: [
+ {
+ resolve: "@sentry/gatsby",
+ options: {
+ dsn: process.env.SENTRY_DSN, // this is the default
+ }
+ },
+ // ...
+ ]
+}
+```
+
+Options will be passed directly to `Sentry.init`. The `environment` value defaults to `NODE_ENV` (or `development` if not set).
+
+## GitHub Actions
+
+The `release` value is inferred from `GITHUB_SHA`.
+
+## Netlify
+
+The `release` value is inferred from `COMMIT_REF`.
+
+## Vercel
+
+To automatically capture the `release` value on Vercel you will need to register appropriate [system environment variable](https://vercel.com/docs/v2/build-step#system-environment-variables) (e.g. `VERCEL_GITHUB_COMMIT_SHA`) in your project.
+
+## Links
+
+- [Official SDK Docs](https://docs.sentry.io/quickstart/)
+- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json
new file mode 100644
index 000000000000..ae459ac1fdbd
--- /dev/null
+++ b/packages/gatsby/package.json
@@ -0,0 +1,78 @@
+{
+ "name": "@sentry/gatsby",
+ "version": "5.17.0",
+ "description": "Offical Sentry SDK for Gatsby.js",
+ "repository": "git://github.com/getsentry/sentry-javascript.git",
+ "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby",
+ "author": "Sentry",
+ "license": "BSD-3-Clause",
+ "keywords": ["gatsby", "gatsby-plugin"],
+ "engines": {
+ "node": ">=6"
+ },
+ "main": "dist/index.js",
+ "module": "esm/index.js",
+ "types": "dist/index.d.ts",
+ "publishConfig": {
+ "access": "public"
+ },
+ "dependencies": {
+ "@sentry/react": "5.17.0",
+ "@sentry/types": "5.17.0"
+ },
+ "peerDependencies": {
+ "gatsby": "*"
+ },
+ "devDependencies": {
+ "jest": "^24.7.1",
+ "npm-run-all": "^4.1.2",
+ "prettier": "^1.17.0",
+ "prettier-check": "^2.0.0",
+ "rimraf": "^2.6.3",
+ "tslint": "^5.16.0",
+ "typescript": "^3.5.1"
+ },
+ "scripts": {
+ "build": "run-p build:es5 build:esm",
+ "build:es5": "tsc -p tsconfig.build.json",
+ "build:esm": "tsc -p tsconfig.esm.json",
+ "build:watch": "run-p build:watch:es5 build:watch:esm",
+ "build:watch:es5": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
+ "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
+ "clean": "rimraf dist coverage build esm",
+ "link:yarn": "yarn link",
+ "lint": "run-s lint:prettier lint:tslint",
+ "lint:prettier": "prettier-check \"{src,test}/**/*.{ts,tsx}\"",
+ "lint:tslint": "tslint -t stylish -p .",
+ "lint:tslint:json": "tslint --format json -p . | tee lint-results.json",
+ "fix": "run-s fix:tslint fix:prettier",
+ "fix:prettier": "prettier --write \"{src,test}/**/*.{ts,tsx}\"",
+ "fix:tslint": "tslint --fix -t stylish -p .",
+ "test": "jest",
+ "test:watch": "jest --watch"
+ },
+ "jest": {
+ "collectCoverage": true,
+ "transform": {
+ "^.+\\.ts$": "ts-jest",
+ "^.+\\.tsx$": "ts-jest"
+ },
+ "moduleFileExtensions": [
+ "js",
+ "ts",
+ "tsx"
+ ],
+ "testEnvironment": "jsdom",
+ "testMatch": [
+ "**/*.test.ts",
+ "**/*.test.tsx"
+ ],
+ "globals": {
+ "ts-jest": {
+ "tsConfig": "./tsconfig.json",
+ "diagnostics": false
+ }
+ }
+ },
+ "sideEffects": false
+}
diff --git a/packages/gatsby/src/gatsby-browser.js b/packages/gatsby/src/gatsby-browser.js
new file mode 100644
index 000000000000..9b1a6a923012
--- /dev/null
+++ b/packages/gatsby/src/gatsby-browser.js
@@ -0,0 +1,20 @@
+exports.onClientEntry = function(_, pluginParams) {
+ require.ensure(['@sentry/react', '@sentry/apm'], function(require) {
+ const Sentry = require('@sentry/browser');
+ const TracingIntegration = require('@sentry/apm').Integrations.Tracing;
+ const tracesSampleRate = pluginParams.tracesSampleRate !== undefined ? pluginParams.tracesSampleRate : 0;
+ const integrations = [...(pluginParams.integrations || [])];
+ if (tracesSampleRate) {
+ integrations.push(new TracingIntegration());
+ }
+ Sentry.init({
+ environment: process.env.NODE_ENV || 'development',
+ release: __SENTRY_RELEASE__,
+ dsn: __SENTRY_DSN__,
+ ...pluginParams,
+ tracesSampleRate,
+ integrations,
+ });
+ window.Sentry = Sentry;
+ });
+};
diff --git a/packages/gatsby/src/gatsby-node.js b/packages/gatsby/src/gatsby-node.js
new file mode 100644
index 000000000000..258e53b60dbe
--- /dev/null
+++ b/packages/gatsby/src/gatsby-node.js
@@ -0,0 +1,24 @@
+exports.onCreateWebpackConfig = ({ plugins, actions }) => {
+ actions.setWebpackConfig({
+ plugins: [
+ plugins.define({
+ __SENTRY_RELEASE__: JSON.stringify(
+ // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
+ process.env.GITHUB_SHA ||
+ // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
+ process.env.COMMIT_REF ||
+ // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
+ process.env.VERCEL_GITHUB_COMMIT_SHA ||
+ process.env.VERCEL_GITLAB_COMMIT_SHA ||
+ process.env.VERCEL_BITBUCKET_COMMIT_SHA ||
+ // Zeit (now known as Vercel)
+ process.env.ZEIT_GITHUB_COMMIT_SHA ||
+ process.env.ZEIT_GITLAB_COMMIT_SHA ||
+ process.env.ZEIT_BITBUCKET_COMMIT_SHA ||
+ '',
+ ),
+ __SENTRY_DSN__: JSON.stringify(process.env.SENTRY_DSN || ''),
+ }),
+ ],
+ });
+};
diff --git a/packages/gatsby/src/index.ts b/packages/gatsby/src/index.ts
new file mode 100644
index 000000000000..c45aad673ad0
--- /dev/null
+++ b/packages/gatsby/src/index.ts
@@ -0,0 +1 @@
+export * from '@sentry/react';
diff --git a/packages/gatsby/test/index.test.ts b/packages/gatsby/test/index.test.ts
new file mode 100644
index 000000000000..ff5898974446
--- /dev/null
+++ b/packages/gatsby/test/index.test.ts
@@ -0,0 +1,18 @@
+import * as GatsbyIntegration from '../src';
+
+describe('package', () => {
+ it('exports init', () => {
+ expect(GatsbyIntegration.init).toBeDefined();
+ });
+
+ it('exports ErrorBoundary', () => {
+ expect(GatsbyIntegration.ErrorBoundary).toBeDefined();
+ expect(GatsbyIntegration.withErrorBoundary).toBeDefined();
+ });
+
+ it('exports Profiler', () => {
+ expect(GatsbyIntegration.Profiler).toBeDefined();
+ expect(GatsbyIntegration.withProfiler).toBeDefined();
+ expect(GatsbyIntegration.useProfiler).toBeDefined();
+ });
+});
diff --git a/packages/gatsby/tsconfig.build.json b/packages/gatsby/tsconfig.build.json
new file mode 100644
index 000000000000..a263a085c70a
--- /dev/null
+++ b/packages/gatsby/tsconfig.build.json
@@ -0,0 +1,8 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "outDir": "dist"
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/gatsby/tsconfig.esm.json b/packages/gatsby/tsconfig.esm.json
new file mode 100644
index 000000000000..b7739d0869e0
--- /dev/null
+++ b/packages/gatsby/tsconfig.esm.json
@@ -0,0 +1,8 @@
+{
+ "extends": "../../tsconfig.esm.json",
+ "compilerOptions": {
+ "baseUrl": ".",
+ "outDir": "esm",
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/gatsby/tsconfig.json b/packages/gatsby/tsconfig.json
new file mode 100644
index 000000000000..55b38e135ae2
--- /dev/null
+++ b/packages/gatsby/tsconfig.json
@@ -0,0 +1,9 @@
+{
+ "extends": "./tsconfig.build.json",
+ "include": ["src/**/*.ts", "test/**/*.ts"],
+ "exclude": ["dist"],
+ "compilerOptions": {
+ "rootDir": ".",
+ "types": ["node", "jest"]
+ }
+}
diff --git a/packages/gatsby/tslint.json b/packages/gatsby/tslint.json
new file mode 100644
index 000000000000..3016a27a85cc
--- /dev/null
+++ b/packages/gatsby/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": "@sentry/typescript/tslint"
+}