Chewy click logs arrive as one JSON object per line, but the file may contain blank lines, whitespace, malformed JSON records, unrelated events, and records with missing fields. Write a function that returns the unique session IDs for matching customer clicks while preserving their first appearance order.
A record matches when all of the following are true:
event equals "click".customer_id equals the requested customer ID.product_id is in the requested set of product IDs.session_id is a non-empty string.Ignore every other record without raising an exception. The input is already split into lines, so the function does not need to open a file.
Implement extract_session_ids(log_lines, customer_id, product_ids), where log_lines is a list of strings, customer_id is a string, and product_ids is a list of strings. Return a list of unique session ID strings in first-seen order.
def extract_session_ids(log_lines, customer_id, product_ids):