Skip to content

Commit 3af894b

Browse files
atticooscaptbaritone
authored andcommitted
tag support (#69)
1 parent 44292fc commit 3af894b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ function createRavenMiddleware(Raven, options = {}) {
99
stateTransformer = identity,
1010
breadcrumbCategory = "redux-action",
1111
filterBreadcrumbActions = filter,
12-
getUserContext
12+
getUserContext,
13+
getTags
1314
} = options;
1415

1516
return store => {
@@ -25,6 +26,9 @@ function createRavenMiddleware(Raven, options = {}) {
2526
if (getUserContext) {
2627
data.user = getUserContext(state);
2728
}
29+
if (getTags) {
30+
data.tags = getTags(state);
31+
}
2832
return original ? original(data) : data;
2933
});
3034

index.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ describe("raven-for-redux", () => {
196196
action => `transformed action ${action.type}`
197197
);
198198
context.getUserContext = jest.fn(state => `user context ${state.value}`);
199+
context.getTags = jest.fn(state => `tags ${state.value}`);
199200
context.breadcrumbDataFromAction = jest.fn(action => ({
200201
extra: action.extra
201202
}));
@@ -211,7 +212,8 @@ describe("raven-for-redux", () => {
211212
actionTransformer: context.actionTransformer,
212213
breadcrumbDataFromAction: context.breadcrumbDataFromAction,
213214
filterBreadcrumbActions: context.filterBreadcrumbActions,
214-
getUserContext: context.getUserContext
215+
getUserContext: context.getUserContext,
216+
getTags: context.getTags
215217
})
216218
)
217219
);
@@ -265,6 +267,16 @@ describe("raven-for-redux", () => {
265267
"user context 1"
266268
);
267269
});
270+
it("transforms the tags on data callback", () => {
271+
context.store.dispatch({ type: "INCREMENT", extra: "FOO" });
272+
expect(() => {
273+
context.store.dispatch({ type: "THROW", extra: "BAR" });
274+
}).toThrow();
275+
expect(context.mockTransport).toHaveBeenCalledTimes(1);
276+
expect(context.mockTransport.mock.calls[0][0].data.tags).toEqual(
277+
"tags 1"
278+
);
279+
});
268280
});
269281
describe("with multiple data callbaks", () => {
270282
beforeEach(() => {

0 commit comments

Comments
 (0)