inhabit-module-base
Advanced tools
Comparing version 1.4.3 to 1.4.5
@@ -118,3 +118,3 @@ "use strict"; | ||
lastStackFrameRegex = new RegExp(/.+\/(.*?):\d+(:\d+)*$/), | ||
currentStackFrameRegex = new RegExp(/getScriptName \(.+\/(.*):\d+:\d+\)/); | ||
currentStackFrameRegex = new RegExp(/\(.+\/(.*):\d+:\d+\)/); | ||
@@ -121,0 +121,0 @@ try { |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "inhabit-module-base", | ||
"version": "1.4.3", | ||
"version": "1.4.5", | ||
"description": "A Base Module class for InHabit.", | ||
"main": "build/index.js", | ||
"scripts": { | ||
"commit": "git-cz", | ||
"release": "standard-version", | ||
"test": "tape tests/*.spec.js | tap-spec", | ||
@@ -31,5 +33,13 @@ "build": "node tasks/build.js", | ||
"babel-preset-es2015": "^6.9.0", | ||
"commitizen": "^2.9.5", | ||
"cz-conventional-changelog": "^1.2.0", | ||
"standard-version": "^4.0.0", | ||
"tap-spec": "^4.1.1", | ||
"tape": "^4.6.0" | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
} |
204
README.md
@@ -5,3 +5,24 @@ # inhabit-module-base [![npm version](https://badge.fury.io/js/inhabit-module-base.svg)](https://badge.fury.io/js/inhabit-module-base) [![Inline docs](http://inch-ci.org/github/ArkadiumInc/node-inhabit-module-base.svg?branch=master)](http://inch-ci.org/github/ArkadiumInc/node-inhabit-module-base) [![Code Climate](https://codeclimate.com/github/ArkadiumInc/node-inhabit-module-base/badges/gpa.svg)](https://codeclimate.com/github/ArkadiumInc/node-inhabit-module-base) | ||
## Installation | ||
###TOC | ||
* [Installation](#install) | ||
* [Usage](#usage) | ||
* [JQuery](#jquery) | ||
* [Handlebars](#handlebars) | ||
* [Semantic service](#semanticservice) | ||
- [Taxonomy](#taxonomy) | ||
- [Entities](#enttities) | ||
- [Keywords](#keywords) | ||
* [AB tests](#abtests) | ||
* [Logger](#logger) | ||
* [Events](#events) | ||
- [Ready](#ready) | ||
- [Error](#error) | ||
- [InteractionStart](#interactionstart) | ||
- [CycleStart](#cyclestart) | ||
- [CycleEnd](#cycleend) | ||
- [Custom](#custom) | ||
* [Modal popup](#modalpopup) | ||
* [Resources root](#resourcesRoot) | ||
## Installation<a name="install"></a> | ||
```sh | ||
@@ -11,3 +32,4 @@ npm install --save-dev inhabit-module-base | ||
## Usage ES5 | ||
## Usage <a name="usage"></a> | ||
```javascript | ||
@@ -31,27 +53,117 @@ var InhabitModuleBase = require('inhabit-module-base'); | ||
##### JQuery | ||
### JQuery <a name="jquery"></a> | ||
````javascript | ||
this.$; | ||
dependencies.$; | ||
```` | ||
##### Handlebars | ||
### Handlebars<a name="handlebars"></a> | ||
````javascript | ||
this.handlebars; | ||
dependencies.handlebars; | ||
```` | ||
##### Semantic service | ||
### Semantic service <a name="semanticservice"></a> | ||
This service allows you to grab contextual information about your page for later use. | ||
````javascript | ||
this.textClassificationService; | ||
dependencies.textClassificationService; | ||
```` | ||
#### Taxonomy<a name="taxonomy"></a> | ||
**getTaxonomy** method returns promise that results into the array of taxonomy information about this page. | ||
````javascript | ||
dependencies.textClassificationService.getTaxonomy().then(function(taxonomy){ | ||
}) | ||
```` | ||
where "taxonomy" is array: | ||
````javascript | ||
[ | ||
{ | ||
"values": [ | ||
"sports", | ||
"football" | ||
], | ||
"score": 0.990101 | ||
}, | ||
{ | ||
"values":[ | ||
"business and industrial", | ||
"logistics", | ||
"freight train" | ||
], | ||
"score":0.36197 | ||
} | ||
... | ||
] | ||
```` | ||
vales in this case are dependent from each other, you should read them like this sports->football; business and industrial->logistics->freight train | ||
For full list of available taxonomy please look this document [Taxonomy reference](docs/taxonomy.csv) | ||
##### AB tests | ||
#### Entities<a name="entities"></a> | ||
**getEntities** - method returns promise that results into array of entities relevant to this page. | ||
````javascript | ||
this.abTestManager; | ||
dependencies.textClassificationService.getEntities().then(function(entities){ | ||
}) | ||
```` | ||
where "entities" is array: | ||
````javascript | ||
{ | ||
"values": [ | ||
"Matt Jones" | ||
], | ||
"score": 0.82653, | ||
"type": "Person" | ||
}, | ||
{ | ||
"values": [ | ||
"Coach Jay Gruden" | ||
], | ||
"score": 0.668899, | ||
"type": "Person", | ||
"misc": { | ||
"subType": [ | ||
"FootballPlayer", | ||
"SportsOfficial" | ||
], | ||
"name": "Jay Gruden" | ||
} | ||
} | ||
```` | ||
List of available [types](docs/entity-types.csv) and [sub types](docs/sub-types.csv) | ||
#### Keywords<a name="keywords"></a> | ||
**getKeywords** - method returns promise that results into array of keywords, keywords are broader view of text than entities and taxonomy based on words that | ||
could be used to describe meaning of the text | ||
````javascript | ||
dependencies.textClassificationService.getKeywords().then(function(keywords){ | ||
}) | ||
```` | ||
where "keywords" is array: | ||
````javascript | ||
[ | ||
{ | ||
"values": [ | ||
"Monday night" | ||
], | ||
"score": 0.926018 | ||
}, | ||
{ | ||
"values": [ | ||
"Coach Jay Gruden" | ||
], | ||
"score": 0.746022 | ||
} | ||
] | ||
```` | ||
### AB tests<a name="abtests"></a> | ||
````javascript | ||
dependencies.abTestManager; | ||
```` | ||
AB test manager allows you to extend your object properties and add AB test support for them | ||
For example you have property: | ||
````javascript | ||
var myTitle = this.configuration.title; | ||
var myTitle = configuration.title; | ||
```` | ||
that you recieve from json configuration delivered by Inhabit platform | ||
that you receive from json configuration delivered by Inhabit platform | ||
````JSON | ||
@@ -94,3 +206,3 @@ { | ||
````javascript | ||
var myTitle = this.abTestManager.getSetting(this.configuration.title); | ||
var myTitle = dependencies.abTestManager.getSetting(configuration.title); | ||
```` | ||
@@ -102,5 +214,5 @@ That's it now AB test will automatically set proper value based on you weights | ||
You can use ABTest manager for any javascript object if you want; | ||
##### Logger | ||
### Logger<a name="logger"></a> | ||
````javascript | ||
this.logger; | ||
dependencies.logger; | ||
```` | ||
@@ -113,51 +225,54 @@ Logger - built-in logger can be enabled in production through specific configuration, allows you debug your application in production. | ||
````javascript | ||
this.logger("simple console log"); | ||
this.logger({h: "header", c:'r', type: 'error'}, "console log with header"); | ||
this.logger({h: "header", c:'r', type: 'error'}, "console log with header","some additional details can be provided here"); | ||
dependencies.logger("simple console log"); | ||
dependencies.logger({h: "header", c:'r', type: 'error'}, "console log with header"); | ||
dependencies.logger({h: "header", c:'r', type: 'error'}, "console log with header","some additional details can be provided here"); | ||
```` | ||
##### Events | ||
don't forget to enable DevMode as well | ||
````HTML | ||
<script async="" ... data-ark-log="true" src="//widgetapi-inhabit.as.arkadiumhosted.com/Widget/v1"></script> | ||
```` | ||
### Events<a name="events"></a> | ||
````javascript | ||
this.events | ||
dependencies.events | ||
```` | ||
###### Ready | ||
#### Ready<a name="ready"></a> | ||
Call this method when interactive loaded all required resources and ready to be displayed to the user | ||
````javascript | ||
this.events.ready(message) | ||
dependencies.events.ready(message) | ||
```` | ||
**message[optional]** - if you need any message attached to the ready event, this message can be later used in analytics dashboard for example | ||
###### Error | ||
#### Error <a name="error"></a> | ||
Call this method if any error appears in your application. This will help to track them down and make your application better | ||
````javascript | ||
this.events.error(message) | ||
dependencies.events.error(message) | ||
```` | ||
**message[optional]** - if you need any message attached to the error event, this message can be later used in analytics dashboard for example | ||
###### InteractionStart | ||
#### InteractionStart<a name="interactionstart"></a> | ||
Call this method when user performs first interaction with application. This event should be called once per application lifetime | ||
````javascript | ||
this.events.interactionStart(message) | ||
dependencies.events.interactionStart(message) | ||
```` | ||
**message[optional]** - if you need any message attached to the interactionStart event, this message can be later used in analytics dashboard for example | ||
###### CycleStart | ||
#### CycleStart<a name="cyclestart"></a> | ||
Call this method when user starts iteration/cycle/sequence of logic in your application | ||
````javascript | ||
this.events.cycleStart(message) | ||
dependencies.events.cycleStart(message) | ||
```` | ||
**message[optional]** - if you need any message attached to the cycleStart event, this message can be later used in analytics dashboard for example | ||
###### CycleEnd | ||
#### CycleEnd<a name="cycleend"></a> | ||
Call this method when user end iteration/cycle/sequence of logic in your application | ||
````javascript | ||
this.events.cycleEnd(message) | ||
dependencies.events.cycleEnd(message) | ||
```` | ||
**message[optional]** - if you need any message attached to the cycleEnd event, this message can be later used in analytics dashboard for example | ||
###### Custom | ||
#### Custom <a name="custom"></a> | ||
You can use this event to propagate any custom messages for analytics purposes | ||
````javascript | ||
this.events.custom(name, message) | ||
dependencies.events.custom(name, message) | ||
```` | ||
@@ -169,21 +284,24 @@ **name** - name of the event | ||
````javascript | ||
this.events.refreshAd | ||
this.events.refreshAd() | ||
```` | ||
##### ModalPopup | ||
### ModalPopup<a name="modalpopup"></a> | ||
````javascript | ||
this.modalPopup | ||
dependencies.modalPopup | ||
```` | ||
Open popup window with your custom url, use method: | ||
````javascritp | ||
this.modalPopup.open('your url') | ||
````javascript | ||
dependencies.modalPopup.open('your url') | ||
```` | ||
Open terms of service popup window, use method: | ||
````javascritp | ||
this.modalPopup.openTermsOfService() | ||
````javascript | ||
dependencies.modalPopup.openTermsOfService() | ||
```` | ||
### Resources root<a name="resourcesRoot"></a> | ||
Provides absolute url to your resources root. Use this to reference all images and other resources you will use in your | ||
code | ||
````javascript | ||
dependencies.resourcesRoot; | ||
```` |
@@ -120,3 +120,3 @@ "use strict"; | ||
, lastStackFrameRegex = new RegExp(/.+\/(.*?):\d+(:\d+)*$/) | ||
, currentStackFrameRegex = new RegExp(/getScriptName \(.+\/(.*):\d+:\d+\)/); | ||
, currentStackFrameRegex = new RegExp(/\(.+\/(.*):\d+:\d+\)/); | ||
@@ -123,0 +123,0 @@ try { throw new Error(); } |
@@ -0,0 +0,0 @@ "use strict"; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164718
26
301
9