1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-02 09:11:54 +02:00

Close GH-571: Add analtyics to current CDN version. Fixes #568

This commit is contained in:
Steve Heffernan 2013-06-11 15:25:19 -07:00
parent 880be64f48
commit 60d389e1f8
3 changed files with 70 additions and 5 deletions

View File

@ -1,8 +1,9 @@
module.exports = function(grunt) {
var pkg, s3, semver, version, verParts;
var pkg, s3, semver, version, verParts, uglify;
semver = require('semver');
pkg = grunt.file.readJSON('package.json');
uglify = require('uglify-js');
try {
s3 = grunt.file.readJSON('.s3config.json');
@ -233,7 +234,7 @@ module.exports = function(grunt) {
grunt.registerTask('dist', 'Creating distribution', function(){
var exec = require('child_process').exec;
var done = this.async();
var css, jsmin, jsdev;
var css, jsmin, jsdev, cdnjs;
// Manually copy each source file
grunt.file.copy('build/files/minified.video.js', 'dist/video-js/video.js');
@ -263,6 +264,12 @@ module.exports = function(grunt) {
css = css.replace(/font\//g, '../f/1/');
grunt.file.write('dist/cdn/video-js.css', css);
// Add CDN-specfic JS
jsmin = grunt.file.read('dist/cdn/video.js');
// GA Tracking Pixel (manually building the pixel URL)
cdnjs = uglify.minify('src/js/cdn.js').code.replace('v0.0.0', 'v'+version.full);
grunt.file.write('dist/cdn/video.js', jsmin + cdnjs);
// Zip up into video-js-VERSION.zip
exec('cd dist && zip -r video-js-'+version.full+'.zip video-js && cd ..', { maxBuffer: 500*1024 }, function(err, stdout, stderr){

View File

@ -1,6 +1,8 @@
{
"owner": "videojs",
"project": "video.js",
"developmentBranch": "master",
"releaseBranch": "stable",
"remote": "origin",
"upstream": "zencoder"
}
"remote": "origin"
}

56
src/js/cdn.js Normal file
View File

@ -0,0 +1,56 @@
/**
* Google Analytics tracking pixel for the freely hosted version of Video.js
* at vjs.zencdn.net. We'll use this data to develop a support matrix of
* browsers and devices, and possibly track errors.
*
* This code generates the GA tracking URL without requiring the GA javascript
* library.
*
* @type {Image}
*/
;(function(i,w,n,e,l){
l=w.location;
// Setting the source of an image will load the URL even without adding to dom
// Using //www, still seems to work for https even though ssl.google is used by google
i.src='//www.google-analytics.com/__utm.gif'
// Version
+'?utmwv=5.4.2'
// ID
+'&utmac=UA-16505296-2'
// Sessions
// &utms=2
// Cache breaker (using utmcc to do this)
+'&utmn='+1
+'&utmhn='+e(l.hostname)
// Encoding
// &utmcs=UTF-8
+'&utmsr='+w.screen.availWidth+'x'+w.screen.availHeight
// Browser window
// &utmvp=1057x1105
// Color depth
// &utmsc=24-bit
+'&utmul='+(n.language||n.userLanguage)
// Java
// &utmje=1
// Flash version
// &utmfl=11.7%20r700
// Page title
// &utmdt=HTML5%20Video%20Player%20%7C%20Video.js
// Adsense
// &utmhid=1112291628
// Referrer, '-' is none
// Using current page as referrer so stats show up cleaner than "Direct"
+'&utmr='+e(l.href)
+'&utmp='+e(l.hostname+l.pathname)
// Current time stamp
// &utmht=1370890439353
// ?
// &utmu=q
// Cookies! Manually setting visitor ID and setting everything else to 1
// Random number used as cache buster instead of utmn
+'&utmcc=__utma%3D1.'+Math.floor(Math.random()*1e10)+'.1.1.1.1%3B'
// Custom Var: vjsv is the variable name and 1.0.0 is the VJS version
+'&utme=8(vjsv)9(v0.0.0)'
;
})(new Image(),window,navigator,encodeURIComponent);