1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate*;
/// Asynchronously send a small amount of data to an HTTP server.
///
/// This API is intended to send analytics and diagnostics data to a server
/// before a document is unloaded.
///
/// See [MDN -
/// Navigator.sendBeacon](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon)
/// for more.
///
/// # Examples
///
/// ```ignore
/// document.on("unload", || {
/// let beacon = Beacon::new();
/// beacon.send_to("localhost:8080/log", b"client closed");
/// });
/// ```