2017-05-02 03:54:36 +02:00
|
|
|
# Clients in Zulip
|
|
|
|
|
|
|
|
`zerver.models.Client` is Zulip's analogue of the HTTP User-Agent
|
2021-08-20 21:53:28 +02:00
|
|
|
header (and is populated from User-Agent). It exists for use in
|
2017-05-02 03:54:36 +02:00
|
|
|
analytics and other places to provide human-readable summary data
|
2024-07-04 12:33:43 +02:00
|
|
|
about "which Zulip client" was used for an operation (e.g., was it the
|
2017-05-02 03:54:36 +02:00
|
|
|
Android app, the desktop app, or a bot?).
|
|
|
|
|
|
|
|
In general, it shouldn't be used for anything controlling the behavior
|
|
|
|
of Zulip; it's primarily intended to assist debugging.
|
|
|
|
|
|
|
|
## Analytics
|
|
|
|
|
|
|
|
A `Client` is used to sort messages into client categories such as
|
2020-10-30 00:46:30 +01:00
|
|
|
`ZulipElectron` on the `/stats` page. For more information see,
|
2022-02-24 00:17:21 +01:00
|
|
|
[Analytics](analytics.md).
|
2017-05-02 03:54:36 +02:00
|
|
|
|
|
|
|
## Integrations
|
|
|
|
|
|
|
|
Generally, integrations in Zulip should declare a unique User-Agent,
|
|
|
|
so that it's easy to figure out which integration is involved when
|
2021-08-20 21:53:28 +02:00
|
|
|
debugging an issue. For incoming webhook integrations, we do that
|
2021-12-28 18:36:59 +01:00
|
|
|
conveniently via the auth decorators (as we will describe shortly);
|
2017-05-02 03:54:36 +02:00
|
|
|
other integrations generally should set the first User-Agent element
|
|
|
|
on their HTTP requests to something of the form
|
|
|
|
ZulipIntegrationName/1.2 so that they are categorized properly.
|
|
|
|
|
2020-08-20 00:32:15 +02:00
|
|
|
The `webhook_view` auth decorator, used for most incoming
|
2017-05-02 03:54:36 +02:00
|
|
|
webhooks, accepts the name of the integration as an argument and uses
|
2021-07-26 14:47:10 +02:00
|
|
|
it to generate a client name that it adds to the `request_notes`
|
|
|
|
object that can be accessed with the `request` (Django
|
2024-05-24 16:57:31 +02:00
|
|
|
[HttpRequest](https://docs.djangoproject.com/en/5.0/ref/request-response/#django.http.HttpRequest))
|
2021-07-26 14:47:10 +02:00
|
|
|
object via `zerver.lib.request.get_request_notes(request)`.
|
2017-05-02 03:54:36 +02:00
|
|
|
|
2021-07-26 14:47:10 +02:00
|
|
|
In most integrations, `request_notes.client` is then passed to
|
|
|
|
`check_send_webhook_message`, where it is used to keep track of which client
|
2017-05-02 03:54:36 +02:00
|
|
|
sent the message (which in turn is used by analytics). For more
|
2020-06-08 23:04:39 +02:00
|
|
|
information, see [the incoming webhook walkthrough](https://zulip.com/api/incoming-webhooks-walkthrough).
|