@sentry/gatsby 8.0.0-alpha.4 → 8.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  # Official Sentry SDK for GatsbyJS
8
8
 
9
- Register the package as a plugin in `gatsby-config.js`:
9
+ First register the package as a plugin in `gatsby-config.js`:
10
10
 
11
11
  ```javascript
12
12
  module.exports = {
@@ -23,66 +23,32 @@ module.exports = {
23
23
  };
24
24
  ```
25
25
 
26
- Options will be passed directly to `Sentry.init`. See all available options in
27
- [our docs](https://docs.sentry.io/error-reporting/configuration/?platform=javascript). The `environment` value defaults
28
- to `NODE_ENV` (or `'development'` if `NODE_ENV` is not set).
29
-
30
- ## GitHub Actions
31
-
32
- The `release` value is inferred from `GITHUB_SHA`.
33
-
34
- ## Netlify
35
-
36
- The `release` value is inferred from `COMMIT_REF`.
37
-
38
- ## Vercel
39
-
40
- To automatically capture the `release` value on Vercel you will need to register appropriate
41
- [system environment variable](https://vercel.com/docs/v2/build-step#system-environment-variables) (e.g.
42
- `VERCEL_GITHUB_COMMIT_SHA`) in your project.
43
-
44
- ## Sentry Performance
45
-
46
- To enable tracing, supply either `tracesSampleRate` or `tracesSampler` to the options. This will turn on the
47
- `BrowserTracing` integration for automatic instrumentation of pageloads and navigations.
26
+ Then configure your `Sentry.init` call:
48
27
 
49
28
  ```javascript
50
- module.exports = {
51
- // ...
52
- plugins: [
53
- {
54
- resolve: '@sentry/gatsby',
55
- options: {
56
- dsn: process.env.SENTRY_DSN, // this is the default
29
+ import * as Sentry from '@sentry/gatsby';
57
30
 
58
- // A rate of 1 means all traces will be sent, so it's good for testing.
59
- // In production, you'll likely want to either choose a lower rate or use `tracesSampler` instead (see below).
60
- tracesSampleRate: 1,
31
+ Sentry.init({
32
+ dsn: '__PUBLIC_DSN__',
33
+ integrations: [Sentry.browserTracingIntegration(), Sentry.replayIntegration()],
61
34
 
62
- // Alternatively:
63
- tracesSampler: samplingContext => {
64
- // Examine provided context data (along with anything in the global namespace) to decide the sample rate
65
- // for this transaction.
66
- // Can return 0 to drop the transaction entirely.
35
+ // Set tracesSampleRate to 1.0 to capture 100%
36
+ // of transactions for performance monitoring.
37
+ // We recommend adjusting this value in production
38
+ tracesSampleRate: 1.0,
67
39
 
68
- if ('...') {
69
- return 0.5; // These are important - take a big sample
70
- } else if ('...') {
71
- return 0.01; // These are less important or happen much more frequently - only take 1% of them
72
- } else if ('...') {
73
- return 0; // These aren't something worth tracking - drop all transactions like this
74
- } else {
75
- return 0.1; // Default sample rate
76
- }
77
- },
78
- },
79
- },
80
- // ...
81
- ],
82
- };
40
+ // Capture Replay for 10% of all sessions,
41
+ // plus for 100% of sessions with an error
42
+ replaysSessionSampleRate: 0.1,
43
+ replaysOnErrorSampleRate: 1.0,
44
+
45
+ // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
46
+ tracePropagationTargets: ['localhost', /^https:\/\/yourserver\.io\/api/],
47
+ });
83
48
  ```
84
49
 
85
- If you want to supply options to the `BrowserTracing` integration, use the `browserTracingOptions` parameter.
50
+ The Gatsby SDK also automatically sets up sourcemaps uploading for you. To disable this functionality, set the
51
+ `enableClientWebpackPlugin` option to be `false`.
86
52
 
87
53
  ```javascript
88
54
  module.exports = {
@@ -91,12 +57,7 @@ module.exports = {
91
57
  {
92
58
  resolve: '@sentry/gatsby',
93
59
  options: {
94
- dsn: process.env.SENTRY_DSN, // this is the default
95
- tracesSampleRate: 1, // or tracesSampler (see above)
96
- browserTracingOptions: {
97
- // disable creating spans for XHR requests
98
- traceXHR: false,
99
- },
60
+ enableClientWebpackPlugin: false,
100
61
  },
101
62
  },
102
63
  // ...
package/cjs/sdk.js CHANGED
@@ -2,17 +2,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  const core = require('@sentry/core');
4
4
  const react = require('@sentry/react');
5
- const integrations = require('./utils/integrations.js');
6
5
 
7
6
  /**
8
7
  * Inits the Sentry Gatsby SDK.
9
8
  */
10
9
  function init(options) {
11
10
  core.applySdkMetadata(options, 'gatsby');
12
- const integrations$1 = integrations.getIntegrationsFromOptions(options);
13
11
  react.init({
14
12
  ...options,
15
- integrations: integrations$1,
16
13
  });
17
14
  }
18
15
 
package/cjs/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { applySdkMetadata } from '@sentry/core';\nimport { init as reactInit } from '@sentry/react';\n\nimport { getIntegrationsFromOptions } from './utils/integrations';\nimport type { GatsbyOptions } from './utils/types';\n\n/**\n * Inits the Sentry Gatsby SDK.\n */\nexport function init(options: GatsbyOptions): void {\n applySdkMetadata(options, 'gatsby');\n const integrations = getIntegrationsFromOptions(options);\n reactInit({\n ...options,\n integrations,\n });\n}\n"],"names":["applySdkMetadata","integrations","getIntegrationsFromOptions","reactInit"],"mappings":";;;;;;AAMA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuB;AACnD,EAAEA,qBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACrC,EAAE,MAAMC,cAAa,GAAEC,uCAA0B,CAAC,OAAO,CAAC,CAAA;AAC1D,EAAEC,UAAS,CAAC;AACZ,IAAI,GAAG,OAAO;AACd,kBAAIF,cAAY;AAChB,GAAG,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { applySdkMetadata } from '@sentry/core';\nimport { init as reactInit } from '@sentry/react';\n\nimport type { GatsbyOptions } from './utils/types';\n\n/**\n * Inits the Sentry Gatsby SDK.\n */\nexport function init(options: GatsbyOptions): void {\n applySdkMetadata(options, 'gatsby');\n reactInit({\n ...options,\n });\n}\n"],"names":["applySdkMetadata","reactInit"],"mappings":";;;;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuB;AACnD,EAAEA,qBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACrC,EAAEC,UAAS,CAAC;AACZ,IAAI,GAAG,OAAO;AACd,GAAG,CAAC,CAAA;AACJ;;;;"}
package/esm/package.json CHANGED
@@ -1 +1 @@
1
- { "type": "module" }
1
+ {"type":"module","sideEffects":false}
package/esm/sdk.js CHANGED
@@ -1,16 +1,13 @@
1
1
  import { applySdkMetadata } from '@sentry/core';
2
2
  import { init as init$1 } from '@sentry/react';
3
- import { getIntegrationsFromOptions } from './utils/integrations.js';
4
3
 
5
4
  /**
6
5
  * Inits the Sentry Gatsby SDK.
7
6
  */
8
7
  function init(options) {
9
8
  applySdkMetadata(options, 'gatsby');
10
- const integrations = getIntegrationsFromOptions(options);
11
9
  init$1({
12
10
  ...options,
13
- integrations,
14
11
  });
15
12
  }
16
13
 
package/esm/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { applySdkMetadata } from '@sentry/core';\nimport { init as reactInit } from '@sentry/react';\n\nimport { getIntegrationsFromOptions } from './utils/integrations';\nimport type { GatsbyOptions } from './utils/types';\n\n/**\n * Inits the Sentry Gatsby SDK.\n */\nexport function init(options: GatsbyOptions): void {\n applySdkMetadata(options, 'gatsby');\n const integrations = getIntegrationsFromOptions(options);\n reactInit({\n ...options,\n integrations,\n });\n}\n"],"names":["reactInit"],"mappings":";;;;AAMA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuB;AACnD,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACrC,EAAE,MAAM,YAAa,GAAE,0BAA0B,CAAC,OAAO,CAAC,CAAA;AAC1D,EAAEA,MAAS,CAAC;AACZ,IAAI,GAAG,OAAO;AACd,IAAI,YAAY;AAChB,GAAG,CAAC,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import { applySdkMetadata } from '@sentry/core';\nimport { init as reactInit } from '@sentry/react';\n\nimport type { GatsbyOptions } from './utils/types';\n\n/**\n * Inits the Sentry Gatsby SDK.\n */\nexport function init(options: GatsbyOptions): void {\n applySdkMetadata(options, 'gatsby');\n reactInit({\n ...options,\n });\n}\n"],"names":["reactInit"],"mappings":";;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAuB;AACnD,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;AACrC,EAAEA,MAAS,CAAC;AACZ,IAAI,GAAG,OAAO;AACd,GAAG,CAAC,CAAA;AACJ;;;;"}
package/gatsby-node.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export function onCreateWebpackConfig({ plugins, getConfig, actions }: {
2
- plugins: any;
1
+ export function onCreateWebpackConfig({ getConfig, actions }: {
3
2
  getConfig: any;
4
3
  actions: any;
5
- }): void;
4
+ }, options: any): void;
package/gatsby-node.js CHANGED
@@ -1,48 +1,25 @@
1
1
  const fs = require('fs');
2
2
 
3
- const SentryWebpackPlugin = require('@sentry/webpack-plugin');
3
+ const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');
4
4
 
5
- const sentryRelease = JSON.stringify(
6
- // Always read first as Sentry takes this as precedence
7
- process.env.SENTRY_RELEASE ||
8
- // GitHub Actions - https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
9
- process.env.GITHUB_SHA ||
10
- // Netlify - https://docs.netlify.com/configure-builds/environment-variables/#build-metadata
11
- process.env.COMMIT_REF ||
12
- // Vercel - https://vercel.com/docs/v2/build-step#system-environment-variables
13
- process.env.VERCEL_GIT_COMMIT_SHA ||
14
- // Zeit (now known as Vercel)
15
- process.env.ZEIT_GITHUB_COMMIT_SHA ||
16
- process.env.ZEIT_GITLAB_COMMIT_SHA ||
17
- process.env.ZEIT_BITBUCKET_COMMIT_SHA ||
18
- undefined,
19
- );
20
-
21
- const sentryDsn = JSON.stringify(process.env.SENTRY_DSN || '');
22
5
  const SENTRY_USER_CONFIG = ['./sentry.config.js', './sentry.config.ts'];
23
6
 
24
- exports.onCreateWebpackConfig = ({ plugins, getConfig, actions }) => {
25
- actions.setWebpackConfig({
26
- plugins: [
27
- plugins.define({
28
- __SENTRY_RELEASE__: sentryRelease,
29
- __SENTRY_DSN__: sentryDsn,
30
- }),
31
- ],
32
- });
33
-
34
- if (process.env.NODE_ENV === 'production') {
7
+ exports.onCreateWebpackConfig = ({ getConfig, actions }, options) => {
8
+ const enableClientWebpackPlugin = options.enableClientWebpackPlugin !== false;
9
+ if (process.env.NODE_ENV === 'production' && enableClientWebpackPlugin) {
35
10
  actions.setWebpackConfig({
36
11
  plugins: [
37
- new SentryWebpackPlugin({
38
- // Only include files from the build output directory
39
- include: 'public',
40
- // Ignore files that aren't users' source code related
41
- ignore: [
42
- 'polyfill-*', // related to polyfills
43
- 'framework-*', // related to the frameworks (e.g. React)
44
- 'webpack-runtime-*', // related to Webpack
45
- ],
12
+ sentryWebpackPlugin({
13
+ sourcemaps: {
14
+ // Only include files from the build output directory
15
+ assets: ['public'],
16
+ // Ignore files that aren't users' source code related
17
+ ignore: [
18
+ 'polyfill-*', // related to polyfills
19
+ 'framework-*', // related to the frameworks (e.g. React)
20
+ 'webpack-runtime-*', // related to Webpack
21
+ ],
22
+ },
46
23
  // Handle sentry-cli configuration errors when the user has not done it not to break
47
24
  // the build.
48
25
  errorHandler(err, invokeErr) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/gatsby",
3
- "version": "8.0.0-alpha.4",
3
+ "version": "8.0.0-alpha.7",
4
4
  "description": "Official Sentry SDK for Gatsby.js",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby",
@@ -18,9 +18,7 @@
18
18
  "esm",
19
19
  "types",
20
20
  "types-ts3.8",
21
- "gatsby-browser.js",
22
21
  "gatsby-node.js",
23
- "gatsby-browser.d.ts",
24
22
  "gatsby-node.d.ts"
25
23
  ],
26
24
  "main": "cjs/index.js",
@@ -50,11 +48,11 @@
50
48
  "access": "public"
51
49
  },
52
50
  "dependencies": {
53
- "@sentry/core": "8.0.0-alpha.4",
54
- "@sentry/react": "8.0.0-alpha.4",
55
- "@sentry/types": "8.0.0-alpha.4",
56
- "@sentry/utils": "8.0.0-alpha.4",
57
- "@sentry/webpack-plugin": "1.19.0"
51
+ "@sentry/core": "8.0.0-alpha.7",
52
+ "@sentry/react": "8.0.0-alpha.7",
53
+ "@sentry/types": "8.0.0-alpha.7",
54
+ "@sentry/utils": "8.0.0-alpha.7",
55
+ "@sentry/webpack-plugin": "2.16.0"
58
56
  },
59
57
  "peerDependencies": {
60
58
  "gatsby": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0",
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAOjD"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAKjD"}
@@ -1,53 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- const core = require('@sentry/core');
4
- const react = require('@sentry/react');
5
-
6
- /**
7
- * Returns the integrations to add to the SDK.
8
- * If tracing is enabled, `BrowserTracing` is always present.
9
- *
10
- * @param options The options users have defined.
11
- */
12
- function getIntegrationsFromOptions(options) {
13
- const isTracingEnabled = core.hasTracingEnabled(options);
14
- if (options.integrations === undefined) {
15
- return getIntegrationsFromArray([], isTracingEnabled);
16
- } else if (Array.isArray(options.integrations)) {
17
- return getIntegrationsFromArray(options.integrations, isTracingEnabled);
18
- } else {
19
- return getIntegrationsFromFunction(options.integrations, isTracingEnabled);
20
- }
21
- }
22
-
23
- /**
24
- * Returns the integrations to add to the SDK, from the given integrations array.
25
- *
26
- * @param userIntegrations Array of user's integrations.
27
- * @param isTracingEnabled Whether the user has enabled tracing.
28
- */
29
- function getIntegrationsFromArray(userIntegrations, isTracingEnabled) {
30
- if (isTracingEnabled && !userIntegrations.some(integration => integration.name === 'BrowserTracing')) {
31
- userIntegrations.push(react.browserTracingIntegration());
32
- }
33
- return userIntegrations;
34
- }
35
-
36
- /**
37
- * Returns the integrations to add to the SDK, from the given function.
38
- *
39
- * @param userIntegrations Function returning the user's integrations.
40
- * @param isTracingEnabled Whether the user has enabled tracing.
41
- */
42
- function getIntegrationsFromFunction(
43
- userIntegrations,
44
- isTracingEnabled,
45
- ) {
46
- const wrapper = (defaultIntegrations) => {
47
- return getIntegrationsFromArray(userIntegrations(defaultIntegrations), isTracingEnabled);
48
- };
49
- return wrapper;
50
- }
51
-
52
- exports.getIntegrationsFromOptions = getIntegrationsFromOptions;
53
- //# sourceMappingURL=integrations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integrations.js","sources":["../../../src/utils/integrations.ts"],"sourcesContent":["import { hasTracingEnabled } from '@sentry/core';\nimport { browserTracingIntegration } from '@sentry/react';\nimport type { Integration } from '@sentry/types';\n\nimport type { GatsbyOptions } from './types';\n\ntype UserFnIntegrations = (integrations: Integration[]) => Integration[];\nexport type UserIntegrations = Integration[] | UserFnIntegrations;\n\n/**\n * Returns the integrations to add to the SDK.\n * If tracing is enabled, `BrowserTracing` is always present.\n *\n * @param options The options users have defined.\n */\nexport function getIntegrationsFromOptions(options: GatsbyOptions): UserIntegrations {\n const isTracingEnabled = hasTracingEnabled(options);\n if (options.integrations === undefined) {\n return getIntegrationsFromArray([], isTracingEnabled);\n } else if (Array.isArray(options.integrations)) {\n return getIntegrationsFromArray(options.integrations, isTracingEnabled);\n } else {\n return getIntegrationsFromFunction(options.integrations, isTracingEnabled);\n }\n}\n\n/**\n * Returns the integrations to add to the SDK, from the given integrations array.\n *\n * @param userIntegrations Array of user's integrations.\n * @param isTracingEnabled Whether the user has enabled tracing.\n */\nfunction getIntegrationsFromArray(userIntegrations: Integration[], isTracingEnabled: boolean): Integration[] {\n if (isTracingEnabled && !userIntegrations.some(integration => integration.name === 'BrowserTracing')) {\n userIntegrations.push(browserTracingIntegration());\n }\n return userIntegrations;\n}\n\n/**\n * Returns the integrations to add to the SDK, from the given function.\n *\n * @param userIntegrations Function returning the user's integrations.\n * @param isTracingEnabled Whether the user has enabled tracing.\n */\nfunction getIntegrationsFromFunction(\n userIntegrations: UserFnIntegrations,\n isTracingEnabled: boolean,\n): UserFnIntegrations {\n const wrapper: UserFnIntegrations = (defaultIntegrations: Integration[]) => {\n return getIntegrationsFromArray(userIntegrations(defaultIntegrations), isTracingEnabled);\n };\n return wrapper;\n}\n"],"names":["hasTracingEnabled","browserTracingIntegration"],"mappings":";;;;;AASA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,OAAO,EAAmC;AACrF,EAAE,MAAM,gBAAiB,GAAEA,sBAAiB,CAAC,OAAO,CAAC,CAAA;AACrD,EAAE,IAAI,OAAO,CAAC,YAAa,KAAI,SAAS,EAAE;AAC1C,IAAI,OAAO,wBAAwB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAA;AACzD,GAAI,MAAK,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AAClD,IAAI,OAAO,wBAAwB,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;AAC3E,SAAS;AACT,IAAI,OAAO,2BAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;AAC9E,GAAE;AACF,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,gBAAgB,EAAiB,gBAAgB,EAA0B;AAC7G,EAAE,IAAI,gBAAA,IAAoB,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAA,IAAe,WAAW,CAAC,SAAS,gBAAgB,CAAC,EAAE;AACxG,IAAI,gBAAgB,CAAC,IAAI,CAACC,+BAAyB,EAAE,CAAC,CAAA;AACtD,GAAE;AACF,EAAE,OAAO,gBAAgB,CAAA;AACzB,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,2BAA2B;AACpC,EAAE,gBAAgB;AAClB,EAAE,gBAAgB;AAClB,EAAsB;AACtB,EAAE,MAAM,OAAO,GAAuB,CAAC,mBAAmB,KAAoB;AAC9E,IAAI,OAAO,wBAAwB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,CAAA;AAC5F,GAAG,CAAA;AACH,EAAE,OAAO,OAAO,CAAA;AAChB;;;;"}
@@ -1,51 +0,0 @@
1
- import { hasTracingEnabled } from '@sentry/core';
2
- import { browserTracingIntegration } from '@sentry/react';
3
-
4
- /**
5
- * Returns the integrations to add to the SDK.
6
- * If tracing is enabled, `BrowserTracing` is always present.
7
- *
8
- * @param options The options users have defined.
9
- */
10
- function getIntegrationsFromOptions(options) {
11
- const isTracingEnabled = hasTracingEnabled(options);
12
- if (options.integrations === undefined) {
13
- return getIntegrationsFromArray([], isTracingEnabled);
14
- } else if (Array.isArray(options.integrations)) {
15
- return getIntegrationsFromArray(options.integrations, isTracingEnabled);
16
- } else {
17
- return getIntegrationsFromFunction(options.integrations, isTracingEnabled);
18
- }
19
- }
20
-
21
- /**
22
- * Returns the integrations to add to the SDK, from the given integrations array.
23
- *
24
- * @param userIntegrations Array of user's integrations.
25
- * @param isTracingEnabled Whether the user has enabled tracing.
26
- */
27
- function getIntegrationsFromArray(userIntegrations, isTracingEnabled) {
28
- if (isTracingEnabled && !userIntegrations.some(integration => integration.name === 'BrowserTracing')) {
29
- userIntegrations.push(browserTracingIntegration());
30
- }
31
- return userIntegrations;
32
- }
33
-
34
- /**
35
- * Returns the integrations to add to the SDK, from the given function.
36
- *
37
- * @param userIntegrations Function returning the user's integrations.
38
- * @param isTracingEnabled Whether the user has enabled tracing.
39
- */
40
- function getIntegrationsFromFunction(
41
- userIntegrations,
42
- isTracingEnabled,
43
- ) {
44
- const wrapper = (defaultIntegrations) => {
45
- return getIntegrationsFromArray(userIntegrations(defaultIntegrations), isTracingEnabled);
46
- };
47
- return wrapper;
48
- }
49
-
50
- export { getIntegrationsFromOptions };
51
- //# sourceMappingURL=integrations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integrations.js","sources":["../../../src/utils/integrations.ts"],"sourcesContent":["import { hasTracingEnabled } from '@sentry/core';\nimport { browserTracingIntegration } from '@sentry/react';\nimport type { Integration } from '@sentry/types';\n\nimport type { GatsbyOptions } from './types';\n\ntype UserFnIntegrations = (integrations: Integration[]) => Integration[];\nexport type UserIntegrations = Integration[] | UserFnIntegrations;\n\n/**\n * Returns the integrations to add to the SDK.\n * If tracing is enabled, `BrowserTracing` is always present.\n *\n * @param options The options users have defined.\n */\nexport function getIntegrationsFromOptions(options: GatsbyOptions): UserIntegrations {\n const isTracingEnabled = hasTracingEnabled(options);\n if (options.integrations === undefined) {\n return getIntegrationsFromArray([], isTracingEnabled);\n } else if (Array.isArray(options.integrations)) {\n return getIntegrationsFromArray(options.integrations, isTracingEnabled);\n } else {\n return getIntegrationsFromFunction(options.integrations, isTracingEnabled);\n }\n}\n\n/**\n * Returns the integrations to add to the SDK, from the given integrations array.\n *\n * @param userIntegrations Array of user's integrations.\n * @param isTracingEnabled Whether the user has enabled tracing.\n */\nfunction getIntegrationsFromArray(userIntegrations: Integration[], isTracingEnabled: boolean): Integration[] {\n if (isTracingEnabled && !userIntegrations.some(integration => integration.name === 'BrowserTracing')) {\n userIntegrations.push(browserTracingIntegration());\n }\n return userIntegrations;\n}\n\n/**\n * Returns the integrations to add to the SDK, from the given function.\n *\n * @param userIntegrations Function returning the user's integrations.\n * @param isTracingEnabled Whether the user has enabled tracing.\n */\nfunction getIntegrationsFromFunction(\n userIntegrations: UserFnIntegrations,\n isTracingEnabled: boolean,\n): UserFnIntegrations {\n const wrapper: UserFnIntegrations = (defaultIntegrations: Integration[]) => {\n return getIntegrationsFromArray(userIntegrations(defaultIntegrations), isTracingEnabled);\n };\n return wrapper;\n}\n"],"names":[],"mappings":";;;AASA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,0BAA0B,CAAC,OAAO,EAAmC;AACrF,EAAE,MAAM,gBAAiB,GAAE,iBAAiB,CAAC,OAAO,CAAC,CAAA;AACrD,EAAE,IAAI,OAAO,CAAC,YAAa,KAAI,SAAS,EAAE;AAC1C,IAAI,OAAO,wBAAwB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAA;AACzD,GAAI,MAAK,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;AAClD,IAAI,OAAO,wBAAwB,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;AAC3E,SAAS;AACT,IAAI,OAAO,2BAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;AAC9E,GAAE;AACF,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,wBAAwB,CAAC,gBAAgB,EAAiB,gBAAgB,EAA0B;AAC7G,EAAE,IAAI,gBAAA,IAAoB,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAA,IAAe,WAAW,CAAC,SAAS,gBAAgB,CAAC,EAAE;AACxG,IAAI,gBAAgB,CAAC,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAA;AACtD,GAAE;AACF,EAAE,OAAO,gBAAgB,CAAA;AACzB,CAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,2BAA2B;AACpC,EAAE,gBAAgB;AAClB,EAAE,gBAAgB;AAClB,EAAsB;AACtB,EAAE,MAAM,OAAO,GAAuB,CAAC,mBAAmB,KAAoB;AAC9E,IAAI,OAAO,wBAAwB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,CAAA;AAC5F,GAAG,CAAA;AACH,EAAE,OAAO,OAAO,CAAA;AAChB;;;;"}
@@ -1 +0,0 @@
1
- export function onClientEntry(_: any, pluginParams: any): void;
package/gatsby-browser.js DELETED
@@ -1,45 +0,0 @@
1
- /* eslint-disable no-console */
2
- import { getClient, init } from '@sentry/gatsby';
3
-
4
- export function onClientEntry(_, pluginParams) {
5
- const isIntialized = isSentryInitialized();
6
- const areOptionsDefined = areSentryOptionsDefined(pluginParams);
7
-
8
- if (isIntialized) {
9
- if (areOptionsDefined) {
10
- console.warn(
11
- 'Sentry Logger [Warn]: The SDK was initialized in the Sentry config file, but options were found in the Gatsby config. ' +
12
- 'These have been ignored. Merge them to the Sentry config if you want to use them.\n' +
13
- 'Learn more about the Gatsby SDK in https://docs.sentry.io/platforms/javascript/guides/gatsby/.',
14
- );
15
- }
16
- return;
17
- }
18
-
19
- if (!areOptionsDefined) {
20
- console.error(
21
- 'Sentry Logger [Error]: No config for the Gatsby SDK was found.\n' +
22
- 'Learn how to configure it in https://docs.sentry.io/platforms/javascript/guides/gatsby/.',
23
- );
24
- return;
25
- }
26
-
27
- init({
28
- // eslint-disable-next-line no-undef
29
- dsn: __SENTRY_DSN__,
30
- ...pluginParams,
31
- });
32
- }
33
-
34
- function isSentryInitialized() {
35
- return !!getClient();
36
- }
37
-
38
- function areSentryOptionsDefined(params) {
39
- if (params == undefined) return false;
40
- // Even if there aren't any options, there's a `plugins` property defined as an empty array
41
- if (Object.keys(params).length == 1 && Array.isArray(params.plugins) && params.plugins.length == 0) {
42
- return false;
43
- }
44
- return true;
45
- }
@@ -1,13 +0,0 @@
1
- import type { Integration } from '@sentry/types';
2
- import type { GatsbyOptions } from './types';
3
- type UserFnIntegrations = (integrations: Integration[]) => Integration[];
4
- export type UserIntegrations = Integration[] | UserFnIntegrations;
5
- /**
6
- * Returns the integrations to add to the SDK.
7
- * If tracing is enabled, `BrowserTracing` is always present.
8
- *
9
- * @param options The options users have defined.
10
- */
11
- export declare function getIntegrationsFromOptions(options: GatsbyOptions): UserIntegrations;
12
- export {};
13
- //# sourceMappingURL=integrations.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../src/utils/integrations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,KAAK,kBAAkB,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,CAAC;AACzE,MAAM,MAAM,gBAAgB,GAAG,WAAW,EAAE,GAAG,kBAAkB,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,gBAAgB,CASnF"}
@@ -1,13 +0,0 @@
1
- import { Integration } from '@sentry/types';
2
- import { GatsbyOptions } from './types';
3
- type UserFnIntegrations = (integrations: Integration[]) => Integration[];
4
- export type UserIntegrations = Integration[] | UserFnIntegrations;
5
- /**
6
- * Returns the integrations to add to the SDK.
7
- * If tracing is enabled, `BrowserTracing` is always present.
8
- *
9
- * @param options The options users have defined.
10
- */
11
- export declare function getIntegrationsFromOptions(options: GatsbyOptions): UserIntegrations;
12
- export {};
13
- //# sourceMappingURL=integrations.d.ts.map