Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix geolocation even if anonymize_ip is enabled #8175

Open
wants to merge 3 commits into
base: staging
from

Conversation

@kuzmany
Copy link
Contributor

kuzmany commented Dec 2, 2019

Please be sure you are submitting this against the staging branch.

Q A
Bug fix?
New feature?
Automated tests included?
Related user documentation PR URL
Related developer documentation PR URL
Issues addressed (#s or URLs)
BC breaks?
Deprecations?

Description:

Noticed If Anonymize IP is enabled not geolocation provide.
This PR fixed it.

Steps to reproduce the bug:

  1. Enable Anonymize IP in configuration > Tracking Settings
  2. Setup tracking code and go to incognito window and hit the trakcing page
  3. You contact should be IP address in anonymous contact list tab without country flag.

Steps to test this PR:

  1. Load up this PR
  2. Repeat all steps
  3. You contact should listed with country flag
@kuzmany kuzmany added Bug WIP labels Dec 2, 2019
@kuzmany kuzmany added this to the 2.16.0 milestone Dec 2, 2019
@npracht npracht requested a review from Enc3phale Dec 2, 2019
@kuzmany kuzmany added Ready To Test and removed WIP labels Dec 2, 2019
Copy link

florentpetitjean left a comment

Hello,
Tested and doesn't seems to work for me :
image
I'm in incognito mode.
Contact history page look like that :
image

Here are the logs in the instance :
(Sorry doesn't know if anything useful here)
[2019-12-02 15:40:21] mautic.DEBUG: LEAD: Tracking ID for this device is gncnoakywdo88c3u9zrafea
[2019-12-02 15:40:24] mautic.DEBUG: LEAD: Tracking ID for this device is gncnoakywdo88c3u9zrafea
[2019-12-02 15:40:24] mautic.DEBUG: CONTACT: Existing lead found with ID# 55.
[2019-12-02 15:40:25] mautic.DEBUG: CONTACT: Tracking session for contact ID# 55 through POST /8175/mtc/event
[2019-12-02 15:40:25] mautic.DEBUG: CONTACT: Tracking session for contact ID# 55 through POST /8175/mtc/event
[2019-12-02 15:40:25] mautic.DEBUG: LEAD: Tracking ID for this device is gncnoakywdo88c3u9zrafea
[2019-12-02 15:40:25] mautic.DEBUG: CAMPAIGN: Campaign triggered for event type page.pagehit(page / )
[2019-12-02 15:40:25] mautic.DEBUG: CONTACT: Tracking session for contact ID# 55 through POST /8175/mtc/event
[2019-12-02 15:40:25] mautic.DEBUG: CAMPAIGN: Current contact ID# 55
[2019-12-02 15:40:25] mautic.DEBUG: CAMPAIGN: Contact does not have any applicable page.pagehit associations.
[2019-12-02 15:40:25] mautic.DEBUG: CAMPAIGN: Campaign triggered for event type page.devicehit(page / )
[2019-12-02 15:40:25] mautic.DEBUG: CONTACT: Tracking session for contact ID# 55 through POST /8175/mtc/event
[2019-12-02 15:40:25] mautic.DEBUG: CAMPAIGN: Current contact ID# 55
[2019-12-02 15:40:25] mautic.DEBUG: CAMPAIGN: Contact does not have any applicable page.devicehit associations.
[2019-12-02 15:40:25] mautic.DEBUG: CONTACT: Tracking session for contact ID# 55 through POST /8175/mtc/event
[2019-12-02 15:40:25] mautic.DEBUG: LEAD: Tracking ID for this device is gncnoakywdo88c3u9zrafea
[2019-12-02 15:40:25] mautic.DEBUG: CONTACT: Tracking session for contact ID# 55 through POST /8175/mtc/event
[2019-12-02 15:40:25] mautic.DEBUG: LEAD: Tracking ID for this device is gncnoakywdo88c3u9zrafea
[2019-12-02 15:42:18] mautic.DEBUG: Segment QB: Create SQL: SELECT count(leadIdPrimary) count, max(leadIdPrimary) maxId, min(leadIdPrimary) minId FROM (SELECT DISTINCT l.id as leadIdPrimary, iFtCRYAU.lead_id AS iFtCRYAU_lead_id FROM 8175_leads l LEFT JOIN 8175_lead_lists_leads iFtCRYAU ON iFtCRYAU.lead_id = l.id and (iFtCRYAU.leadlist_id = 1) WHERE (l.country = 'United States') AND (iFtCRYAU.lead_id IS NULL)) sss {"segmentId":1}
[2019-12-02 15:42:18] mautic.DEBUG: Segment QB: Query took: 00:00:00.001835, Result count: 3 {"segmentId":1}
[2019-12-02 15:42:18] mautic.INFO: Segment QB - No new leads for segment found
[2019-12-02 15:42:19] mautic.DEBUG: Segment QB: Orphan Leads Count SQL: SELECT count(leadIdPrimary) count, max(leadIdPrimary) maxId, min(leadIdPrimary) minId FROM (SELECT DISTINCT orp.lead_id as leadIdPrimary, orp.lead_id as id, orp.leadlist_id FROM 8175_lead_lists_leads orp LEFT JOIN (SELECT l.id FROM 8175_leads l WHERE l.country = 'United States') members ON members.id=orp.lead_id WHERE (orp.leadlist_id = 1) AND (members.id IS NULL) AND (orp.manually_added = '0')) sss {"segmentId":1}
[2019-12-02 15:42:19] mautic.DEBUG: Segment QB: Query took: 00:00:00.000986, Result count: 3 {"segmentId":1}

@kuzmany

This comment has been minimized.

Copy link
Contributor Author

kuzmany commented Dec 2, 2019

@florentpetitjean Did you test it on mautibox? I bet you forgot download IP lookup data in configuration . Now should works

https://mautibox.com/8175/s/contacts

image

Copy link

florentpetitjean left a comment

You're right, I forgot that.
Works fine now thanks a lot.

@@ -507,6 +507,10 @@ public function saveEntity($entity, $unlock = true)
$details = $ips->first()->getIpDetails();
// Only update with IP details if none of the following are set to prevent wrong combinations
if (empty($fields['core']['city']['value']) && empty($fields['core']['state']['value']) && empty($fields['core']['country']['value']) && empty($fields['core']['zipcode']['value'])) {
if ($this->coreParametersHelper->getParameter('anonymize_ip') && $this->ipLookupHelper->getRealIp()) {
$details = $this->ipLookupHelper->getIpDetails($this->ipLookupHelper->getRealIp());

This comment has been minimized.

Copy link
@Enc3phale

Enc3phale Dec 12, 2019

Contributor

On this call if $this->ipLookup == NULL within getIpDetails an error is thrown.

[2019-12-12 13:01:19] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Call to a member function setIpAddress() on null" at app\bundles\CoreBundle\Helper\IpLookupHelper.php line 227

This comment has been minimized.

Copy link
@Enc3phale

Enc3phale Dec 13, 2019

Contributor

With last commit aa3139c, $details from line 507 is erased by an empty array if $this->ipLookup == NULL, is this wanted behavior?

@kuzmany

This comment has been minimized.

Copy link
Contributor Author

kuzmany commented Dec 12, 2019

@Enc3phale last commit should fixed it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.