API Reference

init(options: UserConfigOptions): Djaty

Initiating Djaty tracking. It accepts an options config (Check Configuration section)

destroy(): Djaty

Destroying Djaty tracking by destroying existed states and Event listeners. It accepts an options config (Check Configuration section)

requestHandler(): (req: Express.Request, res: Express.Response, next: Express.Next) => void

A method that return Express Request middleware (Check Installation section)

errorHandler(): (err: utils.RequestError, req: Express.Request, res: Express.Response, next: Express.Next) => void

A method that return Express Error middleware (Check Installation section)

setUser(user: { userId?: string; logon?: string; }): void;

Dynamically set the user that will be sent with the context. Noting that at least logon or userId should be passed.

addBeforeSubmissionContextHandler(cb: (data: AgentData, next: (data: AgentData) => void) => void): void;

Dynamically attach a contextual onBeforeBugSubmission filter callbacks. If Djaty is installed inside a web server and catches bug(s), this filter will be applied on the current submission(s) within the current request only. This filter will not be applied on other requests that have not configured with this filter. Note: If this method is used in a context other than a web server, it’ll acts similar to addBeforeSubmissionHandler() method.

addBeforeSubmissionHandler(cb: (data: AgentData, next: (data: AgentData) => void) => void): void;

Dynamically attach a global onBeforeBugSubmission filter callbacks that will always be applied on every bug submission regardless the current context is a server request or anything else.

addContextCustomData(data: any): void;

Dynamically add contextual custom data that will be sent with every bug submission inside the current request if Djaty is installed inside a web server. Note: If this method is used in a context other than a web server, it’ll acts similar to addCustomData() method.

addCustomData(data: any): void;

Dynamically add global custom data that will be sent with every bug submission regardless the current context is a server request or anything else.

AgentData: The bug submissions payload

Note

This structure should be well known specially when dealing with methods like onBeforeBugSubmission, addBeforeSubmissionContextHandler and addBeforeSubmissionHandler to filter payload data.

interface AgentData {
  agentDataPatch: AgentPatchItem[];
  agentId: string;
  agentVersion: string;
  apiKey: string;
  apiSecret: string;
  hashType: 'sha256';
  platform: string;
  platformVersion?: string;

  // Only include release information if it is set
  release?: string;

  serverLocalIp: string;
  serverName: string;
  stage?: string;
  tags?: string[];
}

interface AgentPatchItem {
  bugType: string;
  customData?: any[];
  djatyReqId?: string;
  hash: string;
  isTemp: boolean;
  longTitle: string;
  shortTitle: string;
  timeline: (ConsoleTimelineItem | ExceptionTimelineItem |
    HttpTimelineItem | TrimmingTimelineItem)[];
  user?: {
    userIp: string;
    userId?: string;
    logon?: string;
  };
}

interface ConsoleTimelineItem {
  itemType: 'console';
  timestamp: number;
  method: string;
  consoleParams: any[];
  hash?: string;
}

interface ExceptionTimelineItem {
  itemType: 'exception';
  timestamp: number;
  stringifiedStack: string;
  type: string;
  msg: string;
  hash: string;
}

interface HttpTimelineItem {
  itemType: 'httpReq';
  timestamp: number;
  method: string;
  queryParams?: {
    [k: string]: any;
  }[];
  url: string;
  status?: number;
  statusText?: string;
  requestTime?: number;
  djatyReqId?: string;
  remoteAddr?: string;
}

interface TrimmingTimelineItem {
  timestamp: number;
  itemType: 'trimming';
}