(function(f,b){if(!b.__SV){var a,e,i,g;window.mixpanel=b;b._i=[];b.init=function(a,e,d){function f(b,h){var a=h.split(".");2==a.length&&(b=b[a[0]],h=a[1]);b[h]=function(){b.push([h].concat(Array.prototype.slice.call(arguments,0)))}}var c=b;"undefined"!==typeof d?c=b[d]=[]:d="mixpanel";c.people=c.people||[];c.toString=function(b){var a="mixpanel";"mixpanel"!==d&&(a+="."+d);b||(a+=" (stub)");return a};c.people.toString=function(){return c.toString(1)+".people (stub)"};i="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(g=0;g { const mixpanelId = mixpanel.get_distinct_id(); setTimeout(() => { redirectWithId(mixpanelId); }, THANK_YOU_PAGE_MS_BEFORE_REDIRECT); } ); } }); } $(document).ready(attachMixpanelIDAndRedirect); }, extension: function(){ if (document.querySelector('[extension-download]') === null) { return; } const firefoxWebstoreUrl = 'https://firefox-extension.zenhub.io'; const chromeWebstoreUrl = 'https://chrome.google.com/webstore/detail/zenhub-for-github/ogcgkffhplmphkaahpmffcafajaocjbd'; const zenHubAvatar = 'https://avatars2.githubusercontent.com/u/8211050?v=3&s=200'; const googleConversionId = 957092904; const googleConversionLabel = 'DwERCIqGwWQQqKiwyAM'; const $githubDownload = $('[extension-download]'); const trackConv = (callback) => { let image = new Image(1, 1); if (callback) { image.onload = callback; image.onerror = callback; } image.src = `//www.googleadservices.com/pagead/conversion/${googleConversionId}/?label=${googleConversionLabel}&script=0`; }; const isBrowser = (browser) => navigator.userAgent.toLowerCase().indexOf(browser) > -1; const downloadChromeExtension = (props, cb) => { mixpanel.track('Zenhub.com : Download', { 'Event': 'Extension Installation Start', 'Via': props.via }); if (typeof cb === 'function') { cb(); } window.open(chromeWebstoreUrl); }; const installFirefoxExtension = (args) => { const url = `${firefoxWebstoreUrl}/all/${args.file}`; const el = $('.js-extension-download'); // add a link under the extensions button to download manually the extension to circumnavigate // the problem that some customers are having and that we cannot reproduce el.after(`
If the installation doesn't start, you can download the extension here.
`); const installParams = { 'ZenHub': { URL: url, IconURL: zenHubAvatar, Hash: args.hash, toString: function() { return this.URL; } } }; // eslint-disable-next-line no-undef InstallTrigger.install(installParams); return false; }; const downloadFirefoxExtension = (props) => { mixpanel.track('Zenhub.com : Download', { 'Event': 'Firefox page download', 'Via': props.via }); try { //- Facebook pixel track on ZenHub Download fbq('track', 'Download', { url: window.location.pathname, page_name: document.title, browser: 'Firefox' }); } catch (error) { // do nothing, we just swallow this error to avoid breaking the download link } $.ajax({ url: `${firefoxWebstoreUrl}/latest.json`, dataType: 'jsonp', jsonp: false, jsonpCallback: 'content' }) .done(installFirefoxExtension); }; const downloadExtension = (via = '', cb) => { const attrs = {via}; console.log('attrs', attrs); trackConv(); if (isBrowser('firefox')) { downloadFirefoxExtension(attrs); } else if (isBrowser('chrome')) { downloadChromeExtension(attrs, cb); } }; function fallBack() { const browserName = isBrowser('safari') ? 'Safari' : 'Other'; if (!isBrowser('chrome') && !isBrowser('firefox')) { $githubDownload.click(function() { const attrs = {'via': $(this).data('via') || ''}; //- Mixpanel track on ZenHub Download mixpanel.track('Zenhub.com : Download', { 'URL': window.location.pathname, 'Page Name': document.title, 'URL Clicked': chromeWebstoreUrl, 'Via': attrs.via }); try { //- Facebook pixel track on ZenHub Download fbq('track', 'Download', { url: window.location.pathname, page_name: document.title, browser: browserName }); } catch (error) { // do nothing, we just swallow this error to avoid breaking the download link } window.open(chromeWebstoreUrl); }); } } function Tracker() {} window.Tracker = Tracker; Tracker.prototype.trackAction = function (category, action, label, value, callback) { if (label === null || label === undefined) { label = ''; } if (value === null || value === undefined) { value = 1; } if (callback === null || callback === undefined) { callback = null; } // Google Analytics ga('send', 'event', { 'eventCategory': category, 'eventAction': action, 'eventLabel': label, 'eventValue': value, 'hitCallback': function() { if (callback) { return callback(); } } }); return this; }; Tracker.prototype.trackVisitorAction = function (action, label, value, callback) { return this.trackAction('Visitor Action', action, label, value, callback); }; Tracker.prototype.trackUserAction = function (action, label, value, callback) { return this.trackAction('User Action', action, label, value, callback); }; var tracker = new Tracker(); $(document).on('click', '[extension-download]', function() { const buttonName = $(this).data('button') || window.location.pathname; downloadExtension($(this).data('via'), () => tracker.trackVisitorAction('Onboarding: Extension Installation Start', buttonName)); }); }, newsletter: function(){ const NEWSLETTER_SUBSCRIPTION_ID = 9845308; const NEWSLETTER_FORM_ID = '484a2531-eaa5-47d7-b077-4b89b13f435e'; const HUBSPOT_PORTAL_ID = '8071990'; const getFormAPIUrl = (portalId, formGuid) => `https://api.hsforms.com/submissions/v3/integration/submit/${portalId}/${formGuid}`; const getLegitimateInterestArg = () => ({ legitimateInterest: { value: true, subscriptionTypeId: NEWSLETTER_SUBSCRIPTION_ID, legalBasis: 'LEAD', text: 'We take privacy seriously' } }); const getOptedInArg = (consentText) => ({ consent: { consentToProcess: true, text: consentText, communications: [ { value: true, subscriptionTypeId: NEWSLETTER_SUBSCRIPTION_ID, text: consentText } ] } }); const getContextFromReq = req => { return { hutk: req.cookies.hubspotutk, ipAddress: req.ip, pageUri: req.header('Referer') }; }; const submitHubSpotForm = (formId, body) => new Promise((resolve, reject) => { const portalId = HUBSPOT_PORTAL_ID; const url = getFormAPIUrl(portalId, formId); if (!portalId) { console.log('No HUBSPOT_PORTAL_ID. Skipping submission to HubSpot'); return resolve(); } if (!formId) return resolve(); $.ajax({ url: url, type: "POST", data: JSON.stringify(body), contentType: "application/json; charset=utf-8", dataType: "json", success: function(){ $('#newsletter').parent().find('.w-form-done').show(); $('#newsletter').hide(); resolve(body); } }) return; request.post({ url, body, json: true }, (httpError, httpResponse, body) => { const statusCode = httpResponse.statusCode; if (statusCode !== 200) { console.log('HubSpot form submission error:', body); const err = new Error('Error while submitting form'); err.statusCode = statusCode; return reject(err); } else if (httpError) { return reject(new Error('Uh oh, something went wrong. Please try again!')); } return resolve(body); }); }); $('#newsletter').submit(function(e){ e.preventDefault(); // prevent native submitting const email = $(this).find('#email').val(); const json = { fields: [ {name: 'email', value: email} ], legalConsentOptions: getLegitimateInterestArg(), context: {}//getContextFromReq(req) } console.log(JSON.stringify(json)); submitHubSpotForm(NEWSLETTER_FORM_ID, json); return false; // prevent native submitting }); } } zh.newsletter(); zh.cookieNotice(); zh.extension();