File tree 2 files changed +43
-1
lines changed
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,14 @@ mod pages;
7
7
8
8
use app:: * ;
9
9
use leptos:: { logging:: log, * } ;
10
- use log:: info;
10
+ use log:: { error, info} ;
11
+ use web_sys:: Url ;
12
+
13
+ static API_URL : & str = "https://rust-lang-en-espanol-api.shuttleapp.rs" ;
11
14
12
15
pub fn main ( ) {
16
+ let _ = create_local_resource ( move || ( ) , |_| track_previous_url ( ) ) ;
17
+
13
18
_ = console_log:: init_with_level ( log:: Level :: Debug ) ;
14
19
console_error_panic_hook:: set_once ( ) ;
15
20
@@ -21,3 +26,19 @@ pub fn main() {
21
26
view ! { <App /> }
22
27
} ) ;
23
28
}
29
+
30
+ pub async fn track_previous_url ( ) {
31
+ let previous_domain = if document ( ) . referrer ( ) == "" {
32
+ "Undefined" . to_owned ( )
33
+ } else {
34
+ let address = document ( ) . referrer ( ) ;
35
+ let url = Url :: new ( & address) . unwrap ( ) ;
36
+ url. host ( )
37
+ } ;
38
+
39
+ let endpoint = format ! ( "{API_URL}/track/count?reference={previous_domain}" ) ;
40
+ match reqwasm:: http:: Request :: post ( & endpoint) . send ( ) . await {
41
+ Ok ( _) => log ! ( "Tracking previous url" ) ,
42
+ Err ( _) => error ! ( "Error tracking previous url" ) ,
43
+ } ;
44
+ }
Original file line number Diff line number Diff line change @@ -787,6 +787,10 @@ video {
787
787
border-radius : 9999px ;
788
788
}
789
789
790
+ .rounded-md {
791
+ border-radius : 0.375rem ;
792
+ }
793
+
790
794
.rounded-r-full {
791
795
border-top-right-radius : 9999px ;
792
796
border-bottom-right-radius : 9999px ;
@@ -852,6 +856,10 @@ video {
852
856
background-color : rgb (124 45 18 / var (--tw-bg-opacity ));
853
857
}
854
858
859
+ .bg-slate-200\/ 20 {
860
+ background-color : rgb (226 232 240 / 0.2 );
861
+ }
862
+
855
863
.bg-white {
856
864
--tw-bg-opacity : 1 ;
857
865
background-color : rgb (255 255 255 / var (--tw-bg-opacity ));
@@ -869,10 +877,18 @@ video {
869
877
fill : currentColor;
870
878
}
871
879
880
+ .p-1 {
881
+ padding : 0.25rem ;
882
+ }
883
+
872
884
.p-2 {
873
885
padding : 0.5rem ;
874
886
}
875
887
888
+ .p-4 {
889
+ padding : 1rem ;
890
+ }
891
+
876
892
.p-6 {
877
893
padding : 1.5rem ;
878
894
}
@@ -959,6 +975,11 @@ video {
959
975
line-height : 1 ;
960
976
}
961
977
978
+ .text-sm {
979
+ font-size : 0.875rem ;
980
+ line-height : 1.25rem ;
981
+ }
982
+
962
983
.text-xl {
963
984
font-size : 1.25rem ;
964
985
line-height : 1.75rem ;
You can’t perform that action at this time.
0 commit comments