• Resolved metricmedia

    (@metricmedia)


    We are dealing with an issue where WordPress customer A’s data is overwriting Salesforce customer B’s data. Often this happens to individual customers but we’ve had a couple of instances where 25 or so customers all got pushed and modified the wrong customers in Salesforce.

    If we can see exactly what is getting pushed to Salesforce, that may help us understand why customer A’s data is writing over customer B’s.

    Before we try hacking the plugin, is there a recommended process for logging the contents of each pushed record?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    First you should try turning on debug mode. See if that logs the data that you want. If it doesn’t, and you do need to use a hook or expand the plugin, you may at least be able to use that pattern.

    Thread Starter metricmedia

    (@metricmedia)

    Thank you. We tried that and we do get a lot of entries but are not seeing the details of what is being pushed or pulled. I’m hoping to see a full JSON object or other array of keys and values.

    Anyone out there who has logged the raw contents of pushed/pulled data, and might be able to suggest a way to do so?

    If not we will experiment. Just hoping someone else has done this first ??

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    Hm I think if you do end up experimenting, this method is probably the most direct place to try. Right now, this particular debug call runs every time the Salesforce API is called, and while it does try to log the full result from the API, it does not include the parameters array even though that is available at this point in the code, both as an array and as a JSON string.

    Especially since this debug log already exists and the data is already available, I wouldn’t be opposed to putting $params into this log’s post body along with the result, if that does what you’re looking for. I can’t think of any negative implications of it, at least.

    I haven’t tested this, but you could potentially use something like this:

    if ( ! empty( $params ) ) {
        $body .= sprintf(
            // translators: placeholder is: 1) the params sent to Salesforce.
            '<h3>' . esc_html__( 'Parameters sent to the Salesforce API', 'object-sync-for-salesforce' ) . '</h3> <div>%1$s</div>',
            print_r( $params, true ) // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
        );
    }
    Thread Starter metricmedia

    (@metricmedia)

    Huh – maybe I’m looking in the wrong place. In WordPress admin there’s a side navigation item “Logs”, and it contains entries titled, for instance, “Success: Update WordPress product with ID of 375142 (Salesforce Experience__c Id of a104x000002X83fAAC)”

    But there’s no other info visible.

    Maybe this Logs item isn’t the right place to look. (We didn’t build this site – we took it over after the previous developer bailed out.)

    Is there another place to access these logs that might be more verbose?

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    No. I will say that there are more verbose logs when an error occurs than there are when an event is successful, but the most verbose that occur regardless of status are definitely the “debug” ones.

    But like I said, I think the debug log call that runs on every Salesforce API call could reasonably be expanded to include the parameters that are sent, whenever there are any. I imagine it just hadn’t occurred to me to include them before.

    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    I’m going to add the additional logging that I mentioned in this reply to the next plugin release in the hopes that it’s helpful during debugging with the plugin’s logs.

    Thread Starter metricmedia

    (@metricmedia)

    That is fabulous – can’t wait.

    Meanwhile we’ll try implementing it manually. Haven’t had a chance yet – fires to put out ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Is it possible to log pushed data?’ is closed to new replies.