Skip to content
Permalink
Browse files

🚒 v1.2.0 (Meteor: v1.3.0)

- πŸ‘¨β€πŸ’» Added `.onPushEvent()` method
- πŸ‘¨β€πŸ’» Added `.onTrack()` method
- πŸ‘·β€β™‚οΈ Improved Global Errors reporting
  • Loading branch information...
dr-dimitru committed Oct 3, 2019
1 parent 42afa91 commit ebb18e7414cb129eb7e15bf12e0a0ce9f8e15935
Showing with 37 additions and 9 deletions.
  1. +1 βˆ’1 .versions
  2. +33 βˆ’5 lib/analytics.js
  3. +1 βˆ’1 lib/analytics.min.js
  4. +1 βˆ’1 package.js
  5. +1 βˆ’1 package.json
@@ -11,5 +11,5 @@ meteor@1.9.3
modern-browsers@0.1.4
modules@0.13.0
modules-runtime@0.10.3
ostrio:analytics@1.2.9
ostrio:analytics@1.3.0
promise@0.11.2
@@ -3,7 +3,7 @@ module.exports = (function () {
var self = this;
this.sid = sid;
this.DNT = !!parseInt(navigator.doNotTrack || 0);
this.version = 205;
this.version = 206;
this.sending = false;
this.loc = location || window.location || document.location;
this.current = '';
@@ -12,6 +12,8 @@ module.exports = (function () {
this.info = console.info.bind(console) || console.log.bind(console) || function () {return;};
this.warn = console.warn.bind(console) || console.log.bind(console) || function () {return;};
this.errs = [];
this.onTrackArr = [];
this.onEventArr = [];

if (this.DNT) {
this.info('We respect your decision to be not tracked. DNT policy: https://en.wikipedia.org/wiki/Do_Not_Track');
@@ -38,9 +40,14 @@ module.exports = (function () {

/* Listen for Global Errors */
var _onerror = window.onerror;
window.onerror = function (msg, url, line, column) {
window.onerror = function (_msg, _url, _line, _column) {
var msg = _msg || 'N/A';
var url = (_url || '') + ' at ' + self.loc.href;
var line = _line || '0';
var column = _column || '0';

if (!!~url.indexOf(self.loc.origin)) {
self.pushEvent('[Global Error]', 'Error: ' + msg + '. File: ' + url.replace(self.loc.origin, '') + ' At: ' + line + ':' + column);
self.pushEvent('[Global Error]', 'Error: ' + msg + '. File: ' + url.replace(self.loc.origin, '').replace(self.loc.origin, '') + ' At: ' + line + ':' + column);
}
if (_onerror) {
_onerror.apply(this, arguments);
@@ -60,8 +67,24 @@ module.exports = (function () {
}
};

OTC.prototype.onPushEvent = function (callback) {
if (callback && typeof callback === 'function') {
this.onEventArr.push(callback);
}
};

OTC.prototype.onTrack = function (callback) {
if (callback && typeof callback === 'function') {
this.onTrackArr.push(callback);
}
};

/* Custom events method */
OTC.prototype.pushEvent = function (_key, _value) {
for (var i = this.onEventArr.length - 1; i >= 0; i--) {
this.onEventArr[i](_key, _value);
}

if (!this.DNT) {
if (_key && _value && '' + _key.length && '' + _value.length) {
var key = '' + _key;
@@ -85,9 +108,14 @@ module.exports = (function () {
};

OTC.prototype.track = function (_query) {
if (!this.DNT) {
var query = _query || '';
var query = _query || '';
if (!~query.indexOf('?3=')) {
for (var i = this.onTrackArr.length - 1; i >= 0; i--) {
this.onTrackArr[i]();
}
}

if (!this.DNT) {
if ((!this.sending && this.current !== this.loc.href) || !!~query.indexOf('?3=')) {
this.sending = true;
var self = this;

Some generated files are not rendered by default. Learn more.

@@ -1,6 +1,6 @@
Package.describe({
name: 'ostrio:analytics',
version: '1.2.9',
version: '1.3.0',
summary: 'Visitor\'s web analytics tracking code for ostr.io service',
git: 'https://github.com/VeliovGroup/ostrio-analytics',
documentation: 'README.md'
@@ -1,6 +1,6 @@
{
"name": "ostrio-analytics",
"version": "1.1.9",
"version": "1.2.0",
"description": "Visitor's web analytics tracking code for ostr.io service",
"main": "./lib/analytics.js",
"scripts": {

0 comments on commit ebb18e7

Please sign in to comment.
You can’t perform that action at this time.