@@ -5,32 +5,38 @@ import { useGetUsersMeQuery } from 'src/features/api';
55import { useActiveWorkspace } from 'src/hooks/useActiveWorkspace' ;
66import { useAnalytics } from 'use-analytics' ;
77
8- // const tagManagerArgs: TagManagerArgs = {
9- // gtmId: process.env.REACT_APP_GTM_ID || 'GTM-WVXPS94',
10- // ...(isDev() && {
11- // auth: 'HjeAxSQB9e685mi-_8YiDw',
12- // preview: 'env-4',
13- // }),
14- // events: {
15- // unguess_loaded: 'unguess_loaded',
16- // workspace_change: 'workspace_change',
17- // generic_error: 'generic_error',
18- // },
19- // };
20- // TagManager.initialize(tagManagerArgs);
21-
228export const Track = ( {
239 title,
10+ description,
11+ metaTags,
2412 children,
2513} : {
2614 title : string ;
15+ description ?: string ;
16+ metaTags ?: { name : string ; content : string } [ ] ;
2717 children : React . ReactNode ;
2818} ) => {
2919 const { data : userData , isLoading, isSuccess } = useGetUsersMeQuery ( ) ;
3020 const { activeWorkspace } = useActiveWorkspace ( ) ;
3121 const { track, identify, page } = useAnalytics ( ) ;
3222 const location = useLocation ( ) ;
3323
24+ const defaultMeta = [
25+ { name : 'og:description' , content : description ?? title } ,
26+ { name : 'robots' , content : 'noindex, nofollow' } ,
27+ ] ;
28+
29+ // Merge metaTags over defaultMeta, overriding by name
30+ const meta : { name : string ; content : string } [ ] = [
31+ ...defaultMeta . map ( ( def ) => {
32+ const override = metaTags ?. find ( ( m ) => m . name === def . name ) ;
33+ return override ?? def ;
34+ } ) ,
35+ ...( metaTags ?. filter (
36+ ( m ) => ! defaultMeta . some ( ( def ) => def . name === m . name )
37+ ) ?? [ ] ) ,
38+ ] ;
39+
3440 useEffect ( ( ) => {
3541 page ( ) ;
3642 } , [ location ] ) ;
@@ -39,7 +45,10 @@ export const Track = ({
3945 < Helmet >
4046 < title > { title } - UNGUESS</ title >
4147 < meta property = "og:title" content = { title } />
42- < meta name = "description" content = { title } />
48+ < meta name = "description" content = { description ?? title } />
49+ { meta . map ( ( m ) => (
50+ < meta key = { m . name } name = { m . name } content = { m . content } />
51+ ) ) }
4352 </ Helmet >
4453 ) ;
4554
@@ -53,6 +62,7 @@ export const Track = ({
5362 name : userData . name ,
5463 email : userData . email ,
5564 company : activeWorkspace . company ,
65+ workspace : activeWorkspace ,
5666 } ) ;
5767
5868 track (
@@ -68,8 +78,8 @@ export const Track = ({
6878 } ,
6979 {
7080 plugins : {
71- // disable track event for segment
72- segment : false ,
81+ // disable userpilot for this event
82+ userpilot : false ,
7383 } ,
7484 }
7585 ) ;
0 commit comments