don't identify mixpanel users if public_id is null

This commit is contained in:
qfrery
2018-07-17 16:04:38 +01:00
parent 3a2ee709eb
commit 2e6a2233f2
2 changed files with 11 additions and 8 deletions

View File

@@ -15,14 +15,17 @@ if (mailpoet_analytics_enabled) {
mixpanel.register({'Platform': 'Plugin'}); mixpanel.register({'Platform': 'Plugin'});
if(window.mailpoet_analytics_new_public_id === true) { console.log(window.mailpoet_analytics_public_id);
mixpanel.alias(window.mailpoet_analytics_public_id); if(typeof window.mailpoet_analytics_public_id === 'string' && window.mailpoet_analytics_public_id.length > 0) {
} else { if(window.mailpoet_analytics_new_public_id === true) {
mixpanel.identify(window.mailpoet_analytics_public_id); mixpanel.alias(window.mailpoet_analytics_public_id);
} } else {
mixpanel.identify(window.mailpoet_analytics_public_id);
}
if (mailpoet_analytics_data != null) { if (mailpoet_analytics_data != null) {
mixpanel.people.set(mailpoet_analytics_data); mixpanel.people.set(mailpoet_analytics_data);
}
} }
} }

View File

@@ -46,7 +46,7 @@ class Analytics {
/** @return string */ /** @return string */
function getPublicId() { function getPublicId() {
$public_id = Setting::getValue('public_id'); $public_id = Setting::getValue('public_id', '');
// if we didn't get the user public_id from the shop yet : we create one based on mixpanel distinct_id // if we didn't get the user public_id from the shop yet : we create one based on mixpanel distinct_id
if(empty($public_id) && !empty($_COOKIE['mixpanel_distinct_id'])) { if(empty($public_id) && !empty($_COOKIE['mixpanel_distinct_id'])) {
// the public id has to be diffent that mixpanel_distinct_id in order to be used on different browser // the public id has to be diffent that mixpanel_distinct_id in order to be used on different browser