Add Checksum to Challenges for Google Analytics
This commit is contained in:
@ -129,7 +129,7 @@ window.common = (function(global) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (common.challengeName) {
|
if (common.challengeName) {
|
||||||
window.ga('send', 'event', 'Challenge', 'load', common.challengeName);
|
window.ga('send', 'event', 'Challenge', 'load', common.gaName);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
||||||
|
@ -20,7 +20,7 @@ window.common = (function(global) {
|
|||||||
const tail = common.arrayToNewLineString(common.tail);
|
const tail = common.arrayToNewLineString(common.tail);
|
||||||
const combinedCode = head + code + tail;
|
const combinedCode = head + code + tail;
|
||||||
|
|
||||||
ga('send', 'event', 'Challenge', 'ran-code', common.challengeName);
|
ga('send', 'event', 'Challenge', 'ran-code', common.gaName);
|
||||||
|
|
||||||
// run checks for unsafe code
|
// run checks for unsafe code
|
||||||
return detectUnsafeCode$(code)
|
return detectUnsafeCode$(code)
|
||||||
|
@ -12,7 +12,7 @@ window.common = (function(global) {
|
|||||||
'event',
|
'event',
|
||||||
'Challenge',
|
'Challenge',
|
||||||
'solved',
|
'solved',
|
||||||
common.challengeName,
|
common.gaName,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@
|
|||||||
"suborder": {
|
"suborder": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
|
"checksum": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
"isBeta": {
|
"isBeta": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Show only during dev or on beta site. Completely omitted otherwise"
|
"description": "Show only during dev or on beta site. Completely omitted otherwise"
|
||||||
|
@ -26,16 +26,17 @@
|
|||||||
"license": "(BSD-3-Clause AND CC-BY-SA-4.0)",
|
"license": "(BSD-3-Clause AND CC-BY-SA-4.0)",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"accepts": "^1.3.0",
|
"accepts": "^1.3.0",
|
||||||
|
"adler32": "~0.1.7",
|
||||||
"async": "^1.5.0",
|
"async": "^1.5.0",
|
||||||
"babel-cli": "^6.3.17",
|
"babel-cli": "^6.3.17",
|
||||||
"babel-core": "^6.3.26",
|
"babel-core": "^6.3.26",
|
||||||
"babel-eslint": "^4.1.4",
|
"babel-eslint": "^4.1.4",
|
||||||
"babel-loader": "^6.2.1",
|
"babel-loader": "^6.2.1",
|
||||||
"babel-register": "^6.3.0",
|
|
||||||
"babel-plugin-add-module-exports": "^0.1.2",
|
"babel-plugin-add-module-exports": "^0.1.2",
|
||||||
"babel-preset-es2015": "^6.3.13",
|
"babel-preset-es2015": "^6.3.13",
|
||||||
"babel-preset-react": "^6.3.13",
|
"babel-preset-react": "^6.3.13",
|
||||||
"babel-preset-stage-0": "^6.3.13",
|
"babel-preset-stage-0": "^6.3.13",
|
||||||
|
"babel-register": "^6.3.0",
|
||||||
"body-parser": "^1.13.2",
|
"body-parser": "^1.13.2",
|
||||||
"chai-jquery": "^2.0.0",
|
"chai-jquery": "^2.0.0",
|
||||||
"cheerio": "~0.19.0",
|
"cheerio": "~0.19.0",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable no-process-exit */
|
/* eslint-disable no-process-exit */
|
||||||
require('babel-register');
|
require('babel-register');
|
||||||
require('dotenv').load();
|
require('dotenv').load();
|
||||||
|
var adler32 = require('adler32');
|
||||||
|
|
||||||
var Rx = require('rx'),
|
var Rx = require('rx'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
@ -40,6 +41,12 @@ destroy()
|
|||||||
.replace(/\:/g, '')
|
.replace(/\:/g, '')
|
||||||
.replace(/\s/g, '-');
|
.replace(/\s/g, '-');
|
||||||
|
|
||||||
|
challenge.checksum = adler32.sum(
|
||||||
|
Buffer(challenge.title +
|
||||||
|
JSON.stringify(challenge.description) +
|
||||||
|
JSON.stringify(challenge.challengeSeed) +
|
||||||
|
JSON.stringify(challenge.tests)));
|
||||||
|
|
||||||
challenge.fileName = fileName;
|
challenge.fileName = fileName;
|
||||||
challenge.helpRoom = helpRoom;
|
challenge.helpRoom = helpRoom;
|
||||||
challenge.order = order;
|
challenge.order = order;
|
||||||
|
@ -178,7 +178,10 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
|
|||||||
// htmls specific
|
// htmls specific
|
||||||
verb: randomVerb(),
|
verb: randomVerb(),
|
||||||
phrase: randomPhrase(),
|
phrase: randomPhrase(),
|
||||||
compliment: randomCompliment()
|
compliment: randomCompliment(),
|
||||||
|
|
||||||
|
// Google Analytics
|
||||||
|
gaName: challenge.title + '~' + challenge.checksum
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Observable } from 'rx';
|
import { Observable } from 'rx';
|
||||||
|
import adler32 from 'adler32';
|
||||||
|
|
||||||
const basePath = process.cwd() + '/seed/challenges/';
|
const basePath = process.cwd() + '/seed/challenges/';
|
||||||
|
|
||||||
@ -21,6 +22,12 @@ export default function getFromDisk$(challenge) {
|
|||||||
return _challenge;
|
return _challenge;
|
||||||
})
|
})
|
||||||
.map(challenge => {
|
.map(challenge => {
|
||||||
|
challenge.checksum = adler32.sum(
|
||||||
|
Buffer(challenge.title +
|
||||||
|
JSON.stringify(challenge.description) +
|
||||||
|
JSON.stringify(challenge.challengeSeed) +
|
||||||
|
JSON.stringify(challenge.tests)));
|
||||||
|
|
||||||
challenge.head = challenge.head || [];
|
challenge.head = challenge.head || [];
|
||||||
challenge.tail = challenge.tail || [];
|
challenge.tail = challenge.tail || [];
|
||||||
challenge.challengeType = '' + challenge.challengeType;
|
challenge.challengeType = '' + challenge.challengeType;
|
||||||
|
@ -93,6 +93,7 @@ block content
|
|||||||
common.challengeType = !{JSON.stringify(challengeType)};
|
common.challengeType = !{JSON.stringify(challengeType)};
|
||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
common.isCompleted = !{JSON.stringify(isCompleted)};
|
common.isCompleted = !{JSON.stringify(isCompleted)};
|
||||||
|
common.gaName = !{JSON.stringify(gaName)};
|
||||||
|
|
||||||
common.username = !{JSON.stringify(user && user.username || '')};
|
common.username = !{JSON.stringify(user && user.username || '')};
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ block content
|
|||||||
common.challengeType = !{JSON.stringify(challengeType)};
|
common.challengeType = !{JSON.stringify(challengeType)};
|
||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
common.isCompleted = !{JSON.stringify(isCompleted)};
|
common.isCompleted = !{JSON.stringify(isCompleted)};
|
||||||
|
common.gaName = !{JSON.stringify(gaName)};
|
||||||
|
|
||||||
common.username = !{JSON.stringify(user && user.username || '')};
|
common.username = !{JSON.stringify(user && user.username || '')};
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ block content
|
|||||||
common.challengeType = !{JSON.stringify(challengeType)};
|
common.challengeType = !{JSON.stringify(challengeType)};
|
||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
common.isCompleted = !{JSON.stringify(isCompleted)};
|
common.isCompleted = !{JSON.stringify(isCompleted)};
|
||||||
|
common.gaName = !{JSON.stringify(gaName)};
|
||||||
|
|
||||||
common.username = !{JSON.stringify(user && user.username || '')};
|
common.username = !{JSON.stringify(user && user.username || '')};
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ block content
|
|||||||
common.challengeName = !{JSON.stringify(name)};
|
common.challengeName = !{JSON.stringify(name)};
|
||||||
common.challengeType = !{JSON.stringify(challengeType)};
|
common.challengeType = !{JSON.stringify(challengeType)};
|
||||||
common.dashedName = !{JSON.stringify(dashedName || '')};
|
common.dashedName = !{JSON.stringify(dashedName || '')};
|
||||||
|
common.gaName = !{JSON.stringify(gaName)};
|
||||||
common.isHonest = !{JSON.stringify(isHonest || false)};
|
common.isHonest = !{JSON.stringify(isHonest || false)};
|
||||||
common.isFrontEndCert = !{JSON.stringify(isFrontEndCert || false)};
|
common.isFrontEndCert = !{JSON.stringify(isFrontEndCert || false)};
|
||||||
common.isFullStackCert = !{JSON.stringify(isFullStackCert || false)};
|
common.isFullStackCert = !{JSON.stringify(isFullStackCert || false)};
|
||||||
|
@ -56,6 +56,7 @@ block content
|
|||||||
common.challengeName = !{JSON.stringify(name)};
|
common.challengeName = !{JSON.stringify(name)};
|
||||||
common.challengeType = !{JSON.stringify(challengeType)};
|
common.challengeType = !{JSON.stringify(challengeType)};
|
||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
|
common.gaName = !{JSON.stringify(gaName)};
|
||||||
common.init.push(function($) {
|
common.init.push(function($) {
|
||||||
function controlEnterHandler(e) {
|
function controlEnterHandler(e) {
|
||||||
if (
|
if (
|
||||||
|
@ -68,6 +68,7 @@ block content
|
|||||||
common.challengeId = !{JSON.stringify(id)};
|
common.challengeId = !{JSON.stringify(id)};
|
||||||
common.challengeName = !{JSON.stringify(name)};
|
common.challengeName = !{JSON.stringify(name)};
|
||||||
common.dashedName = !{JSON.stringify(dashedName)};
|
common.dashedName = !{JSON.stringify(dashedName)};
|
||||||
|
common.gaName = !{JSON.stringify(gaName)};
|
||||||
common.challengeType = !{JSON.stringify(challengeType)};
|
common.challengeType = !{JSON.stringify(challengeType)};
|
||||||
|
|
||||||
common.controlEnterHandler = function (e) {
|
common.controlEnterHandler = function (e) {
|
||||||
|
Reference in New Issue
Block a user