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

geoip no data available #200

Open
Cate2 opened this issue Sep 8, 2016 · 18 comments
Open

geoip no data available #200

Cate2 opened this issue Sep 8, 2016 · 18 comments

Comments

@Cate2
Copy link

Cate2 commented Sep 8, 2016

Hi, I want to ask, if anybody know, where could be a problem, because in tracker_geoip table aren't any data. For example in table tracker_agents are data. In config I have 'log_geoip' => true and I have installed "geoip2/geoip2":"~2.0"

Thank you

@Cate2
Copy link
Author

Cate2 commented Sep 8, 2016

And for example, I have
/*
* Do you wish to log the user agent?
*/
'log_user_agents' => false,
and i have data about user agents in my database anyway, co It's look like it's ignore config.php

@m7vm7v
Copy link

m7vm7v commented Nov 11, 2016

What is the respond of this:
$visitor = Tracker::currentSession();
dd($visitor->geoIp);

@KwanYX
Copy link

KwanYX commented Nov 26, 2016

i have same problem and respond of dd($visitor->geoIp); is null
@antonioribeiro @m7vm7v

@LMCom
Copy link

LMCom commented Oct 4, 2017

Looks like a bug in the code.

When Tracker is trying to retrieve GeoIp data, it finally calls the private method databaseExists() in https://github.com/antonioribeiro/support/blob/master/src/GeoIp/GeoIp.php#L21. If the database does not exist, nothing happens. This silent failure was introduced by commit antonioribeiro/support@776b3e6#diff-fdd42cf520dfaffd4c4d3a0018feb14c. Before that, it likely threw an exception and people figured out what to do. However, the readme file of this project does not tell anything about the requirement of a database file for GeoIp functionality.

Further investigation reveals that the private property databasePath of GeoIp can only be set via its constructor. However, https://github.com/antonioribeiro/tracker/blob/master/src/Vendor/Laravel/ServiceProvider.php#L257 creates an instance of GeoIp without specifying databasePath. So it's to be expected that any attempt to retrieve GeoIp fails silently.

@LMCom
Copy link

LMCom commented Oct 4, 2017

The following fixed it for me, based on my previous findings.

Go to https://dev.maxmind.com/geoip/geoip2/geolite2/ and download the databases GeoLite2 City/Country in the MaxMind format. Copy them both into the same directory of your choice. A quick hack of https://github.com/antonioribeiro/tracker/blob/master/src/Vendor/Laravel/ServiceProvider.php#L258 to instantiate GeoIp with the path to the database files enables geo ip logging. Now, I will implement a cleaner fix for my app by overloading RepositoryManager.

@Cate2 @antonioribeiro @m7vm7v @KwanYX

@antonioribeiro
Copy link
Owner

antonioribeiro commented Oct 4, 2017

Tagged Tracker 3.2.2. You should now have access to the command

php artisan tracker:updategeoip

image

You also add to config/tracker.php the GeoIP database path:

'geoip_database_path' => storage_path('geoip'),

Let me know if it works for you.

@LMCom
Copy link

LMCom commented Oct 5, 2017

Ha! In the meantime I wrote my own command to pull the geo ip databases. And using a config setting to instantiate GeoIp with the correct path, was exactly what I would have done, too. Great minds think alike. ;)

Thanks for the quick coding.

Let me know if it works for you.

It works and I got rid of my hacks. :)

@kabircse
Copy link

kabircse commented Jan 4, 2018

It is not working for me. Just geoip is not saving data. What can I do?

@emadrashad
Copy link

@antonioribeiro man u could be our saver here , using laravel 5.6 and geoip v2 it's always null i walked with all issues , performed what u did exactly , am using windows 10
screencapture-127-0-0-1-8000-1520436154043

@tornadofay
Copy link

any solution for this problem ?

@tornadofay
Copy link

sorry i get it to work finally by following this #130

@osman-mohamad
Copy link

osman-mohamad commented Sep 22, 2018

when I run php artisan tracker:updategeoip
I see error
There are no commands defined in the "tracker" namespace.


the error accour when the tracker is disabled .

@meeprakash25
Copy link

@tornadofay
tornadofay how did you solve this problem can you please explain, the link you provided didn't help

@tornadofay
Copy link

tornadofay commented Oct 11, 2018

here is how i configured it:
first install geoip2/geoip2

in config\app.php

* Package Service Providers
PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
* Class Aliases
'Tracker' => PragmaRX\Tracker\Vendor\Laravel\Facade::class,

in config\tracker.php

return [
'enabled' => true,  //--> important 
'cache_enabled' => true,
'use_middleware' => true,
'log_enabled' => true,
'connection' => 'tracker',
'log_geoip' => true, //--> important 
'geoip_database_path' => storage_path('app/geoip'),  //--> important 
'geoip_model' => 'PragmaRX\Tracker\Vendor\Laravel\Models\GeoIp', //--> important 
.
. 

in app\Http\Kernel.php add

protected $middlewareGroups = [
        'web' => [
                          \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,

after that run
php artisan config:cache <---- if on production
php artisan tracker:updategeoip <----- will take some time to download database but it work after

@meeprakash25 hope this help solve the problem,

@meeprakash25
Copy link

meeprakash25 commented Oct 11, 2018 via email

@meeprakash25
Copy link

@tornadofay is that geoip_database_path correct?

@tornadofay
Copy link

@tornadofay is that geoip_database_path correct?

sorry for late reply, yes I copied it from config\tracker.php

/*
     * GeoIp2 database path.
     *
     * To get a fresh version of this file, use the command
     *
     *      php artisan tracker:updategeoip
     *
     */
    'geoip_database_path' => storage_path('app/geoip'),

also you may need to take look into Torann\GeoIP, if it still not working.

@ionesculiviucristian
Copy link

I think is related to using localhost. If u uncomment the ip range (local) in the tracking.php config file the geoip object will not gather the data required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests