-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
How to make telescope tenant aware? #70
Comments
My suggestion is to keep working telescope on the landlord connection. Next, create a tag for Telescope when you switch a tenant. I will create a TelescopeSwitchTenantTask in the next PR, and I hope that will be merged. |
@masterix21 thanks! I will wait for that 😄 |
@aminraeisi try something like this: class SwitchTenantTelescopeTask implements SwitchTenantTask
{
protected ?array $originalTelescopeTagUsing;
public function makeCurrent(Tenant $tenant): void
{
$this->originalTelescopeTagUsing = Telescope::$tagUsing;
Telescope::$tagUsing = [];
Telescope::tag(fn () => [ $tenant->domain ]);
}
public function forgetCurrent(): void
{
Telescope::$tagUsing = $this->originalTelescopeTagUsing;
Telescope::tag(fn () => [ 'landlord' ]);
}
} |
Thanks for your time! What does this supposed to do? is it for tagging the telescope entries (assuming I need to move the telescope migrations to landlord)? |
Yes! I think that the best way to use Telescope is in only one database (landlord), then when you need to track a request or anything else about a Tenant, you can simply add a "tag" to Telescope. Will works like a charm :) |
It worked! Please update |
Haha, sorry, I made a mistake because I'm using "host" and not "domain" in my project. Thanks. |
Thanks for that! one more thing, It did not tag the non-tenant requests. I can put space to detect them but it would be better if the default is landlord. |
Doesn't works using "landlord" as tag? |
Each tenant has subdomain and visiting tenant1.site.com will tag the request with |
Ok. What happen if you add |
That adds the landlord tag to all the requests even if it is a tenant request. So I need to remove it somehow when it is on the tenant? Or we don't have tasks to run when no tenant is selected? I mean when the request is to the main landlord site? |
Adding this to AppServiceProvider worked: !Tenant::current() ? Telescope::tag(fn () => ['landlord']): ''; So it will only add the landlord tag if we do not have a current tenant. Thanks a lot for your help. |
Well ;) |
How can I make telescope tenant aware? here is the part that throws error because 'mysql' is no longer available but instead the name is dynamic:
The text was updated successfully, but these errors were encountered: