Skip to content

Commit

Permalink
chore: add hydro analytics to storybook (#4558)
Browse files Browse the repository at this point in the history
* chore: add hydro analytics to storybook

* chore: use previewHead over managerHead

* Update build-docs

---------

Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
  • Loading branch information
joshblack and joshblack authored May 7, 2024
1 parent 495935b commit 7e587b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/react/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
'use strict'

const {DEPLOY_ENV = 'development'} = process.env

/**
* @type {import('@storybook/core-common').StorybookConfig}
*/
Expand Down Expand Up @@ -53,4 +57,16 @@ module.exports = {
typescript: {
reactDocgen: 'react-docgen',
},
previewHead: head => {
if (DEPLOY_ENV === 'development') {
return head
}
return `${head}\n<meta name="ha-url" content="https://collector.githubapp.com/primer/collect">`
},
previewBody: body => {
if (DEPLOY_ENV === 'development') {
return body
}
return `${body}\n<script src="https://analytics.githubassets.com/hydro-marketing.min.js"></script>`
},
}
2 changes: 2 additions & 0 deletions script/build-docs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
set -e

if [ -n "$1" ]; then
export DEPLOY_ENV="preview"
npm run build:preview -w docs
npm run build:storybook preview
else
export DEPLOY_ENV="production"
npm run build -w docs
npm run build:storybook
fi

0 comments on commit 7e587b6

Please sign in to comment.