function getQueryParam(e, t) { t = t.replace(/[[]/, '[').replace(/[]]/, ']'); var n = new RegExp('[?&]' + t + '=([^&#]*)').exec(e); if (n === null || (n && typeof n[1] != 'string' && n[1].length)) { return ''; } else { return decodeURIComponent(n[1]).replace(/\W/gi, ' '); } } (function () { var e = document; var t = window.mixpanel || []; var n; var o; var a; var i; if (!t.__SV) { window.mixpanel = t; t._i = []; t.init = function (e, n, o) { function r(e, t) { var n = t.split('.'); if (n.length == 2) { e = e[n[0]]; t = n[1]; } e[t] = function () { e.push([t].concat(Array.prototype.slice.call(arguments, 0))); }; } var c = t; if (o === void 0) { o = 'mixpanel'; } else { c = t[o] = []; } c.people = c.people || []; c.toString = function (e) { var t = 'mixpanel'; if (o !== 'mixpanel') { t += '.' + o; } if (!e) { t += ' (stub)'; } return t; }; c.people.toString = function () { return c.toString(1) + '.people (stub)'; }; a = '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( ' ' ); for (i = 0; i < a.length; i++) { r(c, a[i]); } t._i.push([e, n, o]); }; t.__SV = 1.2; (n = e.createElement('script')).type = 'text/javascript'; n.async = true; n.src = '//cdn.mxpnl.com/libs/mixpanel-2.2.min.js'; (o = e.getElementsByTagName('script')[0]).parentNode.insertBefore(n, o); } })(); var mixpanelDelayHandler = (function () { var e = false; var t = []; return { callOnInit: function (n) { e = true; var o = 0; for (var a = t.length; o < a; o++) { t[o](n); } }, executeOnLoad: function (e) { if (!this.hasLoaded()) { return mixpanelDelayHandler.addToCallbacks(e); } e(mixpanel); }, addToCallbacks: function (e) { t.push(e); }, hasLoaded: function () { return e; }, }; })(); function campaignParams(e) { var n = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' '); var o = ''; var a = {}; var i = {}; var r = ''; for (var t = 0; t < n.length; ++t) { if ((o = getQueryParam(document.URL, n[t])).length) { a[n[t] + ' [last touch]'] = o; r += `${n[t]}=${o}&`; } } for (t = 0; t < n.length; ++t) { if ((o = getQueryParam(document.URL, n[t])).length) { i[n[t] + ' [first touch]'] = o; } } if (r) { r = r.replace(/&\s*$/, ''); const e = 30 * 864e5; const t = new Date(); const n = `; expires=${new Date(t.getTime() + e).toUTCString()}`; document.cookie = `utmAttribution=${r}${n}; path=/`; } e.people.set(a); e.people.set_once(i); e.register(a); } function trackPageViewed(e) { e.track('Page Viewed', { Event: 'Page Viewed', 'Page Name': document.title, URL: window.location.pathname, }); } window.mixpanelDelayedHandler = mixpanelDelayHandler; mixpanelDelayedHandler.addToCallbacks(trackPageViewed); mixpanelDelayedHandler.addToCallbacks(campaignParams); mixpanel.init('28eacd763239e0137e163cc1da830f90', { loaded: mixpanelDelayHandler.callOnInit, }); var zh = { cookieNotice: function () { const e = new Date(); const t = Math.round(e.getTime() / 1e3); const n = localStorage.getItem('cookieNotice'); if (document.getElementById('cn-show') !== null) { if (!n || n < t) { document.getElementById('cn-show').click(); } document.getElementById('cn-hide').addEventListener('click', function () { localStorage.setItem('cookieNotice', t + 31536e3); }); } }, lever: function () { $(function () { var e = $('[data-lever="link"]').removeAttr('data-lever'); var t = e.parent(); $.get( 'https://api.lever.co/v0/postings/launchlabs?department=zenhub&mode=json', function (n) { for (const o in n) { e.attr('href', n[o].hostedUrl); e.find('[data-lever="title"]').text(n[o].text); e.find('[data-lever="location"]').text(n[o].categories.location); t.append(e.clone()); } } ); e.remove(); }); }, thankYou: function () { const e = 3e3; $(document).ready(function () { window.mixpanelDelayedHandler.executeOnLoad(function (t) { const o = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime); if (o) { t.track( 'Extension Install', { extension_platform: o ? 'chrome' : 'firefox' }, () => { const n = t.get_distinct_id(); setTimeout(() => { (function (e) { let t = 'https://api.zenhub.com' + `/auth/github?redirect=https://github.com&mixpanelId=${e}&startOption=extension`; const n = ( document.cookie .split(';') .find((e) => e.trim().startsWith('utmAttribution=')) || '' ) .replace('utmAttribution=', '') .trim(); if (n && n.length) { t += `&${n}`; } window.location.href = t; })(n); }, e); } ); } }); }); }, webapp: function () { if (document.querySelector('[webapp-link]') === null) { return; } let e = 'https://app.zenhub.com/'; const t = ( document.cookie.split(';').find((e) => e.trim().startsWith('utmAttribution=')) || '' ) .replace('utmAttribution=', '') .trim(); if (t && t.length) { e += `?${t}`; } $(document).on('click', '[webapp-link]', function (t) { t.preventDefault(); window.location.href = e; }); }, extension: function () { function a() {} if (document.querySelector('[extension-download]') === null) { return; } const $downloadButton = $('[extension-download]'); const t = (e) => navigator.userAgent.toLowerCase().indexOf(e) > -1; // If firefox, build download URL and add it to button right away if (t('firefox')) { // Disable button initially until we have the URL built $downloadButton.prop('disabled', true); // Fetch JSON file which contains necessary info for building XPI download URL $.ajax({ url: 'https://firefox-extension.zenhub.com/latest.json', dataType: 'jsonp', jsonp: false, jsonpCallback: 'content', }).done((e) => { const firefoxURL = `https://firefox-extension.zenhub.com/all/${e.file}`; $downloadButton.prop('href', firefoxURL); $downloadButton.prop('disabled', false); }); } else if (t('chrome')) { const chromeURL = 'https://chrome.google.com/webstore/detail/zenhub-for-github/ogcgkffhplmphkaahpmffcafajaocjbd'; $downloadButton.prop('href', chromeURL); $downloadButton.prop('target', '_blank'); } const o = (o = '', a) => { const i = { via: o }; ((e) => { let t = new Image(1, 1); if (e) { t.onload = e; t.onerror = e; } t.src = '//www.googleadservices.com/pagead/conversion/957092904/?label=DwERCIqGwWQQqKiwyAM&script=0'; })(); if (t('firefox')) { ((e) => { mixpanel.track('Zenhub.com : Download', { Event: 'Firefox page download', Via: e.via, }); try { fbq('track', 'Download', { url: window.location.pathname, page_name: document.title, browser: 'Firefox', }); } catch (e) {} })(i); } else if (t('chrome')) { ((t, n) => { mixpanel.track('Zenhub.com : Download', { Event: 'Extension Installation Start', Via: t.via, }); if (typeof n == 'function') { n(); } })(i, a); } }; window.Tracker = a; a.prototype.trackAction = function (e, t, n, o, a) { if (n == null) { n = ''; } if (o == null) { o = 1; } if (a == null) { a = null; } ga('send', 'event', { eventCategory: e, eventAction: t, eventLabel: n, eventValue: o, hitCallback: function () { if (a) { return a(); } }, }); return this; }; a.prototype.trackVisitorAction = function (e, t, n, o) { return this.trackAction('Visitor Action', e, t, n, o); }; a.prototype.trackUserAction = function (e, t, n, o) { return this.trackAction('User Action', e, t, n, o); }; var i = new a(); $(document).on('click', '[extension-download]', function () { const e = $(this).data('button') || window.location.pathname; o($(this).data('via'), () => i.trackVisitorAction('Onboarding: Extension Installation Start', e) ); }); }, newsletter: function () { $('#newsletter').submit(function (e) { e.preventDefault(); ((e, t) => new Promise((n, o) => { const a = ((e, t) => `https://api.hsforms.com/submissions/v3/integration/submit/${e}/${t}`)( '8071990', e ); if (!e) { return n(); } $.ajax({ url: a, type: 'POST', data: JSON.stringify(t), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function () { $('#newsletter').parent().find('.w-form-done').show(); $('#newsletter').hide(); n(t); }, }); }))('484a2531-eaa5-47d7-b077-4b89b13f435e', { fields: [ { name: 'email', value: $(this).find('#email').val(), }, ], legalConsentOptions: { legitimateInterest: { value: true, subscriptionTypeId: 9845308, legalBasis: 'LEAD', text: 'We take privacy seriously', }, }, context: {}, }); return false; }); }, }; zh.newsletter(); zh.cookieNotice(); zh.extension(); zh.webapp();