This repository was archived by the owner on Mar 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,17 @@ function getHeapAppID() {
3838 }
3939}
4040
41+ function getHubspotID ( ) {
42+ switch ( process . env . RELEASE_ENV ) {
43+ case 'stage' :
44+ return '8186536'
45+ case 'prod' :
46+ return '8186536'
47+ default :
48+ return null
49+ }
50+ }
51+
4152function getSentryDSN ( ) {
4253 switch ( process . env . RELEASE_ENV ) {
4354 case 'stage' :
@@ -137,6 +148,12 @@ module.exports = {
137148 appId : getHeapAppID ( ) ,
138149 } ,
139150 ] ,
151+ [
152+ require . resolve ( path . resolve ( __dirname , './src/plugins/hubspot.js' ) ) ,
153+ {
154+ appId : getHubspotID ( ) ,
155+ } ,
156+ ] ,
140157 [
141158 require . resolve ( path . resolve ( __dirname , './src/plugins/sentry.js' ) ) ,
142159 {
Original file line number Diff line number Diff line change 1+ const DEFAULT_OPTIONS = {
2+ appId : null ,
3+ enableOnDevMode : false , // if 'false', hubspot will be fired on NODE_ENV=production only
4+ }
5+
6+ module . exports = function ( context , opts ) {
7+ const options = { ...DEFAULT_OPTIONS , ...opts }
8+ const isEnabled =
9+ ( process . env . NODE_ENV === 'production' || options . enableOnDevMode ) &&
10+ options . appId
11+
12+ return {
13+ name : 'docusaurus2-hubspot' ,
14+ injectHtmlTags ( ) {
15+ if ( ! isEnabled ) return { }
16+ return {
17+ headTags : [
18+ {
19+ tagName : 'script' ,
20+ attributes : {
21+ type : 'text/javascript' ,
22+ id : 'hs-script-loader' ,
23+ async,
24+ defer,
25+ src : `//js.hs-scripts.com/${ options . appId } .js` ,
26+ } ,
27+ } ,
28+ ] ,
29+ }
30+ } ,
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments