@sentry/gatsby 6.13.0 → 6.14.0
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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/sdk.d.ts +6 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +24 -0
- package/dist/sdk.js.map +1 -0
- package/dist/utils/integrations.d.ts +13 -0
- package/dist/utils/integrations.d.ts.map +1 -0
- package/dist/utils/integrations.js +48 -0
- package/dist/utils/integrations.js.map +1 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -0
- package/esm/index.js.map +1 -1
- package/esm/sdk.d.ts +6 -0
- package/esm/sdk.d.ts.map +1 -0
- package/esm/sdk.js +22 -0
- package/esm/sdk.js.map +1 -0
- package/esm/utils/integrations.d.ts +13 -0
- package/esm/utils/integrations.d.ts.map +1 -0
- package/esm/utils/integrations.js +45 -0
- package/esm/utils/integrations.js.map +1 -0
- package/esm/utils/types.d.ts +3 -0
- package/esm/utils/types.d.ts.map +1 -0
- package/esm/utils/types.js +1 -0
- package/esm/utils/types.js.map +1 -0
- package/gatsby-browser.js +37 -26
- package/gatsby-node.js +48 -1
- package/package.json +16 -14
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -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 @@
|
|
|
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
|
package/dist/sdk.js.map
ADDED
|
@@ -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 @@
|
|
|
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
|
+
{"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
package/esm/index.d.ts.map
CHANGED
|
@@ -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
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
package/esm/sdk.d.ts.map
ADDED
|
@@ -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 @@
|
|
|
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
|
-
|
|
2
|
-
const
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
const Sentry = require('@sentry/gatsby');
|
|
3
3
|
|
|
4
4
|
exports.onClientEntry = function(_, pluginParams) {
|
|
5
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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,5 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
1
3
|
const sentryRelease = JSON.stringify(
|
|
2
4
|
// Always read first as Sentry takes this as precedence
|
|
3
5
|
process.env.SENTRY_RELEASE ||
|
|
@@ -15,8 +17,9 @@ const sentryRelease = JSON.stringify(
|
|
|
15
17
|
);
|
|
16
18
|
|
|
17
19
|
const sentryDsn = JSON.stringify(process.env.SENTRY_DSN || '');
|
|
20
|
+
const SENTRY_USER_CONFIG = ['./sentry.config.js', './sentry.config.ts'];
|
|
18
21
|
|
|
19
|
-
exports.onCreateWebpackConfig = ({ plugins, actions }) => {
|
|
22
|
+
exports.onCreateWebpackConfig = ({ plugins, getConfig, actions }) => {
|
|
20
23
|
actions.setWebpackConfig({
|
|
21
24
|
plugins: [
|
|
22
25
|
plugins.define({
|
|
@@ -25,4 +28,48 @@ exports.onCreateWebpackConfig = ({ plugins, actions }) => {
|
|
|
25
28
|
}),
|
|
26
29
|
],
|
|
27
30
|
});
|
|
31
|
+
|
|
32
|
+
// To configure the SDK, SENTRY_USER_CONFIG is prioritized over `gatsby-config.js`,
|
|
33
|
+
// since it isn't possible to set non-serializable parameters in the latter.
|
|
34
|
+
// Prioritization here means what `init` is run.
|
|
35
|
+
let configFile = null;
|
|
36
|
+
try {
|
|
37
|
+
configFile = SENTRY_USER_CONFIG.find(file => fs.existsSync(file));
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Some node versions (like v11) throw an exception on `existsSync` instead of
|
|
40
|
+
// returning false. See https://github.com/tschaub/mock-fs/issues/256
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!configFile) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// `setWebpackConfig` merges the Webpack config, ignoring some props like `entry`. See
|
|
47
|
+
// https://www.gatsbyjs.com/docs/reference/config-files/actions/#setWebpackConfig
|
|
48
|
+
// So it's not possible to inject the Sentry properties with that method. Instead, we
|
|
49
|
+
// can replace the whole config with the modifications we need.
|
|
50
|
+
const finalConfig = injectSentryConfig(getConfig(), configFile);
|
|
51
|
+
actions.replaceWebpackConfig(finalConfig);
|
|
28
52
|
};
|
|
53
|
+
|
|
54
|
+
function injectSentryConfig(config, configFile) {
|
|
55
|
+
const injectedEntries = {};
|
|
56
|
+
// TODO: investigate what entries need the Sentry config injected.
|
|
57
|
+
// We may want to skip some.
|
|
58
|
+
Object.keys(config.entry).forEach(prop => {
|
|
59
|
+
const value = config.entry[prop];
|
|
60
|
+
let injectedValue = value;
|
|
61
|
+
if (typeof value === 'string') {
|
|
62
|
+
injectedValue = [configFile, value];
|
|
63
|
+
} else if (Array.isArray(value)) {
|
|
64
|
+
injectedValue = [configFile, ...value];
|
|
65
|
+
} else {
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.error(
|
|
68
|
+
`Sentry Logger [Error]: Could not inject SDK initialization code into ${prop}, unexpected format: `,
|
|
69
|
+
typeof value,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
injectedEntries[prop] = injectedValue;
|
|
73
|
+
});
|
|
74
|
+
return { ...config, entry: injectedEntries };
|
|
75
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/gatsby",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.0",
|
|
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,14 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@sentry/react": "6.
|
|
30
|
-
"@sentry/tracing": "6.
|
|
29
|
+
"@sentry/react": "6.14.0",
|
|
30
|
+
"@sentry/tracing": "6.14.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"gatsby": "^2.0.0 || ^3.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@sentry
|
|
36
|
+
"@sentry/types": "6.14.0",
|
|
37
37
|
"@testing-library/react": "^10.4.9",
|
|
38
38
|
"jest": "^24.7.1",
|
|
39
39
|
"npm-run-all": "^4.1.2",
|
|
@@ -44,23 +44,25 @@
|
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "run-p build:es5 build:esm",
|
|
47
|
+
"build:dev": "run-s build",
|
|
47
48
|
"build:es5": "tsc -p tsconfig.build.json",
|
|
48
49
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
49
|
-
"build:watch": "run-p build:watch
|
|
50
|
-
"build:watch
|
|
51
|
-
"build:watch
|
|
50
|
+
"build:watch": "run-p build:es5:watch build:esm:watch",
|
|
51
|
+
"build:dev:watch": "run-s build:watch",
|
|
52
|
+
"build:es5:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
|
|
53
|
+
"build:esm:watch": "tsc -p tsconfig.esm.json -w --preserveWatchOutput",
|
|
54
|
+
"circularDepCheck": "madge --circular src/index.ts",
|
|
52
55
|
"clean": "rimraf dist esm build coverage",
|
|
56
|
+
"fix": "run-s fix:eslint fix:prettier",
|
|
57
|
+
"fix:eslint": "eslint . --format stylish --fix",
|
|
58
|
+
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
|
|
53
59
|
"link:yarn": "yarn link",
|
|
54
60
|
"lint": "run-s lint:prettier lint:eslint",
|
|
55
|
-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
|
|
56
61
|
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
|
|
57
|
-
"
|
|
58
|
-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
|
|
59
|
-
"fix:eslint": "eslint . --format stylish --fix",
|
|
60
|
-
"test": "jest",
|
|
61
|
-
"test:watch": "jest --watch",
|
|
62
|
+
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
|
|
62
63
|
"pack": "npm pack",
|
|
63
|
-
"
|
|
64
|
+
"test": "jest",
|
|
65
|
+
"test:watch": "jest --watch"
|
|
64
66
|
},
|
|
65
67
|
"volta": {
|
|
66
68
|
"extends": "../../package.json"
|