Skip to content

Commit

Permalink
Merge pull request #749 from Kit/remove-js-store-subscriber-id-cookie
Browse files Browse the repository at this point in the history
Remove JS `convertStoreSubscriberIDInCookie` function
  • Loading branch information
n7studios authored Dec 3, 2024
2 parents 2f68cc7 + 1d0387c commit adae90a
Showing 1 changed file with 2 additions and 71 deletions.
73 changes: 2 additions & 71 deletions resources/frontend/js/convertkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,6 @@
* @author ConvertKit
*/

/**
* Gets the subscriber ID for the given email address, storing
* it in the `ck_subscriber_id` cookie if it exists.
*
* Typically called when the user completes a ConvertKit Form
* that has either "Auto-confirm new subscribers" or
* "Send subscriber to thank you page" enabled (both scenarios
* include a ck_subscriber_id).
*
* @since 1.9.6
*
* @param int id Subscriber ID
*/
function convertStoreSubscriberIDInCookie( subscriber_id ) {

if ( convertkit.debug ) {
console.log( 'convertStoreSubscriberIDInCookie' );
console.log( subscriber_id );
}

fetch(
convertkit.ajaxurl,
{
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams(
{
action: 'convertkit_store_subscriber_id_in_cookie',
convertkit_nonce: convertkit.nonce,
subscriber_id: subscriber_id
}
)
}
)
.then(
function ( response ) {
if ( convertkit.debug ) {
console.log( response );
}

return response.json();
}
)
.then(
function ( result ) {
if ( convertkit.debug ) {
console.log( result );
}

convertKitRemoveSubscriberIDFromURL( window.location.href );
}
)
.catch(
function ( error ) {
if ( convertkit.debug ) {
console.error( error );
}

convertKitRemoveSubscriberIDFromURL( window.location.href );
}
);

}

/**
* Gets the subscriber ID for the given email address, storing
* it in the `ck_subscriber_id` cookie if it exists.
Expand Down Expand Up @@ -217,11 +151,8 @@ document.addEventListener(
'DOMContentLoaded',
function () {

if ( convertkit.subscriber_id > 0 ) {
// If the user can be detected as a ConvertKit Subscriber (i.e. their Subscriber ID is in a cookie or the URL),
// update the cookie now.
convertStoreSubscriberIDInCookie( convertkit.subscriber_id );
}
// Removes `ck_subscriber_id` from the URI.
convertKitRemoveSubscriberIDFromURL( window.location.href );

// Store subscriber ID as a cookie from the email address used when a ConvertKit Form is submitted.
document.addEventListener(
Expand Down

0 comments on commit adae90a

Please sign in to comment.