modern-answer-65441
01/06/2023, 4:44 PMimport { AnalyticsBrowser } from '@segment/analytics-next';
const isEnabled = true;
const key: string = process.env.SEGMENT_KEY as string;
let analytics = AnalyticsBrowser.load({ writeKey: key });
analytics = Object.assign(analytics, { name: 'segment', loaded: () => true });
export default { isEnabled, plugin: analytics };
After building the image and running it, the events are not captured in segment
it works when I directly put the key, something like this
const key: string = 'YDFGDfsdfEW';
I entered the container and ran the command 'printenv'
I can see the env variable in the container
Can someone tell me why 'process.env.SEGMENT_KEY' is not able to pull the value ?modern-answer-65441
01/06/2023, 7:36 PMgreen-football-43791
01/09/2023, 4:34 PMprocess.env.ENV_VAR, its the value of the ENV_VAR when the react bundle was built, not when the react app is servedgreen-football-43791
01/09/2023, 4:35 PMmodern-answer-65441
01/09/2023, 4:35 PMmodern-answer-65441
01/09/2023, 4:35 PMmodern-answer-65441
01/09/2023, 4:36 PM