@sentry/gatsby 6.13.2 → 6.14.2

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/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from '@sentry/react';
2
+ export { Integrations } from '@sentry/tracing';
3
+ export { init } from './sdk';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,8 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
2
  var tslib_1 = require("tslib");
3
3
  tslib_1.__exportStar(require("@sentry/react"), exports);
4
+ var tracing_1 = require("@sentry/tracing");
5
+ exports.Integrations = tracing_1.Integrations;
6
+ var sdk_1 = require("./sdk");
7
+ exports.init = sdk_1.init;
4
8
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,wDAA8B","sourcesContent":["export * from '@sentry/react';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,wDAA8B;AAC9B,2CAA+C;AAAtC,iCAAA,YAAY,CAAA;AAErB,6BAA6B;AAApB,qBAAA,IAAI,CAAA","sourcesContent":["export * from '@sentry/react';\nexport { Integrations } from '@sentry/tracing';\n\nexport { init } from './sdk';\n"]}
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { GatsbyOptions } from './utils/types';
2
+ /**
3
+ * Inits the Sentry Gatsby SDK.
4
+ */
5
+ export declare function init(options: GatsbyOptions): void;
6
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAkBjD"}
package/dist/sdk.js ADDED
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ var tslib_1 = require("tslib");
3
+ var react_1 = require("@sentry/react");
4
+ var integrations_1 = require("./utils/integrations");
5
+ /**
6
+ * Inits the Sentry Gatsby SDK.
7
+ */
8
+ function init(options) {
9
+ options._metadata = options._metadata || {};
10
+ options._metadata.sdk = options._metadata.sdk || {
11
+ name: 'sentry.javascript.gatsby',
12
+ packages: [
13
+ {
14
+ name: 'npm:@sentry/gatsby',
15
+ version: react_1.SDK_VERSION,
16
+ },
17
+ ],
18
+ version: react_1.SDK_VERSION,
19
+ };
20
+ var integrations = integrations_1.getIntegrationsFromOptions(options);
21
+ react_1.init(tslib_1.__assign(tslib_1.__assign({}, options), { integrations: integrations }));
22
+ }
23
+ exports.init = init;
24
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";;AAAA,uCAA+D;AAE/D,qDAAkE;AAGlE;;GAEG;AACH,SAAgB,IAAI,CAAC,OAAsB;IACzC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;QAC/C,IAAI,EAAE,0BAA0B;QAChC,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,mBAAW;aACrB;SACF;QACD,OAAO,EAAE,mBAAW;KACrB,CAAC;IAEF,IAAM,YAAY,GAAG,yCAA0B,CAAC,OAAO,CAAC,CAAC;IACzD,YAAS,uCACJ,OAAO,KACV,YAAY,cAAA,IACZ,CAAC;AACL,CAAC;AAlBD,oBAkBC","sourcesContent":["import { init as reactInit, SDK_VERSION } from '@sentry/react';\n\nimport { getIntegrationsFromOptions } from './utils/integrations';\nimport { GatsbyOptions } from './utils/types';\n\n/**\n * Inits the Sentry Gatsby SDK.\n */\nexport function init(options: GatsbyOptions): void {\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || {\n name: 'sentry.javascript.gatsby',\n packages: [\n {\n name: 'npm:@sentry/gatsby',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n\n const integrations = getIntegrationsFromOptions(options);\n reactInit({\n ...options,\n integrations,\n });\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Integration } from '@sentry/types';
2
+ import { GatsbyOptions } from './types';
3
+ declare type UserFnIntegrations = (integrations: Integration[]) => Integration[];
4
+ export declare 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/utils/integrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,aAAK,kBAAkB,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,CAAC;AACzE,oBAAY,gBAAgB,GAAG,WAAW,EAAE,GAAG,kBAAkB,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,gBAAgB,CASnF"}
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ var tslib_1 = require("tslib");
3
+ var Tracing = tslib_1.__importStar(require("@sentry/tracing"));
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
+ var isTracingEnabled = Tracing.hasTracingEnabled(options);
12
+ if (options.integrations === undefined) {
13
+ return getIntegrationsFromArray([], isTracingEnabled);
14
+ }
15
+ else if (Array.isArray(options.integrations)) {
16
+ return getIntegrationsFromArray(options.integrations, isTracingEnabled);
17
+ }
18
+ else {
19
+ return getIntegrationsFromFunction(options.integrations, isTracingEnabled);
20
+ }
21
+ }
22
+ exports.getIntegrationsFromOptions = getIntegrationsFromOptions;
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 &&
31
+ !userIntegrations.some(function (integration) { return integration.name === Tracing.Integrations.BrowserTracing.name; })) {
32
+ userIntegrations.push(new Tracing.Integrations.BrowserTracing());
33
+ }
34
+ return userIntegrations;
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(userIntegrations, isTracingEnabled) {
43
+ var wrapper = function (defaultIntegrations) {
44
+ return getIntegrationsFromArray(userIntegrations(defaultIntegrations), isTracingEnabled);
45
+ };
46
+ return wrapper;
47
+ }
48
+ //# sourceMappingURL=integrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/utils/integrations.ts"],"names":[],"mappings":";;AAAA,+DAA2C;AAQ3C;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,OAAsB;IAC/D,IAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;QACtC,OAAO,wBAAwB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;KACvD;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QAC9C,OAAO,wBAAwB,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KACzE;SAAM;QACL,OAAO,2BAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KAC5E;AACH,CAAC;AATD,gEASC;AAED;;;;;GAKG;AACH,SAAS,wBAAwB,CAAC,gBAA+B,EAAE,gBAAyB;IAC1F,IACE,gBAAgB;QAChB,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAA,WAAW,IAAI,OAAA,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,EAA7D,CAA6D,CAAC,EACpG;QACA,gBAAgB,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC,CAAC;KAClE;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAClC,gBAAoC,EACpC,gBAAyB;IAEzB,IAAM,OAAO,GAAuB,UAAC,mBAAkC;QACrE,OAAO,wBAAwB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC3F,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import * as Tracing from '@sentry/tracing';\nimport { Integration } from '@sentry/types';\n\nimport { 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 = Tracing.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 (\n isTracingEnabled &&\n !userIntegrations.some(integration => integration.name === Tracing.Integrations.BrowserTracing.name)\n ) {\n userIntegrations.push(new Tracing.Integrations.BrowserTracing());\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"]}
@@ -0,0 +1,3 @@
1
+ import { BrowserOptions } from '@sentry/react';
2
+ export declare type GatsbyOptions = BrowserOptions;
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,oBAAY,aAAa,GAAG,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports, "__esModule", { value: true });
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["import { BrowserOptions } from '@sentry/react';\n\nexport type GatsbyOptions = BrowserOptions;\n"]}
package/esm/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from '@sentry/react';
2
+ export { Integrations } from '@sentry/tracing';
3
+ export { init } from './sdk';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC"}
package/esm/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from '@sentry/react';
2
+ export { Integrations } from '@sentry/tracing';
3
+ export { init } from './sdk';
2
4
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","sourcesContent":["export * from '@sentry/react';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC","sourcesContent":["export * from '@sentry/react';\nexport { Integrations } from '@sentry/tracing';\n\nexport { init } from './sdk';\n"]}
package/esm/sdk.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { GatsbyOptions } from './utils/types';
2
+ /**
3
+ * Inits the Sentry Gatsby SDK.
4
+ */
5
+ export declare function init(options: GatsbyOptions): void;
6
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAkBjD"}
package/esm/sdk.js ADDED
@@ -0,0 +1,22 @@
1
+ import { __assign } from "tslib";
2
+ import { init as reactInit, SDK_VERSION } from '@sentry/react';
3
+ import { getIntegrationsFromOptions } from './utils/integrations';
4
+ /**
5
+ * Inits the Sentry Gatsby SDK.
6
+ */
7
+ export function init(options) {
8
+ options._metadata = options._metadata || {};
9
+ options._metadata.sdk = options._metadata.sdk || {
10
+ name: 'sentry.javascript.gatsby',
11
+ packages: [
12
+ {
13
+ name: 'npm:@sentry/gatsby',
14
+ version: SDK_VERSION,
15
+ },
16
+ ],
17
+ version: SDK_VERSION,
18
+ };
19
+ var integrations = getIntegrationsFromOptions(options);
20
+ reactInit(__assign(__assign({}, options), { integrations: integrations }));
21
+ }
22
+ //# sourceMappingURL=sdk.js.map
package/esm/sdk.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAGlE;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAsB;IACzC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC;IAC5C,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;QAC/C,IAAI,EAAE,0BAA0B;QAChC,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,oBAAoB;gBAC1B,OAAO,EAAE,WAAW;aACrB;SACF;QACD,OAAO,EAAE,WAAW;KACrB,CAAC;IAEF,IAAM,YAAY,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;IACzD,SAAS,uBACJ,OAAO,KACV,YAAY,cAAA,IACZ,CAAC;AACL,CAAC","sourcesContent":["import { init as reactInit, SDK_VERSION } from '@sentry/react';\n\nimport { getIntegrationsFromOptions } from './utils/integrations';\nimport { GatsbyOptions } from './utils/types';\n\n/**\n * Inits the Sentry Gatsby SDK.\n */\nexport function init(options: GatsbyOptions): void {\n options._metadata = options._metadata || {};\n options._metadata.sdk = options._metadata.sdk || {\n name: 'sentry.javascript.gatsby',\n packages: [\n {\n name: 'npm:@sentry/gatsby',\n version: SDK_VERSION,\n },\n ],\n version: SDK_VERSION,\n };\n\n const integrations = getIntegrationsFromOptions(options);\n reactInit({\n ...options,\n integrations,\n });\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { Integration } from '@sentry/types';
2
+ import { GatsbyOptions } from './types';
3
+ declare type UserFnIntegrations = (integrations: Integration[]) => Integration[];
4
+ export declare 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/utils/integrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,aAAK,kBAAkB,GAAG,CAAC,YAAY,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,CAAC;AACzE,oBAAY,gBAAgB,GAAG,WAAW,EAAE,GAAG,kBAAkB,CAAC;AAElE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,aAAa,GAAG,gBAAgB,CASnF"}
@@ -0,0 +1,45 @@
1
+ import * as Tracing from '@sentry/tracing';
2
+ /**
3
+ * Returns the integrations to add to the SDK.
4
+ * If tracing is enabled, `BrowserTracing` is always present.
5
+ *
6
+ * @param options The options users have defined.
7
+ */
8
+ export function getIntegrationsFromOptions(options) {
9
+ var isTracingEnabled = Tracing.hasTracingEnabled(options);
10
+ if (options.integrations === undefined) {
11
+ return getIntegrationsFromArray([], isTracingEnabled);
12
+ }
13
+ else if (Array.isArray(options.integrations)) {
14
+ return getIntegrationsFromArray(options.integrations, isTracingEnabled);
15
+ }
16
+ else {
17
+ return getIntegrationsFromFunction(options.integrations, isTracingEnabled);
18
+ }
19
+ }
20
+ /**
21
+ * Returns the integrations to add to the SDK, from the given integrations array.
22
+ *
23
+ * @param userIntegrations Array of user's integrations.
24
+ * @param isTracingEnabled Whether the user has enabled tracing.
25
+ */
26
+ function getIntegrationsFromArray(userIntegrations, isTracingEnabled) {
27
+ if (isTracingEnabled &&
28
+ !userIntegrations.some(function (integration) { return integration.name === Tracing.Integrations.BrowserTracing.name; })) {
29
+ userIntegrations.push(new Tracing.Integrations.BrowserTracing());
30
+ }
31
+ return userIntegrations;
32
+ }
33
+ /**
34
+ * Returns the integrations to add to the SDK, from the given function.
35
+ *
36
+ * @param userIntegrations Function returning the user's integrations.
37
+ * @param isTracingEnabled Whether the user has enabled tracing.
38
+ */
39
+ function getIntegrationsFromFunction(userIntegrations, isTracingEnabled) {
40
+ var wrapper = function (defaultIntegrations) {
41
+ return getIntegrationsFromArray(userIntegrations(defaultIntegrations), isTracingEnabled);
42
+ };
43
+ return wrapper;
44
+ }
45
+ //# sourceMappingURL=integrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/utils/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAQ3C;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAsB;IAC/D,IAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC5D,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;QACtC,OAAO,wBAAwB,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;KACvD;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QAC9C,OAAO,wBAAwB,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KACzE;SAAM;QACL,OAAO,2BAA2B,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;KAC5E;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,wBAAwB,CAAC,gBAA+B,EAAE,gBAAyB;IAC1F,IACE,gBAAgB;QAChB,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAA,WAAW,IAAI,OAAA,WAAW,CAAC,IAAI,KAAK,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI,EAA7D,CAA6D,CAAC,EACpG;QACA,gBAAgB,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC,CAAC;KAClE;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,SAAS,2BAA2B,CAClC,gBAAoC,EACpC,gBAAyB;IAEzB,IAAM,OAAO,GAAuB,UAAC,mBAAkC;QACrE,OAAO,wBAAwB,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC3F,CAAC,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import * as Tracing from '@sentry/tracing';\nimport { Integration } from '@sentry/types';\n\nimport { 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 = Tracing.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 (\n isTracingEnabled &&\n !userIntegrations.some(integration => integration.name === Tracing.Integrations.BrowserTracing.name)\n ) {\n userIntegrations.push(new Tracing.Integrations.BrowserTracing());\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"]}
@@ -0,0 +1,3 @@
1
+ import { BrowserOptions } from '@sentry/react';
2
+ export declare type GatsbyOptions = BrowserOptions;
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,oBAAY,aAAa,GAAG,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"","sourcesContent":["import { BrowserOptions } from '@sentry/react';\n\nexport type GatsbyOptions = BrowserOptions;\n"]}
package/gatsby-browser.js CHANGED
@@ -1,41 +1,52 @@
1
- const Sentry = require('@sentry/react');
2
- const Tracing = require('@sentry/tracing');
1
+ /* eslint-disable no-console */
2
+ const Sentry = require('@sentry/gatsby');
3
3
 
4
4
  exports.onClientEntry = function(_, pluginParams) {
5
- if (pluginParams === undefined) {
5
+ const isIntialized = isSentryInitialized();
6
+ const areOptionsDefined = areSentryOptionsDefined(pluginParams);
7
+
8
+ if (isIntialized) {
9
+ window.Sentry = Sentry; // For backwards compatibility
10
+ if (areOptionsDefined) {
11
+ console.warn(
12
+ 'Sentry Logger [Warn]: The SDK was initialized in the Sentry config file, but options were found in the Gatsby config. ' +
13
+ 'These have been ignored, merge them to the Sentry config if you want to use them.\n' +
14
+ 'Learn more about the Gatsby SDK on https://docs.sentry.io/platforms/javascript/guides/gatsby/',
15
+ );
16
+ }
6
17
  return;
7
18
  }
8
19
 
9
- pluginParams._metadata = pluginParams._metadata || {};
10
- pluginParams._metadata.sdk = {
11
- name: 'sentry.javascript.gatsby',
12
- packages: [
13
- {
14
- name: 'npm:@sentry/gatsby',
15
- version: Sentry.SDK_VERSION,
16
- },
17
- ],
18
- version: Sentry.SDK_VERSION,
19
- };
20
-
21
- const integrations = [...(pluginParams.integrations || [])];
22
-
23
- if (Tracing.hasTracingEnabled(pluginParams) && !integrations.some(ele => ele.name === 'BrowserTracing')) {
24
- integrations.push(new Tracing.Integrations.BrowserTracing(pluginParams.browserTracingOptions));
20
+ if (!areOptionsDefined) {
21
+ console.error(
22
+ 'Sentry Logger [Error]: No config for the Gatsby SDK was found.\n' +
23
+ 'Learn how to configure it on https://docs.sentry.io/platforms/javascript/guides/gatsby/',
24
+ );
25
+ return;
25
26
  }
26
27
 
27
- Tracing.addExtensionMethods();
28
-
29
28
  Sentry.init({
30
- autoSessionTracking: true,
31
- environment: process.env.NODE_ENV || 'development',
32
29
  // eslint-disable-next-line no-undef
33
30
  release: __SENTRY_RELEASE__,
34
31
  // eslint-disable-next-line no-undef
35
32
  dsn: __SENTRY_DSN__,
36
33
  ...pluginParams,
37
- integrations,
38
34
  });
39
-
40
- window.Sentry = Sentry;
35
+ window.Sentry = Sentry; // For backwards compatibility
41
36
  };
37
+
38
+ function isSentryInitialized() {
39
+ // Although `window` should exist because we're in the browser (where this script
40
+ // is run), and `__SENTRY__.hub` is created when importing the Gatsby SDK, double
41
+ // check that in case something weird happens.
42
+ return !!(window && window.__SENTRY__ && window.__SENTRY__.hub && window.__SENTRY__.hub.getClient());
43
+ }
44
+
45
+ function areSentryOptionsDefined(params) {
46
+ if (params == undefined) return false;
47
+ // Even if there aren't any options, there's a `plugins` property defined as an empty array
48
+ if (Object.keys(params).length == 1 && Array.isArray(params.plugins) && params.plugins.length == 0) {
49
+ return false;
50
+ }
51
+ return true;
52
+ }
package/gatsby-node.js CHANGED
@@ -1,3 +1,7 @@
1
+ const fs = require('fs');
2
+
3
+ const SentryWebpackPlugin = require('@sentry/webpack-plugin');
4
+
1
5
  const sentryRelease = JSON.stringify(
2
6
  // Always read first as Sentry takes this as precedence
3
7
  process.env.SENTRY_RELEASE ||
@@ -15,8 +19,9 @@ const sentryRelease = JSON.stringify(
15
19
  );
16
20
 
17
21
  const sentryDsn = JSON.stringify(process.env.SENTRY_DSN || '');
22
+ const SENTRY_USER_CONFIG = ['./sentry.config.js', './sentry.config.ts'];
18
23
 
19
- exports.onCreateWebpackConfig = ({ plugins, actions }) => {
24
+ exports.onCreateWebpackConfig = ({ plugins, getConfig, actions }) => {
20
25
  actions.setWebpackConfig({
21
26
  plugins: [
22
27
  plugins.define({
@@ -25,4 +30,75 @@ exports.onCreateWebpackConfig = ({ plugins, actions }) => {
25
30
  }),
26
31
  ],
27
32
  });
33
+
34
+ if (process.env.NODE_ENV === 'production') {
35
+ actions.setWebpackConfig({
36
+ 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
+ 'app-*', // related to Gatsby itself
43
+ 'polyfill-*', // related to polyfills
44
+ 'framework-*', // related to the frameworks (e.g. React)
45
+ 'webpack-runtime-*', // related to Webpack
46
+ ],
47
+ // Handle sentry-cli configuration errors when the user has not done it not to break
48
+ // the build.
49
+ errorHandler(err, invokeErr) {
50
+ const { message } = err;
51
+ if (message.includes('organization slug is required') || message.includes('project slug is required')) {
52
+ return;
53
+ }
54
+ invokeErr(err);
55
+ },
56
+ }),
57
+ ],
58
+ });
59
+ }
60
+
61
+ // To configure the SDK, SENTRY_USER_CONFIG is prioritized over `gatsby-config.js`,
62
+ // since it isn't possible to set non-serializable parameters in the latter.
63
+ // Prioritization here means what `init` is run.
64
+ let configFile = null;
65
+ try {
66
+ configFile = SENTRY_USER_CONFIG.find(file => fs.existsSync(file));
67
+ } catch (error) {
68
+ // Some node versions (like v11) throw an exception on `existsSync` instead of
69
+ // returning false. See https://github.com/tschaub/mock-fs/issues/256
70
+ }
71
+
72
+ if (!configFile) {
73
+ return;
74
+ }
75
+ // `setWebpackConfig` merges the Webpack config, ignoring some props like `entry`. See
76
+ // https://www.gatsbyjs.com/docs/reference/config-files/actions/#setWebpackConfig
77
+ // So it's not possible to inject the Sentry properties with that method. Instead, we
78
+ // can replace the whole config with the modifications we need.
79
+ const finalConfig = injectSentryConfig(getConfig(), configFile);
80
+ actions.replaceWebpackConfig(finalConfig);
28
81
  };
82
+
83
+ function injectSentryConfig(config, configFile) {
84
+ const injectedEntries = {};
85
+ // TODO: investigate what entries need the Sentry config injected.
86
+ // We may want to skip some.
87
+ Object.keys(config.entry).forEach(prop => {
88
+ const value = config.entry[prop];
89
+ let injectedValue = value;
90
+ if (typeof value === 'string') {
91
+ injectedValue = [configFile, value];
92
+ } else if (Array.isArray(value)) {
93
+ injectedValue = [configFile, ...value];
94
+ } else {
95
+ // eslint-disable-next-line no-console
96
+ console.error(
97
+ `Sentry Logger [Error]: Could not inject SDK initialization code into ${prop}, unexpected format: `,
98
+ typeof value,
99
+ );
100
+ }
101
+ injectedEntries[prop] = injectedValue;
102
+ });
103
+ return { ...config, entry: injectedEntries };
104
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/gatsby",
3
- "version": "6.13.2",
3
+ "version": "6.14.2",
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",
@@ -26,14 +26,15 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@sentry/react": "6.13.2",
30
- "@sentry/tracing": "6.13.2"
29
+ "@sentry/react": "6.14.2",
30
+ "@sentry/tracing": "6.14.2",
31
+ "@sentry/webpack-plugin": "1.18.3"
31
32
  },
32
33
  "peerDependencies": {
33
- "gatsby": "^2.0.0 || ^3.0.0"
34
+ "gatsby": "^2.0.0 || ^3.0.0 || ^4.0.0"
34
35
  },
35
36
  "devDependencies": {
36
- "@sentry-internal/eslint-config-sdk": "6.13.2",
37
+ "@sentry/types": "6.14.2",
37
38
  "@testing-library/react": "^10.4.9",
38
39
  "jest": "^24.7.1",
39
40
  "npm-run-all": "^4.1.2",
@@ -44,23 +45,25 @@
44
45
  },
45
46
  "scripts": {
46
47
  "build": "run-p build:es5 build:esm",
48
+ "build:dev": "run-s build",
47
49
  "build:es5": "tsc -p tsconfig.build.json",
48
50
  "build:esm": "tsc -p tsconfig.esm.json",
49
- "build:watch": "run-p build:watch:es5 build:watch:esm",
50
- "build:watch:es5": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
51
- "build:watch:esm": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
51
+ "build:watch": "run-p build:es5:watch build:esm:watch",
52
+ "build:dev:watch": "run-s build:watch",
53
+ "build:es5:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
54
+ "build:esm:watch": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
55
+ "circularDepCheck": "madge --circular src/index.ts",
52
56
  "clean": "rimraf dist esm build coverage",
57
+ "fix": "run-s fix:eslint fix:prettier",
58
+ "fix:eslint": "eslint . --format stylish --fix",
59
+ "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
53
60
  "link:yarn": "yarn link",
54
61
  "lint": "run-s lint:prettier lint:eslint",
55
- "lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
56
62
  "lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
57
- "fix": "run-s fix:eslint fix:prettier",
58
- "fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
59
- "fix:eslint": "eslint . --format stylish --fix",
60
- "test": "jest",
61
- "test:watch": "jest --watch",
63
+ "lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
62
64
  "pack": "npm pack",
63
- "circularDepCheck": "madge --circular src/index.ts"
65
+ "test": "jest",
66
+ "test:watch": "jest --watch"
64
67
  },
65
68
  "volta": {
66
69
  "extends": "../../package.json"