1.0.5 • Published 2 years ago
taticbr-error-tracking v1.0.5
This project contains the code for tracking errors generated in orders.
Installation
npm install taticbr-error-tracking
or
yarn add taticbr-error-tracking
How to use
Implementing on your application
It is necessary to implement a concrete class for the EventEmitterPort abstract class, responsible for sending the error message:
export abstract class EventEmitterPort {
request: (topic: string, payload: unknown) => Promise<void>;
}
Order error tracking
To implement, you must import the OrderErrorTracking
decorator and configure the method to start tracking order errors:
import { Injectable } from '@nestjs/common';
import { OrderErrorTracking } from 'taticbr-error-tracking';
@Injectable()
export class MyService {
constructor() {}
@OrderErrorTracking({
state: "ERROR",
dataExtractor: (data: any) => data,
})
private async execute() {
// Implementation
}
}
Configuration
You can configure this lib by setting some environemnt variables:
Environment Variables | Utility | Default |
---|---|---|
ORDER_ERROR_TRACKING_TOPIC | Defines the name of the topic that will be sent to the event emitter | OrderErrorTrackingTopic |