Skip to content

Commit

Permalink
feat: aggregate each script's API calls
Browse files Browse the repository at this point in the history
  • Loading branch information
SichangHe committed Oct 9, 2024
1 parent f3568c4 commit 827d99b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions jsphere_vv8_log/src/aggregating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl RecordAggregate {
attr: Some(method),
may_be_interaction: self.interaction_injected,
};
self.current_script()?.api_calls.push(api_call);
let api_calls = &mut self.current_script()?.api_calls;api_calls.entry(api_call).or_default().push(line);
}
None
}
Expand All @@ -108,7 +108,7 @@ impl RecordAggregate {
attr: None,
may_be_interaction: self.interaction_injected,
};
self.current_script()?.api_calls.push(api_call);
let api_calls = &mut self.current_script()?.api_calls;api_calls.entry(api_call).or_default().push(line);
None
},

Expand Down Expand Up @@ -145,7 +145,8 @@ impl RecordAggregate {
attr,
may_be_interaction: self.interaction_injected,
};
self.current_script()?.api_calls.push(api_call);
let api_calls = &mut self.current_script()?.api_calls;
api_calls.entry(api_call).or_default().push(line);
}
}
}
Expand All @@ -161,13 +162,17 @@ impl RecordAggregate {

/// A script that was executed and its aggregate information.
#[pub_fields]
#[derive_enum_everything]
#[derive(Debug, Clone)]
pub struct ScriptAggregate {
/// Line number in the log file where the script's context appears.
line: usize,
/// Indicates where the script came from.
name: ScriptName,
/// JS source code.
source: String,
injection_type: ScriptInjectionType,
api_calls: Vec<ApiCall>,
/// API calls made, and the lines where they were made.
api_calls: HashMap<ApiCall, Vec<usize>>,
}

/// A browser JS API call.
Expand Down

0 comments on commit 827d99b

Please sign in to comment.