Dataclasses
NOTE: Basic Usage
To use a dataclass, you can either use it directly or by using a dictionary.
It's up to you. But with an IDE such as one from JetBrains you'll get these type hints even for dictionaries.
Dataclass - UmamiConfig (Source)
Class - UmamiConfig
PARAMETER | DATA TYPE | EXAMPLE | DESCRIPTION | REQUIRED |
---|---|---|---|---|
enabled | boolean | True | Whether django_umami should be enabled. This is good to temporarily turn off tracking without removing all decorators etc. | |
host_url | string | "https://mysite.com/" | The main URL where your umami is hosted. The BASE url NOT including anything like script.js or /api/send |
|
website_id | string (uuid) | "a123b4c5-xxxx-xxxx-xxxx-xxxxxxxxx" | The website ID of the website object in Umami. Go to Websites -> Edit to copy the ID. | |
session | requests.Session | Don't add to this manually, use create_session() to create the session. |
NAME | PARAMETERS | DESCRIPTION |
---|---|---|
create_session | Used to create a session that will allow requests to your Umami server to be made much faster. | |
close_session | This will close any active session Umami is using. | |
set_enabled | enabled (bool) | Sets the value of enabled to whatever you pass in. This will enable/disable django_umami. Django will still perform normally even if disabled. |
set_host_url | host_url (string) | Sets the value of host_url to whatever you pass in. This will globally set it for all future calls. |
set_website_id | website_id (string) | Sets the value of website_id to whatever you pass in. This will globally change the website ID for all future calls. |
Dataclass - UmamiEventData (Source)
Class - UmamiConfig
PARAMETER | DATA TYPE | EXAMPLE | REQUIRED |
---|---|---|---|
hostname | string | "My Host" | |
language | string | "en-GB" | |
referrer | string | "https://example.com" | |
screen | string | "1920x1080" | |
title | string | "my site | Page One" | |
url | string | "/page1/blob/ | |
name | string | "Someone visited my site!?" |
Dataclass - UmamiPayload (Source)
Class - UmamiPayload
Main Class - Umami (Source)
Main Class - Umami
PARAMETER | DATA TYPE | EXAMPLE | REQUIRED |
---|---|---|---|
options | UmamiConfig | {"enabled": True, ...} |
NAME | INFO | RETURNS |
---|---|---|
check_website_settings | Used to check if settings are valid and should send request | bool |
send | Used to send raw request | |
track | Used to send tracking events (wrapper around send) | UmamiResponse |
track_event_name | Used to send just an event name (wrapper around send) | UmamiResponse |