Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds check to ensure view is present #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 37 additions & 33 deletions www/EqatecAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
{{#crossLink "EqatecAnalytics.Factory/CreateMonitorWithSettings"}}Factory.CreateMonitorWithSettings{{/crossLink}}<br/>
{{#crossLink "EqatecAnalytics.Factory/CreateSettings"}}Factory.CreateSettings{{/crossLink}}<br/>
{{#crossLink "EqatecAnalytics.Monitor/Start"}}Monitor.Start{{/crossLink}}<br/>

// Create the monitor instance using the unique product key
// You should add this snippet to your application's startup code somewhere
var productId = "YOUR-PRODUCT-KEY-HERE";
var factory = window.plugins.EqatecAnalytics.Factory;
var factory = window.plugins.EqatecAnalytics.Factory;
var settings = factory.CreateSettings(productId);
settings.LoggingInterface = factory.CreateTraceLogger(); // please log
factory.CreateMonitorWithSettings(settings,
Expand All @@ -32,7 +32,7 @@
});

....

// Elsewhere in your code you can further use the Analytics API to track app's usage
// EXAMPLE BEGIN
var mon = window.plugins.EqatecAnalytics.Monitor;
Expand All @@ -50,7 +50,7 @@
mon.TrackExceptionMessage(ex, "Image processing failed for " + folder.name);
}
// EXAMPLE END

* @module EqatecAnalytics
*/

Expand All @@ -74,7 +74,7 @@ var iceniumPluginVersion = "3.3.1";

/**
* Create the EqatecAnalytics monitor.
*
*
* @namespace EqatecAnalytics
* @for Factory
* @method CreateMonitor
Expand Down Expand Up @@ -108,13 +108,13 @@ AnalyticsMonitorFactory.prototype.CreateMonitor = function(productId, version, s

/**
* Create the EqatecAnalytics monitor with more detailed settings.
*
*
* @namespace EqatecAnalytics
* @for Factory
* @method CreateMonitorWithSettings
* @param {Object} settings Detailed settings, created by {{#crossLink "EqatecAnalytics.Factory/CreateSettings"}}Factory.CreateSettings{{/crossLink}}:
@param {String} settings.ProductId The numeric product id, e.g. "B568811797BD4419B50631716F0359AD"
@param {String} settings.Version An optional application version, e.g. "1.2.3"; if null or empty, the app version will be deduced automatically
@param {String} settings.Version An optional application version, e.g. "1.2.3"; if null or empty, the app version will be deduced automatically
@param {Object} settings.LocationCoordinates Use this for geolocation. It has these two members:
@param {Number} settings.LocationCoordinates.Latitude The latitude
@param {Number} settings.LocationCoordinates.Longitude The longitude
Expand Down Expand Up @@ -173,7 +173,7 @@ AnalyticsMonitorFactory.prototype.CreateMonitorWithSettings = function(settings,
}
settings.LoggingInterface.LogMessage("Telerik Analytics Monitor: Logging enabled (plugin version " + iceniumPluginVersion + ")");
}

// Sanitize the settings-object because invalid data may cause cordova to crash hard (eg SIGSEGV on iOS)
if (settings) {
// Make sure at least one property is set, as empty objects make cordova crash
Expand All @@ -184,15 +184,15 @@ AnalyticsMonitorFactory.prototype.CreateMonitorWithSettings = function(settings,
if (proxy && !proxy.Host && !proxy.Port && !proxy.UserName && !proxy.Password)
delete settings.ProxyConfig;
}

cordova.exec(successCallback, failureCallback, "EqatecAnalytics", "FactoryCreateMonitorWithSettings", [settings]);
};


/**
* Detect whether the monitor has already been created by one of the Create-methods
* and therefore is alive and cannot be created again.
*
*
* @namespace EqatecAnalytics
* @for Factory
* @method IsMonitorCreated
Expand All @@ -215,7 +215,7 @@ AnalyticsMonitorFactory.prototype.IsMonitorCreated = function(successCallback)

/**
* Create settings suitable for passing to {{#crossLink "EqatecAnalytics.Factory/CreateMonitorWithSettings"}}Factory.CreateMonitorWithSettings{{/crossLink}}.
*
*
* @namespace EqatecAnalytics
* @for Factory
* @method CreateSettings
Expand Down Expand Up @@ -259,7 +259,7 @@ AnalyticsMonitorFactory.prototype.CreateSettings = function(productId, version)
"LocationCoordinates": { "Latitude":0.0, "Longitude":0.0 },
"ProxyConfig": { "Host":"", "Port":0, "UserName":"", "Password":"" },
"LoggingInterface":null,
"DailyNetworkUtilizationInKB": INTEGER_MAX_VALUE,
"DailyNetworkUtilizationInKB": INTEGER_MAX_VALUE,
"MaxStorageSizeInKB": INTEGER_MAX_VALUE,
"ServerUri": "http://" + productId.replace("-", "") + ".monitor-eqatec.com/",
"StorageSaveInterval": 60,
Expand All @@ -275,7 +275,7 @@ AnalyticsMonitorFactory.prototype.CreateSettings = function(productId, version)
* own logger and pass it along in the settings when creating a monitor using
* {{#crossLink "EqatecAnalytics.Factory/CreateMonitorWithSettings"}}Factory.CreateMonitorWithSettings{{/crossLink}} or you can use
* this one, which will output to the standard console.log.
*
*
* @namespace EqatecAnalytics
* @for Factory
* @method CreateTraceLogger
Expand All @@ -288,7 +288,7 @@ AnalyticsMonitorFactory.prototype.CreateSettings = function(productId, version)
settings.LoggingInterface = factory.CreateTraceLogger(); // please log
factory.CreateMonitorWithSettings(settings,
function() { console.log("Monitor created"); },
function(msg) { console.log("Error creating monitor: " + msg); });
function(msg) { console.log("Error creating monitor: " + msg); });
*/
AnalyticsMonitorFactory.prototype.CreateTraceLogger = function()
{
Expand Down Expand Up @@ -365,7 +365,7 @@ AnalyticsMonitor.prototype.Stop = function(successCallback)
* attempted to deliver the data again on the next start of the monitor with
* the same product id.
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method StopWithTimeout
Expand All @@ -386,7 +386,7 @@ AnalyticsMonitor.prototype.StopWithTimeout = function(waitForCompletionInSeconds
/**
* Track an exception with a context message. Delivers the exception
* information to the server as soon as possible.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method TrackExceptionMessage
Expand Down Expand Up @@ -429,9 +429,9 @@ AnalyticsMonitor.prototype.TrackExceptionMessage = function(exception, message)
* dot-notation for feature naming to allow for better grouping of related
* features. Tracked features are not delivered to the server immediately
* but are piggy-backed on the next delivery.
*
*
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method TrackFeature
Expand All @@ -444,15 +444,15 @@ AnalyticsMonitor.prototype.TrackFeature = function(featureName)
cordova.exec(null, null, "EqatecAnalytics", "MonitorTrackFeature", [featureName]);
};


/**
* Start time tracking of a named feature. Note that the timing is not
* recorded before a matching TrackFeatureStop has been called and that
* there is no support for multiple concurrent timings of the same named
* feature so multiple start calls without a matching stop for the same
* feature will have no effect.
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method TrackFeatureStart
Expand All @@ -476,12 +476,12 @@ AnalyticsMonitor.prototype.TrackFeatureStart = function(featureName)
cordova.exec(null, null, "EqatecAnalytics", "MonitorTrackFeatureStart", [featureName]);
};


/**
* Stop time tracking of a named feature. Note that this has no effect if
* there has not been a matching TrackFeatureStart.
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method TrackFeatureStop
Expand Down Expand Up @@ -512,7 +512,7 @@ AnalyticsMonitor.prototype.TrackFeatureStop = function(featureName)
* expected such as an exception occurring or the user canceling the
* activity.
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method TrackFeatureCancel
Expand All @@ -536,13 +536,13 @@ AnalyticsMonitor.prototype.TrackFeatureCancel = function(featureName)
cordova.exec(null, null, "EqatecAnalytics", "MonitorTrackFeatureCancel", [featureName]);
};


/**
* Track a value associated with a feature name. This tracking will
* associate the given value with the feature and allow you to inspect e.g.
* the distribution of value server side
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method TrackFeatureValue
Expand All @@ -556,7 +556,7 @@ AnalyticsMonitor.prototype.TrackFeatureValue = function(featureName, trackedValu
cordova.exec(null, null, "EqatecAnalytics", "MonitorTrackFeatureValue", [featureName, trackedValue]);
};


/**
* Explicitly force a synchronization of the current information with the
* analytics server. This call is not expected to be used in a standard
Expand All @@ -577,11 +577,11 @@ AnalyticsMonitor.prototype.ForceSync = function()
cordova.exec(null, null, "EqatecAnalytics", "MonitorForceSync", []);
};


/**
* Associate an installation ID with the current monitor and current session.
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method SetInstallationInfo
Expand All @@ -594,19 +594,19 @@ AnalyticsMonitor.prototype.SetInstallationInfo = function(installationId)
cordova.exec(null, null, "EqatecAnalytics", "MonitorSetInstallationInfo", [installationId]);
};


/**
* Associate an installation ID with the current monitor and allows for further
* installation properties to be associated with the current session.
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method SetInstallationInfoAndProperties
* @param installationID any given string that would suitably identify the installation
* @param installationProperties a JSON object with key-value pairs to register for this installation and this session
* @example
window.plugins.EqatecAnalytics.Monitor.SetInstallationInfo(user.id,
window.plugins.EqatecAnalytics.Monitor.SetInstallationInfo(user.id,
{ name:user.name,
company:account.company,
license:account.license,
Expand All @@ -617,10 +617,10 @@ AnalyticsMonitor.prototype.SetInstallationInfoAndProperties = function(installat
cordova.exec(null, null, "EqatecAnalytics", "MonitorSetInstallationInfoAndProperties", [installationId, installationProperties]);
};


/**
* The monitor must have been created prior to this call using a Factory.Create method.
*
*
* @namespace EqatecAnalytics
* @for Monitor
* @method GetStatus
Expand Down Expand Up @@ -935,6 +935,10 @@ module.exports = EqatecAnalytics;
isBack = target.hash === "#:back",
view = kendo.widgetInstance($(target).closest(".km-view"), kendo.mobile.ui);

if (!view) {
return;
}

if (target && (view.trackingEnabled || isBack)) {
feature = target.getAttribute("data-track-feature");
rel = target.getAttribute("data-rel");
Expand Down