From 60d389e1f8b51ee3e9cb38e6607d86b96f6ce848 Mon Sep 17 00:00:00 2001 From: Steve Heffernan Date: Tue, 11 Jun 2013 15:25:19 -0700 Subject: [PATCH] Close GH-571: Add analtyics to current CDN version. Fixes #568 --- Gruntfile.js | 11 ++++++++-- contrib.json | 8 +++++--- src/js/cdn.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 src/js/cdn.js diff --git a/Gruntfile.js b/Gruntfile.js index fbec5d398..bdc70c676 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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){ diff --git a/contrib.json b/contrib.json index 10a1a6553..4640c2024 100644 --- a/contrib.json +++ b/contrib.json @@ -1,6 +1,8 @@ { + "owner": "videojs", + "project": "video.js", "developmentBranch": "master", "releaseBranch": "stable", - "remote": "origin", - "upstream": "zencoder" -} \ No newline at end of file + "remote": "origin" +} + diff --git a/src/js/cdn.js b/src/js/cdn.js new file mode 100644 index 000000000..2f8eee9db --- /dev/null +++ b/src/js/cdn.js @@ -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); \ No newline at end of file