Add a possible random value to the tracking URL for use with Google Analytics tracking
This commit is contained in:
@@ -65,6 +65,7 @@ import org.apache.commons.codec.binary.Base64;
|
|||||||
import com.samskivert.io.StreamUtil;
|
import com.samskivert.io.StreamUtil;
|
||||||
import com.samskivert.text.MessageUtil;
|
import com.samskivert.text.MessageUtil;
|
||||||
import com.samskivert.util.ArrayIntSet;
|
import com.samskivert.util.ArrayIntSet;
|
||||||
|
import com.samskivert.util.RandomUtil;
|
||||||
import com.samskivert.util.RunAnywhere;
|
import com.samskivert.util.RunAnywhere;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
@@ -368,7 +369,9 @@ public class Application
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix;
|
String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix;
|
||||||
return _trackingURL == null ? null : new URL(_trackingURL + event + suffix);
|
String random = _trackingURLRandomPrefix == null ?
|
||||||
|
"" : _trackingURLRandomPrefix + RandomUtil.getInt(_trackingRandomRange);
|
||||||
|
return _trackingURL == null ? null : new URL(_trackingURL + event + suffix + random);
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
log.warning("Invalid tracking URL [path=" + _trackingURL + ", event=" + event +
|
log.warning("Invalid tracking URL [path=" + _trackingURL + ", event=" + event +
|
||||||
", error=" + mue + "].");
|
", error=" + mue + "].");
|
||||||
@@ -513,6 +516,18 @@ public class Application
|
|||||||
// Some app may need an extra suffix added to the tracking URL
|
// Some app may need an extra suffix added to the tracking URL
|
||||||
_trackingURLSuffix = (String)cdata.get("tracking_url_suffix");
|
_trackingURLSuffix = (String)cdata.get("tracking_url_suffix");
|
||||||
|
|
||||||
|
// Some app may need a random value in the tracking URL
|
||||||
|
_trackingURLRandomPrefix = (String)cdata.get("tracking_url_random_prefix");
|
||||||
|
vstr = (String)cdata.get("tracking_random_range");
|
||||||
|
if (vstr != null) {
|
||||||
|
try {
|
||||||
|
_trackingRandomRange = Integer.parseInt(vstr);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String err = MessageUtil.tcompose("m.invalid_random_range", vstr);
|
||||||
|
throw (IOException) new IOException(err).initCause(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// clear our arrays as we may be reinitializing
|
// clear our arrays as we may be reinitializing
|
||||||
_codes.clear();
|
_codes.clear();
|
||||||
_resources.clear();
|
_resources.clear();
|
||||||
@@ -1412,6 +1427,8 @@ public class Application
|
|||||||
protected String _trackingCookieName;
|
protected String _trackingCookieName;
|
||||||
protected String _trackingCookieProperty;
|
protected String _trackingCookieProperty;
|
||||||
protected String _trackingURLSuffix;
|
protected String _trackingURLSuffix;
|
||||||
|
protected String _trackingURLRandomPrefix;
|
||||||
|
protected int _trackingRandomRange;
|
||||||
|
|
||||||
protected int _javaVersion;
|
protected int _javaVersion;
|
||||||
protected String _javaLocation;
|
protected String _javaLocation;
|
||||||
|
|||||||
Reference in New Issue
Block a user