dd-trace
    Preparing search index...

    Interface Appsec

    interface Appsec {
        eventTrackingV2: EventTrackingV2;
        blockRequest(
            req?: IncomingMessage,
            res?: OutgoingMessage<IncomingMessage>,
        ): boolean;
        isUserBlocked(user: User): boolean;
        setUser(user: User): void;
        trackCustomEvent(
            eventName: string,
            metadata?: { [key: string]: string },
        ): void;
        trackUserLoginFailureEvent(
            userId: string,
            exists: boolean,
            metadata?: { [key: string]: string },
        ): void;
        trackUserLoginSuccessEvent(
            user: User,
            metadata?: { [key: string]: string },
        ): void;
    }
    Index

    Properties

    eventTrackingV2: EventTrackingV2

    Methods

    • Beta

      Sends a "blocked" template response based on the request accept header and ends the response. You should stop processing the request after calling this function!

      Parameters

      • Optionalreq: IncomingMessage

        Can be passed to force which request to act on. Optional.

      • Optionalres: OutgoingMessage<IncomingMessage>

        Can be passed to force which response to act on. Optional.

      Returns boolean

      Indicates if the action was successful.

      This method is in beta and could change in the future

    • Beta

      Checks if the passed user should be blocked according to AppSec rules. If no user is linked to the current trace, will link the passed user to it.

      Parameters

      • user: User

        Properties of the authenticated user. Accepts custom fields.

      Returns boolean

      Indicates whether the user should be blocked.

      This method is in beta and could change in the future

    • Beta

      Links an authenticated user to the current trace.

      Parameters

      • user: User

        Properties of the authenticated user. Accepts custom fields.

        This method is in beta and could change in the future

      Returns void

    • Beta

      Links a custom event to the current trace.

      Parameters

      • eventName: string

        The name of the event.

      • Optionalmetadata: { [key: string]: string }

        Custom fields to link to the event.

        This method is in beta and could change in future versions.

      Returns void

    • Beta

      Links a failed login event to the current trace.

      Parameters

      • userId: string

        The user id of the attempted login.

      • exists: boolean

        If the user id exists.

      • Optionalmetadata: { [key: string]: string }

        Custom fields to link to the login failure event.

        This method is in beta and could change in future versions.

      Returns void

      In favor of eventTrackingV2.trackUserLoginFailure

    • Beta

      Links a successful login event to the current trace. Will link the passed user to the current trace with Appsec.setUser() internally.

      Parameters

      • user: User

        Properties of the authenticated user. Accepts custom fields.

      • Optionalmetadata: { [key: string]: string }

        Custom fields to link to the login success event.

        This method is in beta and could change in future versions.

      Returns void

      In favor of eventTrackingV2.trackUserLoginSuccess