1"use strict"; 2 3/** 4 * Handle Gigya events. 5 * 6 * @link: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/41532ab870b21014bbc5a10ce4041860.html?locale=en-US&q=accounts.addEventHandlers#screen-set-events 7 */ 8(function (drupalSettings) { 9 var handler = { 10 11 onAfterScreenLoad: function (event) { 12 console.log('event-handler.js onAfterScreenLoad', event); 13 // var provider; 14 // var interval = setInterval(function () { 15 // // Handler provider button click 16 // var elProviders = 17 // document.querySelectorAll('span[data-gigya-provider]'); 18 // console.log('providerElement 2', elProviders.length); if 19 // (elProviders.length > 0) { clearInterval(interval); 20 // elProviders.forEach((el) => { el.addEventListener('click', function 21 // (event) { console.log(event); // The event details 22 // console.log(event.target); // The clicked element 23 // console.log('provider', 24 // event.target.parentNode.getAttribute('gigid')); 25 // //gigyaGTM.pushUserSocialLoginStarted(event.target.getAttribute('provider')); 26 // }); }); } }, 3000); 27 28 switch (event.currentScreen) { 29 case 'gigya-register-screen': 30 break; 31 case 'gigya-link-account-screen': 32 // Set to global variable to use in onSubmit or onAfterSubmit event 33 // handler. 34 window.gigyaSocial.accountsSocialLogin = event.response.response.requestParams.accountsSocialLogin; 35 window.gigyaSocial.provider = event.response.response.requestParams.provider; 36 // if(event.response.response.requestParams.accountsSocialLogin){ 37 // provider = event.response.response.requestParams.provider; 38 // } 39 break; 40 } 41 }, onSubmit: function (event) { 42 console.log('event-handler.js onSubmit', event); 43 }, onAfterSubmit: function (event) { 44 var accountType, gigyaId, userType, mediaNetwork; 45 console.log('event-handler.js onAfterSubmit', event); 46 switch (event.screen) { 47 case 'gigya-login-screen': 48 gigyaGTM.pushUserEmailLoginStarted(); 49 break; 50 case 'gigya-register-screen': 51 gigyaGTM.pushUserEmailRegistrationCompletedStepX(1); 52 break; 53 case 'gigya-register-children-info-screen': 54 gigyaGTM.pushUserEmailRegistrationCompletedStepX(2); 55 // If the account do not have to verify the email, then it may be 56 // finished. if (event.response.status !== "FAIL" && 57 // event.response.errorCode !== 206002) { } 58 break; 59 case 'gigya-link-account-screen': 60 gigyaGTM.pushUserSocialLoginAccountLink(window.gigyaSocial.provider); 61 break; 62 } 63 64 /** 65 * @TODO: Consider fire 66 * gigyaGTM.pushUserEmailRegistrationCompletedStepX(3); after user 67 * active the email account. 68 */ 69 }, onError: function (event) { 70 console.log('event-handler.js onError', event); 71 switch (event.screen) { 72 case 'gigya-login-screen': 73 gigyaGTM.pushUserEmailLoginErrorWithLogin(); 74 break; 75 case 'gigya-register-screen': 76 gigyaGTM.pushUserEmailRegistrationErrorWithStepXCompletion(1); 77 break; 78 case 'gigya-register-children-info-screen': 79 gigyaGTM.pushUserEmailRegistrationErrorWithStepXCompletion(2); 80 // If the account do not have to verify the email, then it may be 81 // finished. if (event.response.status !== "FAIL" && 82 // event.response.errorCode !== 206002) { } 83 gigyaGTM.pushUserEmailRegistrationErrorWithCompletedRegistration(); 84 break; 85 case 'gigya-link-account-screen': 86 gigyaGTM.pushUserSocialLoginAccountLink(window.gigyaSocial.provider); 87 break; 88 } 89 }, onAccountsLogin: function (event) { 90 var accountType, gigyaId, userType; 91 console.log('event-handler.js onAccountsLogin', event); 92 if (window.gigyaSocial.provider === '') { 93 accountType = 'email'; 94 gigyaId = event.UID; 95 userType = 'guest'; 96 gigyaGTM.pushUserEmailLoginSuccessfulLogin(accountType,gigyaId,userType); 97 } 98 }, onAccountsLogout: function (event) { 99 console.log('event-handler.js onAccountsLogout', event); 100 }, onSocializeLogin: function (event) { 101 console.log('event-handler.js onSocializeLogin', event); 102 gigyaGTM.pushUserSocialLoginStarted(event.provider); 103 gigyaGTM.pushUserSocialLoginSuccessfulLogin(event.provider); 104 }, onSocializeLogout: function (event) { 105 console.log('event-handler.js onSocializeLogout', event); 106 }, onSocializeError: function (event) { 107 var step, mediaNetwork; 108 console.log('event-handler.js onSocializeError', event); 109 gigyaGTM.pushUserSocialLoginErrorWithLogin(event.response.loginProvider); 110 // gigyaGTM.pushUserSocialRegistrationErrorWithStepXCompletion(event.response.loginProvider); 111 }, onSocializeConnectionAdded: function (event) { 112 console.log('event-handler.js onSocializeConnectionAdded', event); 113 }, onSocializeConnectionRemoved: function (event) { 114 console.log('event-handler.js onSocializeConnectionRemoved', event); 115 let mediaNetwork = event.provider; 116 gigyaGTM.pushUserSocialLoginAccountLink(); 117 } 118 }; 119 120 if (drupalSettings.gigya.enableRaaS) { 121 /** 122 * @link: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/41532ab870b21014bbc5a10ce4041860.html?locale=en-US&q=accounts.addEventHandlers 123 * */ 124 gigyaHelper.addGigyaFunctionCall('accounts.addEventHandlers', { 125 onLogin: handler.onAccountsLogin 126 }); 127 /** 128 * @link https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/41739dca70b21014bbc5a10ce4041860.html?locale=en-US&q=onLogin 129 * onLogin - Fired whenever a user successfully logs in to Gigya. This 130 * may happen, for example, as a result of using the 131 * socialize.showLoginUI method. onLogout - Fired whenever a user logs 132 * out of Gigya, using the socialize.logout call. onConnectionAdded - 133 * Fired whenever a user is connected to a provider ? . This may happen, 134 * for example, as a result of calling one of the following methods: 135 * socialize.addConnection, socialize.showAddConnectionsUI, 136 * socialize.showEditConnectionsUI. onConnectionRemoved - Fired whenever 137 * a user is disconnected from a provider. As above, this event will be 138 * fired regardless of the action that triggered it. onLinkBack - Fired whenever a linkback is detected. Read more about the onLinkback event . 139 */ 140 gigyaHelper.addGigyaFunctionCall('socialize.addEventHandlers', { 141 onLogin: handler.onSocializeLogin, 142 onLogout: handler.onSocializeLogout, 143 onError: handler.onSocializeError, 144 onConnectionAdded: handler.onSocializeConnectionAdded, 145 onConnectionRemoved: handler.onSocializeConnectionRemoved, 146 }); 147 /** 148 * This object should be called in gigya javascript in console.gigya to 149 * handle screenset events. 150 * 151 * Add the script below into screenset event in gigya console javascript 152 * foreach event type. 153 * 154 * var ogilvyGigyaEventHandler = window.ogilvyGigyaEventHandler || 155 * function() { }; ogilvyGigyaEventHandler('onAfterSubmit', event); 156 */ 157 window.ogilvyGigyaEventHandler = window.ogilvyGigyaEventHandler || function (event) { 158 let method = 'on' + event.eventName.charAt(0).toUpperCase() + event.eventName.slice(1); 159 var f = handler[method]; 160 if (typeof f === "function") { 161 f(event); 162 } 163 }; 164 } 165})(drupalSettings);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.