File tree Expand file tree Collapse file tree 3 files changed +30
-11
lines changed Expand file tree Collapse file tree 3 files changed +30
-11
lines changed Original file line number Diff line number Diff line change 61
61
env :
62
62
USE_SSH : true
63
63
run : |
64
+ export COCOINDEX_DOCS_POSTHOG_API_KEY=${{ secrets.COCOINDEX_DOCS_POSTHOG_API_KEY }}
65
+ export COCOINDEX_DOCS_MIXPANEL_API_KEY=${{ secrets.COCOINDEX_DOCS_MIXPANEL_API_KEY }}
64
66
git config --global user.email "cocoindex.io@gmail.com"
65
67
git config --global user.name "CocoIndex"
66
68
yarn install --frozen-lockfile
Original file line number Diff line number Diff line change
1
+ import webpack from 'webpack' ;
1
2
import { themes as prismThemes } from 'prism-react-renderer' ;
2
3
import type { Config } from '@docusaurus/types' ;
3
4
import type * as Preset from '@docusaurus/preset-classic' ;
@@ -33,14 +34,17 @@ const config: Config = {
33
34
} ,
34
35
35
36
plugins : [
36
- [
37
- "posthog-docusaurus" ,
38
- {
39
- apiKey : "phc_SgKiQafwZjHu4jQW2q402gbz6FYQ2NJRkcgooZMNNcy" ,
40
- appUrl : "https://us.i.posthog.com" ,
41
- enableInDevelopment : false ,
42
- } ,
43
- ] ,
37
+ ( ) => ( {
38
+ name : 'load-env-vars' ,
39
+ configureWebpack : ( ) => ( {
40
+ mergeStrategy : { plugins : "append" , resolve : "merge" } ,
41
+ plugins : [
42
+ new webpack . DefinePlugin ( {
43
+ 'process.env.COCOINDEX_DOCS_MIXPANEL_API_KEY' : JSON . stringify ( process . env . COCOINDEX_DOCS_MIXPANEL_API_KEY ) ,
44
+ } )
45
+ ] ,
46
+ } ) ,
47
+ } ) ,
44
48
] ,
45
49
46
50
presets : [
@@ -147,4 +151,16 @@ const config: Config = {
147
151
} satisfies Preset . ThemeConfig ,
148
152
} ;
149
153
154
+
155
+ if ( ! ! process . env . COCOINDEX_DOCS_POSTHOG_API_KEY ) {
156
+ config . plugins . push ( [
157
+ "posthog-docusaurus" ,
158
+ {
159
+ apiKey : process . env . COCOINDEX_DOCS_POSTHOG_API_KEY ,
160
+ appUrl : "https://us.i.posthog.com" ,
161
+ enableInDevelopment : false ,
162
+ } ,
163
+ ] ) ;
164
+ }
165
+
150
166
export default config ;
Original file line number Diff line number Diff line change @@ -2,11 +2,12 @@ import React from 'react';
2
2
import mixpanel from 'mixpanel-browser' ;
3
3
4
4
// Default implementation, that you can customize
5
- export default function Root ( { children} ) {
5
+ export default function Root ( { children } ) {
6
6
React . useEffect ( ( ) => {
7
- if ( typeof window !== 'undefined' ) {
7
+ const mixpanelApiKey = process . env . COCOINDEX_DOCS_MIXPANEL_API_KEY ;
8
+ if ( typeof window !== 'undefined' && ! ! mixpanelApiKey ) {
8
9
// Initialize Mixpanel with the token
9
- mixpanel . init ( '46addeb6bedf8684a445aced6e67c76e' , {
10
+ mixpanel . init ( mixpanelApiKey , {
10
11
track_pageview : true ,
11
12
debug : process . env . NODE_ENV === 'development'
12
13
} ) ;
You can’t perform that action at this time.
0 commit comments