npm.io
1.3.0 • Published 2 months ago

@attacksimulator/events

Licence
MIT
Version
1.3.0
Deps
1
Size
1.7 MB
Vulns
0
Weekly
0

ATTACK Simulator Events

This library helps our clients collect events from their custom landing pages and send them to our API.

Instalation

Events was designed to work both in the browser and in Node.js.

Node.js

To get started with Events in your Node.js project, simply add the dependency with NPM.

npm i @attacksimulator/events --save
Browser

Include the bundle.min.js file in your project.

<script src="path/to/events/bundle.min.js"></script>
CDN

The events package can be included by way of a CDN provider like cdnjs.com, unpkg and jsDelivr ...

<script src="https://cdn.jsdelivr.net/npm/@attacksimulator/events@1.2.2/dist/bundle.min.js"></script>

Usage

Before running the plugin, make sure you get an api key from our support team.

<script>
  const ev = new ATSEvents({ apiKey: "YOUR_API_KEY" });
  ev.listen();
</script>

Options

Name Type Description
apiKey string The key required to access our api. You can get it by contacting our support team.
eventsToInclude string[] Set the events to watch. Leave empty to watch all available events. The default value is [].
eventsToExclude string[] Set the events to not watch. Leave empty to watch all available events. The default value is [].
debug boolean Set debugging true of false. The default value is false.
shouldRedirect boolean Specify whether the page should redirect after click or submit events. The default value is true.
redirectUrl string Set the redirect url after affecting events have been triggered. The default value is https://tips.attacksimulator.com.
source string Set the source of the events. Supported values are LP or LP_EDU. The default value is LP.
url string The destination url that the events should be sent at
extraPayload object An object with extra data to be sent with the events.

Available events

Name Type Description
attachment_opened internal The event gets triggered automatically when an attachment is opened. This requires the url of the host page to have a file_type=attachment query string.
button_clicked user+redirect The event gets triggered when a user clicks on a link that does not point to a file. After this event is sent, the webpage will redirect to redirectUrl.
download_file_event user The event gets triggered when a user clicks on a link that does point to a file.
file_opened internal The event gets triggered automatically when an attachment is opened. This requires the url of the host page to have a file_type=download query string.
input_filled user The event gets triggered once per input field when a user enters a non-empty value. Later changes to the same field are ignored.
page_loaded internal The events triggers automatically whenever the page is loaded.
page_read internal The event gets triggered automatically whenever a user stays on the page for at least 30 seconds. This event is useful for educational pages.
form_submitted user + redirect The events is triggered when a user submits a form. After this event is sent, the webpage will redirect to redirectUrl.
mic_accepted manual + redirect The events is triggered manually and should be run after a user accepts the microphone permissions prompt. After this event is sent, the webpage will redirect to redirectUrl.
webcam_accepted manual + redirect The events is triggered manually and should be run after a user accepts the webcam permissions prompt. After this event is sent, the webpage will redirect to redirectUrl.
location_accepted manual + redirect The events is triggered manually and should be run after a user accepts the location permissions prompt. After this event is sent, the webpage will redirect to redirectUrl.
notification_accepted manual + redirect The events is triggered manually and should be run after a user accepts the notifications permissions prompt. After this event is sent, the webpage will redirect to redirectUrl.
clipboard_accepted manual + redirect The events is triggered manually and should be run after a user accepts the clipboard permissions prompt. After this event is sent, the webpage will redirect to redirectUrl.