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 6161 env :
6262 USE_SSH : true
6363 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 }}
6466 git config --global user.email "[email protected] " 6567 git config --global user.name "CocoIndex"
6668 yarn install --frozen-lockfile
Original file line number Diff line number Diff line change 1+ import webpack from 'webpack' ;
12import { themes as prismThemes } from 'prism-react-renderer' ;
23import type { Config } from '@docusaurus/types' ;
34import type * as Preset from '@docusaurus/preset-classic' ;
@@ -33,14 +34,17 @@ const config: Config = {
3334 } ,
3435
3536 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+ } ) ,
4448 ] ,
4549
4650 presets : [
@@ -147,4 +151,16 @@ const config: Config = {
147151 } satisfies Preset . ThemeConfig ,
148152} ;
149153
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+
150166export default config ;
Original file line number Diff line number Diff line change @@ -2,11 +2,12 @@ import React from 'react';
22import mixpanel from 'mixpanel-browser' ;
33
44// Default implementation, that you can customize
5- export default function Root ( { children} ) {
5+ export default function Root ( { children } ) {
66 React . useEffect ( ( ) => {
7- if ( typeof window !== 'undefined' ) {
7+ const mixpanelApiKey = process . env . COCOINDEX_DOCS_MIXPANEL_API_KEY ;
8+ if ( typeof window !== 'undefined' && ! ! mixpanelApiKey ) {
89 // Initialize Mixpanel with the token
9- mixpanel . init ( '46addeb6bedf8684a445aced6e67c76e' , {
10+ mixpanel . init ( mixpanelApiKey , {
1011 track_pageview : true ,
1112 debug : process . env . NODE_ENV === 'development'
1213 } ) ;
You can’t perform that action at this time.
0 commit comments