lib/google/ads/google_ads/interceptors/logging_interceptor.rb in google-ads-googleads-8.1.0 vs lib/google/ads/google_ads/interceptors/logging_interceptor.rb in google-ads-googleads-9.0.0

- old
+ new

@@ -31,12 +31,16 @@ SEARCH_RESPONSE_FIELDS_TO_MASK = %w[ emailAddress inviterUserEmailAddress userEmail ] - SEARCH_REQUEST_MASK = - /customer_user_access.email_address|change_event.user_email|feed.places_location_feed_data.email_address/ + SEARCH_REQUEST_MASK = / + customer_user_access.email_address| + customer_user_access_invitation.email_address| + change_event.user_email| + feed.places_location_feed_data.email_address + /x MASK_REPLACEMENT = "REDACTED" def initialize(logger) # Don't propagate args, parens are necessary @@ -182,11 +186,11 @@ message_class) # Sanitize all known sensitive fields across all search responses. message = clone_to_json(message) message["fieldMask"].split(",").each do |path| if SEARCH_RESPONSE_FIELDS_TO_MASK.include?(path.split(".").last) - message["results"].each do |result| + message["results"]&.each do |result| sanitize_field(result, path) end end end message @@ -207,10 +211,22 @@ if message.include?("operation") && message["operation"].include?("update") message["operation"]["update"] = sanitize_customer_user_access(message["operation"]["update"]) end message + elsif "CustomerUserAccessInvitation" == message_class + # Sanitize sensitive fields specific to CustomerUserAccessInvitation get requests. + message = clone_to_json(message) + sanitize_customer_user_access_invitation(message) + elsif "MutateCustomerUserAccessInvitationRequest" == message_class + # Sanitize sensitive fields when mutating a CustomerUserAccessInvitation. + message = clone_to_json(message) + if message.include?("operation") && message["operation"].include?("create") + message["operation"]["create"] = + sanitize_customer_user_access_invitation(message["operation"]["create"]) + end + message elsif "Feed" == message_class # Sanitize sensitive fields specific to Feed get requests. message = clone_to_json(message) if message.include?("placesLocationFeedData") && message["placesLocationFeedData"].include?("emailAddress") @@ -237,9 +253,16 @@ if message.include?("emailAddress") message["emailAddress"] = MASK_REPLACEMENT end if message.include?("inviterUserEmailAddress") message["inviterUserEmailAddress"] = MASK_REPLACEMENT + end + message + end + + def sanitize_customer_user_access_invitation(message) + if message.include?("emailAddress") + message["emailAddress"] = MASK_REPLACEMENT end message end def sanitize_feeds_request(message)