Skip to content

Commit dad8950

Browse files
joshblackTylerJDev
authored andcommitted
chore: add hydro analytics to storybook (#4558)
* chore: add hydro analytics to storybook * chore: use previewHead over managerHead * Update build-docs --------- Co-authored-by: Josh Black <[email protected]>
1 parent 8d4b60d commit dad8950

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/react/.storybook/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
'use strict'
2+
3+
const {DEPLOY_ENV = 'development'} = process.env
4+
15
/**
26
* @type {import('@storybook/core-common').StorybookConfig}
37
*/
@@ -53,4 +57,16 @@ module.exports = {
5357
typescript: {
5458
reactDocgen: 'react-docgen',
5559
},
60+
previewHead: head => {
61+
if (DEPLOY_ENV === 'development') {
62+
return head
63+
}
64+
return `${head}\n<meta name="ha-url" content="https://collector.githubapp.com/primer/collect">`
65+
},
66+
previewBody: body => {
67+
if (DEPLOY_ENV === 'development') {
68+
return body
69+
}
70+
return `${body}\n<script src="https://analytics.githubassets.com/hydro-marketing.min.js"></script>`
71+
},
5672
}

script/build-docs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
set -e
33

44
if [ -n "$1" ]; then
5+
export DEPLOY_ENV="preview"
56
npm run build:preview -w docs
67
npm run build:storybook preview
78
else
9+
export DEPLOY_ENV="production"
810
npm run build -w docs
911
npm run build:storybook
1012
fi

0 commit comments

Comments
 (0)