5
5
6
6
from umami import models , urls
7
7
8
- __version__ = '0.1.12 '
8
+ __version__ = '0.1.13 '
9
9
10
10
from umami .errors import ValidationError , OperationNotAllowedError
11
11
@@ -168,7 +168,7 @@ def websites() -> list[models.Website]:
168
168
async def new_event_async (event_name : str , hostname : Optional [str ] = None , url : str = '/' ,
169
169
website_id : Optional [str ] = None , title : Optional [str ] = None ,
170
170
custom_data = None , referrer : str = '' , language : str = 'en-US' ,
171
- screen : str = "1920x1080" ) -> str :
171
+ screen : str = "1920x1080" , ip_address : Optional [ str ] = None ) -> str :
172
172
"""
173
173
Creates a new custom event in Umami for the given website_id and hostname (both use the default
174
174
if you have set them with the other functions such as set_hostname()). These events will both
@@ -185,6 +185,7 @@ async def new_event_async(event_name: str, hostname: Optional[str] = None, url:
185
185
referrer: The referrer of the client if there is any (what location lead them to this event)
186
186
language: The language of the event / client.
187
187
screen: The screen resolution of the client.
188
+ ip_address: OPTIONAL: The true IP address of the user, used when handling requests in APIs, etc. on the server.
188
189
189
190
Returns: The text returned from the Umami API.
190
191
"""
@@ -214,6 +215,9 @@ async def new_event_async(event_name: str, hostname: Optional[str] = None, url:
214
215
"data" : custom_data
215
216
}
216
217
218
+ if ip_address and ip_address .strip ():
219
+ payload ['ip' ] = ip_address
220
+
217
221
event_data = {
218
222
'payload' : payload ,
219
223
'type' : 'event'
@@ -229,7 +233,7 @@ async def new_event_async(event_name: str, hostname: Optional[str] = None, url:
229
233
def new_event (event_name : str , hostname : Optional [str ] = None , url : str = '/event-api-endpoint' ,
230
234
website_id : Optional [str ] = None , title : Optional [str ] = None ,
231
235
custom_data = None , referrer : str = '' , language : str = 'en-US' ,
232
- screen : str = "1920x1080" ) -> str :
236
+ screen : str = "1920x1080" , ip_address : Optional [ str ] = None ) -> str :
233
237
"""
234
238
Creates a new custom event in Umami for the given website_id and hostname (both use the default
235
239
if you have set them with the other functions such as set_hostname()). These events will both
@@ -246,6 +250,7 @@ def new_event(event_name: str, hostname: Optional[str] = None, url: str = '/even
246
250
referrer: The referrer of the client if there is any (what location lead them to this event)
247
251
language: The language of the event / client.
248
252
screen: The screen resolution of the client.
253
+ ip_address: OPTIONAL: The true IP address of the user, used when handling requests in APIs, etc. on the server.
249
254
250
255
Returns: The text returned from the Umami API.
251
256
"""
@@ -275,6 +280,9 @@ def new_event(event_name: str, hostname: Optional[str] = None, url: str = '/even
275
280
"data" : custom_data
276
281
}
277
282
283
+ if ip_address and ip_address .strip ():
284
+ payload ['ip' ] = ip_address
285
+
278
286
event_data = {
279
287
'payload' : payload ,
280
288
'type' : 'event'
@@ -288,7 +296,8 @@ def new_event(event_name: str, hostname: Optional[str] = None, url: str = '/even
288
296
289
297
async def new_page_view_async (page_title : str , url : str , hostname : Optional [str ] = None ,
290
298
website_id : Optional [str ] = None , referrer : str = '' ,
291
- language : str = 'en-US' , screen : str = "1920x1080" , ua : str = event_user_agent ) -> str :
299
+ language : str = 'en-US' , screen : str = "1920x1080" , ua : str = event_user_agent ,
300
+ ip_address : Optional [str ] = None ) -> str :
292
301
"""
293
302
Creates a new page view event in Umami for the given website_id and hostname (both use the default
294
303
if you have set them with the other functions such as set_hostname()). This is equivalent to what
@@ -303,6 +312,7 @@ async def new_page_view_async(page_title: str, url: str, hostname: Optional[str]
303
312
language: OPTIONAL: The language of the event / client.
304
313
screen: OPTIONAL: The screen resolution of the client.
305
314
ua: OPTIONAL: The UserAgent resolution of the client. Note umami blocks non browsers by default.
315
+ ip_address: OPTIONAL: The true IP address of the user, used when handling requests in APIs, etc. on the server.
306
316
307
317
Returns: The text returned from the Umami API.
308
318
"""
@@ -328,6 +338,9 @@ async def new_page_view_async(page_title: str, url: str, hostname: Optional[str]
328
338
"website" : website_id ,
329
339
}
330
340
341
+ if ip_address and ip_address .strip ():
342
+ payload ['ip' ] = ip_address
343
+
331
344
event_data = {
332
345
'payload' : payload ,
333
346
'type' : 'event'
@@ -342,7 +355,8 @@ async def new_page_view_async(page_title: str, url: str, hostname: Optional[str]
342
355
343
356
def new_page_view (page_title : str , url : str , hostname : Optional [str ] = None ,
344
357
website_id : Optional [str ] = None , referrer : str = '' ,
345
- language : str = 'en-US' , screen : str = "1920x1080" , ua : str = event_user_agent ) -> str :
358
+ language : str = 'en-US' , screen : str = "1920x1080" , ua : str = event_user_agent ,
359
+ ip_address : Optional [str ] = None ) -> str :
346
360
"""
347
361
Creates a new page view event in Umami for the given website_id and hostname (both use the default
348
362
if you have set them with the other functions such as set_hostname()). This is equivalent to what
@@ -357,6 +371,7 @@ def new_page_view(page_title: str, url: str, hostname: Optional[str] = None,
357
371
language: OPTIONAL: The language of the event / client.
358
372
screen: OPTIONAL: The screen resolution of the client.
359
373
ua: OPTIONAL: The UserAgent resolution of the client. Note umami blocks non browsers by default.
374
+ ip_address: OPTIONAL: The true IP address of the user, used when handling requests in APIs, etc. on the server.
360
375
361
376
Returns: The text returned from the Umami API.
362
377
"""
@@ -382,6 +397,9 @@ def new_page_view(page_title: str, url: str, hostname: Optional[str] = None,
382
397
"website" : website_id ,
383
398
}
384
399
400
+ if ip_address and ip_address .strip ():
401
+ payload ['ip' ] = ip_address
402
+
385
403
event_data = {
386
404
'payload' : payload ,
387
405
'type' : 'event'
0 commit comments