API Reference

init

Signature: init(options: ConfigOptions): void

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

destroy

Signature: destroy(): Djaty

Destroying Djaty tracking by destroying existed states and Event listeners.

trackBug

Signature: trackBug(): (err: Error) => void

Manually submit a bug.

setUser

Signature: 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.

addSubmitHandler

Signature: addSubmitHandler((djatyBugReport: {data: AgentPatchItem, addCustomDataCb: () => void}, next: (djatyBugReport) => void) => void): void;

Dynamically add a one - Or more - filter callback function to filter the context data right before bug submission.

addGlobalCustomData

Signature: addGlobalCustomData(data): void

Dynamically add global custom data that will be sent with every bug submission.

The bug submissions payload (AgentData)

Note

This structure should be taken into consideration especially when dealing with methods like onBeforeBugSubmission to filter payload data.

import {AgentPatchItem} from '.';

interface AgentData {
  agentDataPatch: AgentPatchItem[];
  agentId: 'jsFrontendAgent';
  agentVersion: string;
  apiKey: string;
  hashType: 'sha256';
  screen: {
    colorDepth: number;
    screenSize: number;
  };
  useAgent: {
    ua: string;
    browser: {
      name: string;
      version: string;
      major: string;
    };
    engine: {
      name: string;
      version: string;
    };
    os: {
      name: string;
      version: string;
    };
    cpu: {
      architecture: string;
    };
    device: {
      model: string;
      type: string;
      vendor: string;
    };
  };

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

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

AgentPatchItem

import {JsFrontendAjaxTimelineItem, JsFrontendConsoleTimelineItem,
 JsFrontendExceptionTimelineItem, JsFrontendFileTimelineItem,
 JsFrontendNavigationTimelineItem, TrimmingTimelineItem, JsFrontendAgentDataForm} from './';

interface AgentPatchItem {
  curUrl: string;
  timeline: (JsFrontendAjaxTimelineItem | JsFrontendConsoleTimelineItem |
   JsFrontendExceptionTimelineItem | JsFrontendFileTimelineItem |
   JsFrontendNavigationTimelineItem | TrimmingTimelineItem)[];

  bugType?: 'ajax' | 'console' | 'file' | 'exception';  curUrl: string;
  form?: {
    pwdFormSubmission?: JsFrontendAgentDataForm;
    lastFormSubmission?: JsFrontendAgentDataForm;
  };
  hash?: string;
  longTitle?: string;
  shortTitle?: string;
  customData?: any[];
  cookies?: {name: string, value: string}[];
  localStorage?: {[p: string]: string};
  sessionStorage?: {[p: string]: string};
  user?: {
    userId?: string;
    logon?: string;
  };
}

JsFrontendAjaxTimelineItem

interface JsFrontendAjaxTimelineItem {
  itemType: 'ajax';
  timestamp: number;
  status: number;
  reqId: string;
  openParams: {
    method: string;
    url: string;

    async?: boolean;
    user?: string | number; 
    password?: string | number; 
  };

  url?: string;
  statusText?: string;
  isAborted?: boolean;
  hash?: string;
  queryParams?: {
    name: string;
    value: string;
  }[];
  cookies?: {
    name: string;
    value: string;
  }[];
  headers?: {
    requestHeaders?: {
      name: string;
      value: string
    }[],
    responseHeaders?: {
      name: string;
      value: string;
    }[];
  };
  
  requestTime?: number;
  response?: {
    responseText: string;
    responseType: string;
    responseURL?: string;
    responseXML?: string;
    withCredentials: boolean;
  };
  longTitle?: string;
  requestPayload?: any[] | string;
}

JsFrontendConsoleTimelineItem

interface JsFrontendConsoleTimelineItem {
  itemType: 'console';
  timestamp: number;
  method: string;
  consoleParams: any[];

  longTitle?: string;
  hash?: string;
  isTrimmed?: boolean;
  repetitionCount?: number;
}

JsFrontendExceptionTimelineItem

interface JsFrontendExceptionTimelineItem {
    itemType: 'exception';
    timestamp: number;
    method: 'onerror';
    stringifiedStack: string;
    msg: string;
    longTitle: string;
    hash: string;
    repetitionCount?: number;
}

JsFrontendFileTimelineItem

interface JsFrontendFileTimelineItem {
    itemType: 'file';
    timestamp: number;
    tagName: 'img' | 'input' | 'link' | 'script' | 'audio' | 'video' | 'source' | 'track';
    src: string;
    fileStatus: 'error';

    longTitle?: string;
    hash?: string;
}

JsFrontendNavigationTimelineItem

interface JsFrontendNavigationTimelineItem {
    itemType: 'navigation';
    timestamp: number;
    curPageUrl: string;
    method: 'pushstate' | 'popstate';

    title?: string;
    state?: string;
}

TrimmingTimelineItem

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

JsFrontendAgentDataForm

import {JsFrontendAgentFormInputValues} from '.';

interface JsFrontendAgentDataForm {
  inputs: JsFrontendAgentFormInputValues[];
  url: string;
  timestamp: number;
}

JsFrontendAgentFormInputValues

interface JsFrontendAgentFormInputValues {
  type: string;
  name: string;

  value?: string;
  values?: {
    text: string;
    value: string;
  }[];
}