Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-link-sentry

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-sentry - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/OperationBreadcrumb.d.ts

22

CHANGELOG.md

@@ -5,2 +5,24 @@ # Changelog

## [1.1.0](https://github.com/DiederikvandenB/apollo-link-sentry/compare/v1.0.0...v1.1.0) (2020-02-26)
### ⚠ BREAKING CHANGES
* rename class and methods in OperationBreadcrumb.ts (#11)
### Features
* allow adding keys from the context to the breadcrumb ([#7](https://github.com/DiederikvandenB/apollo-link-sentry/issues/7)) ([15ea217](https://github.com/DiederikvandenB/apollo-link-sentry/commit/15ea21727abd19932d487e0001ca0b70ad2ef876))
* allows altering breadcrumb with beforeBreadcrumb ([8b101e9](https://github.com/DiederikvandenB/apollo-link-sentry/commit/8b101e968eb0859bb2c14d3a7c54766384ca97e1))
* provides callback for filtering operations ([a330abd](https://github.com/DiederikvandenB/apollo-link-sentry/commit/a330abdcb671267590e379bdbdbd5e4a4bea0a4f))
### Documentation
* adds section on beforeBreadcrumb ([1923195](https://github.com/DiederikvandenB/apollo-link-sentry/commit/1923195ba11b6a2ec9149f03358ea42424871714))
* adds section on filter option ([0a0e6ce](https://github.com/DiederikvandenB/apollo-link-sentry/commit/0a0e6ceb31bfb9321212fefe7b3c711bd34f7d2a))
* rename class and methods in OperationBreadcrumb.ts ([#11](https://github.com/DiederikvandenB/apollo-link-sentry/issues/11)) ([72b6b67](https://github.com/DiederikvandenB/apollo-link-sentry/commit/72b6b67c10f25d56554375ef0d9692e8beb27865))
## 1.0.0 (2020-02-25)

@@ -7,0 +29,0 @@

2

lib/index.d.ts

@@ -0,3 +1,3 @@

export { Operation } from './Operation';
export * from './SentryLink';
export * from './types';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var Operation_1 = require("./Operation");
exports.Operation = Operation_1.Operation;
tslib_1.__exportStar(require("./SentryLink"), exports);
//# sourceMappingURL=index.js.map
import { Operation as ApolloOperation } from 'apollo-link';
import { ApolloLinkSentry } from './types';
export declare class Operation {
private readonly operation;
name: string;
type: ApolloLinkSentry.Operation.Type;
type: 'query' | 'mutation' | 'subscription' | undefined;
cache: object | undefined;

@@ -16,3 +15,6 @@ variables: object | undefined;

private getQuery;
getContextKeys: (keys: string[]) => {
[s: string]: any;
} | undefined;
}
//# sourceMappingURL=Operation.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var dot_prop_1 = tslib_1.__importDefault(require("dot-prop"));
var utils_1 = require("./utils");

@@ -11,2 +13,14 @@ var Operation = (function () {

};
this.getContextKeys = function (keys) {
var context = _this.operation.getContext();
var find = keys
.map(function (key) {
var _a;
return (_a = {}, _a[key] = dot_prop_1.default.get(context, key), _a);
})
.reduce(function (a, b) { return (tslib_1.__assign(tslib_1.__assign({}, a), b)); }, {});
return !utils_1.isEmpty(find)
? find
: undefined;
};
this.operation = operation;

@@ -13,0 +27,0 @@ this.name = this.getName();

@@ -0,22 +1,36 @@

import { FetchResult } from 'apollo-link/lib/types';
import { ApolloLink, NextLink, Observable, Operation as ApolloOperation } from 'apollo-link';
import { FetchResult } from 'apollo-link/lib/types';
import { OperationBreadcrumb } from './OperationBreadcrumb';
import { Operation } from './Operation';
import { OperationsBreadcrumb } from './OperationsBreadcrumb';
import { ApolloLinkSentry } from './types';
export interface Options {
setTransaction?: boolean;
setFingerprint?: boolean;
breadcrumb?: {
enable?: boolean;
includeQuery?: boolean;
includeCache?: boolean;
includeVariables?: boolean;
includeResponse?: boolean;
includeError?: boolean;
includeContextKeys?: string[];
};
filter?: (operation: Operation) => boolean;
beforeBreadcrumb?: (breadcrumb: OperationBreadcrumb) => OperationBreadcrumb;
}
export declare class SentryLink extends ApolloLink {
private readonly options;
constructor(options?: ApolloLinkSentry.Options);
constructor(options?: Options);
request: (op: ApolloOperation, forward: NextLink) => Observable<FetchResult<{
[key: string]: any;
}, Record<string, any>, Record<string, any>>> | null;
fillBreadcrumb: (breadcrumb: OperationsBreadcrumb, operation: Operation) => void;
fillBreadcrumb: (breadcrumb: OperationBreadcrumb, operation: Operation) => void;
handleResult: (result: FetchResult<{
[key: string]: any;
}, Record<string, any>, Record<string, any>>, breadcrumb: OperationsBreadcrumb, observer: any) => void;
handleError: (breadcrumb: OperationsBreadcrumb, error: any, observer: any) => void;
handleComplete: (breadcrumb: OperationsBreadcrumb, observer: any) => void;
}, Record<string, any>, Record<string, any>>, breadcrumb: OperationBreadcrumb, observer: any) => void;
handleError: (breadcrumb: OperationBreadcrumb, error: any, observer: any) => void;
handleComplete: (breadcrumb: OperationBreadcrumb, observer: any) => void;
setTransaction: (operation: Operation) => void;
setFingerprint: () => void;
attachBreadcrumbToSentry: (breadcrumb: OperationsBreadcrumb) => void;
attachBreadcrumbToSentry: (breadcrumb: OperationBreadcrumb) => void;
}
//# sourceMappingURL=SentryLink.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var apollo_link_1 = require("apollo-link");
var Sentry = tslib_1.__importStar(require("@sentry/browser"));
var types_1 = require("@sentry/types");
var deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
var types_1 = require("@sentry/types");
var apollo_link_1 = require("apollo-link");
var OperationBreadcrumb_1 = require("./OperationBreadcrumb");
var Operation_1 = require("./Operation");
var OperationsBreadcrumb_1 = require("./OperationsBreadcrumb");
var defaultOptions = {

@@ -20,2 +20,3 @@ setTransaction: true,

includeError: false,
includeContextKeys: [],
},

@@ -30,3 +31,3 @@ };

var operation = new Operation_1.Operation(op);
var breadcrumb = new OperationsBreadcrumb_1.OperationsBreadcrumb();
var breadcrumb = new OperationBreadcrumb_1.OperationBreadcrumb();
_this.fillBreadcrumb(breadcrumb, operation);

@@ -46,3 +47,8 @@ return new apollo_link_1.Observable(function (observer) {

_this.fillBreadcrumb = function (breadcrumb, operation) {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f;
if (typeof _this.options.filter === 'function') {
var stop_1 = breadcrumb.filter(_this.options.filter(operation));
if (stop_1)
return;
}
breadcrumb

@@ -58,10 +64,13 @@ .setMessage(operation.name)

if ((_a = _this.options.breadcrumb) === null || _a === void 0 ? void 0 : _a.includeQuery) {
breadcrumb.addQuery(operation.query);
breadcrumb.setQuery(operation.query);
}
if ((_b = _this.options.breadcrumb) === null || _b === void 0 ? void 0 : _b.includeCache) {
breadcrumb.addCache(operation.cache);
breadcrumb.setCache(operation.cache);
}
if ((_c = _this.options.breadcrumb) === null || _c === void 0 ? void 0 : _c.includeVariables) {
breadcrumb.addVariables(operation.variables);
breadcrumb.setVariables(operation.variables);
}
if ((_f = (_e = (_d = _this.options) === null || _d === void 0 ? void 0 : _d.breadcrumb) === null || _e === void 0 ? void 0 : _e.includeContextKeys) === null || _f === void 0 ? void 0 : _f.length) {
breadcrumb.setContext(operation.getContextKeys(_this.options.breadcrumb.includeContextKeys));
}
};

@@ -71,3 +80,3 @@ _this.handleResult = function (result, breadcrumb, observer) {

if ((_a = _this.options.breadcrumb) === null || _a === void 0 ? void 0 : _a.includeResponse) {
breadcrumb.addResponse(result);
breadcrumb.setResponse(result);
}

@@ -82,3 +91,3 @@ observer.next(result);

if ((_a = _this.options.breadcrumb) === null || _a === void 0 ? void 0 : _a.includeError) {
breadcrumb.addError(error);
breadcrumb.setError(error);
}

@@ -109,2 +118,4 @@ _this.attachBreadcrumbToSentry(breadcrumb);

return;
if (breadcrumb.filtered)
return;
if (breadcrumb.flushed) {

@@ -114,2 +125,7 @@ console.warn('[apollo-link-sentry] SentryLink.attachBreadcrumbToSentry() was called on an already flushed breadcrumb');

}
if (typeof _this.options.beforeBreadcrumb === 'function') {
var after = _this.options.beforeBreadcrumb(breadcrumb);
Sentry.addBreadcrumb(after.flush());
return;
}
Sentry.addBreadcrumb(breadcrumb.flush());

@@ -116,0 +132,0 @@ };

{
"name": "apollo-link-sentry",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",

@@ -31,2 +31,3 @@ "main": "./lib/index.js",

"deepmerge": "^4.2.2",
"dot-prop": "^5.2.0",
"graphql": "^14.6.0"

@@ -33,0 +34,0 @@ },

# Apollo Link Sentry
Apollo Link middleware to enrich SentryJS events with GraphQL data.
[![Coverage Status](https://coveralls.io/repos/github/DiederikvandenB/apollo-link-sentry/badge.svg?branch=master)](https://coveralls.io/github/DiederikvandenB/apollo-link-sentry?branch=master)
![Test](https://github.com/DiederikvandenB/apollo-link-sentry/workflows/Test/badge.svg)
[![npm](https://img.shields.io/npm/v/apollo-link-sentry)](https://www.npmjs.com/package/apollo-link-sentry)
[![David](https://img.shields.io/david/diederikvandenb/apollo-link-sentry)](https://github.com/diederikvandenb/apollo-link-sentry)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/DiederikvandenB/apollo-link-sentry/Test)](https://github.com/DiederikvandenB/apollo-link-sentry/actions)
[![Coveralls github branch](https://img.shields.io/coveralls/github/DiederikvandenB/apollo-link-sentry/master)](https://coveralls.io/github/DiederikvandenB/apollo-link-sentry?branch=master)
[![npm-downloads](https://img.shields.io/npm/dt/apollo-link-sentry)](https://www.npmjs.com/package/apollo-link-sentry)

@@ -12,4 +16,2 @@ ## Installation

## Features
Apollo Link middleware to enrich SentryJS events with GraphQL data.
Turn this:

@@ -94,6 +96,19 @@

* The data is stringified and formatted. Can be used to include headers for instance.
* Note that this option is not yet implemented.
*/
includeContextKeys: [],
},
/**
* Provide a callback function which receives an instance of this package's Operation class
* Only operations that pass the test are sent to Sentry. Leave undefined if you want all
* operations to pass. See PR #9 for more details.
*/
filter: (operation) => true,
/**
* Provide a callback function which receives an instance of this package's OperationBreadcrumb class
* Use it to modify the data that is added to the breadcrumb. Leave undefined if you want all
* data to be included. Very useful in combination with options like includeVariables and includeContextKeys.
*/
beforeBreadcrumb: (breadcrumb) => breadcrumb,
};

@@ -151,4 +166,5 @@ ```

- Add the possibility to exclude:
- Operations
- URLs?
- data through a custom beforeBreadcrumb
- Provide wrapper for Sentry's beforeBreadcrumb to filter out fetch requests
- Caveat: people using `unfetch`?
- Write best practice scenario:

@@ -155,0 +171,0 @@ - setting `includeError` true

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc