Skip to content

Commit

Permalink
Add GrowthBook and segment dev env (#12952)
Browse files Browse the repository at this point in the history
* Add growthbook

* Fix data-track to match button when logged in

* Add segment key for dev environment

* Added cypress wait to make sure we don't scroll before the page loads

* Update site.cy.js
  • Loading branch information
sicarul authored Sep 27, 2024
1 parent fa02867 commit c7be7b9
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 127 deletions.
2 changes: 1 addition & 1 deletion assets/js/bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cypress/e2e/site.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("www.pulumi.com", () => {
cy.get(".header-container")
.should("not.have.class", "is-pinned");

cy.wait(6000)
cy.scrollTo(0, 250);

cy.get(".header-container")
Expand Down
265 changes: 140 additions & 125 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,139 +233,154 @@

<script async defer src="https://buttons.github.io/buttons.js"></script>

{{- if eq hugo.Environment "production" }}
<!-- Clearbit snippet -->
<script src="https://tag.clearbitscripts.com/v1/pk_54e7d7c428c6d5e79098374d93a7b333/tags.js" referrerpolicy="strict-origin-when-cross-origin"></script>
<script>
var segmentWriteKey;
{{- if eq hugo.Environment "production" }}
segmentWriteKey = "UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u";
{{- else }}
segmentWriteKey = "bATvhu6XKpwi7Cs258MGsELkDpVOzvdY";
{{- end }}
</script>

<!--Segment tracking-->
<script>
// Do not load Segment for these user agents.
userAgentBlacklist = [
'Mozilla/5.0 (compatible; SiteAuditBot/0.97; +http://www.semrush.com/bot.html)',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
]

!(function () {
var i = "analytics",
analytics = (window[i] = window[i] || []);
if (!analytics.initialize)
if (analytics.invoked) {
window.console && console.error && console.error("Segment snippet included twice.");
} else if (userAgentBlacklist.includes(navigator.userAgent)) {
console.log("Segment snippet not loaded for user agent: " + navigator.userAgent);
} else {
analytics.invoked = !0;
analytics.methods = [
"trackSubmit",
"trackClick",
"trackLink",
"trackForm",
"pageview",
"identify",
"reset",
"group",
"track",
"ready",
"alias",
"debug",
"page",
"screen",
"once",
"off",
"on",
"addSourceMiddleware",
"addIntegrationMiddleware",
"setAnonymousId",
"addDestinationMiddleware",
"register",
];
analytics.factory = function (e) {
return function () {
if (window[i].initialized) return window[i][e].apply(window[i], arguments);
var n = Array.prototype.slice.call(arguments);
if (["track", "screen", "alias", "group", "page", "identify"].indexOf(e) > -1) {
var c = document.querySelector("link[rel='canonical']");
n.push({ __t: "bpc", c: (c && c.getAttribute("href")) || void 0, p: location.pathname, u: location.href, s: location.search, t: document.title, r: document.referrer });
}
n.unshift(e);
analytics.push(n);
return analytics;
};
};
for (var n = 0; n < analytics.methods.length; n++) {
var key = analytics.methods[n];
analytics[key] = analytics.factory(key);
}
analytics.load = function (key, n) {
var t = document.createElement("script");
t.type = "text/javascript";
t.async = !0;
t.setAttribute("data-global-segment-analytics-key", i);
t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";
var r = document.getElementsByTagName("script")[0];
r.parentNode.insertBefore(t, r);
analytics._loadOptions = n;
<!--Segment tracking-->
<script>
// Do not load Segment for these user agents.
userAgentBlacklist = [
'Mozilla/5.0 (compatible; SiteAuditBot/0.97; +http://www.semrush.com/bot.html)',
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36'
]

!(function () {
var i = "analytics",
analytics = (window[i] = window[i] || []);
if (!analytics.initialize)
if (analytics.invoked) {
window.console && console.error && console.error("Segment snippet included twice.");
} else if (userAgentBlacklist.includes(navigator.userAgent)) {
console.log("Segment snippet not loaded for user agent: " + navigator.userAgent);
} else {
analytics.invoked = !0;
analytics.methods = [
"trackSubmit",
"trackClick",
"trackLink",
"trackForm",
"pageview",
"identify",
"reset",
"group",
"track",
"ready",
"alias",
"debug",
"page",
"screen",
"once",
"off",
"on",
"addSourceMiddleware",
"addIntegrationMiddleware",
"setAnonymousId",
"addDestinationMiddleware",
"register",
];
analytics.factory = function (e) {
return function () {
if (window[i].initialized) return window[i][e].apply(window[i], arguments);
var n = Array.prototype.slice.call(arguments);
if (["track", "screen", "alias", "group", "page", "identify"].indexOf(e) > -1) {
var c = document.querySelector("link[rel='canonical']");
n.push({ __t: "bpc", c: (c && c.getAttribute("href")) || void 0, p: location.pathname, u: location.href, s: location.search, t: document.title, r: document.referrer });
}
n.unshift(e);
analytics.push(n);
return analytics;
};
analytics._writeKey = "UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u";
analytics.SNIPPET_VERSION = "5.2.0";
analytics.load("UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u");
analytics.page();
};
for (var n = 0; n < analytics.methods.length; n++) {
var key = analytics.methods[n];
analytics[key] = analytics.factory(key);
}
})();
</script>

<!-- Segment Consent Manager -->
<script>
window.consentManagerConfig = function(exports) {
var React = exports.React;
var inEU = exports.inEU;

var bannerContent = React.createElement(
'span',
null,
'We use cookies (and other similar technologies) to collect data to improve your experience on our site. By using our website, you՚re agreeing to the collection of data as described in our',
' ',
React.createElement(
'a',
{ href: '/privacy/', target: '_blank' },
'Privacy Policy'
),
'.'
)
var bannerSubContent = React.createElement(
'div',
{ class: "manage-cookies-btn" },
'Manage cookies'
)
//var bannerSubContent = 'You can change your preferences at any time.'
var preferencesDialogTitle = 'Website Data Collection Preferences'
var preferencesDialogContent =
'We use data collected by cookies and JavaScript libraries to improve your browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.'
var cancelDialogTitle = 'Are you sure you want to cancel?'
var cancelDialogContent =
'Your preferences have not been saved. By continuing to use our website, you are agreeing to our Website Data Collection Policy.'

return {
container: '#segment-consent-manager',
writeKey: 'UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u',
bannerContent: bannerContent,
bannerSubContent: bannerSubContent,
preferencesDialogTitle: preferencesDialogTitle,
preferencesDialogContent: preferencesDialogContent,
cancelDialogTitle: cancelDialogTitle,
cancelDialogContent: cancelDialogContent,
shouldRequireConsent: () => true,
closeBehavior: exports.inEU() ? "dismiss" : "accept",
bannerTextColor: "black",
analytics.load = function (key, n) {
var t = document.createElement("script");
t.type = "text/javascript";
t.async = !0;
t.setAttribute("data-global-segment-analytics-key", i);
t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";
var r = document.getElementsByTagName("script")[0];
r.parentNode.insertBefore(t, r);
analytics._loadOptions = n;
};
analytics._writeKey = segmentWriteKey;
analytics.SNIPPET_VERSION = "5.2.0";
analytics.load(segmentWriteKey);
analytics.page();
}
})();
</script>

<!-- Segment Consent Manager -->
<script>
window.consentManagerConfig = function(exports) {
var React = exports.React;
var inEU = exports.inEU;

var bannerContent = React.createElement(
'span',
null,
'We use cookies (and other similar technologies) to collect data to improve your experience on our site. By using our website, you՚re agreeing to the collection of data as described in our',
' ',
React.createElement(
'a',
{ href: '/privacy/', target: '_blank' },
'Privacy Policy'
),
'.'
)
var bannerSubContent = React.createElement(
'div',
{ class: "manage-cookies-btn" },
'Manage cookies'
)
//var bannerSubContent = 'You can change your preferences at any time.'
var preferencesDialogTitle = 'Website Data Collection Preferences'
var preferencesDialogContent =
'We use data collected by cookies and JavaScript libraries to improve your browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.'
var cancelDialogTitle = 'Are you sure you want to cancel?'
var cancelDialogContent =
'Your preferences have not been saved. By continuing to use our website, you are agreeing to our Website Data Collection Policy.'

return {
container: '#segment-consent-manager',
writeKey: segmentWriteKey,
bannerContent: bannerContent,
bannerSubContent: bannerSubContent,
preferencesDialogTitle: preferencesDialogTitle,
preferencesDialogContent: preferencesDialogContent,
cancelDialogTitle: cancelDialogTitle,
cancelDialogContent: cancelDialogContent,
shouldRequireConsent: () => true,
closeBehavior: exports.inEU() ? "dismiss" : "accept",
bannerTextColor: "black",
}
</script>
}
</script>

<script
src="https://unpkg.com/@segment/[email protected]/standalone/consent-manager.js"
defer
<script
src="https://unpkg.com/@segment/[email protected]/standalone/consent-manager.js"
defer
></script>

<script async
data-api-host="https://cdn.growthbook.io"
data-client-key="sdk-0aUDa6bDbQqms3aJ"
src="https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js"
></script>

{{- if eq hugo.Environment "production" }}
<!-- Clearbit snippet -->
<script src="https://tag.clearbitscripts.com/v1/pk_54e7d7c428c6d5e79098374d93a7b333/tags.js" referrerpolicy="strict-origin-when-cross-origin"></script>

<!-- Facebook Domain Verification -->
<meta name="facebook-domain-verification" content="phlf6qes2bxa9ufzk8zt2es0qivg8j" />

Expand Down
2 changes: 1 addition & 1 deletion theme/stencil/src/components/header-cta/header-cta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class HeaderCta {

if (this.isLoggedIn) {
return(
<a class={this.buttonClass} data-track="header-get-started-mobile" href="https://app.pulumi.com/signup/" target="_blank" rel="noopener noreferrer" title="Dashboard">Dashboard</a>
<a class={this.buttonClass} data-track="header-get-started" href="https://app.pulumi.com/signup/" target="_blank" rel="noopener noreferrer" title="Dashboard">Dashboard</a>
);
}

Expand Down

0 comments on commit c7be7b9

Please sign in to comment.