Socket
Socket
Sign inDemoInstall

@melmacaluso/skadi

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @melmacaluso/skadi

A simple js class to send tracking events to your google analytics accounts


Version published
Maintainers
1
Created

Readme

Source

Skadi.js 0.0.0-semantically-released

A simple js class to send tracking events to your google analytics account

skadi.js

new Skadi()

Main Skadi.js class

Returns
  • Void
Skadi.constructor(options)
Parameters
NameTypeDescription
optionsobjectSets the custom user defined arguments. 
Properties
NameTypeDescription
optionsobjectSets the custom user defined arguments. 
Returns
  • Void
Skadi.logDebug(logItems, message)

Simple logger for the debug mode.

Parameters
NameTypeDescription
logItemsarrayItems to be logged in the console 
messagestringArbitrary message that goes along the logItems 
Returns
  • Void
Skadi.updatePropsOnLoad()

Updates the class propreties with user defined ones after the page has loaded and if there's a window.Skadi object in place.

Returns
  • Void
Skadi.getEventType(event)

Filters the event types and gets the DOM node element clicked/focused. It also sets the class constructor's proprieties accordingly and filters out event types that are not allowed updating elementAllowed property accordingly. It also prevents registering continous events when the target is a input or textarea on keyup events that are not key === 'Tab'

Parameters
NameTypeDescription
eventobjectEither the mousevent or keyevent event object. 
Returns
  • Void
Skadi.parseElementClickedTag()

Translates event types to human readable events.

Returns
  • string The layman's terms event type.
Skadi.getElementClickedAction()

Parses the the GA action to be human readable.

Returns
  • string The action's type and target.
Skadi.getElementClickedContext()

Gets the nearest data-skadi-context bubbling up until finding a context or to the user defined maxBubbling value.

Returns
  • string The nearest context or "Default context" if nothing found.
Skadi.getElementClickedLabel()

Gets and parses the the GA Label to be human readable assuming canonical html is being used for label tags.

Returns
  • string The label parsed.
Skadi.parseToGaEvent(event)

Updates Skadi's constructor properties with the relevant parsed action, category and label and triggers GA function to send the GA event.

Parameters
NameTypeDescription
eventobjectThe click or keyboard event. 
Returns
  • Void
Skadi.sendToGa()

Sends the events to GA.

Returns
  • Void
Skadi.addClickListener()

Adds click and keyup listeners to the window global.

Returns
  • Void
Skadi.init(isCDN)

Initialises Skadi bootstrapping the listeners. It prevents es module version of skadi to work if there's a CDN version embedded.

Parameters
NameTypeDescription
isCDNbooleanDisables errors in CDN versions of skadi. 
Returns
  • Void

Documentation generated with doxdox.

FAQs

Last updated on 01 Nov 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc