modify this snippet and add a function to log sent emails, the log should be saved as json file:

function send_new_product_notification($product_id) {
// Get the product object
$product = wc_get_product($product_id);

// Get the product details
$title = $product->get_name();
$category = $product->get_category_ids();
$price = $product->get_price();
$url = $product->get_permalink();

// Get the custom field values
$activite_principale = get_field('activite_principale', $product_id);
$besoin_assurances = get_field('besoins_assurance', $product_id);
$autres_besoins = get_field('besoins_', $product_id);
$adresse_client = get_field('adresse', $product_id);
$departement = get_field('departement', $product_id);
$ca = get_field('c_affaire', $product_id);
$date_creation = get_field('date_de_creation', $product_id);
$deja_assure = get_field('deja_assure', $product_id);
$compagnie = get_field('compagnie', $product_id);
$echeance_principale = get_field('echeance_principale', $product_id);
$type_prospet = get_field('type_prospet', $product_id);
$date_rappel = get_field('date_de_rappel', $product_id);
$heure_rappel = get_field('heure_rappel', $product_id);
$methode_contact = get_field('methode_de_contact', $product_id);
$date_rdv = get_field('date_du_rdv', $product_id);
$heure_rdv = get_field('heure_du_rdv', $product_id);
$commentaire = get_field('commentaire_', $product_id);