-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguestful-track.min.js
2 lines (2 loc) · 16.3 KB
/
guestful-track.min.js
1
2
/*! guestful-track 0.23.0 2015-06-03 22:06:22 */
!function(a,b){if(!b.__SV){var c,d,e,f;window.mixpanel=b,c=a.createElement("script"),c.type="text/javascript",c.async=!0,c.src=("https:"===a.location.protocol?"https:":"http:")+"//cdn.mxpnl.com/libs/mixpanel-2.2.min.js",d=a.getElementsByTagName("script")[0],b._i=[],b.init=function(a,c,d){function g(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]),a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var h=b;for("undefined"!=typeof d?h=b[d]=[]:d="mixpanel",h.people=h.people||[],h.toString=function(a){var b="mixpanel";return"mixpanel"!==d&&(b+="."+d),a||(b+=" (stub)"),b},h.people.toString=function(){return h.toString(1)+".people (stub)"},e="disable track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config people.set people.set_once people.increment people.append people.track_charge people.clear_charges people.delete_user".split(" "),f=0;f<e.length;f++)g(h,e[f]);b._i.push([a,c,d])},b.__SV=1.2,d.parentNode.insertBefore(c,d)}}(document,window.mixpanel||[]),function(a,b,c){"use strict";var d="YYYY-MM-DDTHH:mm:ss",e=function(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&""!==a[b]&&null!==a[b]&&void 0!==a[b]&&(c[b]=a[b]);return c},f=function(a){return/([a-z]{2,3})(_[a-z]{2,3})?/.exec((a||"en").toLowerCase())[1]},g=function(a){var b=[];return a.isAdmin&&b.push("Admin"),a.isEditor&&b.push("Editor"),a.isManager&&b.push("Manager"),a.isPublisher&&b.push("Publisher"),a.isStaff&&b.push("Staff"),b},h=function(a){if(!a)return"Guestful";switch(a){case"facebook":return"Facebook";case"joomla":return"Joomla";case"wordress":return"Wordpress";case"wix":return"Wix"}return a.charAt(0).toUpperCase()+a.slice(1)},i=function(a){a&&(a.user&&a.user.id?mixpanel.identify(a.user.id):a.guest&&a.guest.id?mixpanel.identify(a.guest.id):a.reservation&&a.reservation.id&&mixpanel.identify(a.reservation.id))},j=function(a,b){var d=c();return{"Event Origin":a,"Website Language":b,"Event Hour":(new Date).getHours(),last_utm_source:d.param("utm_source")||h(d.param("origin")),last_utm_campaign:d.param("utm_campaign"),last_utm_content:d.param("utm_content"),last_utm_term:d.param("utm_term"),last_utm_medium:d.param("utm_medium")}},k=function(c,e,f){f=f||{};var g=f.user||{},h=f.guest||{},i=f.restaurant||{},k=f.publisher||{},l=f.event||{},m=f.product||{},n=f.collection||{},o=f.author||(f.collection||{}).author||{},p=a.extend(j(c,e),{"Authentication Platform":"Guestful","User ID":g.id,"User Name":g.name,"User Email":g.email,"Guestful Event ID":l.id,"Guestful Event Alias":l.alias,"Guestful Event Name":l.name,"List ID":n.id,"List Alias":n.alias,"List Name":n.name,"Author ID":o.id,"Author Alias":o.alias,"Author Name":o.name,"Product Title":m.title,"Product Time":m.time,"Product Day":m.day,"Guest ID":h.id,"Guest Name":h.name,"Guest Email":h.email,"Restaurant ID":i.id,"Restaurant Alias":i.alias,"Restaurant Name":i.name,"Restaurant Region":(i.address||{}).region,"Restaurant Neighborhood":(i.address||{}).neighborhood,"Restaurant City":(i.address||{}).city,"Restaurant Country Code":(i.address||{}).countryCode,"Restaurant State Code":(i.address||{}).stateCode,"Publisher ID":k.id,"Publisher Alias":k.alias,"Publisher Name":k.name});return h.createdDate&&(p["Guest Creation Date"]=b(h.createdDate).utc().format(d)),p},l=function(a,c,e,f){f=f||{};var g=k(c,e,f),h=b(),i=f.restaurant||a.restaurant||{},j=(f.guest||{},b(a.start).tz((i||{}).timeZone));return g["Reservation Origin"]=(a.origin||{}).name,g["Reservation ID"]=a.id,g["Party Size"]=a.partySize,g["Reserved Date"]=j.clone().utc().format(d),g["Reserved Hour"]=j.hour(),g["Days Ahead"]=j.clone().diff(h,"days"),g["Hours Ahead"]=j.clone().diff(h,"hours"),g["Reservation Walkin"]=a.walkin,g};window.Guestful=a.extend(window.Guestful||{},{track:{eventOrigin:"",language:"en",init:function(a,b){b=b||{},this.eventOrigin=b.eventOrigin,this.language=b.language||Guestful.track.language,mixpanel.init(a)},viewOpened:function(a,b){var c=k(Guestful.track.eventOrigin,Guestful.track.language,b);c["View Name"]=a,i(b),b&&b.pageLocation&&(c["Page Location"]=b.pageLocation),mixpanel.track("View Opened",e(c))},viewShared:function(a,b,c){var d=k(Guestful.track.eventOrigin,Guestful.track.language,c);d["Service Name"]=b.service,d["Service Url"]=b.url,d["Service Title"]=b.title,d["View Name"]=a,i(c),mixpanel.track("View Shared",e(d))},error:function(a,b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,d);f["View Name"]=b,f["Event Name"]=c,f["Error Type"]=a,i(d),mixpanel.track("Error",e(f))},reservationCreated:function(a,b,c,d){var f=l(a,Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:c,publisher:d});i({guest:b,reservation:a}),mixpanel.track("Reservation Created",e(f)),mixpanel.people.set({"Last Activity Date":new Date})},reservationConfirmed:function(a,b,c,d){var f=l(a,Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:c,publisher:d});i({guest:b,reservation:a}),mixpanel.track("Reservation Confirmed",e(f)),mixpanel.people.set({"Last Activity Date":new Date})},reservationEdited:function(a,b,c,d){var f=l(a,Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:c,publisher:d});i({guest:b,reservation:a}),mixpanel.track("Reservation Edited",e(f)),mixpanel.people.set({"Last Activity Date":new Date})},reservationCanceled:function(a,b,c,d){var f=l(a,Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:c,publisher:d});i({guest:b,reservation:a}),mixpanel.track("Reservation Canceled",e(f)),mixpanel.people.increment("Cancelation Count"),mixpanel.people.set({"Last Activity Date":new Date})},reservationCompleted:function(a,b,c,d){var f=l(a,Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:c,publisher:d});i({guest:b,reservation:a}),mixpanel.track("Reservation Completed",e(f)),mixpanel.people.set({"Last Activity Date":new Date})},reservationNoShow:function(a,b,c,d){var f=l(a,Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:c,publisher:d});i({guest:b,reservation:a}),mixpanel.people.increment("NoShow Count"),mixpanel.track("Reservation NoShow",e(f)),mixpanel.people.set({"Last Activity Date":new Date})},reservationReviewed:function(b,c,d,f,g,h){var j=l(c,Guestful.track.eventOrigin,Guestful.track.language,{guest:d,restaurant:f,publisher:g});j.Liked=b>=.5,i({guest:d,reservation:c}),mixpanel.people.set({"Last Activity Date":new Date,"Last Review Date":new Date}),mixpanel.people.increment("Reviewed Count"),mixpanel.people.append({"Reviewed Restaurant IDS":f.id,"Reviewed Restaurant Aliases":f.alias,"Reviewed Restaurant Names":f.name}),mixpanel.track("Reservation Reviewed",e(j),h||a.noop)},guestLogin:function(b,c,d){if(!b)return(d||a.noop)();c=c||{};var g=c.restaurant||{},h=c.publisher||{};i({guest:b}),mixpanel.people.set(e({$first_name:b.firstName,$last_name:b.lastName,$name:b.name,$phone:b.phoneNumber,$email:b.email,$created:new Date(b.createdDate),"Facebook ID":b.facebookId,Gender:b.gender,"Last Authentication Date":new Date,"Last Authentication Platform":b.facebookAuth?"Facebook":"Guestful",Language:f(b.locale),"Time Zone":b.timeZone,Roles:["Guest"],"Last Restaurant Region":(g.address||{}).region,"Last Restaurant Neighborhood":(g.address||{}).neighborhood,"Last Restaurant City":(g.address||{}).city,"Last Restaurant Country Code":(g.address||{}).countryCode,"Last Restaurant State Code":(g.address||{}).stateCode}),function(){mixpanel.people.set_once(e({"First Authentication Date":new Date,"First Authentication Platform":b.facebookAuth?"Facebook":"Guestful"})),mixpanel.track("Guest Login",e(k(Guestful.track.eventOrigin,Guestful.track.language,{guest:b,restaurant:g,publisher:h}))),mixpanel.people.set({"Last Activity Date":new Date}),(d||a.noop)()})},guestLogout:function(a,b){if(a){b=b||{};var c=b.restaurant||{},d=b.publisher||{},f=k(Guestful.track.eventOrigin,Guestful.track.language,{guest:a,restaurant:c,publisher:d});i({guest:a}),mixpanel.track("Guest Logout",e(f)),mixpanel.people.set({"Last Activity Date":new Date})}},guestSubscribed:function(a,b,c){var d=k(Guestful.track.eventOrigin,Guestful.track.language,{guest:a,restaurant:b});d["Guest Language"]=a.lang,d["Page Location"]=c,i({guest:a}),mixpanel.track("Guest Opt-In",e(d))},guestEdited:function(b,c,d){i({guest:b}),mixpanel.track("Guest Edited",e(k(Guestful.track.eventOrigin,Guestful.track.language,{guest:b}))),mixpanel.people.set({"Last Activity Date":new Date}),(d||a.noop)()},eventBooked:function(a,b,c,d){mixpanel.track("Event Booking",e(k(Guestful.track.eventOrigin,Guestful.track.language,{event:a,restaurant:c,product:b,guest:d.guest||{}})))},eventBack:function(a,b,c,d){mixpanel.track("Event Booking Back",e(k(Guestful.track.eventOrigin,Guestful.track.language,{event:a,restaurant:c,product:b,guest:d.guest||{}})))},showMoreProducts:function(a,b,c){mixpanel.track("Event Loading More",e(k(Guestful.track.eventOrigin,Guestful.track.language,{event:a,restaurant:b,guest:c.guest||{}})))},eventCheckoutStarted:function(a,b,c,d){mixpanel.track("Checkout Started",e(k(Guestful.track.eventOrigin,Guestful.track.language,{event:a,restaurant:c,product:b,guest:d.guest||{}})))},installedWidget:function(a,b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:a,restaurant:b});d&&(f["Event Origin"]=d),f.Platform=c,i({user:a}),mixpanel.track("Widget Installed",e(f))},contactAdded:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b,restaurant:c});i({user:b}),mixpanel.track("Contact Added",e(f),d||a.noop)},contactEdited:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b,restaurant:c});i({user:b}),mixpanel.track("Contact Edited",e(f),d||a.noop)},contactRemoved:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b,restaurant:c});i({user:b}),mixpanel.track("Contact Removed",e(f),d||a.noop)},serviceAdded:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});f.Days=c.recurrence.daysOfWeek,i({user:b}),mixpanel.track("Service Added",e(f),d||a.noop)},serviceEdited:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});f.Days=c.recurrence.daysOfWeek,i({user:b}),mixpanel.track("Service Edited",e(f),d||a.noop)},serviceRemoved:function(b,c){var d=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});i({user:b}),mixpanel.track("Service Removed",e(d),c||a.noop)},noteAdded:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});f.Days=c.recurrence.daysOfWeek,i({user:b}),mixpanel.track("Note Added",e(f),d||a.noop)},noteEdited:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});f.Days=c.recurrence.daysOfWeek,i({user:b}),mixpanel.track("Note Edited",e(f),d||a.noop)},noteRemoved:function(b,c){var d=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});i({user:b}),mixpanel.track("Note Removed",e(d),c||a.noop)},restaurantCreated:function(b,c,d){i({user:b}),mixpanel.people.set(e({Roles:g(b),"Staffed Restaurant Aliases":a.map(b.restaurants||[],function(a){return a.alias}),"Staffed Restaurant IDS":a.map(b.restaurants||[],function(a){return a.id}),"Staffed Restaurant Names":a.map(b.restaurants||[],function(a){return a.name}),"Managed Restaurant Aliases":a.map(b.managedRestaurants||[],function(a){return a.alias}),"Managed Restaurant IDS":a.map(b.managedRestaurants||[],function(a){return a.id}),"Managed Restaurant Names":a.map(b.managedRestaurants||[],function(a){return a.name})}),function(){mixpanel.track("Restaurant Created",e(k(Guestful.track.eventOrigin,Guestful.track.language,{user:b,restaurant:c})),d||a.noop)})},restaurantEdited:function(b,c,d){var f=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b,restaurant:c});i({user:b}),mixpanel.track("Restaurant Edited",e(f),d||a.noop)},passwordResetRequested:function(a){var b=k(Guestful.track.eventOrigin,Guestful.track.language);b["User Email"]=a,mixpanel.track("Password Reset Requested",e(b))},userLoaded:function(b){i({user:b}),mixpanel.people.set(e({$first_name:b.firstName,$last_name:b.lastName,$name:b.name,$phone:b.phoneNumber,$email:b.email,$created:new Date(b.createdDate),Gender:b.gender,"Last Authentication Date":new Date,"Last Authentication Platform":"Guestful",Language:f(b.locale),Roles:g(b),"Staffed Restaurant Aliases":a.map(b.restaurants||[],function(a){return a.alias}),"Staffed Restaurant IDS":a.map(b.restaurants||[],function(a){return a.id}),"Staffed Restaurant Names":a.map(b.restaurants||[],function(a){return a.name}),"Managed Restaurant Aliases":a.map(b.managedRestaurants||[],function(a){return a.alias}),"Managed Restaurant IDS":a.map(b.managedRestaurants||[],function(a){return a.id}),"Managed Restaurant Names":a.map(b.managedRestaurants||[],function(a){return a.name}),"Time Zone":b.timeZone}))},userLogged:function(b,c){i({user:b}),mixpanel.people.set(e({$first_name:b.firstName,$last_name:b.lastName,$name:b.name,$phone:b.phoneNumber,$email:b.email,$created:new Date(b.createdDate),Gender:b.gender,"Last Authentication Platform":"Guestful","Last Authentication Date":new Date,Language:f(b.locale),Roles:g(b),"Staffed Restaurant Aliases":a.map(b.restaurants||[],function(a){return a.alias}),"Staffed Restaurant IDS":a.map(b.restaurants||[],function(a){return a.id}),"Staffed Restaurant Names":a.map(b.restaurants||[],function(a){return a.name}),"Managed Restaurant Aliases":a.map(b.managedRestaurants||[],function(a){return a.alias}),"Managed Restaurant IDS":a.map(b.managedRestaurants||[],function(a){return a.id}),"Managed Restaurant Names":a.map(b.managedRestaurants||[],function(a){return a.name}),"Time Zone":b.timeZone}),function(){mixpanel.people.set_once(e({"First Authentication Date":new Date,"First Authentication Platform":"Guestful"}));var d=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});mixpanel.track("User Login",e(d),c||a.noop)})},userRegistered:function(b){i({user:b}),mixpanel.people.set(e({$first_name:b.firstName,$last_name:b.lastName,$name:b.name,$phone:b.phoneNumber,$email:b.email,$created:new Date(b.createdDate),"Last Authentication Platform":"Guestful","Last Authentication Date":new Date,Gender:b.gender,Language:f(b.locale),"Time Zone":b.timeZone,Roles:g(b),"Staffed Restaurant Aliases":a.map(b.restaurants||[],function(a){return a.alias}),"Staffed Restaurant IDS":a.map(b.restaurants||[],function(a){return a.id}),"Staffed Restaurant Names":a.map(b.restaurants||[],function(a){return a.name}),"Managed Restaurant Aliases":a.map(b.managedRestaurants||[],function(a){return a.alias}),"Managed Restaurant IDS":a.map(b.managedRestaurants||[],function(a){return a.id}),"Managed Restaurant Names":a.map(b.managedRestaurants||[],function(a){return a.name})}));var c=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});mixpanel.track("User Registered",e(c))},userEdited:function(b,c){i({user:b}),mixpanel.people.set(e({$first_name:b.firstName,$last_name:b.lastName,$name:b.name,$phone:b.phoneNumber,$email:b.email,$created:new Date(b.createdDate),"Facebook ID":b.facebookId,Gender:b.gender,Language:f(b.locale),Roles:g(b),"Staffed Restaurant Aliases":a.map(b.restaurants||[],function(a){return a.alias}),"Staffed Restaurant IDS":a.map(b.restaurants||[],function(a){return a.id}),"Staffed Restaurant Names":a.map(b.restaurants||[],function(a){return a.name}),"Managed Restaurant Aliases":a.map(b.managedRestaurants||[],function(a){return a.alias}),"Managed Restaurant IDS":a.map(b.managedRestaurants||[],function(a){return a.id}),"Managed Restaurant Names":a.map(b.managedRestaurants||[],function(a){return a.name}),"Time Zone":b.timeZone}),function(){var d=k(Guestful.track.eventOrigin,Guestful.track.language,{user:b});mixpanel.track("User Edited",e(d),c||a.noop)})},searchTerm:function(b,c,d,f){b=b||{};var g={author:{"Author ID":b.id,"Author Alias":b.alias,"Author Name":b.name},restaurant:{"Restaurant ID":b.id,"Restaurant Alias":b.alias,"Restaurant Name":b.name},collection:{"List ID":b.id,"List Alias":b.alias,"List Name":b.name}};mixpanel.track("Search",e(a.extend({"No Result":!b.name,Term:c},j(Guestful.track.eventOrigin,Guestful.track.language),g[b.type]||{}),f||a.noop))},searchNotFound:function(b){var c=j(Guestful.track.eventOrigin,Guestful.track.language);c["No Result"]=!0,mixpanel.track("Search",e(c),b||a.noop)},voted:function(a,b){var c=k(Guestful.track.eventOrigin,Guestful.track.language,{guest:a});c.Platform=b,mixpanel.track("Vote",e(c))},links:function(a,b){mixpanel.track_links(a,b,function(a){var b=j(Guestful.track.eventOrigin,Guestful.track.language);return b.Link=a.href,b.Location=document.location.href,b["Website Language"]=Guestful.track.language,e(b)})}}})}(jQuery,moment,purl);