Skip to content

Commit

Permalink
feat(NabuError): include id in nabu error analytics
Browse files Browse the repository at this point in the history
Towards FWN-1742
  • Loading branch information
awiermanncasas-bc committed Jul 26, 2022
1 parent babeda1 commit a87fec1
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type ClientErrorProperties = {
action?: string
category?: string[]
error: ErrorType
id?: string
network_endpoint?: string
network_error_code?: number
network_error_description?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('NabuError()', () => {
})

it('Should create a nabu error with all properties', () => {
const id = 'nabu_error_id'
const title = 'Unable to quote USDC-USD'
const message =
"We are having problems fetching a quote for USDC-USD, don't worry - we're on it"
Expand All @@ -32,11 +33,13 @@ describe('NabuError()', () => {

const error = new NabuError({
icon,
id,
message,
title
})

expect(error.title).toEqual(title)
expect(error.id).toEqual(id)
expect(error.message).toEqual(message)
expect(error.icon).toEqual(icon)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NabuErrorAction, NabuErrorIconProps, NabuErrorProps } from './NabuError.types'

class NabuError extends Error {
id?: string

title: string

icon?: NabuErrorIconProps
Expand All @@ -11,9 +13,10 @@ class NabuError extends Error {

actions?: NabuErrorAction[]

constructor({ actions, categories, icon, message, title }: NabuErrorProps) {
constructor({ actions, categories, icon, id, message, title }: NabuErrorProps) {
super(title)

this.id = id
this.title = title
this.message = message
this.categories = categories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type NabuErrorProps = {
actions?: NabuErrorAction[]
categories?: string[]
icon?: NabuErrorIconProps
id?: string
message: string
title: string
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('createNabuErrorAnalyticsInterceptor()', () => {
const dispatchSpy = jest.fn()
const error = new NabuError({
categories: ['TestCategory'],
id: 'nabu_error_id',
message: 'Message',
title: 'Error title'
})
Expand All @@ -34,6 +35,7 @@ describe('createNabuErrorAnalyticsInterceptor()', () => {
properties: {
category: ['TestCategory'],
error: 'NABU_ERROR',
id: error.id,
network_error_description: error.message,
network_error_type: 'NABU_ERROR',
source: 'NABU',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const createNabuErrorAnalyticsInterceptor: CreateNabuErrorAnalyticsInterc
const clientError: ClientErrorProperties = {
category: error.categories,
error: 'NABU_ERROR',
id: error.id,
network_error_description: error.message,
network_error_type: 'NABU_ERROR',
source: 'NABU',
Expand Down

0 comments on commit a87fec1

Please sign in to comment.