@@ -49,20 +49,35 @@ const SetupAnalyticsModal = ({
49
49
50
50
const pm2StartupScript = "pm2 startup" ;
51
51
52
- const analyticsScript = useMemo < string > ( ( ) => {
52
+ const analyticsScriptConfiguration = useMemo < string > ( ( ) => {
53
53
if ( ! hasProjectApiKey || ! hasAuthenticatedUser ) {
54
54
return "" ;
55
55
}
56
56
57
57
const apiKey = project . apiKey as string ;
58
58
const userId = String ( authenticatedUser . id ) ;
59
59
60
- return `npx @git-fit/analytics@latest track ${ apiKey } ${ userId } <project-path-1> <project-path-2> ...` ;
60
+ return `{
61
+ "apiKey": "${ apiKey } ",
62
+ "userId": ${ userId } ,
63
+ "repoPaths": [
64
+
65
+ ]
66
+ }` ;
61
67
} , [ hasProjectApiKey , hasAuthenticatedUser , project , authenticatedUser ] ) ;
62
68
69
+ const analyticsScript = useMemo < string > ( ( ) => {
70
+ if ( ! hasProjectApiKey || ! hasAuthenticatedUser ) {
71
+ return "" ;
72
+ }
73
+
74
+ return "npx @git-fit/analytics@latest track <config-path>" ;
75
+ } , [ hasProjectApiKey , hasAuthenticatedUser ] ) ;
76
+
63
77
const { control, errors, handleSubmit, handleValueSet } = useAppForm ( {
64
78
defaultValues : {
65
79
analyticsScript,
80
+ analyticsScriptConfiguration,
66
81
apiKey : project . apiKey ?? "" ,
67
82
pm2StartupScript,
68
83
projectId : project . id ,
@@ -96,6 +111,10 @@ const SetupAnalyticsModal = ({
96
111
handleCopyApiKeyToClipboard ( project . apiKey as string ) ;
97
112
} , [ handleCopyApiKeyToClipboard , project ] ) ;
98
113
114
+ const handleCopyAnalyticsScriptConfigurationClick = useCallback ( ( ) => {
115
+ handleCopyScriptToClipboard ( analyticsScriptConfiguration ) ;
116
+ } , [ handleCopyScriptToClipboard , analyticsScriptConfiguration ] ) ;
117
+
99
118
const handleCopyAnalyticsScriptClick = useCallback ( ( ) => {
100
119
handleCopyScriptToClipboard ( analyticsScript ) ;
101
120
} , [ handleCopyScriptToClipboard , analyticsScript ] ) ;
@@ -221,21 +240,47 @@ const SetupAnalyticsModal = ({
221
240
</ li >
222
241
< li className = { styles [ "list-item" ] } >
223
242
< span className = { styles [ "list-item-title" ] } >
224
- Clone your project repository .
243
+ Clone your project repositories .
225
244
</ span >
226
245
< p className = { styles [ "list-item-text" ] } >
227
- Use Git to clone your project repository to your local machine.
246
+ Use Git to clone your project repositories to your local
247
+ machine.
228
248
</ p >
229
249
</ li >
230
250
251
+ < li className = { styles [ "list-item" ] } >
252
+ < span className = { styles [ "list-item-title" ] } >
253
+ Save the following configuration file to your local machine and
254
+ add local paths to all of your repositories to it.
255
+ </ span >
256
+
257
+ < Input
258
+ control = { control }
259
+ errors = { errors }
260
+ isLabelHidden
261
+ isReadOnly
262
+ label = "Analytics script configuration"
263
+ name = "analyticsScriptConfiguration"
264
+ placeholder = "Need to generate API key"
265
+ rightIcon = {
266
+ < IconButton
267
+ iconName = "clipboard"
268
+ isDisabled = { isCopyButtonDisabled }
269
+ label = "Copy script configuration"
270
+ onClick = { handleCopyAnalyticsScriptConfigurationClick }
271
+ />
272
+ }
273
+ rowsCount = { 9 }
274
+ />
275
+ </ li >
276
+
231
277
< li className = { styles [ "list-item" ] } >
232
278
< span className = { styles [ "list-item-title" ] } >
233
279
Prepare the script.
234
280
</ span >
235
281
< p className = { styles [ "list-item-text" ] } >
236
- Copy the command below and replace <project-path-1>,
237
- <project-path-2>, ... placeholder with your local
238
- repositories paths:
282
+ Copy the command below and replace <config-path> with the
283
+ path to your configuration file from the previous step.
239
284
</ p >
240
285
< Input
241
286
control = { control }
0 commit comments