mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,22 @@
|
||||
package libraries.uanalytics.tracker
|
||||
{
|
||||
public class DataSource
|
||||
{
|
||||
|
||||
public static const WEB:String = "web";
|
||||
|
||||
public static const APP:String = "app";
|
||||
|
||||
public static const DESKTOP:String = "desktop";
|
||||
|
||||
public static const MOBILE:String = "mobile";
|
||||
|
||||
public static const COMMAND_LINE:String = "commandline";
|
||||
|
||||
public function DataSource()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,432 @@
|
||||
package libraries.uanalytics.tracker
|
||||
{
|
||||
import flash.system.ApplicationDomain;
|
||||
import flash.utils.Dictionary;
|
||||
import libraries.uanalytics.tracker.senders.LoaderHitSender;
|
||||
import libraries.uanalytics.tracking.Configuration;
|
||||
import libraries.uanalytics.tracking.HitModel;
|
||||
import libraries.uanalytics.tracking.HitSampler;
|
||||
import libraries.uanalytics.tracking.RateLimitError;
|
||||
import libraries.uanalytics.tracking.RateLimiter;
|
||||
import libraries.uanalytics.tracking.Tracker;
|
||||
import libraries.uanalytics.utils.generateUUID;
|
||||
import libraries.uanalytics.utils.getHostname;
|
||||
|
||||
public class DefaultTracker extends Tracker
|
||||
{
|
||||
|
||||
public function DefaultTracker(param1:String = "", param2:Configuration = null)
|
||||
{
|
||||
super();
|
||||
if(!param2)
|
||||
{
|
||||
param2 = new Configuration();
|
||||
}
|
||||
_config = param2;
|
||||
_ctor(param1);
|
||||
}
|
||||
|
||||
protected function _ctor(param1:String = "") : void
|
||||
{
|
||||
var _loc2_:Class = null;
|
||||
_model = new HitModel();
|
||||
_temporary = new HitModel();
|
||||
if(_config.senderType != "")
|
||||
{
|
||||
_loc2_ = ApplicationDomain.currentDomain.getDefinition(_config.senderType) as Class;
|
||||
_sender = new _loc2_(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sender = new LoaderHitSender(this);
|
||||
}
|
||||
_limiter = new RateLimiter(100,10);
|
||||
if(param1 != "")
|
||||
{
|
||||
set("trackingId",param1);
|
||||
}
|
||||
var _loc3_:String = _getClientID();
|
||||
if(_loc3_ != "")
|
||||
{
|
||||
set("clientId",_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _getClientID() : String
|
||||
{
|
||||
return generateUUID();
|
||||
}
|
||||
|
||||
protected function _getCacheBuster() : String
|
||||
{
|
||||
var _loc1_:Date = new Date();
|
||||
var _loc2_:Number = Math.random();
|
||||
return String(_loc1_.valueOf() + _loc2_);
|
||||
}
|
||||
|
||||
override public function send(param1:String = null, param2:Dictionary = null) : Boolean
|
||||
{
|
||||
if(trackingId == "" || trackingId == null)
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("tracking id is missing.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(clientId == "" || clientId == null)
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("client id is missing.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc5_:HitModel = _model.clone();
|
||||
_loc5_.add(_temporary);
|
||||
_temporary.clear();
|
||||
if(param2 != null)
|
||||
{
|
||||
for(var _loc3_:String in param2)
|
||||
{
|
||||
_loc5_.set(_loc3_,param2[_loc3_]);
|
||||
}
|
||||
}
|
||||
if((param1 != "" || param1 != null) && HitType.isValid(param1))
|
||||
{
|
||||
_loc5_.set("hitType",param1);
|
||||
if(_config && _config.enableSampling)
|
||||
{
|
||||
if(HitSampler.isSampled(_loc5_,String(_config.sampleRate)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(_config && _config.enableThrottling)
|
||||
{
|
||||
if(!_limiter.consumeToken())
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new RateLimitError();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(_config && _config.enableCacheBusting)
|
||||
{
|
||||
_loc5_.set("cacheBuster",_getCacheBuster());
|
||||
}
|
||||
if(_config && _config.anonymizeIp)
|
||||
{
|
||||
_loc5_.set("anonymizeIp","1");
|
||||
}
|
||||
if(_config && _config.overrideIpAddress != "")
|
||||
{
|
||||
_loc5_.set("ipOverride",_config.overrideIpAddress);
|
||||
}
|
||||
if(_config && _config.overrideUserAgent != "")
|
||||
{
|
||||
_loc5_.set("userAgentOverride",_config.overrideUserAgent);
|
||||
}
|
||||
if(_config && _config.overrideGeographicalId != "")
|
||||
{
|
||||
_loc5_.set("geographicalOverride",_config.overrideGeographicalId);
|
||||
}
|
||||
var _loc4_:Error = null;
|
||||
try
|
||||
{
|
||||
_sender.send(_loc5_);
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_loc4_ = e;
|
||||
}
|
||||
if(_config && _config.enableErrorChecking && _loc4_)
|
||||
{
|
||||
throw _loc4_;
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("hit type \"" + param1 + "\" is not valid.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
override public function pageview(param1:String, param2:String = "") : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("path is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc4_:Dictionary = new Dictionary();
|
||||
_loc4_["documentPath"] = param1;
|
||||
if(param2 && param2.length > 0)
|
||||
{
|
||||
if(param2.length > 1500)
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("Title is bigger than 1500 bytes.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_loc4_["documentTitle"] = param2;
|
||||
}
|
||||
var _loc3_:String = get("documentHostname");
|
||||
if(_loc3_ == null)
|
||||
{
|
||||
if(!("documentHostname" in _loc4_))
|
||||
{
|
||||
_loc3_ = getHostname();
|
||||
if(_loc3_ == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("hostname is not defined.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_loc4_["documentHostname"] = _loc3_;
|
||||
}
|
||||
}
|
||||
return send("pageview",_loc4_);
|
||||
}
|
||||
|
||||
override public function screenview(param1:String, param2:Dictionary = null) : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("name is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc5_:Dictionary = new Dictionary();
|
||||
if(param2 != null)
|
||||
{
|
||||
for(var _loc3_:String in param2)
|
||||
{
|
||||
_loc5_[_loc3_] = param2[_loc3_];
|
||||
}
|
||||
}
|
||||
var _loc4_:String = get("appName");
|
||||
if(_loc4_ == null)
|
||||
{
|
||||
if(!("appName" in _loc5_))
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("Application name is not defined.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_loc5_["screenName"] = param1;
|
||||
return send("screenview",_loc5_);
|
||||
}
|
||||
|
||||
override public function event(param1:String, param2:String, param3:String = "", param4:int = -1) : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("category is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(param2 == null || param2 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("action is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc5_:Dictionary = new Dictionary();
|
||||
_loc5_["eventCategory"] = param1;
|
||||
_loc5_["eventAction"] = param2;
|
||||
if(param3 != "")
|
||||
{
|
||||
_loc5_["eventLabel"] = param3;
|
||||
}
|
||||
if(param4 > -1)
|
||||
{
|
||||
_loc5_["eventValue"] = param4;
|
||||
}
|
||||
return send("event",_loc5_);
|
||||
}
|
||||
|
||||
override public function transaction(param1:String, param2:String = "", param3:Number = 0, param4:Number = 0, param5:Number = 0, param6:String = "") : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("id is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc7_:Dictionary = new Dictionary();
|
||||
_loc7_["transactionId"] = param1;
|
||||
if(param2 != "")
|
||||
{
|
||||
_loc7_["transactionAffiliation"] = param2;
|
||||
}
|
||||
_loc7_["transactionRevenue"] = param3;
|
||||
_loc7_["transactionShipping"] = param4;
|
||||
_loc7_["transactionTax"] = param5;
|
||||
if(param6 != "")
|
||||
{
|
||||
_loc7_["currencyCode"] = param6;
|
||||
}
|
||||
return send("transaction",_loc7_);
|
||||
}
|
||||
|
||||
override public function item(param1:String, param2:String, param3:Number = 0, param4:int = 0, param5:String = "", param6:String = "", param7:String = "") : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("transaction id is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(param2 == null || param2 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("name is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc8_:Dictionary = new Dictionary();
|
||||
_loc8_["transactionId"] = param1;
|
||||
_loc8_["itemName"] = param2;
|
||||
_loc8_["itemPrice"] = param3;
|
||||
_loc8_["itemQuantity"] = param4;
|
||||
if(param5 != "")
|
||||
{
|
||||
_loc8_["itemCode"] = param5;
|
||||
}
|
||||
if(param6 != "")
|
||||
{
|
||||
_loc8_["itemCategory"] = param6;
|
||||
}
|
||||
if(param7 != "")
|
||||
{
|
||||
_loc8_["currencyCode"] = param7;
|
||||
}
|
||||
return send("item",_loc8_);
|
||||
}
|
||||
|
||||
override public function social(param1:String, param2:String, param3:String) : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("network is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(param2 == null || param2 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("action is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(param3 == null || param3 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("target is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc4_:Dictionary = new Dictionary();
|
||||
_loc4_["socialNetwork"] = param1;
|
||||
_loc4_["socialAction"] = param2;
|
||||
_loc4_["socialTarget"] = param3;
|
||||
return send("social",_loc4_);
|
||||
}
|
||||
|
||||
override public function exception(param1:String = "", param2:Boolean = true) : Boolean
|
||||
{
|
||||
var _loc3_:Dictionary = new Dictionary();
|
||||
if(param1 != "")
|
||||
{
|
||||
_loc3_["exceptionDescription"] = param1;
|
||||
}
|
||||
if(param2)
|
||||
{
|
||||
_loc3_["exceptionFatal"] = "1";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_["exceptionFatal"] = "0";
|
||||
}
|
||||
return send("exception",_loc3_);
|
||||
}
|
||||
|
||||
override public function timing(param1:String, param2:String, param3:int, param4:String = "", param5:Dictionary = null) : Boolean
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("category is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(param2 == null || param2 == "")
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("name is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if(param3 < 0)
|
||||
{
|
||||
if(_config && _config.enableErrorChecking)
|
||||
{
|
||||
throw new ArgumentError("value is empty");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var _loc7_:Dictionary = new Dictionary();
|
||||
_loc7_["userTimingCategory"] = param1;
|
||||
_loc7_["userTimingVar"] = param2;
|
||||
_loc7_["userTimingTime"] = param3;
|
||||
if(param4 != "")
|
||||
{
|
||||
_loc7_["userTimingLabel"] = param4;
|
||||
}
|
||||
if(param5 != null)
|
||||
{
|
||||
for(var _loc6_:String in param5)
|
||||
{
|
||||
_loc7_[_loc6_] = param5[_loc6_];
|
||||
}
|
||||
}
|
||||
return send("timing",_loc7_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package libraries.uanalytics.tracker
|
||||
{
|
||||
import flash.system.System;
|
||||
import flash.utils.describeType;
|
||||
|
||||
public class HitType
|
||||
{
|
||||
|
||||
public static const PAGEVIEW:String = "pageview";
|
||||
|
||||
public static const SCREENVIEW:String = "screenview";
|
||||
|
||||
public static const EVENT:String = "event";
|
||||
|
||||
public static const TRANSACTION:String = "transaction";
|
||||
|
||||
public static const ITEM:String = "item";
|
||||
|
||||
public static const SOCIAL:String = "social";
|
||||
|
||||
public static const EXCEPTION:String = "exception";
|
||||
|
||||
public static const TIMING:String = "timing";
|
||||
|
||||
public function HitType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function isValid(param1:String) : Boolean
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc5_:XML = describeType(HitType);
|
||||
var _loc2_:Boolean = false;
|
||||
for each(var _loc4_:XML in _loc5_.constant)
|
||||
{
|
||||
_loc3_ = String(_loc4_.@name);
|
||||
if(HitType[_loc3_] == param1)
|
||||
{
|
||||
_loc2_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.disposeXML(_loc5_);
|
||||
if(_loc2_)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package libraries.uanalytics.tracker
|
||||
{
|
||||
import flash.events.NetStatusEvent;
|
||||
import flash.net.SharedObject;
|
||||
import flash.system.ApplicationDomain;
|
||||
import libraries.uanalytics.tracker.senders.LoaderHitSender;
|
||||
import libraries.uanalytics.tracking.Configuration;
|
||||
import libraries.uanalytics.tracking.HitModel;
|
||||
import libraries.uanalytics.tracking.RateLimiter;
|
||||
import libraries.uanalytics.utils.generateUUID;
|
||||
|
||||
public class WebTracker extends DefaultTracker
|
||||
{
|
||||
|
||||
protected var _storage:SharedObject;
|
||||
|
||||
public function WebTracker(param1:String = "", param2:Configuration = null)
|
||||
{
|
||||
super(param1,param2);
|
||||
}
|
||||
|
||||
override protected function _ctor(param1:String = "") : void
|
||||
{
|
||||
var _loc2_:Class = null;
|
||||
_model = new HitModel();
|
||||
_temporary = new HitModel();
|
||||
if(_config.senderType != "")
|
||||
{
|
||||
_loc2_ = ApplicationDomain.currentDomain.getDefinition(_config.senderType) as Class;
|
||||
_sender = new _loc2_(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
_sender = new LoaderHitSender(this);
|
||||
}
|
||||
_limiter = new RateLimiter(20,2,1);
|
||||
if(param1 != "")
|
||||
{
|
||||
set("trackingId",param1);
|
||||
}
|
||||
var _loc3_:String = _getClientID();
|
||||
if(_loc3_ != "")
|
||||
{
|
||||
set("clientId",_loc3_);
|
||||
}
|
||||
set("dataSource","web");
|
||||
}
|
||||
|
||||
override protected function _getClientID() : String
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc1_:String = null;
|
||||
_storage = SharedObject.getLocal(_config.storageName);
|
||||
if(!_storage.data.clientid)
|
||||
{
|
||||
_loc2_ = generateUUID();
|
||||
_storage.data.clientid = _loc2_;
|
||||
_loc1_ = null;
|
||||
try
|
||||
{
|
||||
_loc1_ = _storage.flush(1024);
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
}
|
||||
if(_loc1_ != null)
|
||||
{
|
||||
switch(_loc1_)
|
||||
{
|
||||
case "pending":
|
||||
_storage.addEventListener("netStatus",onFlushStatus);
|
||||
break;
|
||||
case "flushed":
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ = _storage.data.clientid;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
protected function onFlushStatus(param1:NetStatusEvent) : void
|
||||
{
|
||||
_storage.removeEventListener("netStatus",onFlushStatus);
|
||||
switch(param1.info.code)
|
||||
{
|
||||
case "SharedObject.Flush.Success":
|
||||
case "SharedObject.Flush.Failed":
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package libraries.uanalytics.tracker.senders
|
||||
{
|
||||
import flash.display.Loader;
|
||||
import flash.display.LoaderInfo;
|
||||
import flash.errors.IOError;
|
||||
import flash.errors.IllegalOperationError;
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.Event;
|
||||
import flash.events.HTTPStatusEvent;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.UncaughtErrorEvent;
|
||||
import flash.net.URLRequest;
|
||||
import libraries.uanalytics.tracking.AnalyticsTracker;
|
||||
import libraries.uanalytics.tracking.HitModel;
|
||||
import libraries.uanalytics.tracking.HitSender;
|
||||
|
||||
public class LoaderHitSender extends HitSender
|
||||
{
|
||||
|
||||
protected var _tracker:AnalyticsTracker;
|
||||
|
||||
public function LoaderHitSender(param1:AnalyticsTracker)
|
||||
{
|
||||
super();
|
||||
_tracker = param1;
|
||||
}
|
||||
|
||||
protected function _hookEvents(param1:Loader) : void
|
||||
{
|
||||
param1.uncaughtErrorEvents.addEventListener("uncaughtError",onUncaughtError);
|
||||
param1.contentLoaderInfo.addEventListener("httpStatus",onHTTPStatus);
|
||||
param1.contentLoaderInfo.addEventListener("ioError",onIOError);
|
||||
param1.contentLoaderInfo.addEventListener("complete",onComplete);
|
||||
}
|
||||
|
||||
protected function _unhookEvents(param1:Loader) : void
|
||||
{
|
||||
param1.uncaughtErrorEvents.removeEventListener("uncaughtError",onUncaughtError);
|
||||
param1.contentLoaderInfo.removeEventListener("httpStatus",onHTTPStatus);
|
||||
param1.contentLoaderInfo.removeEventListener("ioError",onIOError);
|
||||
param1.contentLoaderInfo.removeEventListener("complete",onComplete);
|
||||
}
|
||||
|
||||
protected function onUncaughtError(param1:UncaughtErrorEvent) : void
|
||||
{
|
||||
var _loc3_:Error = null;
|
||||
var _loc2_:ErrorEvent = null;
|
||||
_unhookEvents(param1.target as Loader);
|
||||
if(param1.error is Error)
|
||||
{
|
||||
_loc3_ = param1.error as Error;
|
||||
}
|
||||
else if(param1.error is ErrorEvent)
|
||||
{
|
||||
_loc2_ = param1.error as ErrorEvent;
|
||||
_loc3_ = new Error(_loc2_.text,_loc2_.errorID);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ = new Error("a non-Error, non-ErrorEvent type was thrown and uncaught");
|
||||
}
|
||||
if(_tracker.config.enableErrorChecking)
|
||||
{
|
||||
throw _loc3_;
|
||||
}
|
||||
}
|
||||
|
||||
protected function onHTTPStatus(param1:HTTPStatusEvent) : void
|
||||
{
|
||||
}
|
||||
|
||||
protected function onIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
var _loc3_:* = null;
|
||||
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
|
||||
_unhookEvents(_loc2_.loader);
|
||||
if(_tracker.config.enableErrorChecking)
|
||||
{
|
||||
throw new IOError(param1.text,param1.errorID);
|
||||
}
|
||||
}
|
||||
|
||||
protected function onComplete(param1:Event) : void
|
||||
{
|
||||
var _loc2_:LoaderInfo = param1.target as LoaderInfo;
|
||||
_unhookEvents(_loc2_.loader);
|
||||
}
|
||||
|
||||
override public function send(param1:HitModel) : void
|
||||
{
|
||||
var _loc5_:String = _buildHit(param1);
|
||||
var _loc7_:String = "";
|
||||
var _loc3_:Boolean = false;
|
||||
if(_tracker.config.forcePOST || _loc5_.length > _tracker.config.maxGETlength)
|
||||
{
|
||||
_loc3_ = true;
|
||||
}
|
||||
if(_loc5_.length > _tracker.config.maxPOSTlength)
|
||||
{
|
||||
throw new ArgumentError("POST data is bigger than " + _tracker.config.maxPOSTlength + " bytes.");
|
||||
}
|
||||
if(_tracker.config.forceSSL)
|
||||
{
|
||||
_loc7_ = _tracker.config.secureEndpoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc7_ = _tracker.config.endpoint;
|
||||
}
|
||||
var _loc2_:URLRequest = new URLRequest();
|
||||
_loc2_.url = _loc7_;
|
||||
if(_loc3_)
|
||||
{
|
||||
_loc2_.method = "POST";
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_.method = "GET";
|
||||
}
|
||||
_loc2_.data = _loc5_;
|
||||
var _loc6_:Loader = new Loader();
|
||||
_hookEvents(_loc6_);
|
||||
var _loc4_:§--UNKNOWN--§ = null;
|
||||
try
|
||||
{
|
||||
_loc6_.load(_loc2_);
|
||||
}
|
||||
catch(e:IOError)
|
||||
{
|
||||
_unhookEvents(_loc6_);
|
||||
_loc4_ = e;
|
||||
}
|
||||
catch(e:SecurityError)
|
||||
{
|
||||
_unhookEvents(_loc6_);
|
||||
_loc4_ = e;
|
||||
}
|
||||
catch(e:IllegalOperationError)
|
||||
{
|
||||
_unhookEvents(_loc6_);
|
||||
_loc4_ = e;
|
||||
}
|
||||
catch(e:Error)
|
||||
{
|
||||
_unhookEvents(_loc6_);
|
||||
_loc4_ = e;
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
throw _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
public interface AnalyticsSender
|
||||
{
|
||||
|
||||
function send(param1:HitModel) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public interface AnalyticsTracker
|
||||
{
|
||||
|
||||
function get trackingId() : String;
|
||||
|
||||
function get clientId() : String;
|
||||
|
||||
function get config() : Configuration;
|
||||
|
||||
function send(param1:String = null, param2:Dictionary = null) : Boolean;
|
||||
|
||||
function pageview(param1:String, param2:String = "") : Boolean;
|
||||
|
||||
function screenview(param1:String, param2:Dictionary = null) : Boolean;
|
||||
|
||||
function event(param1:String, param2:String, param3:String = "", param4:int = -1) : Boolean;
|
||||
|
||||
function transaction(param1:String, param2:String = "", param3:Number = 0, param4:Number = 0, param5:Number = 0, param6:String = "") : Boolean;
|
||||
|
||||
function item(param1:String, param2:String, param3:Number = 0, param4:int = 0, param5:String = "", param6:String = "", param7:String = "") : Boolean;
|
||||
|
||||
function social(param1:String, param2:String, param3:String) : Boolean;
|
||||
|
||||
function exception(param1:String = "", param2:Boolean = true) : Boolean;
|
||||
|
||||
function timing(param1:String, param2:String, param3:int, param4:String = "", param5:Dictionary = null) : Boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
public static var SDKversion:String = "as3uanalytics1";
|
||||
|
||||
private var _endpoint:String = "http://www.google-analytics.com/collect";
|
||||
|
||||
private var _secureEndpoint:String = "https://ssl.google-analytics.com/collect";
|
||||
|
||||
private var _maxGETlength:uint = 2000;
|
||||
|
||||
private var _maxPOSTlength:uint = 8192;
|
||||
|
||||
private var _storageName:String = "_ga";
|
||||
|
||||
public var senderType:String = "";
|
||||
|
||||
public var enableErrorChecking:Boolean = false;
|
||||
|
||||
public var enableThrottling:Boolean = true;
|
||||
|
||||
public var enableSampling:Boolean = true;
|
||||
|
||||
public var enableCacheBusting:Boolean = false;
|
||||
|
||||
public var forceSSL:Boolean = false;
|
||||
|
||||
public var forcePOST:Boolean = false;
|
||||
|
||||
public var sampleRate:Number = 100;
|
||||
|
||||
public var anonymizeIp:Boolean = false;
|
||||
|
||||
public var overrideIpAddress:String = "";
|
||||
|
||||
public var overrideUserAgent:String = "";
|
||||
|
||||
public var overrideGeographicalId:String = "";
|
||||
|
||||
public function Configuration()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get endpoint() : String
|
||||
{
|
||||
return _endpoint;
|
||||
}
|
||||
|
||||
public function get secureEndpoint() : String
|
||||
{
|
||||
return _secureEndpoint;
|
||||
}
|
||||
|
||||
public function get maxGETlength() : uint
|
||||
{
|
||||
return _maxGETlength;
|
||||
}
|
||||
|
||||
public function get maxPOSTlength() : uint
|
||||
{
|
||||
return _maxPOSTlength;
|
||||
}
|
||||
|
||||
public function get storageName() : String
|
||||
{
|
||||
return _storageName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class HitModel
|
||||
{
|
||||
|
||||
private var _data:Dictionary;
|
||||
|
||||
private var _metadata:Metadata;
|
||||
|
||||
public function HitModel()
|
||||
{
|
||||
super();
|
||||
_metadata = new Metadata();
|
||||
clear();
|
||||
}
|
||||
|
||||
public function set(param1:String, param2:String) : void
|
||||
{
|
||||
_data[_metadata.getHitModelKey(param1)] = param2;
|
||||
}
|
||||
|
||||
public function get(param1:String) : String
|
||||
{
|
||||
return _data[_metadata.getHitModelKey(param1)];
|
||||
}
|
||||
|
||||
public function add(param1:HitModel) : void
|
||||
{
|
||||
for(var _loc2_:String in param1._data)
|
||||
{
|
||||
_data[_loc2_] = param1._data[_loc2_];
|
||||
}
|
||||
}
|
||||
|
||||
public function clone() : HitModel
|
||||
{
|
||||
var _loc1_:HitModel = new HitModel();
|
||||
for(var _loc2_:String in _data)
|
||||
{
|
||||
_loc1_._data[_loc2_] = _data[_loc2_];
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
public function clear() : void
|
||||
{
|
||||
_data = new Dictionary();
|
||||
}
|
||||
|
||||
public function getFieldNames() : Vector.<String>
|
||||
{
|
||||
var _loc1_:Vector.<String> = new Vector.<String>();
|
||||
for(var _loc2_:String in _data)
|
||||
{
|
||||
_loc1_.push(_loc2_);
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
import libraries.uanalytics.utils.crc32;
|
||||
import libraries.uanalytics.utils.isDigit;
|
||||
|
||||
public class HitSampler
|
||||
{
|
||||
|
||||
public function HitSampler()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
private static function _hashString(param1:String) : Number
|
||||
{
|
||||
var _loc2_:crc32 = new crc32();
|
||||
var _loc3_:ByteArray = new ByteArray();
|
||||
_loc3_.writeUTFBytes(param1);
|
||||
_loc2_.update(_loc3_);
|
||||
return _loc2_.valueOf();
|
||||
}
|
||||
|
||||
private static function _parseNumber(param1:String) : Number
|
||||
{
|
||||
var _loc3_:* = 0;
|
||||
if(param1 == "")
|
||||
{
|
||||
return NaN;
|
||||
}
|
||||
var _loc4_:uint = uint(param1.length);
|
||||
var _loc2_:uint = 0;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < _loc4_)
|
||||
{
|
||||
if(param1.charAt(_loc3_) == "." && _loc2_ == 0)
|
||||
{
|
||||
_loc2_++;
|
||||
}
|
||||
else if(!isDigit(param1,_loc3_))
|
||||
{
|
||||
return NaN;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return parseFloat(param1);
|
||||
}
|
||||
|
||||
public static function isSampled(param1:HitModel, param2:String = "") : Boolean
|
||||
{
|
||||
var _loc3_:Number = getSampleRate(param2);
|
||||
return _loc3_ < 100 && _hashString(param1.get("clientId")) % 10000 >= 100 * _loc3_;
|
||||
}
|
||||
|
||||
public static function getSampleRate(param1:String) : Number
|
||||
{
|
||||
if(param1 == null || param1 == "")
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
var _loc2_:Number = Math.max(0,Math.min(100,Math.round(_parseNumber(param1) * 100) / 100));
|
||||
if(isNaN(_loc2_))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
public class HitSender implements AnalyticsSender
|
||||
{
|
||||
|
||||
public function HitSender()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected function _addParameter(param1:String, param2:String) : String
|
||||
{
|
||||
var _loc3_:String = "";
|
||||
_loc3_ += "&";
|
||||
_loc3_ += _appendEncoded(param1.substring(1));
|
||||
_loc3_ += "=";
|
||||
return _loc3_ + _appendEncoded(param2);
|
||||
}
|
||||
|
||||
protected function _appendEncoded(param1:String) : String
|
||||
{
|
||||
return encodeURIComponent(param1);
|
||||
}
|
||||
|
||||
protected function _buildHit(param1:HitModel) : String
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc5_:* = 0;
|
||||
var _loc2_:String = "";
|
||||
_loc2_ += "v=1";
|
||||
if(Configuration.SDKversion != "")
|
||||
{
|
||||
_loc2_ += _addParameter("&_v",Configuration.SDKversion);
|
||||
}
|
||||
var _loc3_:Vector.<String> = param1.getFieldNames();
|
||||
_loc3_.sort(1);
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc3_.length)
|
||||
{
|
||||
_loc4_ = _loc3_[_loc5_];
|
||||
if(_loc4_.length > 0 && _loc4_.charAt(0) == "&")
|
||||
{
|
||||
_loc6_ = param1.get(_loc4_);
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
_loc2_ += _addParameter(_loc4_,_loc6_);
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
public function send(param1:HitModel) : void
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class Metadata
|
||||
{
|
||||
|
||||
public static const FIELD_PREFIX:String = "&";
|
||||
|
||||
private var _nameToParameterMap:Dictionary = new Dictionary();
|
||||
|
||||
private var _patternToParameterMap:Dictionary = new Dictionary();
|
||||
|
||||
public function Metadata()
|
||||
{
|
||||
super();
|
||||
addAlias("protocolVersion","v");
|
||||
addAlias("trackingId","tid");
|
||||
addAlias("anonymizeIp","aip");
|
||||
addAlias("dataSource","ds");
|
||||
addAlias("queueTime","qt");
|
||||
addAlias("cacheBuster","z");
|
||||
addAlias("clientId","cid");
|
||||
addAlias("userId","uid");
|
||||
addAlias("sessionControl","sc");
|
||||
addAlias("ipOverride","uip");
|
||||
addAlias("userAgentOverride","ua");
|
||||
addAlias("geographicalOverride","geoid");
|
||||
addAlias("documentReferrer","dr");
|
||||
addAlias("campaignName","cn");
|
||||
addAlias("campaignSource","cs");
|
||||
addAlias("campaignMedium","cm");
|
||||
addAlias("campaignKeyword","ck");
|
||||
addAlias("campaignContent","cc");
|
||||
addAlias("campaignId","ci");
|
||||
addAlias("googleAdwordsId","gclid");
|
||||
addAlias("googleDisplayAdsId","dclid");
|
||||
addAlias("screenResolution","sr");
|
||||
addAlias("viewportSize","vp");
|
||||
addAlias("documentEncoding","de");
|
||||
addAlias("screenColors","sd");
|
||||
addAlias("userLanguage","ul");
|
||||
addAlias("javaEnabled","je");
|
||||
addAlias("flashVersion","fl");
|
||||
addAlias("hitType","t");
|
||||
addAlias("nonInteraction","ni");
|
||||
addAlias("documentLocation","dl");
|
||||
addAlias("documentHostname","dh");
|
||||
addAlias("documentPath","dp");
|
||||
addAlias("documentTitle","dt");
|
||||
addAlias("screenName","cd");
|
||||
addAlias("linkId","linkid");
|
||||
addAlias("appName","an");
|
||||
addAlias("appId","aid");
|
||||
addAlias("appVersion","av");
|
||||
addAlias("appInstallerId","aiid");
|
||||
addAlias("eventCategory","ec");
|
||||
addAlias("eventAction","ea");
|
||||
addAlias("eventLabel","el");
|
||||
addAlias("eventValue","ev");
|
||||
addAlias("transactionId","ti");
|
||||
addAlias("transactionAffiliation","ta");
|
||||
addAlias("transactionRevenue","tr");
|
||||
addAlias("transactionShipping","ts");
|
||||
addAlias("transactionTax","tt");
|
||||
addAlias("itemName","in");
|
||||
addAlias("itemPrice","ip");
|
||||
addAlias("itemQuantity","iq");
|
||||
addAlias("itemCode","ic");
|
||||
addAlias("itemCategory","iv");
|
||||
addAlias("currencyCode","cu");
|
||||
addAlias("productAction","pa");
|
||||
addAlias("couponCode","tcc");
|
||||
addAlias("productActionList","pal");
|
||||
addAlias("checkoutStep","cos");
|
||||
addAlias("checkoutStepOption","col");
|
||||
addAlias("promotionAction","promoa");
|
||||
addAlias("socialNetwork","sn");
|
||||
addAlias("socialAction","sa");
|
||||
addAlias("socialTarget","st");
|
||||
addAlias("userTimingCategory","utc");
|
||||
addAlias("userTimingVar","utv");
|
||||
addAlias("userTimingTime","utt");
|
||||
addAlias("userTimingLabel","utl");
|
||||
addAlias("pageLoadTime","plt");
|
||||
addAlias("dnsTime","dns");
|
||||
addAlias("pageDownloadTime","pdt");
|
||||
addAlias("redirectResponseTime","rrt");
|
||||
addAlias("tcpConnectTime","tcp");
|
||||
addAlias("serverResponseTime","srt");
|
||||
addAlias("domInteractiveTime","dit");
|
||||
addAlias("contentLoadTime","clt");
|
||||
addAlias("exceptionDescription","exd");
|
||||
addAlias("exceptionFatal","exf");
|
||||
addPatternAlias("dimension([0-9]+)","cd");
|
||||
addPatternAlias("metric([0-9]+)","cm");
|
||||
}
|
||||
|
||||
private function _getKeyFromPattern(param1:String) : String
|
||||
{
|
||||
var _loc3_:RegExp = null;
|
||||
var _loc2_:Object = null;
|
||||
var _loc4_:String = null;
|
||||
for(var _loc5_:String in _patternToParameterMap)
|
||||
{
|
||||
_loc3_ = new RegExp(_loc5_);
|
||||
_loc2_ = _loc3_.exec(param1);
|
||||
if(_loc2_ && _loc2_[1])
|
||||
{
|
||||
_loc4_ = "&" + _patternToParameterMap[_loc5_] + _loc2_[1];
|
||||
addAlias(param1,_loc4_);
|
||||
return _loc4_;
|
||||
}
|
||||
}
|
||||
return param1;
|
||||
}
|
||||
|
||||
protected function addAlias(param1:String, param2:String) : void
|
||||
{
|
||||
_nameToParameterMap[param1] = "&" + param2;
|
||||
}
|
||||
|
||||
protected function addPatternAlias(param1:String, param2:String) : void
|
||||
{
|
||||
_patternToParameterMap[param1] = param2;
|
||||
}
|
||||
|
||||
public function getHitModelKey(param1:String) : String
|
||||
{
|
||||
if(param1.length > 0 && param1.charAt(0) == "&")
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
var _loc2_:String = _nameToParameterMap[param1];
|
||||
if(_loc2_ == null)
|
||||
{
|
||||
_loc2_ = _getKeyFromPattern(param1);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
public class RateLimitError extends Error
|
||||
{
|
||||
|
||||
public function RateLimitError(param1:String = "", param2:int = 0)
|
||||
{
|
||||
super(param1,param2);
|
||||
this.name = "RateLimitError";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
import flash.utils.getTimer;
|
||||
|
||||
public class RateLimiter
|
||||
{
|
||||
|
||||
private var _capacity:int;
|
||||
|
||||
private var _rate:int;
|
||||
|
||||
private var _span:Number;
|
||||
|
||||
private var _lastTime:int;
|
||||
|
||||
private var _tokenCount:int;
|
||||
|
||||
public function RateLimiter(param1:int, param2:int, param3:Number = 1)
|
||||
{
|
||||
super();
|
||||
_capacity = param1;
|
||||
_rate = param2;
|
||||
_span = param3;
|
||||
_tokenCount = param1;
|
||||
_lastTime = now();
|
||||
}
|
||||
|
||||
protected function now() : int
|
||||
{
|
||||
return getTimer();
|
||||
}
|
||||
|
||||
public function consumeToken() : Boolean
|
||||
{
|
||||
var _loc2_:int = getTimer();
|
||||
var _loc1_:int = Math.max(0,(_loc2_ - _lastTime) * (_rate * _span / 1000));
|
||||
_tokenCount = Math.min(_tokenCount + _loc1_,_capacity);
|
||||
if(_tokenCount > 0)
|
||||
{
|
||||
_tokenCount = _tokenCount - 1;
|
||||
_lastTime = _loc2_;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
package libraries.uanalytics.tracking
|
||||
{
|
||||
import flash.utils.Dictionary;
|
||||
|
||||
public class Tracker implements AnalyticsTracker
|
||||
{
|
||||
|
||||
public static const PROTOCOL_VERSION:String = "protocolVersion";
|
||||
|
||||
public static const TRACKING_ID:String = "trackingId";
|
||||
|
||||
public static const ANON_IP:String = "anonymizeIp";
|
||||
|
||||
public static const DATA_SOURCE:String = "dataSource";
|
||||
|
||||
public static const QUEUE_TIME:String = "queueTime";
|
||||
|
||||
public static const CACHE_BUSTER:String = "cacheBuster";
|
||||
|
||||
public static const CLIENT_ID:String = "clientId";
|
||||
|
||||
public static const USER_ID:String = "userId";
|
||||
|
||||
public static const SESSION_CONTROL:String = "sessionControl";
|
||||
|
||||
public static const IP_OVERRIDE:String = "ipOverride";
|
||||
|
||||
public static const USER_AGENT_OVERRIDE:String = "userAgentOverride";
|
||||
|
||||
public static const GEOGRAPHICAL_OVERRIDE:String = "geographicalOverride";
|
||||
|
||||
public static const DOCUMENT_REFERRER:String = "documentReferrer";
|
||||
|
||||
public static const CAMPAIGN_NAME:String = "campaignName";
|
||||
|
||||
public static const CAMPAIGN_SOURCE:String = "campaignSource";
|
||||
|
||||
public static const CAMPAIGN_MEDIUM:String = "campaignMedium";
|
||||
|
||||
public static const CAMPAIGN_KEYWORD:String = "campaignKeyword";
|
||||
|
||||
public static const CAMPAIGN_CONTENT:String = "campaignContent";
|
||||
|
||||
public static const CAMPAIGN_ID:String = "campaignId";
|
||||
|
||||
public static const GOOGLE_ADWORDS_ID:String = "googleAdwordsId";
|
||||
|
||||
public static const GOOGLE_DISPLAY_ADS_ID:String = "googleDisplayAdsId";
|
||||
|
||||
public static const SCREEN_RESOLUTION:String = "screenResolution";
|
||||
|
||||
public static const VIEWPORT_SIZE:String = "viewportSize";
|
||||
|
||||
public static const DOCUMENT_ENCODING:String = "documentEncoding";
|
||||
|
||||
public static const SCREEN_COLORS:String = "screenColors";
|
||||
|
||||
public static const USER_LANGUAGE:String = "userLanguage";
|
||||
|
||||
public static const JAVA_ENABLED:String = "javaEnabled";
|
||||
|
||||
public static const FLASH_VERSION:String = "flashVersion";
|
||||
|
||||
public static const HIT_TYPE:String = "hitType";
|
||||
|
||||
public static const NON_INTERACTION:String = "nonInteraction";
|
||||
|
||||
public static const DOCUMENT_LOCATION:String = "documentLocation";
|
||||
|
||||
public static const DOCUMENT_HOSTNAME:String = "documentHostname";
|
||||
|
||||
public static const DOCUMENT_PATH:String = "documentPath";
|
||||
|
||||
public static const DOCUMENT_TITLE:String = "documentTitle";
|
||||
|
||||
public static const SCREEN_NAME:String = "screenName";
|
||||
|
||||
public static const LINK_ID:String = "linkId";
|
||||
|
||||
public static const APP_NAME:String = "appName";
|
||||
|
||||
public static const APP_ID:String = "appId";
|
||||
|
||||
public static const APP_VERSION:String = "appVersion";
|
||||
|
||||
public static const APP_INSTALLER_ID:String = "appInstallerId";
|
||||
|
||||
public static const EVENT_CATEGORY:String = "eventCategory";
|
||||
|
||||
public static const EVENT_ACTION:String = "eventAction";
|
||||
|
||||
public static const EVENT_LABEL:String = "eventLabel";
|
||||
|
||||
public static const EVENT_VALUE:String = "eventValue";
|
||||
|
||||
public static const TRANSACTION_ID:String = "transactionId";
|
||||
|
||||
public static const TRANSACTION_AFFILIATION:String = "transactionAffiliation";
|
||||
|
||||
public static const TRANSACTION_REVENUE:String = "transactionRevenue";
|
||||
|
||||
public static const TRANSACTION_SHIPPING:String = "transactionShipping";
|
||||
|
||||
public static const TRANSACTION_TAX:String = "transactionTax";
|
||||
|
||||
public static const ITEM_NAME:String = "itemName";
|
||||
|
||||
public static const ITEM_PRICE:String = "itemPrice";
|
||||
|
||||
public static const ITEM_QUANTITY:String = "itemQuantity";
|
||||
|
||||
public static const ITEM_CODE:String = "itemCode";
|
||||
|
||||
public static const ITEM_CATEGORY:String = "itemCategory";
|
||||
|
||||
public static const CURRENCY_CODE:String = "currencyCode";
|
||||
|
||||
public static const PRODUCT_ACTION:String = "productAction";
|
||||
|
||||
public static const COUPON_CODE:String = "couponCode";
|
||||
|
||||
public static const PRODUCT_ACTION_LIST:String = "productActionList";
|
||||
|
||||
public static const CHECKOUT_STEP:String = "checkoutStep";
|
||||
|
||||
public static const CHECKOUT_STEP_OPTION:String = "checkoutStepOption";
|
||||
|
||||
public static const PROMOTION_ACTION:String = "promotionAction";
|
||||
|
||||
public static const SOCIAL_NETWORK:String = "socialNetwork";
|
||||
|
||||
public static const SOCIAL_ACTION:String = "socialAction";
|
||||
|
||||
public static const SOCIAL_TARGET:String = "socialTarget";
|
||||
|
||||
public static const USER_TIMING_CATEGORY:String = "userTimingCategory";
|
||||
|
||||
public static const USER_TIMING_VAR:String = "userTimingVar";
|
||||
|
||||
public static const USER_TIMING_TIME:String = "userTimingTime";
|
||||
|
||||
public static const USER_TIMING_LABEL:String = "userTimingLabel";
|
||||
|
||||
public static const PAGE_LOAD_TIME:String = "pageLoadTime";
|
||||
|
||||
public static const DNS_TIME:String = "dnsTime";
|
||||
|
||||
public static const PAGE_DOWNLOAD_TIME:String = "pageDownloadTime";
|
||||
|
||||
public static const REDIRECT_RESPONSE_TIME:String = "redirectResponseTime";
|
||||
|
||||
public static const TCP_CONNECT_TIME:String = "tcpConnectTime";
|
||||
|
||||
public static const SERVER_RESPONSE_TIME:String = "serverResponseTime";
|
||||
|
||||
public static const DOM_INTERACTIVE_TIME:String = "domInteractiveTime";
|
||||
|
||||
public static const CONTENT_LOAD_TIME:String = "contentLoadTime";
|
||||
|
||||
public static const EXCEPT_DESCRIPTION:String = "exceptionDescription";
|
||||
|
||||
public static const EXCEPT_FATAL:String = "exceptionFatal";
|
||||
|
||||
protected var _model:HitModel;
|
||||
|
||||
protected var _temporary:HitModel;
|
||||
|
||||
protected var _sender:HitSender;
|
||||
|
||||
protected var _limiter:RateLimiter;
|
||||
|
||||
protected var _config:Configuration;
|
||||
|
||||
public function Tracker()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function CUSTOM_DIMENSION(param1:uint = 0) : String
|
||||
{
|
||||
if(param1 < 1)
|
||||
{
|
||||
param1 = 1;
|
||||
}
|
||||
if(param1 > 200)
|
||||
{
|
||||
param1 = 200;
|
||||
}
|
||||
return "dimension" + param1;
|
||||
}
|
||||
|
||||
public static function CUSTOM_METRIC(param1:uint = 0) : String
|
||||
{
|
||||
if(param1 < 1)
|
||||
{
|
||||
param1 = 1;
|
||||
}
|
||||
if(param1 > 200)
|
||||
{
|
||||
param1 = 200;
|
||||
}
|
||||
return "metric" + param1;
|
||||
}
|
||||
|
||||
public function get trackingId() : String
|
||||
{
|
||||
return get("trackingId");
|
||||
}
|
||||
|
||||
public function get clientId() : String
|
||||
{
|
||||
return get("clientId");
|
||||
}
|
||||
|
||||
public function get config() : Configuration
|
||||
{
|
||||
return _config;
|
||||
}
|
||||
|
||||
public function set(param1:String, param2:String) : void
|
||||
{
|
||||
if(_model)
|
||||
{
|
||||
_model.set(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function setOneTime(param1:String, param2:String) : void
|
||||
{
|
||||
if(_temporary)
|
||||
{
|
||||
_temporary.set(param1,param2);
|
||||
}
|
||||
}
|
||||
|
||||
public function get(param1:String) : String
|
||||
{
|
||||
if(_model)
|
||||
{
|
||||
return _model.get(param1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function add(param1:Dictionary) : void
|
||||
{
|
||||
if(_model)
|
||||
{
|
||||
for(var _loc2_:String in param1)
|
||||
{
|
||||
set(_loc2_,param1[_loc2_]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addOneTime(param1:Dictionary) : void
|
||||
{
|
||||
if(_temporary)
|
||||
{
|
||||
for(var _loc2_:String in param1)
|
||||
{
|
||||
setOneTime(_loc2_,param1[_loc2_]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function send(param1:String = null, param2:Dictionary = null) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function pageview(param1:String, param2:String = "") : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function screenview(param1:String, param2:Dictionary = null) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function event(param1:String, param2:String, param3:String = "", param4:int = -1) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function transaction(param1:String, param2:String = "", param3:Number = 0, param4:Number = 0, param5:Number = 0, param6:String = "") : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function item(param1:String, param2:String, param3:Number = 0, param4:int = 0, param5:String = "", param6:String = "", param7:String = "") : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function social(param1:String, param2:String, param3:String) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function exception(param1:String = "", param2:Boolean = true) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function timing(param1:String, param2:String, param3:int, param4:String = "", param5:Dictionary = null) : Boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package libraries.uanalytics.utils
|
||||
{
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public final class crc32
|
||||
{
|
||||
|
||||
private static var _poly:uint = 3988292384;
|
||||
|
||||
private static var _init:uint = 4294967295;
|
||||
|
||||
private static var lookup:Vector.<uint> = make_crc_table();
|
||||
|
||||
private var _crc:uint;
|
||||
|
||||
private var _length:uint;
|
||||
|
||||
private var _endian:String;
|
||||
|
||||
public function crc32()
|
||||
{
|
||||
super();
|
||||
_length = 4294967295;
|
||||
_endian = "littleEndian";
|
||||
reset();
|
||||
}
|
||||
|
||||
private static function make_crc_table() : Vector.<uint>
|
||||
{
|
||||
var _loc1_:* = 0;
|
||||
var _loc2_:* = 0;
|
||||
var _loc3_:* = 0;
|
||||
var _loc4_:Vector.<uint> = new Vector.<uint>();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < 256)
|
||||
{
|
||||
_loc1_ = _loc2_;
|
||||
_loc3_ = 0;
|
||||
while(_loc3_ < 8)
|
||||
{
|
||||
if((_loc1_ & 1) != 0)
|
||||
{
|
||||
_loc1_ = uint(_loc1_ >>> 1 ^ _poly);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc1_ >>>= 1;
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
_loc4_[_loc2_] = _loc1_;
|
||||
_loc2_++;
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public function get endian() : String
|
||||
{
|
||||
return _endian;
|
||||
}
|
||||
|
||||
public function get length() : uint
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
|
||||
public function update(param1:ByteArray, param2:uint = 0, param3:uint = 0) : void
|
||||
{
|
||||
var _loc6_:* = 0;
|
||||
var _loc4_:* = 0;
|
||||
if(param3 == 0)
|
||||
{
|
||||
param3 = param1.length;
|
||||
}
|
||||
param1.position = param2;
|
||||
var _loc5_:uint = uint(_length & _crc);
|
||||
_loc6_ = param2;
|
||||
while(_loc6_ < param3)
|
||||
{
|
||||
_loc4_ = uint(param1[_loc6_]);
|
||||
_loc5_ = uint(_loc5_ >>> 8 ^ lookup[(_loc5_ ^ _loc4_) & 0xFF]);
|
||||
_loc6_++;
|
||||
}
|
||||
_crc = ~_loc5_;
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
{
|
||||
_crc = _init;
|
||||
}
|
||||
|
||||
public function valueOf() : uint
|
||||
{
|
||||
return _crc;
|
||||
}
|
||||
|
||||
public function toString(param1:Number = 16) : String
|
||||
{
|
||||
return _crc.toString(param1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package libraries.uanalytics.utils
|
||||
{
|
||||
import flash.crypto.generateRandomBytes;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public function generateUUID() : String
|
||||
{
|
||||
var toHex:Function;
|
||||
var str:String;
|
||||
var i:uint;
|
||||
var l:uint;
|
||||
var byte:uint;
|
||||
var uuid:String;
|
||||
var randomBytes:ByteArray = generateRandomBytes(16);
|
||||
randomBytes[6] &= 15;
|
||||
randomBytes[6] |= 64;
|
||||
randomBytes[8] &= 63;
|
||||
randomBytes[8] |= 128;
|
||||
toHex = function(param1:uint):String
|
||||
{
|
||||
var _loc2_:String = param1.toString(16);
|
||||
return _loc2_.length > 1 ? _loc2_ : "0" + _loc2_;
|
||||
};
|
||||
str = "";
|
||||
l = randomBytes.length;
|
||||
randomBytes.position = 0;
|
||||
i = 0;
|
||||
while(i < l)
|
||||
{
|
||||
byte = uint(randomBytes[i]);
|
||||
str += toHex(byte);
|
||||
i = i + 1;
|
||||
}
|
||||
uuid = "";
|
||||
uuid += str.substr(0,8);
|
||||
uuid += "-";
|
||||
uuid += str.substr(8,4);
|
||||
uuid += "-";
|
||||
uuid += str.substr(12,4);
|
||||
uuid += "-";
|
||||
uuid += str.substr(16,4);
|
||||
uuid += "-";
|
||||
uuid += str.substr(20,12);
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package libraries.uanalytics.utils
|
||||
{
|
||||
import flash.net.LocalConnection;
|
||||
|
||||
public function getHostname() : String
|
||||
{
|
||||
var _loc2_:LocalConnection = null;
|
||||
var _loc1_:String = "";
|
||||
if(LocalConnection.isSupported)
|
||||
{
|
||||
_loc2_ = new LocalConnection();
|
||||
_loc1_ = _loc2_.domain;
|
||||
}
|
||||
if(_loc1_.substr(0,4) == "app#" || _loc1_ == "")
|
||||
{
|
||||
_loc1_ = "localhost";
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package libraries.uanalytics.utils
|
||||
{
|
||||
public function isDigit(param1:String, param2:uint = 0) : Boolean
|
||||
{
|
||||
if(param2 > 0)
|
||||
{
|
||||
param1 = param1.charAt(param2);
|
||||
}
|
||||
return "0" <= param1 && param1 <= "9";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user