@waves/event-sender
Advanced tools
Comparing version 0.3.0 to 0.4.0
declare class EventSender { | ||
private active; | ||
private static _instance; | ||
private internalQueue; | ||
/** | ||
@@ -22,4 +23,2 @@ * EventSender | ||
* Upon user agreement to send statistics | ||
* @param {string} newUrl ad | ||
* @param {string} referrer | ||
* @return {EventSender} | ||
@@ -29,2 +28,7 @@ */ | ||
/** | ||
* Deactivate event tracking | ||
* @return {EventSender} | ||
*/ | ||
deactivate: () => EventSender; | ||
/** | ||
* Queue custom event | ||
@@ -31,0 +35,0 @@ * @param {string} category e.g 'DEX' |
@@ -18,4 +18,2 @@ "use strict"; | ||
* Upon user agreement to send statistics | ||
* @param {string} newUrl ad | ||
* @param {string} referrer | ||
* @return {EventSender} | ||
@@ -31,2 +29,10 @@ */ | ||
/** | ||
* Deactivate event tracking | ||
* @return {EventSender} | ||
*/ | ||
this.deactivate = function () { | ||
_this.active = false; | ||
return _this; | ||
}; | ||
/** | ||
* Queue custom event | ||
@@ -84,2 +90,5 @@ * @param {string} category e.g 'DEX' | ||
var URL = '//wavesplatform.innocraft.cloud/'; | ||
// push internal queue into piwik | ||
this._pushAll('paq', this.internalQueue); | ||
this.internalQueue = []; | ||
this._pushAll('_paq', [ | ||
@@ -104,9 +113,19 @@ // ['setDocumentTitle', document.domain + '/' + document.title], | ||
EventSender.prototype._pushAll = function (queueName, data) { | ||
window[queueName] = window[queueName] || []; | ||
data.forEach(function (obj) { return window[queueName].push(obj); }); | ||
if (this.active) { | ||
window[queueName] = window[queueName] || []; | ||
data.forEach(function (obj) { return window[queueName].push(obj); }); | ||
} | ||
else { | ||
this.internalQueue = this.internalQueue.concat(data); | ||
} | ||
return this; | ||
}; | ||
EventSender.prototype._push = function (queueName, data) { | ||
window[queueName] = window[queueName] || []; | ||
window[queueName].push(data); | ||
if (this.active) { | ||
window[queueName] = window[queueName] || []; | ||
window[queueName].push(data); | ||
} | ||
else { | ||
this.internalQueue.push(data); | ||
} | ||
return this; | ||
@@ -113,0 +132,0 @@ }; |
@@ -19,4 +19,2 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.eventSender = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
* Upon user agreement to send statistics | ||
* @param {string} newUrl ad | ||
* @param {string} referrer | ||
* @return {EventSender} | ||
@@ -32,2 +30,10 @@ */ | ||
/** | ||
* Deactivate event tracking | ||
* @return {EventSender} | ||
*/ | ||
this.deactivate = function () { | ||
_this.active = false; | ||
return _this; | ||
}; | ||
/** | ||
* Queue custom event | ||
@@ -85,2 +91,5 @@ * @param {string} category e.g 'DEX' | ||
var URL = '//wavesplatform.innocraft.cloud/'; | ||
// push internal queue into piwik | ||
this._pushAll('paq', this.internalQueue); | ||
this.internalQueue = []; | ||
this._pushAll('_paq', [ | ||
@@ -105,9 +114,19 @@ // ['setDocumentTitle', document.domain + '/' + document.title], | ||
EventSender.prototype._pushAll = function (queueName, data) { | ||
window[queueName] = window[queueName] || []; | ||
data.forEach(function (obj) { return window[queueName].push(obj); }); | ||
if (this.active) { | ||
window[queueName] = window[queueName] || []; | ||
data.forEach(function (obj) { return window[queueName].push(obj); }); | ||
} | ||
else { | ||
this.internalQueue = this.internalQueue.concat(data); | ||
} | ||
return this; | ||
}; | ||
EventSender.prototype._push = function (queueName, data) { | ||
window[queueName] = window[queueName] || []; | ||
window[queueName].push(data); | ||
if (this.active) { | ||
window[queueName] = window[queueName] || []; | ||
window[queueName].push(data); | ||
} | ||
else { | ||
this.internalQueue.push(data); | ||
} | ||
return this; | ||
@@ -114,0 +133,0 @@ }; |
{ | ||
"name": "@waves/event-sender", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "An interface for sending analytics events from Waves JS applications", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
13240
320