0.5.0 • Published 7 years ago

cryptid v0.5.0

Weekly downloads
5
License
MIT
Repository
github
Last release
7 years ago

cryptid-js

Javascript client for Cryptid Analytics

This library should be used to integrate Cryptid Analytics into web-based javascript applications (React, Vue, etc. or a simple script tag at the bottome of a static page.)

For React Native javascript projects, use cryptid-react-native, which will gather device information rather than browser information.

Install

To install into a project:

npm install cryptid --save

To install for CLI usage only:

npm install cryptid --global

Configure

Create a new Tracker using the trackerId of the property you're tracking.

import Tracker from 'cryptid';

const tracker = new Tracker('web|AB5A928D-7244-4A07-9653-E4557C500C53')

You may also supply additional options as a second argument. They will be passed through to the reqwest ajax call.

import Tracker from 'cryptid';

const tracker = new Tracker('web|AB5A928D-7244-4A07-9653-E4557C500C53', {
  success: (response) => console.log(response),
  error: (err) => console.error(err),
});

React/Redux

In a react+redux application, you may want to consider intializing a Tracker instance in your store, and then tracking events when actions are fired or when reducers commit changes to the store.

Use

Tracker has one method: send, which is used to send an event to the cryptid service. When you call send the library gathers browser metadata to include with the event data you supply. All of this metadata may be overridden by fields you include on the event object (see the Events section below.)

Simple example:

tracker.send({eventValue: 'button-clicked'});

More complex:

tracker.send({
  eventCategory: 'eCommerce',
  eventAction: 'checkout',
  eventValue: 'checkout-initiated',
  customField1: 'abc123456789', // user id
  customField2: 5, // items in cart
  customField3: 'email', // referral code
});

Events

List of fields that can be included in the event object:

FieldDescriptionRequired?Example
eventCategoryCategory of the eventNoAuthentication
eventActionAction or workflow the event occured duringNoLogin
eventLabelLabel of the eventNoform-submission
eventValueValue of the eventYesbutton-click or enter-key
customField_1Custom dataNo
customField_2Custom dataNo
customField_3Custom dataNo
customField_4Custom dataNo
customField_5Custom dataNo

You may use the Category, Action, Label and Value event fields any way that you'd like in your application; they exist merely to allow for an event taxonomy that works for you. The simplest way to use them is to only supply an event value such as login-successful. If you don't need anything more complicated, you may omit the rest of the fields.

Likewise, the customField values are there to log supplemental application information that may bes useful to you, but are not required by the send event or the service.

List of browser metadata fields that are automatically collected and may be overridden by including them in the event object:

FieldDescriptionExample
documentLocationUrlURL of the pagehttp://example.org/foo.html
documentRefererReferrer (if any) of the pagehttp://google.com
documentEncodingThe character set used on the pageUTF-8
documentTitleThe title of the pageMy Cool Application > Login
documentHostnameThe hostname the page was served fromexample.org
documentPathThe document path of the page/foo.html
userLanguageThe configured language of the browseren-US
screenResolutionThe resolution of the display2560x1417
viewportSizeThe viewable size of the browser at the time of the event2560x1440
screenColorsThe screen color depth24

CLI Client

Installing the cryptid module also gives you access to a command-line admin client to the cryptid analytics service.

Login to the service with:

$(npm bin)/cryptid login

And then all functionality should be available. View available commands with:

$(npm bin)/cryptid -h
0.5.0

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago