-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Automatically detect Tauri v1/v2 #16142
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
Comments
So which "field" should become Tauri? The browser? is there a version? |
My guess is that the web views used across each platform result in a user agent that results in a strange browser or device to be listed. For example the web view in Tauri on macOS results in the client being listed as something like "Apple Mail". This is probably caused by whatever library Sentry uses for user agent parsing. |
Tauri should be the browser, since it actual engine is apparent from the combination (Ubuntu = webkit-gtk, MacOS = webkit, Windows = blink-edge). A future version might ship with a Servo engine, but that is still WIP. Unfortunately, the information from my mail was pasted directly into markdown, so the information was mangled. The properties are |
Can you get a Tauri version from |
You can currently inject this data into events via Sentry.init({
dsn: '__DSN__',
beforeSend(event) {
if('__TAURI__' in window || '__TAURI_INTERNALS__' in window) {
event.contexts = {
...event.contexts,
runtime: {
name: 'Tauri',
// You might be able to set a version or other data here
// version: (window.__TAURI__ || window__TAURI_INTERNALS__).tauriVersion,
},
};
// You might need to remove the User-Agent header so Sentry doesn't auto detect the browser
// This might break platform detection though, needs testing... 🤔
if (event?.request?.headers?.['User-Agent']) {
delete event.request.headers['User-Agent'];
}
}
return event;
},
}); |
That is indeed a nice workaround. I guess a default behavior would be nice. |
I think we should write up a quick guide somewhere about adding tauri related tags (maybe GH discussion), and reference that in our docs, but I wouldn't make an SDK change to do this until we invest in a first-class Tauri SDK (which is a while away). Going to close this issue as a result. |
Mentioning this in the docs is a solution, too. Thank you. I don't think we need a specialized Tauri SDK, since we can use both the JS and the Rust APIs all right. The ability to detect tauri is also solely interesting for isomorphic apps that run the same code within tauri and on the web. |
Problem Statement
When using Sentry within a Tauri application, what gets detected from the user agent is somewhat misleading, e.g. Ubuntu/Safari. While not exactly false, since it is using gtk-webkit, it is not telling the whole story, so I think it would be a nice feature to detect the tauri version and platform instead.
Solution Brainstorm
To detect Tauri v1, you just have to look if window.TAURI is present; for v2, it is window.TAURI_INTERNALS. Tauri v1 supports Linux/Ubuntu, MacOS X and Windows. Tauri v2 additionally supports Android and iOS.
So instead of Ubuntu/Safari, it would be great to see Ubuntu/Tauri in the future.
Original request from Zendesk.
The text was updated successfully, but these errors were encountered: