Commit ef8fba1d authored by vignesh mohankumar's avatar vignesh mohankumar Committed by GitHub

feat: add git commit hash on build (#4701)

* feat: add git commit hash on build

* process.env.

* works

* log

* import

* log full
parent be64c03d
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin') const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin') const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { DefinePlugin } = require('webpack')
const commitHash = require('child_process').execSync('git rev-parse HEAD')
module.exports = { module.exports = {
babel: { babel: {
plugins: ['@vanilla-extract/babel-plugin'], plugins: ['@vanilla-extract/babel-plugin'],
}, },
webpack: { webpack: {
plugins: [new VanillaExtractPlugin()], plugins: [
new VanillaExtractPlugin(),
new DefinePlugin({
'process.env.REACT_APP_GIT_COMMIT_HASH': JSON.stringify(commitHash.toString()),
}),
],
configure: (webpackConfig) => { configure: (webpackConfig) => {
const instanceOfMiniCssExtractPlugin = webpackConfig.plugins.find( const instanceOfMiniCssExtractPlugin = webpackConfig.plugins.find(
(plugin) => plugin instanceof MiniCssExtractPlugin (plugin) => plugin instanceof MiniCssExtractPlugin
......
...@@ -45,7 +45,13 @@ export const Trace = memo( ...@@ -45,7 +45,13 @@ export const Trace = memo(
useEffect(() => { useEffect(() => {
if (shouldLogImpression) { if (shouldLogImpression) {
const origin = window.location.origin const origin = window.location.origin
sendAnalyticsEvent(name ?? EventName.PAGE_VIEWED, { ...combinedProps, ...properties, origin }) const commitHash = process.env.REACT_APP_GIT_COMMIT_HASH
sendAnalyticsEvent(name ?? EventName.PAGE_VIEWED, {
...combinedProps,
...properties,
origin,
git_commit_hash: commitHash,
})
} }
// Impressions should only be logged on mount. // Impressions should only be logged on mount.
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment