posthog-js
Advanced tools
Comparing version 1.223.4 to 1.223.5
@@ -1,2 +0,2 @@ | ||
!function(){"use strict";var e="undefined"!=typeof window?window:void 0,r="undefined"!=typeof globalThis?globalThis:e,n=Array.prototype.forEach,t=null==r?void 0:r.navigator,o=null==r?void 0:r.document,i=null==r?void 0:r.location;null==r||r.fetch,null!=r&&r.XMLHttpRequest&&"withCredentials"in new r.XMLHttpRequest&&r.XMLHttpRequest,null==r||r.AbortController;var a,s=null==t?void 0:t.userAgent,l=null!=e?e:{};function u(e,r){return-1!==e.indexOf(r)}!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(a||(a={}));var c=Array.isArray,p=Object.prototype,f=p.hasOwnProperty,d=p.toString,g=c||function(e){return"[object Array]"===d.call(e)},v=e=>void 0===e,h=e=>null===e,m=e=>"[object Number]"==d.call(e),w={DEBUG:!1,LIB_VERSION:"1.223.4"},_=r=>{var n={_log:function(n){if(e&&l.POSTHOG_DEBUG&&!v(e.console)&&e.console){for(var t=("__rrweb_original__"in e.console[n]?e.console[n].__rrweb_original__:e.console[n]),o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];t(r,...i)}},info:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n._log("log",...r)},warn:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n._log("warn",...r)},error:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n._log("error",...r)},critical:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];console.error(r,...n)},uninitializedWarning:e=>{n.error("You must initialize PostHog before calling ".concat(e))},createLogger:e=>_("".concat(r," ").concat(e))};return n},b=_("[PostHog.js]"),P={};function $(e,r,t){if(g(e))if(n&&e.forEach===n)e.forEach(r,t);else if("length"in e&&e.length===+e.length)for(var o=0,i=e.length;o<i;o++)if(o in e&&r.call(t,e[o],o)===P)return}function y(e,r,n){if(!v(t=e)&&!h(t)){var t;if(g(e))return $(e,r,n);if((e=>e instanceof FormData)(e)){for(var o of e.entries())if(r.call(n,o[1],o[0])===P)return}else for(var i in e)if(f.call(e,i)&&r.call(n,e[i],i)===P)return}}var E=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return $(n,(function(r){for(var n in r)void 0!==r[n]&&(e[n]=r[n])})),e},x=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return $(n,(function(r){$(r,(function(r){e.push(r)}))})),e},O=function(e){var r={};return y(e,(function(e,n){var t;t=e,"[object String]"==d.call(t)&&e.length>0&&(r[n]=e)})),r},R=e=>{var r=null==o?void 0:o.createElement("a");return v(r)?null:(r.href=e,r)},k=function(e,r){for(var n,t=((e.split("#")[0]||"").split("?")[1]||"").split("&"),o=0;o<t.length;o++){var i=t[o].split("=");if(i[0]===r){n=i;break}}if(!g(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch(e){b.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},S=function(e,r,n){if(!e||!r||!r.length)return e;for(var t=e.split("#"),o=t[0]||"",i=t[1],a=o.split("?"),s=a[1],l=a[0],u=(s||"").split("&"),c=[],p=0;p<u.length;p++){var f=u[p].split("=");g(f)&&(r.includes(f[0])?c.push(f[0]+"="+n):c.push(u[p]))}var d=l;return null!=s&&(d+="?"+c.join("&")),null!=i&&(d+="#"+i),d},D="Mobile",B="iOS",I="Android",A="Tablet",j=I+" "+A,F="iPad",T="Apple",C=T+" Watch",M="Safari",L="BlackBerry",z="Samsung",U=z+"Browser",W=z+" Internet",N="Chrome",H=N+" OS",X=N+" "+B,V="Internet Explorer",q=V+" "+D,G="Opera",K=G+" Mini",Z="Edge",Q="Microsoft "+Z,J="Firefox",Y=J+" "+B,ee="Nintendo",re="PlayStation",ne="Xbox",te=I+" "+D,oe=D+" "+M,ie="Windows",ae=ie+" Phone",se="Nokia",le="Ouya",ue="Generic",ce=ue+" "+D.toLowerCase(),pe=ue+" "+A.toLowerCase(),fe="Konqueror",de="(\\d+(\\.\\d+)?)",ge=new RegExp("Version/"+de),ve=new RegExp(ne,"i"),he=new RegExp(re+" \\w+","i"),me=new RegExp(ee+" \\w+","i"),we=new RegExp(L+"|PlayBook|BB10","i"),_e={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var be=(e,r)=>r&&u(r,T)||function(e){return u(e,M)&&!u(e,N)&&!u(e,I)}(e),Pe=function(e,r){return r=r||"",u(e," OPR/")&&u(e,"Mini")?K:u(e," OPR/")?G:we.test(e)?L:u(e,"IE"+D)||u(e,"WPDesktop")?q:u(e,U)?W:u(e,Z)||u(e,"Edg/")?Q:u(e,"FBIOS")?"Facebook "+D:u(e,"UCWEB")||u(e,"UCBrowser")?"UC Browser":u(e,"CriOS")?X:u(e,"CrMo")||u(e,N)?N:u(e,I)&&u(e,M)?te:u(e,"FxiOS")?Y:u(e.toLowerCase(),fe.toLowerCase())?fe:be(e,r)?u(e,D)?oe:M:u(e,J)?J:u(e,"MSIE")||u(e,"Trident/")?V:u(e,"Gecko")?J:""},$e={[q]:[new RegExp("rv:"+de)],[Q]:[new RegExp(Z+"?\\/"+de)],[N]:[new RegExp("("+N+"|CrMo)\\/"+de)],[X]:[new RegExp("CriOS\\/"+de)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+de)],[M]:[ge],[oe]:[ge],[G]:[new RegExp("(Opera|OPR)\\/"+de)],[J]:[new RegExp(J+"\\/"+de)],[Y]:[new RegExp("FxiOS\\/"+de)],[fe]:[new RegExp("Konqueror[:/]?"+de,"i")],[L]:[new RegExp(L+" "+de),ge],[te]:[new RegExp("android\\s"+de,"i")],[W]:[new RegExp(U+"\\/"+de)],[V]:[new RegExp("(rv:|MSIE )"+de)],Mozilla:[new RegExp("rv:"+de)]},ye=[[new RegExp(ne+"; "+ne+" (.*?)[);]","i"),e=>[ne,e&&e[1]||""]],[new RegExp(ee,"i"),[ee,""]],[new RegExp(re,"i"),[re,""]],[we,[L,""]],[new RegExp(ie,"i"),(e,r)=>{if(/Phone/.test(r)||/WPDesktop/.test(r))return[ae,""];if(new RegExp(D).test(r)&&!/IEMobile\b/.test(r))return[ie+" "+D,""];var n=/Windows NT ([0-9.]+)/i.exec(r);if(n&&n[1]){var t=n[1],o=_e[t]||"";return/arm/i.test(r)&&(o="RT"),[ie,o]}return[ie,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var r=[e[3],e[4],e[5]||"0"];return[B,r.join(".")]}return[B,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var r="";return e&&e.length>=3&&(r=v(e[2])?e[3]:e[2]),["watchOS",r]}],[new RegExp("("+I+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+I+")","i"),e=>{if(e&&e[2]){var r=[e[2],e[3],e[4]||"0"];return[I,r.join(".")]}return[I,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var r=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];r[1]=n.join(".")}return r}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[H,""]],[/Linux|debian/i,["Linux",""]]],Ee=function(e){return me.test(e)?ee:he.test(e)?re:ve.test(e)?ne:new RegExp(le,"i").test(e)?le:new RegExp("("+ae+"|WPDesktop)","i").test(e)?ae:/iPad/.test(e)?F:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?C:we.test(e)?L:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(se,"i").test(e)?se:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(D).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?I:j:I:new RegExp("(pda|"+D+")","i").test(e)?ce:new RegExp(A,"i").test(e)&&!new RegExp(A+" pc","i").test(e)?pe:""},xe="https?://(.*)",Oe=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],Re=x(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Oe),ke=["$app_build","$app_name","$app_namespace","$app_version","$browser","$browser_version","$device_type","$current_url","$pathname","$os","$os_name","$os_version","$referring_domain","$referrer"],Se="<masked>",De={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:r,customPersonalDataProperties:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!o)return{};var t=r?x([],Oe,n||[]):[];return this._campaignParamsFromUrl(S(o.URL,t,Se),e)},_campaignParamsFromUrl:function(e,r){var n=Re.concat(r||[]),t={};return y(n,(function(r){var n=k(e,r);t[r]=n||null})),t},_searchEngine:function(e){return e?0===e.search(xe+"google.([^/?]*)")?"google":0===e.search(xe+"bing.com")?"bing":0===e.search(xe+"yahoo.com")?"yahoo":0===e.search(xe+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var r=De._searchEngine(e),n="yahoo"!=r?"q":"p",t={};if(!h(r)){t.$search_engine=r;var i=o?k(o.referrer,n):"";i.length&&(t.ph_keyword=i)}return t},searchInfo:function(){var e=null==o?void 0:o.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Pe,browserVersion:function(e,r){var n=Pe(e,r),t=$e[n];if(v(t))return null;for(var o=0;o<t.length;o++){var i=t[o],a=e.match(i);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return"string"==typeof e?e.split("-")[0]:void 0},os:function(e){for(var r=0;r<ye.length;r++){var[n,t]=ye[r],o=n.exec(e),i=o&&("function"==typeof t?t(o,e):t);if(i)return i}return["",""]},device:Ee,deviceType:function(e){var r=Ee(e);return r===F||r===j||"Kobo"===r||"Kindle Fire"===r||r===pe?A:r===ee||r===ne||r===re||r===le?"Console":r===C?"Wearable":r?D:"Desktop"},referrer:function(){return(null==o?void 0:o.referrer)||"$direct"},referringDomain:function(){var e;return null!=o&&o.referrer&&(null===(e=R(o.referrer))||void 0===e?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e?x([],Oe,r||[]):[],t=null==i?void 0:i.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:t?S(t,n,Se):void 0}},personPropsFromInfo:function(e){var r,{r:n,u:t}=e,o={$referrer:n,$referring_domain:null==n?void 0:"$direct"==n?"$direct":null===(r=R(n))||void 0===r?void 0:r.host};if(t){o.$current_url=t;var i=R(t);o.$host=null==i?void 0:i.host,o.$pathname=null==i?void 0:i.pathname;var a=this._campaignParamsFromUrl(t);E(o,a)}if(n){var s=this._searchInfoFromReferrer(n);E(o,s)}return o},initialPersonPropsFromInfo:function(e){var r=this.personPropsFromInfo(e),n={};return y(r,(function(e,r){var t;n["$initial_".concat((t=r,t.replace(/^\$/,"")))]=e})),n},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}},timezoneOffset:function(){try{return(new Date).getTimezoneOffset()}catch(e){return}},properties:function(){var{maskPersonalDataProperties:r,customPersonalDataProperties:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!s)return{};var t=r?x([],Oe,n||[]):[],[o,a]=De.os(s);return E(O({$os:o,$os_version:a,$browser:De.browser(s,navigator.vendor),$device:De.device(s),$device_type:De.deviceType(s),$timezone:De.timezone(),$timezone_offset:De.timezoneOffset()}),{$current_url:S(null==i?void 0:i.href,t,Se),$host:null==i?void 0:i.host,$pathname:null==i?void 0:i.pathname,$raw_user_agent:s.length>1e3?s.substring(0,997)+"...":s,$browser_version:De.browserVersion(s,navigator.vendor),$browser_language:De.browserLanguage(),$browser_language_prefix:De.browserLanguagePrefix(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:"web",$lib_version:w.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!s)return{};var[e,r]=De.os(s);return E(O({$os:e,$os_version:r,$browser:De.browser(s,navigator.vendor)}),{$browser_version:De.browserVersion(s,navigator.vendor)})}};function Be(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function Ie(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?Be(Object(n),!0).forEach((function(r){Ae(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Ae(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function je(e,r,n,t,o){return m(e)?e>n?n:e<r?r:e:je(n,r,n)}function Fe(e,r){return[...e||[],...g(r)?r:[r]]}function Te(e,r){return(v(e)?1:e)*r}function Ce(e,r){return function(e){for(var r=0,n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n),r|=0;return Math.abs(r)}(e)%100<je(100*r,0,100)}var Me=Object.freeze({__proto__:null,printAndDropEverything:e=>(console.log("Would have sent event:",e),null),sampleByDistinctId:function(e){return r=>r&&Ce(r.properties.distinct_id,e)?Ie(Ie({},r),{},{properties:Ie(Ie({},r.properties),{},{$sample_type:["sampleByDistinctId"],$sample_threshold:e})}):null},sampleByEvent:function(e,r){return n=>{var t,o,i;return n?u(e,n.event)?100*Math.random()<je(100*r,0,100)?Ie(Ie({},n),{},{properties:Ie(Ie({},n.properties),{},{$sample_type:Fe(null===(t=n.properties)||void 0===t?void 0:t.$sample_type,"sampleByEvent"),$sample_threshold:Te(null===(o=n.properties)||void 0===o?void 0:o.$sample_threshold,r),$sampled_events:Fe(null===(i=n.properties)||void 0===i?void 0:i.$sampled_events,e)})}):null:n:null}},sampleBySessionId:function(e){return r=>r&&Ce(r.properties.$session_id,e)?Ie(Ie({},r),{},{properties:Ie(Ie({},r.properties),{},{$sample_type:Fe(r.properties.$sample_type,"sampleBySessionId"),$sample_threshold:Te(r.properties.$sample_threshold,e)})}):null},setAllPersonProfilePropertiesAsPersonPropertiesForFlags:e=>{var r=E({},De.properties({maskPersonalDataProperties:e.config.mask_personal_data_properties,customPersonalDataProperties:e.config.custom_personal_data_properties}),De.campaignParams({customTrackedParams:e.config.custom_campaign_params,maskPersonalDataProperties:e.config.mask_personal_data_properties,customPersonalDataProperties:e.config.custom_personal_data_properties}),De.referrerInfo()),n={};y(r,(function(e,r){(u(Re,r)||u(ke,r))&&(n[r]=e)})),e.setPersonPropertiesForFlags(n)}});l.posthogCustomizations=Me}(); | ||
!function(){"use strict";var e="undefined"!=typeof window?window:void 0,r="undefined"!=typeof globalThis?globalThis:e,n=Array.prototype.forEach,t=null==r?void 0:r.navigator,o=null==r?void 0:r.document,i=null==r?void 0:r.location;null==r||r.fetch,null!=r&&r.XMLHttpRequest&&"withCredentials"in new r.XMLHttpRequest&&r.XMLHttpRequest,null==r||r.AbortController;var a,s=null==t?void 0:t.userAgent,l=null!=e?e:{};function u(e,r){return-1!==e.indexOf(r)}!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(a||(a={}));var c=Array.isArray,p=Object.prototype,f=p.hasOwnProperty,d=p.toString,g=c||function(e){return"[object Array]"===d.call(e)},v=e=>void 0===e,h=e=>null===e,m=e=>"[object Number]"==d.call(e),w={DEBUG:!1,LIB_VERSION:"1.223.5"},_=r=>{var n={_log:function(n){if(e&&l.POSTHOG_DEBUG&&!v(e.console)&&e.console){for(var t=("__rrweb_original__"in e.console[n]?e.console[n].__rrweb_original__:e.console[n]),o=arguments.length,i=new Array(o>1?o-1:0),a=1;a<o;a++)i[a-1]=arguments[a];t(r,...i)}},info:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n._log("log",...r)},warn:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n._log("warn",...r)},error:function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];n._log("error",...r)},critical:function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];console.error(r,...n)},uninitializedWarning:e=>{n.error("You must initialize PostHog before calling ".concat(e))},createLogger:e=>_("".concat(r," ").concat(e))};return n},b=_("[PostHog.js]"),P={};function $(e,r,t){if(g(e))if(n&&e.forEach===n)e.forEach(r,t);else if("length"in e&&e.length===+e.length)for(var o=0,i=e.length;o<i;o++)if(o in e&&r.call(t,e[o],o)===P)return}function y(e,r,n){if(!v(t=e)&&!h(t)){var t;if(g(e))return $(e,r,n);if((e=>e instanceof FormData)(e)){for(var o of e.entries())if(r.call(n,o[1],o[0])===P)return}else for(var i in e)if(f.call(e,i)&&r.call(n,e[i],i)===P)return}}var E=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return $(n,(function(r){for(var n in r)void 0!==r[n]&&(e[n]=r[n])})),e},x=function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++)n[t-1]=arguments[t];return $(n,(function(r){$(r,(function(r){e.push(r)}))})),e},O=function(e){var r={};return y(e,(function(e,n){var t;t=e,"[object String]"==d.call(t)&&e.length>0&&(r[n]=e)})),r},R=e=>{var r=null==o?void 0:o.createElement("a");return v(r)?null:(r.href=e,r)},k=function(e,r){for(var n,t=((e.split("#")[0]||"").split("?")[1]||"").split("&"),o=0;o<t.length;o++){var i=t[o].split("=");if(i[0]===r){n=i;break}}if(!g(n)||n.length<2)return"";var a=n[1];try{a=decodeURIComponent(a)}catch(e){b.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},S=function(e,r,n){if(!e||!r||!r.length)return e;for(var t=e.split("#"),o=t[0]||"",i=t[1],a=o.split("?"),s=a[1],l=a[0],u=(s||"").split("&"),c=[],p=0;p<u.length;p++){var f=u[p].split("=");g(f)&&(r.includes(f[0])?c.push(f[0]+"="+n):c.push(u[p]))}var d=l;return null!=s&&(d+="?"+c.join("&")),null!=i&&(d+="#"+i),d},D="Mobile",B="iOS",I="Android",A="Tablet",j=I+" "+A,F="iPad",T="Apple",C=T+" Watch",M="Safari",L="BlackBerry",z="Samsung",U=z+"Browser",W=z+" Internet",N="Chrome",H=N+" OS",X=N+" "+B,V="Internet Explorer",q=V+" "+D,G="Opera",K=G+" Mini",Z="Edge",Q="Microsoft "+Z,J="Firefox",Y=J+" "+B,ee="Nintendo",re="PlayStation",ne="Xbox",te=I+" "+D,oe=D+" "+M,ie="Windows",ae=ie+" Phone",se="Nokia",le="Ouya",ue="Generic",ce=ue+" "+D.toLowerCase(),pe=ue+" "+A.toLowerCase(),fe="Konqueror",de="(\\d+(\\.\\d+)?)",ge=new RegExp("Version/"+de),ve=new RegExp(ne,"i"),he=new RegExp(re+" \\w+","i"),me=new RegExp(ee+" \\w+","i"),we=new RegExp(L+"|PlayBook|BB10","i"),_e={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var be=(e,r)=>r&&u(r,T)||function(e){return u(e,M)&&!u(e,N)&&!u(e,I)}(e),Pe=function(e,r){return r=r||"",u(e," OPR/")&&u(e,"Mini")?K:u(e," OPR/")?G:we.test(e)?L:u(e,"IE"+D)||u(e,"WPDesktop")?q:u(e,U)?W:u(e,Z)||u(e,"Edg/")?Q:u(e,"FBIOS")?"Facebook "+D:u(e,"UCWEB")||u(e,"UCBrowser")?"UC Browser":u(e,"CriOS")?X:u(e,"CrMo")||u(e,N)?N:u(e,I)&&u(e,M)?te:u(e,"FxiOS")?Y:u(e.toLowerCase(),fe.toLowerCase())?fe:be(e,r)?u(e,D)?oe:M:u(e,J)?J:u(e,"MSIE")||u(e,"Trident/")?V:u(e,"Gecko")?J:""},$e={[q]:[new RegExp("rv:"+de)],[Q]:[new RegExp(Z+"?\\/"+de)],[N]:[new RegExp("("+N+"|CrMo)\\/"+de)],[X]:[new RegExp("CriOS\\/"+de)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+de)],[M]:[ge],[oe]:[ge],[G]:[new RegExp("(Opera|OPR)\\/"+de)],[J]:[new RegExp(J+"\\/"+de)],[Y]:[new RegExp("FxiOS\\/"+de)],[fe]:[new RegExp("Konqueror[:/]?"+de,"i")],[L]:[new RegExp(L+" "+de),ge],[te]:[new RegExp("android\\s"+de,"i")],[W]:[new RegExp(U+"\\/"+de)],[V]:[new RegExp("(rv:|MSIE )"+de)],Mozilla:[new RegExp("rv:"+de)]},ye=[[new RegExp(ne+"; "+ne+" (.*?)[);]","i"),e=>[ne,e&&e[1]||""]],[new RegExp(ee,"i"),[ee,""]],[new RegExp(re,"i"),[re,""]],[we,[L,""]],[new RegExp(ie,"i"),(e,r)=>{if(/Phone/.test(r)||/WPDesktop/.test(r))return[ae,""];if(new RegExp(D).test(r)&&!/IEMobile\b/.test(r))return[ie+" "+D,""];var n=/Windows NT ([0-9.]+)/i.exec(r);if(n&&n[1]){var t=n[1],o=_e[t]||"";return/arm/i.test(r)&&(o="RT"),[ie,o]}return[ie,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var r=[e[3],e[4],e[5]||"0"];return[B,r.join(".")]}return[B,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var r="";return e&&e.length>=3&&(r=v(e[2])?e[3]:e[2]),["watchOS",r]}],[new RegExp("("+I+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+I+")","i"),e=>{if(e&&e[2]){var r=[e[2],e[3],e[4]||"0"];return[I,r.join(".")]}return[I,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var r=["Mac OS X",""];if(e&&e[1]){var n=[e[1],e[2],e[3]||"0"];r[1]=n.join(".")}return r}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[H,""]],[/Linux|debian/i,["Linux",""]]],Ee=function(e){return me.test(e)?ee:he.test(e)?re:ve.test(e)?ne:new RegExp(le,"i").test(e)?le:new RegExp("("+ae+"|WPDesktop)","i").test(e)?ae:/iPad/.test(e)?F:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?C:we.test(e)?L:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(se,"i").test(e)?se:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(D).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?I:j:I:new RegExp("(pda|"+D+")","i").test(e)?ce:new RegExp(A,"i").test(e)&&!new RegExp(A+" pc","i").test(e)?pe:""},xe="https?://(.*)",Oe=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],Re=x(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Oe),ke=["$app_build","$app_name","$app_namespace","$app_version","$browser","$browser_version","$device_type","$current_url","$pathname","$os","$os_name","$os_version","$referring_domain","$referrer"],Se="<masked>",De={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:r,customPersonalDataProperties:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!o)return{};var t=r?x([],Oe,n||[]):[];return this._campaignParamsFromUrl(S(o.URL,t,Se),e)},_campaignParamsFromUrl:function(e,r){var n=Re.concat(r||[]),t={};return y(n,(function(r){var n=k(e,r);t[r]=n||null})),t},_searchEngine:function(e){return e?0===e.search(xe+"google.([^/?]*)")?"google":0===e.search(xe+"bing.com")?"bing":0===e.search(xe+"yahoo.com")?"yahoo":0===e.search(xe+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var r=De._searchEngine(e),n="yahoo"!=r?"q":"p",t={};if(!h(r)){t.$search_engine=r;var i=o?k(o.referrer,n):"";i.length&&(t.ph_keyword=i)}return t},searchInfo:function(){var e=null==o?void 0:o.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Pe,browserVersion:function(e,r){var n=Pe(e,r),t=$e[n];if(v(t))return null;for(var o=0;o<t.length;o++){var i=t[o],a=e.match(i);if(a)return parseFloat(a[a.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return"string"==typeof e?e.split("-")[0]:void 0},os:function(e){for(var r=0;r<ye.length;r++){var[n,t]=ye[r],o=n.exec(e),i=o&&("function"==typeof t?t(o,e):t);if(i)return i}return["",""]},device:Ee,deviceType:function(e){var r=Ee(e);return r===F||r===j||"Kobo"===r||"Kindle Fire"===r||r===pe?A:r===ee||r===ne||r===re||r===le?"Console":r===C?"Wearable":r?D:"Desktop"},referrer:function(){return(null==o?void 0:o.referrer)||"$direct"},referringDomain:function(){var e;return null!=o&&o.referrer&&(null===(e=R(o.referrer))||void 0===e?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e?x([],Oe,r||[]):[],t=null==i?void 0:i.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:t?S(t,n,Se):void 0}},personPropsFromInfo:function(e){var r,{r:n,u:t}=e,o={$referrer:n,$referring_domain:null==n?void 0:"$direct"==n?"$direct":null===(r=R(n))||void 0===r?void 0:r.host};if(t){o.$current_url=t;var i=R(t);o.$host=null==i?void 0:i.host,o.$pathname=null==i?void 0:i.pathname;var a=this._campaignParamsFromUrl(t);E(o,a)}if(n){var s=this._searchInfoFromReferrer(n);E(o,s)}return o},initialPersonPropsFromInfo:function(e){var r=this.personPropsFromInfo(e),n={};return y(r,(function(e,r){var t;n["$initial_".concat((t=r,t.replace(/^\$/,"")))]=e})),n},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}},timezoneOffset:function(){try{return(new Date).getTimezoneOffset()}catch(e){return}},properties:function(){var{maskPersonalDataProperties:r,customPersonalDataProperties:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!s)return{};var t=r?x([],Oe,n||[]):[],[o,a]=De.os(s);return E(O({$os:o,$os_version:a,$browser:De.browser(s,navigator.vendor),$device:De.device(s),$device_type:De.deviceType(s),$timezone:De.timezone(),$timezone_offset:De.timezoneOffset()}),{$current_url:S(null==i?void 0:i.href,t,Se),$host:null==i?void 0:i.host,$pathname:null==i?void 0:i.pathname,$raw_user_agent:s.length>1e3?s.substring(0,997)+"...":s,$browser_version:De.browserVersion(s,navigator.vendor),$browser_language:De.browserLanguage(),$browser_language_prefix:De.browserLanguagePrefix(),$screen_height:null==e?void 0:e.screen.height,$screen_width:null==e?void 0:e.screen.width,$viewport_height:null==e?void 0:e.innerHeight,$viewport_width:null==e?void 0:e.innerWidth,$lib:"web",$lib_version:w.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!s)return{};var[e,r]=De.os(s);return E(O({$os:e,$os_version:r,$browser:De.browser(s,navigator.vendor)}),{$browser_version:De.browserVersion(s,navigator.vendor)})}};function Be(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function Ie(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?Be(Object(n),!0).forEach((function(r){Ae(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function Ae(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function je(e,r,n,t,o){return m(e)?e>n?n:e<r?r:e:je(n,r,n)}function Fe(e,r){return[...e||[],...g(r)?r:[r]]}function Te(e,r){return(v(e)?1:e)*r}function Ce(e,r){return function(e){for(var r=0,n=0;n<e.length;n++)r=(r<<5)-r+e.charCodeAt(n),r|=0;return Math.abs(r)}(e)%100<je(100*r,0,100)}var Me=Object.freeze({__proto__:null,printAndDropEverything:e=>(console.log("Would have sent event:",e),null),sampleByDistinctId:function(e){return r=>r&&Ce(r.properties.distinct_id,e)?Ie(Ie({},r),{},{properties:Ie(Ie({},r.properties),{},{$sample_type:["sampleByDistinctId"],$sample_threshold:e})}):null},sampleByEvent:function(e,r){return n=>{var t,o,i;return n?u(e,n.event)?100*Math.random()<je(100*r,0,100)?Ie(Ie({},n),{},{properties:Ie(Ie({},n.properties),{},{$sample_type:Fe(null===(t=n.properties)||void 0===t?void 0:t.$sample_type,"sampleByEvent"),$sample_threshold:Te(null===(o=n.properties)||void 0===o?void 0:o.$sample_threshold,r),$sampled_events:Fe(null===(i=n.properties)||void 0===i?void 0:i.$sampled_events,e)})}):null:n:null}},sampleBySessionId:function(e){return r=>r&&Ce(r.properties.$session_id,e)?Ie(Ie({},r),{},{properties:Ie(Ie({},r.properties),{},{$sample_type:Fe(r.properties.$sample_type,"sampleBySessionId"),$sample_threshold:Te(r.properties.$sample_threshold,e)})}):null},setAllPersonProfilePropertiesAsPersonPropertiesForFlags:e=>{var r=E({},De.properties({maskPersonalDataProperties:e.config.mask_personal_data_properties,customPersonalDataProperties:e.config.custom_personal_data_properties}),De.campaignParams({customTrackedParams:e.config.custom_campaign_params,maskPersonalDataProperties:e.config.mask_personal_data_properties,customPersonalDataProperties:e.config.custom_personal_data_properties}),De.referrerInfo()),n={};y(r,(function(e,r){(u(Re,r)||u(ke,r))&&(n[r]=e)})),e.setPersonPropertiesForFlags(n)}});l.posthogCustomizations=Me}(); | ||
//# sourceMappingURL=customizations.full.js.map |
@@ -0,3 +1,4 @@ | ||
import { PostHog } from '../posthog-core'; | ||
import { Survey } from '../posthog-surveys-types'; | ||
export declare function createWidgetShadow(survey: Survey): ShadowRoot; | ||
export declare function createWidgetShadow(survey: Survey, posthog?: PostHog): ShadowRoot; | ||
export declare function createWidgetStyle(widgetColor?: string): string; |
@@ -10,3 +10,3 @@ import { VNode } from 'preact'; | ||
export declare const defaultBackgroundColor = "#eeeded"; | ||
export declare const createShadow: (styleSheet: string, surveyId: string, element?: Element) => ShadowRoot; | ||
export declare const createShadow: (styleSheet: string, surveyId: string, element?: Element, posthog?: PostHog) => ShadowRoot; | ||
export declare const sendSurveyEvent: (responses: Record<string, string | number | string[] | null> | undefined, survey: Survey, posthog?: PostHog) => void; | ||
@@ -13,0 +13,0 @@ export declare const dismissedSurveyEvent: (survey: Survey, posthog?: PostHog, readOnly?: boolean) => void; |
import { PostHog } from '../../posthog-core'; | ||
export declare const prepareStylesheet: (innerText: string, posthog?: PostHog) => HTMLStyleElement | null; | ||
export declare const prepareStylesheet: (document: Document, innerText: string, posthog?: PostHog) => HTMLStyleElement | null; |
{ | ||
"name": "posthog-js", | ||
"version": "1.223.4", | ||
"version": "1.223.5", | ||
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/PostHog/posthog-js", |
@@ -0,3 +1,4 @@ | ||
import { PostHog } from '../posthog-core'; | ||
import { Survey } from '../posthog-surveys-types'; | ||
export declare function createWidgetShadow(survey: Survey): ShadowRoot; | ||
export declare function createWidgetShadow(survey: Survey, posthog?: PostHog): ShadowRoot; | ||
export declare function createWidgetStyle(widgetColor?: string): string; |
import { document as _document } from '../utils/globals'; | ||
import { prepareStylesheet } from './utils/stylesheet-loader'; | ||
// We cast the types here which is dangerous but protected by the top level generateSurveys call | ||
var document = _document; | ||
export function createWidgetShadow(survey) { | ||
export function createWidgetShadow(survey, posthog) { | ||
var _a; | ||
@@ -10,3 +11,6 @@ var div = document.createElement('div'); | ||
var widgetStyleSheet = createWidgetStyle((_a = survey.appearance) === null || _a === void 0 ? void 0 : _a.widgetColor); | ||
shadow.append(Object.assign(document.createElement('style'), { innerText: widgetStyleSheet })); | ||
var stylesheet = prepareStylesheet(document, widgetStyleSheet, posthog); | ||
if (stylesheet) { | ||
shadow.append(stylesheet); | ||
} | ||
document.body.appendChild(div); | ||
@@ -13,0 +17,0 @@ return shadow; |
@@ -167,3 +167,3 @@ var __assign = (this && this.__assign) || function () { | ||
_this.addSurveyToFocus(survey.id); | ||
var shadow = createShadow(style(survey === null || survey === void 0 ? void 0 : survey.appearance), survey.id); | ||
var shadow = createShadow(style(survey === null || survey === void 0 ? void 0 : survey.appearance), survey.id, undefined, _this.posthog); | ||
Preact.render(<SurveyPopup key={'popover-survey'} posthog={_this.posthog} survey={survey} removeSurveyFromFocus={_this.removeSurveyFromFocus} isPopup={true}/>, shadow); | ||
@@ -173,5 +173,5 @@ } | ||
this.handleWidget = function (survey) { | ||
var shadow = createWidgetShadow(survey); | ||
var shadow = createWidgetShadow(survey, _this.posthog); | ||
var stylesheetContent = style(survey.appearance); | ||
var stylesheet = prepareStylesheet(stylesheetContent, _this.posthog); | ||
var stylesheet = prepareStylesheet(document, stylesheetContent, _this.posthog); | ||
if (stylesheet) { | ||
@@ -326,3 +326,3 @@ shadow.appendChild(stylesheet); | ||
var stylesheetContent = style(survey.appearance); | ||
var stylesheet = prepareStylesheet(stylesheetContent, posthog); | ||
var stylesheet = prepareStylesheet(document, stylesheetContent, posthog); | ||
// Remove previously attached <style> | ||
@@ -350,3 +350,3 @@ Array.from(parentElement.children).forEach(function (child) { | ||
var stylesheetContent = createWidgetStyle((_b = survey.appearance) === null || _b === void 0 ? void 0 : _b.widgetColor); | ||
var stylesheet = prepareStylesheet(stylesheetContent, posthog); | ||
var stylesheet = prepareStylesheet(document, stylesheetContent, posthog); | ||
if (stylesheet) { | ||
@@ -353,0 +353,0 @@ root.appendChild(stylesheet); |
@@ -10,3 +10,3 @@ import { VNode } from 'preact'; | ||
export declare const defaultBackgroundColor = "#eeeded"; | ||
export declare const createShadow: (styleSheet: string, surveyId: string, element?: Element) => ShadowRoot; | ||
export declare const createShadow: (styleSheet: string, surveyId: string, element?: Element, posthog?: PostHog) => ShadowRoot; | ||
export declare const sendSurveyEvent: (responses: Record<string, string | number | string[] | null> | undefined, survey: Survey, posthog?: PostHog) => void; | ||
@@ -13,0 +13,0 @@ export declare const dismissedSurveyEvent: (survey: Survey, posthog?: PostHog, readOnly?: boolean) => void; |
@@ -16,2 +16,3 @@ var __assign = (this && this.__assign) || function () { | ||
import { createLogger } from '../../utils/logger'; | ||
import { prepareStylesheet } from '../utils/stylesheet-loader'; | ||
// We cast the types here which is dangerous but protected by the top level generateSurveys call | ||
@@ -246,3 +247,3 @@ var window = _window; | ||
export var defaultBackgroundColor = '#eeeded'; | ||
export var createShadow = function (styleSheet, surveyId, element) { | ||
export var createShadow = function (styleSheet, surveyId, element, posthog) { | ||
var div = document.createElement('div'); | ||
@@ -252,6 +253,6 @@ div.className = "PostHogSurvey".concat(surveyId); | ||
if (styleSheet) { | ||
var styleElement = Object.assign(document.createElement('style'), { | ||
innerText: styleSheet, | ||
}); | ||
shadow.appendChild(styleElement); | ||
var styleElement = prepareStylesheet(document, styleSheet, posthog); | ||
if (styleElement) { | ||
shadow.appendChild(styleElement); | ||
} | ||
} | ||
@@ -258,0 +259,0 @@ ; |
import { PostHog } from '../../posthog-core'; | ||
export declare const prepareStylesheet: (innerText: string, posthog?: PostHog) => HTMLStyleElement | null; | ||
export declare const prepareStylesheet: (document: Document, innerText: string, posthog?: PostHog) => HTMLStyleElement | null; |
@@ -1,9 +0,9 @@ | ||
import { document } from '../../utils/globals'; | ||
import { createLogger } from '../../utils/logger'; | ||
var logger = createLogger('[Stylesheet Loader]'); | ||
export var prepareStylesheet = function (innerText, posthog) { | ||
export var prepareStylesheet = function (document, innerText, posthog) { | ||
var _a; | ||
// Forcing the existence of `document` requires this function to be called in a browser environment | ||
var stylesheet = document.createElement('style'); | ||
stylesheet.innerText = innerText; | ||
if (posthog === null || posthog === void 0 ? void 0 : posthog.config.prepare_external_dependency_stylesheet) { | ||
if ((_a = posthog === null || posthog === void 0 ? void 0 : posthog.config) === null || _a === void 0 ? void 0 : _a.prepare_external_dependency_stylesheet) { | ||
stylesheet = posthog.config.prepare_external_dependency_stylesheet(stylesheet); | ||
@@ -10,0 +10,0 @@ } |
{ | ||
"name": "posthog-js", | ||
"version": "1.223.4", | ||
"version": "1.223.5", | ||
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/PostHog/posthog-js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
20618469
51188