-
Notifications
You must be signed in to change notification settings - Fork 595
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
Column not found: 1054 Unknown column 'user_agent' in 'field list' ... #325
Comments
Hello, I'm also having the same problem (laravel + pgsql)
There is the agent_id column, but not the user_agent column. |
+1 |
Hello, I resolved temporarily: In the
|
I also have same problem. :D |
same issue here. Followed instructions as per readme. edit: I created this migration to deal with this issue
|
Got this error as well. Wondering if adding the column would be the right solution as there is already an |
hello, I am getting this error too but it just appears when I refresh my pages on mobile views. |
@antonioribeiro Faced the similar issue is there any reliable solution? Please assist. |
+1 |
How is a migration now a reliable and repeatable solution? :D You'll find that this repo relies on them heavily. @akaamitgupta @atiehmokhtary Sorry - maybe I'll just create a PR for that migration when I get the chance. Then the work is done for you, if it's not already. |
@semasping did you run the migration I provided? are your db's in sync? Can you confirm the column is not on production but it is on your dev? Also if you want to switch off "Tracker" completely you'll have to set more than Try by starting with this one (as per the docs) : |
@floodedcodeboy |
@semasping Thanks, it wasn't clear... |
@floodedcodeboy the column is not on production and is not on dev servers |
@semasping apparently my migration is missing something - however I know that it resolves the issue. Note - it has not been tested extensively. Sounds like you have a night of debugging ahead of you - sorry i can't help more at this point. |
I ran into the same error. And it comes out whathever the value of 'log_user_agents'. I agree with @emmerink : the agents should be stored in the tracker_agents and referenced with the agent_id field. I tried to create a user_agent field in the tracker_sessions table, as suggested by @floodedcodeboy, and I have a good new : it works ! But don't be fooled, "Working" here means "The error message has disapeared"... I really think it is no more than a workaround : it gives the developpers the time to correct the bug, but leaving the database this way would be a great misuse of the relationnal databases. |
I observed the same behavior in one of my apps while changing from desktop to mobile view in chromium and then reloading the page. The simplest workaround might be maikos code trick from September 2017 by just ignoring this field in the update loop. But there should also exist a cleaner way. Maybe @antonioribeiro has an idea? |
@mintalicious same issue, Any good solution yet? |
Nope, sorry. Still using the workaround mentoined above. KR |
In the file vendor/pragmarx/tracker/src/Tracker.php you can see // The key user_agent is not present in the sessions table, but
// it's internally used to check if the user agent changed
// during a session.
'user_agent' => $this->dataRepositoryManager->getCurrentUserAgent(), I'm not sure the migration is the best solution. A hint from @antonioribeiro would be appreciated ! |
It's been working great since I started to use it in late 2018. Today I encounter this error in the development environment (Laradock). The error appears using Firefox 65.0. Hope this information helps! |
I also have same problem... |
Me too. Laravel 5.8. Googlebot triggered it. |
// The key user_agent is not present in the sessions table, but
// it's internally used to check if the user agent changed
// during a session.
'user_agent' => $this->dataRepositoryManager->getCurrentUserAgent(), If that is the case then: foreach ($this->sessionInfo as $key => $value) {
if ($key == 'user_agent') {
continue;
}
if ($sessionData[$key] !== $value) {
if (!isset($model)) {
$model = $this->find($this->sessionInfo['id']);
}
$model->setAttribute($key, $value);
$model->save();
$wasComplete = false;
}
} or this but will brake some "rules": $userAgent = $sessionData['user_agent'];
if ($userAgent != $this->sessionInfo['user_agent']) {
$uaParser = new UserAgentParser(app()->make('path.base'));
$sessionData['agent_id'] = (new \PragmaRX\Tracker\Vendor\Laravel\Models\Agent())->forceFill([
'name' => $name = $uaParser->originalUserAgent ?: 'Other',
'browser' => $uaParser->userAgent->family,
'browser_version' => $uaParser->getUserAgentVersion(),
'name_hash' => hash('sha256', $name),
])->getKey();
}
foreach ($this->sessionInfo as $key => $value) {
if ($key == 'user_agent') {
continue;
}
if ($sessionData[$key] !== $value) {
if (!isset($model)) {
$model = $this->find($this->sessionInfo['id']);
}
$model->setAttribute($key, $value);
$model->save();
$wasComplete = false;
}
} Hope this gets fixed as there is no way to switch to mobile testing after refresh. |
Still have this issue. So far for me, it only happens on mobile (via Google Chrome's Device Tool) like so: When not in a mobile device, there are no problems. @antonioribeiro, maybe the logging code when on mobile device has not been updated according to the new schema. |
I FIXED this by overriding the class that has the issue with First, copy the original class from the vendor to your app: Second, add the following inside the Your "autoload": {
"psr-4": {
"App\\": "app/"
},
"classmap": [
"database/seeds",
"database/factories"
],
"files": ["app/VendorOverrides/PragmaRX/Tracker/Data/Repositories/Session.php"]
}, Third, add the following line after The private function ensureSessionDataIsComplete()
{
$sessionData = $this->getSessionData();
$wasComplete = true;
foreach ($this->sessionInfo as $key => $value) {
if ($key === 'user_agent') continue; // <--- THIS IS WHAT IS NEW!!!
if ($sessionData[$key] !== $value) {
if (!isset($model)) {
$model = $this->find($this->sessionInfo['id']);
}
$model->setAttribute($key, $value);
$model->save();
$wasComplete = false;
}
}
if (!$wasComplete) {
$this->storeSession();
}
} Finally, run Pull-requests for this like #391 or #448 are not yet merged. Until that, this should fix this issue. |
I got this error:
Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_agent' in 'field list' (SQL: update
tracker_sessionsset
user_agent= Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0,
updated_at= 2017-09-23 06:40:46 where
id= 301550)
But even on a fresh install I don't have this column in the tracker_sessions table! Is there a migration missing or something like that?
thanks
The text was updated successfully, but these errors were encountered: