mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Facebook pixel Revert (3rd time's a charm?) (#8450)
* attempt revert * Add back unrelated stuff
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
"IP":"0.0.0.0",
|
"IP":"0.0.0.0",
|
||||||
"CORES":1,
|
"CORES":1,
|
||||||
"BASE_URL":"http://localhost:3000",
|
"BASE_URL":"http://localhost:3000",
|
||||||
"FACEBOOK_ANALYTICS":"1234567890123456",
|
|
||||||
"FACEBOOK_KEY":"123456789012345",
|
"FACEBOOK_KEY":"123456789012345",
|
||||||
"FACEBOOK_SECRET":"aaaabbbbccccddddeeeeffff00001111",
|
"FACEBOOK_SECRET":"aaaabbbbccccddddeeeeffff00001111",
|
||||||
"GOOGLE_CLIENT_ID":"123456789012345",
|
"GOOGLE_CLIENT_ID":"123456789012345",
|
||||||
|
|||||||
@@ -26,14 +26,22 @@ describe('Analytics Service', function () {
|
|||||||
describe('register', function() {
|
describe('register', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sandbox.stub(window, 'fbq');
|
sandbox.stub(amplitude, 'setUserId');
|
||||||
|
sandbox.stub(window, 'ga');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('records a registration event on Facebook', function() {
|
it('sets up user with Amplitude', function() {
|
||||||
analytics.register();
|
analytics.register();
|
||||||
clock.tick();
|
clock.tick();
|
||||||
expect(fbq).to.have.been.calledOnce;
|
expect(amplitude.setUserId).to.have.been.calledOnce;
|
||||||
expect(fbq).to.have.been.calledWith('track', 'CompleteRegistration');
|
expect(amplitude.setUserId).to.have.been.calledWith(user._id);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets up user with Google Analytics', function() {
|
||||||
|
analytics.register();
|
||||||
|
clock.tick();
|
||||||
|
expect(ga).to.have.been.calledOnce;
|
||||||
|
expect(ga).to.have.been.calledWith('set', {userId: user._id});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,7 +74,6 @@ describe('Analytics Service', function () {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sandbox.stub(amplitude, 'logEvent');
|
sandbox.stub(amplitude, 'logEvent');
|
||||||
sandbox.stub(window, 'ga');
|
sandbox.stub(window, 'ga');
|
||||||
sandbox.stub(window, 'fbq');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('successful tracking', function() {
|
context('successful tracking', function() {
|
||||||
@@ -106,15 +113,6 @@ describe('Analytics Service', function () {
|
|||||||
expect(ga).to.have.been.calledOnce;
|
expect(ga).to.have.been.calledOnce;
|
||||||
expect(ga).to.have.been.calledWith('send', properties);
|
expect(ga).to.have.been.calledWith('send', properties);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('tracks a page view with Facebook', function() {
|
|
||||||
var properties = {'hitType':'pageview','eventCategory':'behavior','eventAction':'tasks'};
|
|
||||||
analytics.track(properties);
|
|
||||||
clock.tick();
|
|
||||||
|
|
||||||
expect(fbq).to.have.been.calledOnce;
|
|
||||||
expect(fbq).to.have.been.calledWith('track', 'PageView');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
context('unsuccessful tracking', function() {
|
context('unsuccessful tracking', function() {
|
||||||
|
|||||||
@@ -32,17 +32,6 @@
|
|||||||
}, window['ga'].l = 1 * new Date();
|
}, window['ga'].l = 1 * new Date();
|
||||||
ga('create', window.env.GA_ID, user ? {'userId': user._id} : undefined);
|
ga('create', window.env.GA_ID, user ? {'userId': user._id} : undefined);
|
||||||
|
|
||||||
// Facebook
|
|
||||||
var n = window.fbq = function() {
|
|
||||||
n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments)
|
|
||||||
};
|
|
||||||
if (!window._fbq) window._fbq = n;
|
|
||||||
n.push = n;
|
|
||||||
n.loaded = !0;
|
|
||||||
n.version = '2.0';
|
|
||||||
n.queue = [];
|
|
||||||
fbq('init', window.env.FACEBOOK_ANALYTICS);
|
|
||||||
|
|
||||||
function loadScripts() {
|
function loadScripts() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
// Amplitude
|
// Amplitude
|
||||||
@@ -56,22 +45,16 @@
|
|||||||
// Google Analytics
|
// Google Analytics
|
||||||
var a = document.createElement('script');
|
var a = document.createElement('script');
|
||||||
var m = document.getElementsByTagName('script')[0];
|
var m = document.getElementsByTagName('script')[0];
|
||||||
a.async = true;
|
a.async = 1;
|
||||||
a.src = '//www.google-analytics.com/analytics.js';
|
a.src = '//www.google-analytics.com/analytics.js';
|
||||||
m.parentNode.insertBefore(a, m);
|
m.parentNode.insertBefore(a, m);
|
||||||
|
|
||||||
// Facebook
|
|
||||||
var t = document.createElement('script');
|
|
||||||
var f = document.getElementsByTagName('script')[0];
|
|
||||||
t.async = true;
|
|
||||||
t.src = 'https://connect.facebook.net/en_US/fbevents.js';
|
|
||||||
f.parentNode.insertBefore(t, f);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function register() {
|
function register() {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
fbq('track', 'CompleteRegistration');
|
amplitude.setUserId(user._id);
|
||||||
|
ga('set', {'userId':user._id});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,9 +72,6 @@
|
|||||||
|
|
||||||
amplitude.logEvent(properties.eventAction,properties);
|
amplitude.logEvent(properties.eventAction,properties);
|
||||||
ga('send',properties);
|
ga('send',properties);
|
||||||
if(properties.hitType === 'pageview') {
|
|
||||||
fbq('track', 'PageView');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { mods } from '../models/user';
|
|||||||
// To avoid stringifying more data then we need,
|
// To avoid stringifying more data then we need,
|
||||||
// items from `env` used on the client will have to be specified in this array
|
// items from `env` used on the client will have to be specified in this array
|
||||||
const CLIENT_VARS = ['language', 'isStaticPage', 'availableLanguages', 'translations',
|
const CLIENT_VARS = ['language', 'isStaticPage', 'availableLanguages', 'translations',
|
||||||
'FACEBOOK_KEY', 'GOOGLE_CLIENT_ID', 'FACEBOOK_ANALYTICS', 'NODE_ENV', 'BASE_URL', 'GA_ID',
|
'FACEBOOK_KEY', 'GOOGLE_CLIENT_ID', 'NODE_ENV', 'BASE_URL', 'GA_ID',
|
||||||
'AMAZON_PAYMENTS', 'STRIPE_PUB_KEY', 'AMPLITUDE_KEY',
|
'AMAZON_PAYMENTS', 'STRIPE_PUB_KEY', 'AMPLITUDE_KEY',
|
||||||
'worldDmg', 'mods', 'IS_MOBILE', 'PUSHER:KEY', 'PUSHER:ENABLED'];
|
'worldDmg', 'mods', 'IS_MOBILE', 'PUSHER:KEY', 'PUSHER:ENABLED'];
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ let env = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
'NODE_ENV BASE_URL GA_ID STRIPE_PUB_KEY FACEBOOK_ANALYTICS FACEBOOK_KEY GOOGLE_CLIENT_ID AMPLITUDE_KEY PUSHER:KEY PUSHER:ENABLED'
|
'NODE_ENV BASE_URL GA_ID STRIPE_PUB_KEY FACEBOOK_KEY GOOGLE_CLIENT_ID AMPLITUDE_KEY PUSHER:KEY PUSHER:ENABLED'
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.forEach(key => {
|
.forEach(key => {
|
||||||
env[key] = nconf.get(key);
|
env[key] = nconf.get(key);
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ html(ng-app='habitrpg', ng-controller='RootCtrl', ng-class='{"applying-action":a
|
|||||||
meta(name='viewport', content='width=device-width, initial-scale=1.0')
|
meta(name='viewport', content='width=device-width, initial-scale=1.0')
|
||||||
meta(name='apple-mobile-web-app-capable', content='yes')
|
meta(name='apple-mobile-web-app-capable', content='yes')
|
||||||
meta(name='mobile-web-app-capable', content='yes')
|
meta(name='mobile-web-app-capable', content='yes')
|
||||||
noscript
|
|
||||||
img(height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=#{env.FACEBOOK_ANALYTICS}&ev=PageView&noscript=1")
|
|
||||||
|
|
||||||
!= env.getManifestFiles("app", "css")
|
!= env.getManifestFiles("app", "css")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user