Skip to content

Commit

Permalink
Merge pull request #5691 from pulumi/replicate-docs-changes-segment-c…
Browse files Browse the repository at this point in the history
…onsent-growthbook

Replicate changes done on docs repository for Segment consent and growthbook
  • Loading branch information
sicarul authored Oct 14, 2024
2 parents 0c22949 + 1b5432f commit 26624c6
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 30 deletions.
45 changes: 20 additions & 25 deletions themes/default/layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

<!-- GrowthBook / Segment keys -->
<script>
{{- if eq hugo.Environment "production" }}
var segmentWriteKey = "UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u";
var snippetName = "C8Y429BDEy/06ujkUhzfL.min.js";
window.growthbook_sdk_key="sdk-psPofGr6jFV2ja9O";
window.growthbook_decrypt_key="9NsAVMNWaDS+Oky3rhLQ+A==";
window.growthbook_dev_mode=false;
{{- else }}
var segmentWriteKey = "bATvhu6XKpwi7Cs258MGsELkDpVOzvdY";
var snippetName = "C8Y429BDEy/hpBKpR8Nx1yVCjKPB2nJWg.min.js";
window.growthbook_sdk_key="sdk-BwIkZCqXQ9pZyp0P";
window.growthbook_decrypt_key="SSWIMld/D7pGr+Mnibv5DA==";
window.growthbook_dev_mode=true;
{{- end }}
</script>

<!-- Our CSS and JS bundles. -->
{{ partial "assets" . }}

Expand Down Expand Up @@ -233,19 +250,6 @@

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

<script>
var segmentWriteKey;
var snippetName;
{{- if eq hugo.Environment "production" }}
segmentWriteKey = "UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u";
snippetName = "C8Y429BDEy/06ujkUhzfL.min.js"
{{- else }}
segmentWriteKey = "bATvhu6XKpwi7Cs258MGsELkDpVOzvdY";
snippetName = "C8Y429BDEy/hpBKpR8Nx1yVCjKPB2nJWg.min.js"
{{- end }}
</script>


<!--Segment tracking-->
<script>
// Do not load Segment for these user agents.
Expand Down Expand Up @@ -364,29 +368,20 @@
preferencesDialogContent: preferencesDialogContent,
cancelDialogTitle: cancelDialogTitle,
cancelDialogContent: cancelDialogContent,
shouldRequireConsent: () => true,
shouldRequireConsent: exports.inEU,
closeBehavior: exports.inEU() ? "dismiss" : "accept",
bannerTextColor: "black",
cdnHost: "evs.analytics.pulumi.com",
shouldReload: false
}
}
</script>

<script
src="https://unpkg.com/@segment/consent-manager@5.3.0/standalone/consent-manager.js"
src="https://unpkg.com/@segment/consent-manager@5.8.1/standalone/consent-manager.js"
defer
></script>

<script async
data-api-host="https://cdn.growthbook.io"
{{- if eq hugo.Environment "production" }}
data-client-key="sdk-0aUDa6bDbQqms3aJ"
{{- else }}
data-client-key="sdk-ut2foRRgupXGuPj3"
{{- end }}
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>
Expand Down
1 change: 1 addition & 0 deletions themes/default/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@algolia/autocomplete-plugin-recent-searches": "^1.9.2",
"@algolia/autocomplete-plugin-tags": "^1.9.2",
"@algolia/autocomplete-theme-classic": "^1.9.2",
"@growthbook/growthbook": "^1.2.1",
"@types/marked": "^4.0.8",
"algoliasearch": "^4.17.0",
"clipboard-polyfill": "^3.0.3",
Expand Down
8 changes: 3 additions & 5 deletions themes/default/theme/src/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,10 @@ section.newsletter-input pulumi-hubspot-form input.hs-input {
@apply fixed bottom-0 right-0 left-0 text-black;
z-index: 100;

> div:first-child {
@apply w-full px-3;
@apply w-full px-3;

@screen lg {
@apply w-1/3 float-right mb-2 mr-2 rounded-lg shadow-lg overflow-hidden px-4 py-2;
}
@screen lg {
@apply w-1/3 float-left mb-2 mr-2 rounded-lg shadow-lg overflow-hidden px-4 py-2;
}

div {
Expand Down
28 changes: 28 additions & 0 deletions themes/default/theme/stencil/src/util/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
import * as uuid from "uuid";
import { GrowthBook } from "@growthbook/growthbook";

// Initialize GrowthBook
export const gb = new GrowthBook({
apiHost: "https://cdn.growthbook.io",
clientKey: (window as any).growthbook_sdk_key,
decryptionKey: (window as any).growthbook_decrypt_key,
enableDevMode: (window as any).growthbook_dev_mode,
});

gb.init({ streaming: true });

// Hook up GrowthBook to analytics when ready
(window as any).analytics.ready(function() {
gb.setTrackingCallback((experiment, result) => {
(window as any).analytics.track("Experiment Viewed", {
experimentId: experiment.key,
variationId: result.key,
});
});

gb.setAttributes({
// Set Anon/UserId for GB
...gb.getAttributes(),
id: (window as any).analytics.user().anonymousId(),
userId: (window as any).analytics.user().id(),
})
})

// Extracts a query string variable from the browser's location.
export function getQueryVariable(paramKey: string): string | null {
Expand Down
12 changes: 12 additions & 0 deletions themes/default/theme/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@
dependencies:
purgecss "^4.0.3"

"@growthbook/growthbook@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@growthbook/growthbook/-/growthbook-1.2.1.tgz#efc236afec8aa061d306d72ab1c9fa67697e513e"
integrity sha512-V0of0mGXZ69poOTPoZ8TFkJkPpC9T766NZiJ1qwzwFAl8ZsuunmguC6RP4muri4q5DRPDzf3lRUSWLk0g8bdbw==
dependencies:
dom-mutator "^0.6.0"

"@jridgewell/gen-mapping@^0.3.0":
version "0.3.2"
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz#c1aedc61e853f2bb9f5dfe6d4442d3b565b253b9"
Expand Down Expand Up @@ -974,6 +981,11 @@ dlv@^1.1.3:
resolved "https://registry.yarnpkg.com/dlv/-/dlv-1.1.3.tgz#5c198a8a11453596e751494d49874bc7732f2e79"
integrity sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==

dom-mutator@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/dom-mutator/-/dom-mutator-0.6.0.tgz#079d7a4b3e8981a562cd777548b99baab51d65c5"
integrity sha512-iCt9o0aYfXMUkz/43ZOAUFQYotjGB+GNbYJiJdz4TgXkyToXbbRy5S6FbTp72lRBtfpUMwEc1KmpFEU4CZeoNg==

dom-serializer@^1.0.1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91"
Expand Down

0 comments on commit 26624c6

Please sign in to comment.