Skip to content

Commit

Permalink
Merge pull request googleanalytics#49 from googleanalytics/ngrok
Browse files Browse the repository at this point in the history
Use ngrok instead of sauce connect
  • Loading branch information
philipwalton committed Apr 5, 2016
2 parents 82af21e + ec152fb commit 4412989
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 20 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ language: node_js
node_js:
- "5"

addons:
sauce_connect: true

env:
global:
- SAUCE_USERNAME=autotrack
Expand Down
23 changes: 19 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@
*/


/* eslint require-jsdoc: "off" */


var browserify = require('browserify');
var buffer = require('vinyl-buffer');
var connect = require('connect');
var eslint = require('gulp-eslint');
var fs = require('fs');
var gulp = require('gulp');
var gutil = require('gulp-util');
var seleniumServerJar = require('selenium-server-standalone-jar');
var ngrok = require('ngrok');
var pkg = require('./package.json');
var shell = require('shelljs');
var seleniumServerJar = require('selenium-server-standalone-jar');
var serveStatic = require('serve-static');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
Expand All @@ -34,6 +37,7 @@ var webdriver = require('gulp-webdriver');


var server;
var seleniumServer;


gulp.task('javascript', function(done) {
Expand Down Expand Up @@ -67,16 +71,17 @@ gulp.task('javascript', function(done) {


gulp.task('lint', function () {
return gulp.src(['lib/**/*.js', 'test/**/*.js'])
return gulp.src(['gulpfile.js', 'lib/**/*.js', 'test/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});


gulp.task('test', ['javascript', 'lint', 'serve', 'selenium'], function() {
gulp.task('test', ['javascript', 'lint', 'tunnel', 'selenium'], function() {
function stopServers() {
server.close();
ngrok.kill();
if (!process.env.CI) seleniumServer.kill();
}
return gulp.src('./wdio.conf.js')
Expand All @@ -85,6 +90,16 @@ gulp.task('test', ['javascript', 'lint', 'serve', 'selenium'], function() {
});


gulp.task('tunnel', ['serve'], function(done) {
ngrok.connect(8080, function(err, url) {
if (err) return done(err);

process.env.BASE_URL = url;
done();
});
});


gulp.task('serve', ['javascript'], function(done) {
server = connect().use(serveStatic('./')).listen(8080, done);
});
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/autotrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/


// Imports sub-plugins.
require('./event-tracker');
require('./media-query-tracker');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"gulp-webdriver": "^1.0.2",
"lodash": "^3.10.1",
"mocha": "^2.3.4",
"ngrok": "^2.1.6",
"saucelabs": "^1.0.1",
"selenium-server-standalone-jar": "^2.48.2",
"selenium-webdriver": "^2.48.2",
"serve-static": "^1.10.0",
"shelljs": "^0.5.3",
"uglify-js": "^2.6.1",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test/outbound-form-tracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</head>
<body>

<form action="http://google-analytics.com/collect">
<form action="https://google-analytics.com/collect">
<input id="submit-1" type="submit">
</form>

Expand Down
8 changes: 4 additions & 4 deletions test/outbound-form-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('outboundFormTracker', function() {

assert.equal(hitData[0].eventCategory, 'Outbound Form');
assert.equal(hitData[0].eventAction, 'submit');
assert.equal(hitData[0].eventLabel, 'http://google-analytics.com/collect');
assert.equal(hitData[0].eventLabel, 'https://google-analytics.com/collect');
});


Expand Down Expand Up @@ -95,7 +95,7 @@ describe('outboundFormTracker', function() {
.execute(utilities.stubBeacon)
.execute(ga.run, 'require', 'outboundFormTracker')
.click('#submit-1')
.waitUntil(utilities.urlMatches('http://google-analytics.com/collect'));
.waitUntil(utilities.urlMatches('https://google-analytics.com/collect'));

// Restores the page state.
yield setupPage();
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('outboundFormTracker', function() {
// Tests that the hit is sent.
assert.equal(hitData[0].eventCategory, 'Outbound Form');
assert.equal(hitData[0].eventAction, 'submit');
assert.equal(hitData[0].eventLabel, 'http://google-analytics.com/collect');
assert.equal(hitData[0].eventLabel, 'https://google-analytics.com/collect');

// Tests that navigation actually happens
yield setupPage();
Expand All @@ -138,7 +138,7 @@ describe('outboundFormTracker', function() {
.execute(utilities.stubNoBeacon)
.execute(ga.run, 'require', 'outboundFormTracker')
.click('#submit-1')
.waitUntil(utilities.urlMatches('http://google-analytics.com/collect'));
.waitUntil(utilities.urlMatches('https://google-analytics.com/collect'));

// Restores the page state.
yield setupPage();
Expand Down
2 changes: 1 addition & 1 deletion test/outbound-link-tracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</head>
<body>

<a id="outbound-link" href="http://google-analytics.com/collect">Outbound</a>
<a id="outbound-link" href="https://google-analytics.com/collect">Outbound</a>
<a id="local-link" href="/test/blank.html">Local</a>
<a id="javascript-protocol" href="javascript:console.log('clicked!')">javascript protocol</a>
<a id="file-protocol" href="file:///content.txt">file protocol</a>
Expand Down
4 changes: 2 additions & 2 deletions test/outbound-link-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('outboundLinkTracker', function() {
assert.equal(hitData.length, 1);
assert.equal(hitData[0].eventCategory, 'Outbound Link');
assert.equal(hitData[0].eventAction, 'click');
assert.equal(hitData[0].eventLabel, 'http://google-analytics.com/collect');
assert.equal(hitData[0].eventLabel, 'https://google-analytics.com/collect');
});


Expand Down Expand Up @@ -95,7 +95,7 @@ describe('outboundLinkTracker', function() {
.execute(utilities.stubBeacon)
.execute(ga.run, 'require', 'outboundLinkTracker')
.click('#outbound-link')
.waitUntil(utilities.urlMatches('http://google-analytics.com/collect'));
.waitUntil(utilities.urlMatches('https://google-analytics.com/collect'));

// Restores the page state.
yield setupPage();
Expand Down
4 changes: 2 additions & 2 deletions test/social-tracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<title>Social Tracker Test</title>
<meta property="og:title" content="Social Tracker Test" />
<meta property="og:url" content="http://example.com" />
<meta property="og:url" content="https://example.com" />
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
</script>
Expand Down Expand Up @@ -39,7 +39,7 @@
Tweet
</button>

<p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://example.com">Tweet</a></p>
<p><a href="https://twitter.com/share" class="twitter-share-button" data-url="https://example.com">Tweet</a></p>

<p><a class="twitter-follow-button" href="https://twitter.com/twitter">
Follow @twitter</a></p>
Expand Down
2 changes: 1 addition & 1 deletion test/social-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('socialTracker', function() {
.waitUntil(ga.hitDataMatches([
['[0].socialNetwork', 'Twitter'],
['[0].socialAction', 'tweet'],
['[0].socialTarget', 'http://example.com'],
['[0].socialTarget', 'https://example.com'],
['[1].socialNetwork', 'Twitter'],
['[1].socialAction', 'follow'],
['[1].socialTarget', 'twitter']
Expand Down
1 change: 0 additions & 1 deletion wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ if (isSauceLabs) {
' - ' + (cap.version || 'latest');

cap['build'] = process.env.TRAVIS_BUILD_NUMBER;
cap['tunnel-identifier'] = process.env.TRAVIS_JOB_NUMBER;
});
}

Expand Down

0 comments on commit 4412989

Please sign in to comment.