@@ -12,6 +12,9 @@ pub struct WebScraperContentRequest<'a> {
12
12
/// A script (Playwright scenario) used to extract web page content that needs to be tracked.
13
13
pub extractor : & ' a str ,
14
14
15
+ /// Tags associated with the tracker.
16
+ pub tags : & ' a Vec < String > ,
17
+
15
18
/// Optional user agent string to use for every request at the web page.
16
19
pub user_agent : Option < & ' a str > ,
17
20
@@ -44,13 +47,18 @@ mod tests {
44
47
fn serialization ( ) -> anyhow:: Result < ( ) > {
45
48
assert_json_snapshot ! ( WebScraperContentRequest {
46
49
extractor: "export async function execute(p) { await p.goto('http://localhost:1234/my/app?q=2'); return await p.content(); }" ,
50
+ tags: & vec![ "tag1" . to_string( ) , "tag2" . to_string( ) ] ,
47
51
timeout: Some ( Duration :: from_millis( 100 ) ) ,
48
52
previous_content: Some ( & json!( "some content" ) ) ,
49
53
user_agent: Some ( "Retrack/1.0.0" ) ,
50
54
ignore_https_errors: true
51
55
} , @r###"
52
56
{
53
57
"extractor": "export async function execute(p) { await p.goto('http://localhost:1234/my/app?q=2'); return await p.content(); }",
58
+ "tags": [
59
+ "tag1",
60
+ "tag2"
61
+ ],
54
62
"userAgent": "Retrack/1.0.0",
55
63
"ignoreHTTPSErrors": true,
56
64
"timeout": 100,
@@ -75,6 +83,7 @@ mod tests {
75
83
) ?
76
84
. with_target ( TrackerTarget :: Page ( target. clone ( ) ) )
77
85
. with_timeout ( Duration :: from_millis ( 2500 ) )
86
+ . with_tags ( vec ! [ "tag1" . to_string( ) , "tag2" . to_string( ) ] )
78
87
. build ( ) ;
79
88
80
89
let request = WebScraperContentRequest :: try_from ( & tracker) ?;
@@ -83,6 +92,7 @@ mod tests {
83
92
assert_eq ! ( request. extractor, target. extractor. as_str( ) ) ;
84
93
assert_eq ! ( request. user_agent, target. user_agent. as_deref( ) ) ;
85
94
assert_eq ! ( request. ignore_https_errors, target. ignore_https_errors) ;
95
+ assert_eq ! ( request. tags, & tracker. tags) ;
86
96
87
97
// Config properties.
88
98
assert_eq ! ( request. timeout, Some ( Duration :: from_millis( 2500 ) ) ) ;
0 commit comments