Jump to content

New Plugin - Device Locations


Recommended Posts

mwongjay
Posted (edited)
14 minutes ago, darkassassin07 said:

@mwongjay

Nothing is ever simple, lol.

 

Emby server v4.8.11.0

 

2025-04-20 08:44:43.524 Info EmbyDeviceLocations.ScheduledTasks: Starting User Device Activity Sync
2025-04-20 08:44:43.529 Info EmbyDeviceLocations: Opening read connection
2025-04-20 08:44:43.530 Info EmbyDeviceLocations: Default journal_mode for /config/data/authentication.db is delete
2025-04-20 08:44:43.537 Info EmbyDeviceLocations: Opening read connection
2025-04-20 08:44:43.537 Info EmbyDeviceLocations: Default journal_mode for /config/data/activitylog.db is delete
2025-04-20 08:44:43.538 Info App: Sqlite: 1 - no such function: CONCAT in "SELECT Id, Type, Name, CONCAT(ShortOverview, Overview) as COverview, DateCreatedMs, InternalUserId from ActivityLog WHERE DateCreatedMs > 1744869745737  AND ActivityLog.Type in ('A
2025-04-20 08:44:43.545 Error TaskManager: Error
	*** Error Report ***
	Version: 4.8.11.0
	Command line: /system/EmbyServer.dll -programdata /config -ffdetect /bin/ffdetect -ffmpeg /bin/ffmpeg -ffprobe /bin/ffprobe -restartexitcode 3
	Operating system: Linux version 6.1.0-18-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT
	Framework: .NET 6.0.36
	OS/Process: x64/x64
	Runtime: system/System.Private.CoreLib.dll
	Processor count: 12
	Data path: /config
	Application path: /system
	SQLitePCL.pretty.SQLiteException: Error: no such function: CONCAT - SELECT Id, Type, Name, CONCAT(ShortOverview, Overview) as COverview, DateCreatedMs, InternalUserId from ActivityLog WHERE DateCreatedMs > 1744869745737  AND ActivityLog.Type in ('AuthenticationSucceeded','user.authenticated') AND InternalUserId IS NOT NULL AND LENGTH(COverview) > 0 ORDER BY DateCreatedMs
	SQLitePCL.pretty.SQLiteException: Exception of type 'SQLitePCL.pretty.SQLiteException' was thrown.
	   at SQLitePCL.pretty.SQLiteDatabaseConnection.PrepareStatement(String sql, ReadOnlySpan`1& tail)
	   at SQLitePCL.pretty.DatabaseConnection.PrepareStatement(IDatabaseConnection This, String sql)
	   at EmbyDeviceLocations.Data.ActivityLogRepository.GetActivityLogs(Int64 minDateCreatedToFetch, ActivityLogFilter filter, EmbyActivityLogType[] activityLogTypes)
	   at EmbyDeviceLocations.Services.LocationService.SyncUserDeviceActivity(IProgress`1 progress, CancellationToken cancellationToken)
	   at EmbyDeviceLocations.ScheduledTasks.SyncDeviceActivityTask.<>c__DisplayClass11_0.<Execute>b__0()
	   at System.Threading.Tasks.Task.InnerInvoke()
	   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
	--- End of stack trace from previous location ---
	   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
	--- End of stack trace from previous location ---
	   at EmbyDeviceLocations.ScheduledTasks.SyncDeviceActivityTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: SQLitePCL.pretty
	TargetSite: SQLitePCL.pretty.IStatement PrepareStatement(System.String, System.ReadOnlySpan`1[System.Byte] ByRef)
	
2025-04-20 08:44:43.545 Info TaskManager: Sync activity data Failed after 0 minute(s) and 0 seconds

 

Interesting, concat was added to sqlite 3.44.0 (2023-11-01) so your version must be older than that. FWIW beta versions run this fine, but I appreciate the feedback. I'll get another version out that handles older versions some time later today.

Edited by mwongjay
seanbuff
Posted
10 hours ago, mwongjay said:

@seanbuff@JatorLet me know if this latest version changes the behavior you were seeing on your server

Thank you, I will test the newest plugin version over the next few days.

Posted (edited)

The plugin works but it is not returning any information after 3/31/2025. I am using the latest version of the plugin above. and running emby Version 4.11.0.  Playback reporting is working OK and is returning more recent dates.

 

location.jpg

 

embyserver.txt

Edited by gihayes
Replaced Log. Had forgotton to turn on Debug
mwongjay
Posted
16 hours ago, gihayes said:

The plugin works but it is not returning any information after 3/31/2025. I am using the latest version of the plugin above. and running emby Version 4.11.0.  Playback reporting is working OK and is returning more recent dates.

 

location.jpg

 

embyserver.txt 198.08 kB · 0 downloads

Reviewing your log I don't see any issues. This plugin is not meant for playback reporting; there is already a plugin for that as you alluded to. This plugin syncs successful authentication events from external (remote) network devices from Emby's activity logs. Once those logs are synced to the plugin's database the data is enriched with geo ip data and referenced in the table in your screenshot. If you have a user on a remote device log out and log in, then run "Sync activity data" followed by "Enrich location data" you should see updated information.

Posted (edited)

Thanks for your reply Mwongjay. The only reason I mentioned Playback Reporting is because the menu at the top of the page when displaying Location Data is the menu from Playback Reporting and because Playback Reporting shows that connections to the server from new IP addresses have been made since the last date shown by the Location Plugin. Are there any reasons why the Location Plugin is only showing information upto 3/31/2025? I've run "Sync activity data" followed by "Enrich location data" and the result is the same, No Location data after 3/31/2025 is displayed.

 

location.jpg

embyserver.txt

location2.jpg

Edited by gihayes
darkassassin07
Posted (edited)

Have you had anyone actually login since 3/31?

 

Not resuming a previous session or using a pin, but actually entering their username and password from scratch.

Playback activities, as shown in your second screenshot, are irrelevant. We need actual login events.

Edited by darkassassin07
mwongjay
Posted
18 minutes ago, gihayes said:

Thanks for your reply Mwongjay. The only reason I mentioned Playback Reporting is because the menu at the top of the page when displaying Location Data is the menu from Playback Reporting and because Playback Reporting shows that connections to the server from new IP addresses have been made since the last date shown by the Location Plugin. Are there any reasons why the Location Plugin is only showing information upto 3/31/2025? I've run "Sync activity data" followed by "Enrich location data" and the result is the same, No Location data after 3/31/2025 is displayed.

 

location.jpg

embyserver.txt 67.02 MB · 0 downloads

location2.jpg

It’s possible the user having different remote ip addresses is roaming and hasn’t actually logged out and  re-authenticated as @darkassassin07was stating. For example, I could log into Emby on my phone at 1.1.1.1, play Movie 1 then travel to another location. At the new location my phone gets handed a different ip address, 2.2.2.2 and I open Emby but I’m already logged in on my app, then play Movie 2. The result of these activities would only create a single device location having the ip 1.1.1.1. Yet, in the activity log there would be activities associated with each ip address which is the behavior you’re experiencing. If this is not the case then I would need your activity log database to have certainty. 

Posted

It's working. Thanks for the explanation. The issue was that myself and other users were not logging out. I used a vpn to login play a short video, then log out from several worldwide  locations and the plugin is showing that activity.

Thanks !! 👍

darkassassin07
Posted

@mwongjayThis has begun erroring again as of 4/29. No other changes to the server since (besides new media).

 

2025-05-01 18:44:43.554 Info EmbyDeviceLocations.ScheduledTasks: Starting User Device Activity Sync
2025-05-01 18:44:43.558 Info App: Sqlite: 11 - database corruption at line 71062 of [831d0fb283]
2025-05-01 18:44:43.558 Info App: Sqlite: 11 - statement aborts at 26: [SELECT Id, Type, Name, COALESCE(ShortOverview, Overview) as COverview, DateCreatedMs, InternalUserId from ActivityLog WHERE DateCreatedMs > 1745347159475  AND ActivityLog.Type in ('Aut
2025-05-01 18:44:43.558 Error TaskManager: Error
	*** Error Report ***
	Version: 4.8.11.0
	Command line: /system/EmbyServer.dll -programdata /config -ffdetect /bin/ffdetect -ffmpeg /bin/ffmpeg -ffprobe /bin/ffprobe -restartexitcode 3
	Operating system: Linux version 6.1.0-18-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT
	Framework: .NET 6.0.36
	OS/Process: x64/x64
	Runtime: system/System.Private.CoreLib.dll
	Processor count: 12
	Data path: /config
	Application path: /system
	SQLitePCL.pretty.SQLiteException: Corrupt: database disk image is malformed
	SQLitePCL.pretty.SQLiteException: Exception of type 'SQLitePCL.pretty.SQLiteException' was thrown.
	   at SQLitePCL.pretty.SQLiteException.CheckOk(sqlite3 db, Int32 rc)
	   at SQLitePCL.pretty.StatementImpl.MoveNext()
	   at EmbyDeviceLocations.Data.SqliteExtensions.ExecuteQuery(IStatement This)+MoveNext()
	   at EmbyDeviceLocations.Data.ActivityLogRepository.GetActivityLogs(Int64 minDateCreatedToFetch, ActivityLogFilter filter, EmbyActivityLogType[] activityLogTypes)
	   at EmbyDeviceLocations.Services.LocationService.SyncUserDeviceActivity(IProgress`1 progress, CancellationToken cancellationToken)
	   at EmbyDeviceLocations.ScheduledTasks.SyncDeviceActivityTask.<>c__DisplayClass11_0.<Execute>b__0()
	   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
	--- End of stack trace from previous location ---
	   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
	--- End of stack trace from previous location ---
	   at EmbyDeviceLocations.ScheduledTasks.SyncDeviceActivityTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: SQLitePCL.pretty
	TargetSite: Void CheckOk(SQLitePCLEx.sqlite3, Int32)
	

 

  • Agree 1
Posted

Hi.  This is very cool and pretty useful but I just want to set expectations that we probably cannot put this in our catalog.  The privacy implications are just too complex.

Thanks and nice work.

Posted

Also there should be a better way than having to touch the activity log db directly.

mwongjay
Posted
On 5/1/2025 at 10:39 PM, darkassassin07 said:

@mwongjayThis has begun erroring again as of 4/29. No other changes to the server since (besides new media).

 

2025-05-01 18:44:43.554 Info EmbyDeviceLocations.ScheduledTasks: Starting User Device Activity Sync
2025-05-01 18:44:43.558 Info App: Sqlite: 11 - database corruption at line 71062 of [831d0fb283]
2025-05-01 18:44:43.558 Info App: Sqlite: 11 - statement aborts at 26: [SELECT Id, Type, Name, COALESCE(ShortOverview, Overview) as COverview, DateCreatedMs, InternalUserId from ActivityLog WHERE DateCreatedMs > 1745347159475  AND ActivityLog.Type in ('Aut
2025-05-01 18:44:43.558 Error TaskManager: Error
	*** Error Report ***
	Version: 4.8.11.0
	Command line: /system/EmbyServer.dll -programdata /config -ffdetect /bin/ffdetect -ffmpeg /bin/ffmpeg -ffprobe /bin/ffprobe -restartexitcode 3
	Operating system: Linux version 6.1.0-18-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT
	Framework: .NET 6.0.36
	OS/Process: x64/x64
	Runtime: system/System.Private.CoreLib.dll
	Processor count: 12
	Data path: /config
	Application path: /system
	SQLitePCL.pretty.SQLiteException: Corrupt: database disk image is malformed
	SQLitePCL.pretty.SQLiteException: Exception of type 'SQLitePCL.pretty.SQLiteException' was thrown.
	   at SQLitePCL.pretty.SQLiteException.CheckOk(sqlite3 db, Int32 rc)
	   at SQLitePCL.pretty.StatementImpl.MoveNext()
	   at EmbyDeviceLocations.Data.SqliteExtensions.ExecuteQuery(IStatement This)+MoveNext()
	   at EmbyDeviceLocations.Data.ActivityLogRepository.GetActivityLogs(Int64 minDateCreatedToFetch, ActivityLogFilter filter, EmbyActivityLogType[] activityLogTypes)
	   at EmbyDeviceLocations.Services.LocationService.SyncUserDeviceActivity(IProgress`1 progress, CancellationToken cancellationToken)
	   at EmbyDeviceLocations.ScheduledTasks.SyncDeviceActivityTask.<>c__DisplayClass11_0.<Execute>b__0()
	   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
	--- End of stack trace from previous location ---
	   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
	--- End of stack trace from previous location ---
	   at EmbyDeviceLocations.ScheduledTasks.SyncDeviceActivityTask.Execute(CancellationToken cancellationToken, IProgress`1 progress)
	   at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
	Source: SQLitePCL.pretty
	TargetSite: Void CheckOk(SQLitePCLEx.sqlite3, Int32)
	

 

It appears your activity log database is corrupted. You'll need to address that before we know if there are issues related to the plugin. FWIW, the plugin is still running fine for me on 4.9.0.52.

darkassassin07
Posted

....I highly doubt that.

 

There are no other issues present; the rest of the server and all other plugins are functioning just fine.

 

 

I'll pm you a copy of the db to take a look.

darkassassin07
Posted

For those following along; restarted the server and this issue disappeared.

Jdiesel
Posted
On 5/2/2025 at 9:03 AM, ebr said:

Hi.  This is very cool and pretty useful but I just want to set expectations that we probably cannot put this in our catalog.  The privacy implications are just too complex.

Thanks and nice work.

Is there really a privacy concern though? All it's doing it automating an IP lookup. The actual resolution of the location is very very low so it's not like it could be used to identify someone's exact location.

Posted
16 hours ago, Jdiesel said:

Is there really a privacy concern though? All it's doing it automating an IP lookup. The actual resolution of the location is very very low so it's not like it could be used to identify someone's exact location.

From the standpoint of any of the app stores we have to pass validation for and, also, various laws in place now, yes.

  • Agree 1
rbjtech
Posted
18 hours ago, Jdiesel said:

Is there really a privacy concern though? All it's doing it automating an IP lookup. The actual resolution of the location is very very low so it's not like it could be used to identify someone's exact location.

A public IP is not considered PII data in isolation but when used in combination with a login - it is actually reasonably easy to deduce where that person is.  Thus privacy is a real concern.

So while I'm tending to agree with Eric that making this available in the catalogue is opening up 'potential' privacy alarm bells - all the information that it gathers is openly available to the admin in the logs anyway. 

mwongjay
Posted (edited)
On 5/7/2025 at 8:30 AM, ebr said:

From the standpoint of any of the app stores we have to pass validation for and, also, various laws in place now, yes.

 

22 hours ago, rbjtech said:

A public IP is not considered PII data in isolation but when used in combination with a login - it is actually reasonably easy to deduce where that person is.  Thus privacy is a real concern.

So while I'm tending to agree with Eric that making this available in the catalogue is opening up 'potential' privacy alarm bells - all the information that it gathers is openly available to the admin in the logs anyway. 

FWIW the Playback Reporting plugin (in addition to the logs) is already in the catalog and displays the ip address for currently actively connected clients as well as playback summary per user and IMO is more invasive in terms of privacy because you can track a user's location continuously. This plugin only captures ip addresses correlated to authentication events specifically to limit tracking users with the target being permanent devices (apple tv, fire tv, etc). I don't have a strong opinion whether it's added to the catalog; I built this plugin for my own needs and shared it with others, however, the fact that an app exists in the catalog that doesn't abide by the same set of standards should be evaluated.

Edited by mwongjay
rbjtech
Posted
3 minutes ago, mwongjay said:

 

FWIW the Playback Reporting plugin (in addition to the logs) is already in the catalog and displays the ip address for currently actively connected clients as well as playback summary per user and IMO is more invasive in terms of privacy because you can track a user's location continuously. This plugin only captures ip addresses correlated to authentication events specifically to limit tracking users with the target being permanent devices (apple tv, fire tv, etc). I don't have a strong opinion whether it's added to the catalog; I built this plugin for my own needs and shared it with others, however, the fact that an app exists in the catalog that doesn't abide by the same set of standards should evaluated.

I think what makes this Plugin different, is the IP data is being passed to a 3rd party to Geo locate - that is effectively passing trusted Emby data to a 3rd party where we have no control over what happens to it.  Playback Reporting is not doing that - it just keeps it local in a DB. 

mwongjay
Posted
1 minute ago, rbjtech said:

I think what makes this Plugin different, is the IP data is being passed to a 3rd party to Geo locate - that is effectively passing trusted Emby data to a 3rd party where we have no control over what happens to it.  Playback Reporting is not doing that - it just keeps it local in a DB. 

The only information going to a 3rd party is the ip address and api key. Docs: https://www.ip2location.io/ip2location-documentation. All relationships between devices, ips, and users are maintained in this plugin's database.

  • Agree 1
rbjtech
Posted
6 minutes ago, mwongjay said:

The only information going to a 3rd party is the ip address and api key. Docs: https://www.ip2location.io/ip2location-documentation. All relationships between devices, ips, and users are maintained in this plugin's database.

Agreed - that's why I said IP data ;) - but there is now a 'trust' that is needed - hence the need to be cautious for a more global release of the plugin.

mwongjay
Posted
4 minutes ago, rbjtech said:

Agreed - that's why I said IP data ;) - but there is now a 'trust' that is needed - hence the need to be cautious for a more global release of the plugin.

I guess where I'm having cognitive dissonance is that you've stated 

Quote

A public IP is not considered PII data in isolation

so the ip relayed to a 3rd party with no other identifying information would fall into this category I believe. The Emby server and at least one plugin stores ip address correlated with users and devices which is not different than the scope of this plugin, yet that is allowable.

Posted
2 hours ago, mwongjay said:

so the ip relayed to a 3rd party

One of the questions we have to ask in all the stores is "do you send any data to a 3rd party".

Also, with this plugin, it is immediately obvious that the sole purpose is to locate users.  To any un-informed body (read as ALL the reviewers in the store) this is an immediate red flag.

It is just too risky for us to attempt.

  • Agree 2
TMCsw
Posted

Just curious as I don’t use this plugin anyway… But do think it's kina neat!

7 hours ago, ebr said:

One of the questions we have to ask in all the stores is "do you send any data to a 3rd party".

I’ve been using MaxMind’s Geolite2 (free) via my Nginx RP. to geo-block any IP’s that that is not in my short list of allowed Countries/Regions/… (nginx logs record all IP's for the last 7 days)

As far as I can tell Geolite2 does not send the IP to any 3rd party but relies on it’s databases that are downloaded regularly to the local machine. So if the plugin switched to using Geolite2 then that should eliminate this problem.

7 hours ago, ebr said:

Also, with this plugin, it is immediately obvious that the sole purpose is to locate users.  To any un-informed body (read as ALL the reviewers in the store) this is an immediate red flag.

But I guess that would still be too much of a risk?

P.S. It seams rather ridiculous that if a little guy does something like this that is so benign the get booted but the worst offenders get away with actually collecting/using/selling PII thrive (Google/Microsoft...............)  (I'm not just talking about there OS's but there apps!)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...