4
4
import { __ } from '@wordpress/i18n' ;
5
5
import CustomerEffortScore from '@woocommerce/customer-effort-score' ;
6
6
import { recordEvent } from '@woocommerce/tracks' ;
7
+ import PropTypes from 'prop-types' ;
7
8
8
9
/**
9
10
* Internal dependencies
10
11
*/
11
12
import { LOCAL_STORAGE_KEYS } from '.~/constants' ;
12
13
import localStorage from '.~/utils/localStorage' ;
13
14
14
- const EVENT_CONTEXT = 'gla-setup' ;
15
-
16
- export default function CustomerEffortScorePrompt ( ) {
15
+ const CustomerEffortScorePrompt = ( { eventContext, label } ) => {
17
16
const removeCESPromptFlagFromLocal = ( ) => {
18
17
localStorage . remove (
19
18
LOCAL_STORAGE_KEYS . CAN_ONBOARDING_SETUP_CES_PROMPT_OPEN
@@ -22,38 +21,35 @@ export default function CustomerEffortScorePrompt() {
22
21
23
22
const onNoticeShown = ( ) => {
24
23
recordEvent ( 'gla_ces_snackbar_open' , {
25
- context : EVENT_CONTEXT ,
24
+ context : eventContext ,
26
25
} ) ;
27
26
} ;
28
27
29
28
const onNoticeDismissed = ( ) => {
30
29
removeCESPromptFlagFromLocal ( ) ;
31
30
recordEvent ( 'gla_ces_snackbar_closed' , {
32
- context : EVENT_CONTEXT ,
31
+ context : eventContext ,
33
32
} ) ;
34
33
} ;
35
34
36
35
const onModalShown = ( ) => {
37
36
removeCESPromptFlagFromLocal ( ) ;
38
37
recordEvent ( 'gla_ces_modal_open' , {
39
- context : EVENT_CONTEXT ,
38
+ context : eventContext ,
40
39
} ) ;
41
40
} ;
42
41
43
42
const recordScore = ( score , comments ) => {
44
43
recordEvent ( 'gla_ces_feedback' , {
45
- context : EVENT_CONTEXT ,
44
+ context : eventContext ,
46
45
score,
47
46
comments : comments || '' ,
48
47
} ) ;
49
48
} ;
50
49
51
50
return (
52
51
< CustomerEffortScore
53
- label = { __ (
54
- 'How easy was it to set up Google Listings & Ads?' ,
55
- 'google-listings-and-ads'
56
- ) }
52
+ label = { label }
57
53
recordScoreCallback = { recordScore }
58
54
onNoticeShownCallback = { onNoticeShown }
59
55
onNoticeDismissedCallback = { onNoticeDismissed }
@@ -72,4 +68,17 @@ export default function CustomerEffortScorePrompt() {
72
68
}
73
69
/>
74
70
) ;
75
- }
71
+ } ;
72
+
73
+ CustomerEffortScorePrompt . propTypes = {
74
+ /**
75
+ * The text to be displayed on the CES prompt
76
+ */
77
+ label : PropTypes . string . isRequired ,
78
+ /**
79
+ * Context property to be sent when calling recordEvent
80
+ */
81
+ eventContext : PropTypes . string . isRequired ,
82
+ } ;
83
+
84
+ export default CustomerEffortScorePrompt ;
0 commit comments