Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable users to seamlessly set up conversion tracking during the onboarding flow #2415

Merged
merged 224 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
224 commits
Select commit Hold shift + click to select a range
42a81e1
Add google ads card in setup mc
ankitrox Jan 12, 2024
58493df
Make Google ads card mandatory
ankitrox Jan 18, 2024
c516601
Remove unused prop
ankitrox Jan 18, 2024
c3f1487
Remove Google ads from step-4
ankitrox Jan 19, 2024
45965dc
Fix: tests code coverage
ankitrox Jan 22, 2024
b61de0d
Remove redundant code
ankitrox Jan 22, 2024
d13f0e2
Merge branch 'develop' into feature/setup-google-ads-in-step1
ankitrox Jan 22, 2024
b44aadc
Fix: create new ads account link
ankitrox Jan 26, 2024
20f06a0
Pass disabled prop to ads component
ankitrox Jan 26, 2024
6252fed
Revert "Remove redundant code"
joemcgill Jan 29, 2024
b96751d
Allow Ads/MC connection from either step
joemcgill Jan 29, 2024
3658a39
Revert "Fix: tests code coverage"
joemcgill Jan 29, 2024
f9e7b79
Fix unit tests
joemcgill Jan 29, 2024
a28f3e9
Add unit tests for Merchant service changes
joemcgill Jan 29, 2024
41d1a8c
Define Ads object for MC Service tets
joemcgill Jan 29, 2024
0cfd5ed
Fix MC service step tests
joemcgill Jan 29, 2024
824cfcc
Fix MC service unit tests
joemcgill Jan 29, 2024
1d0b9a6
Fix step 1 E2E tests
joemcgill Jan 30, 2024
bc4520c
Move useGoogleAccountCheck to its own file.
asvinb Jan 30, 2024
a4c67fd
Merge pull request #2227 from woocommerce/feature/setup-google-ads-in…
joemcgill Jan 30, 2024
b35cd36
Merge pull request #2223 from woocommerce/update/R1-E2E-tests
ankitrox Jan 31, 2024
9d71f69
Fix: e2e setup-mc tests
ankitrox Jan 31, 2024
d99404b
Tests for google ads modal
ankitrox Jan 31, 2024
7af7a95
Tests: connect existing google ads account
ankitrox Jan 31, 2024
d50edc1
Handle null ads links when linking MC accounts
joemcgill Feb 1, 2024
ce544a1
Make MC and Ads account creation decoupled
ankitrox Feb 2, 2024
0f66ae8
Fix: Linting errors
ankitrox Feb 2, 2024
4e97b52
Add conversion tracking message in ads connected card
ankitrox Feb 2, 2024
bbd18f5
Styled success Notice within AccountCard.
asvinb Feb 2, 2024
f33c7cf
Fix: e2e MC tests
ankitrox Feb 2, 2024
cdba793
Update step 1 E2E tests
joemcgill Feb 2, 2024
af9936f
Do not show notice in ads card when setup is complete
ankitrox Feb 5, 2024
1d1bdd9
Update ads card text
ankitrox Feb 5, 2024
8c2614d
Hide Create Account button in ads and mc card
ankitrox Feb 5, 2024
2e5d20f
Move success notice to GA Account card
joemcgill Feb 6, 2024
e22b570
Fix linting
joemcgill Feb 6, 2024
5a5b410
R1.2 – Update Step 4 of the Onboarding flow
ankitrox Feb 7, 2024
8597a8c
Merge pull request #2248 from woocommerce/feature/setup-google-ads-in…
joemcgill Feb 14, 2024
d118f00
Merge branch 'develop' into feature/setup-google-ads-in-step1
ankitrox Feb 21, 2024
93eec03
Add Google Ads invite acceptance flow
ankitrox Feb 21, 2024
16477bb
Add account_status step in ads account setup
ankitrox Feb 21, 2024
83bf0e6
Extract and store OCID from billing url
ankitrox Feb 22, 2024
7bf450f
Run the linking steps conditionally
ankitrox Feb 22, 2024
7b60f42
Fix: Unit tests
ankitrox Feb 23, 2024
b8a2d6d
Add doc block
ankitrox Feb 23, 2024
fae47e4
Fix: phpcs
ankitrox Feb 23, 2024
337063b
Add Google Ads account acceptance modal.
asvinb Feb 23, 2024
5b58ee9
Remove debugging lines.
asvinb Feb 23, 2024
7f75d72
Update wording.
asvinb Feb 23, 2024
da87d4e
Merge branch 'feature/2262-acceptance-flow' into update/2262-ads-acce…
joemcgill Feb 26, 2024
717bba9
Tests for account access function
ankitrox Feb 26, 2024
e96c7e5
Merge branch 'update/2262-ads-accept-invite-flow' of https://github.c…
ankitrox Feb 26, 2024
d004d69
Return early if no ads ID
ankitrox Feb 27, 2024
11c5f10
Fix: typo and unit tests
ankitrox Feb 27, 2024
22a2881
Remove ui property from main data store.
asvinb Feb 27, 2024
2da2153
Fire account creation process after invite has been accepted.
asvinb Feb 27, 2024
b99668c
Fix: unit tests php
ankitrox Feb 27, 2024
35a8887
Merge branch 'update/2262-ads-accept-invite-flow' of https://github.c…
ankitrox Feb 27, 2024
44452ff
Refresh stale data when there's a new ads account.
asvinb Feb 27, 2024
5e47286
Merge branch 'update/2262-ads-accept-invite-flow' of github.com:wooco…
asvinb Feb 27, 2024
1cf2f96
Remove unused props and cleanup.
asvinb Feb 27, 2024
bf779b7
Fix: unit tests - linking ads id
ankitrox Feb 27, 2024
35a590c
Invalidate Google Ads account status when other actions are dispatched.
asvinb Feb 27, 2024
b529739
Fix linting errors.
asvinb Feb 27, 2024
9e0c55f
Add new useFetchCreateAdsAccount.js hook.
asvinb Feb 28, 2024
9203183
Remove unused styles.
asvinb Feb 28, 2024
99806c4
Add missing file.
asvinb Feb 28, 2024
5a9839f
Add tests for showing the ClaimAccount component.
asvinb Feb 28, 2024
f96466a
Update endpoint response to 200 for no ads id
ankitrox Feb 28, 2024
7ce1440
Merge branch 'update/2262-ads-accept-invite-flow' of https://github.c…
ankitrox Feb 28, 2024
f76d93a
Update conditions to enable Continue button.
asvinb Feb 28, 2024
314e2ab
Remove unused variable.
asvinb Feb 28, 2024
cce1329
Review code review feedback and implementation.
asvinb Feb 28, 2024
c552027
Return ExceptionWithResponseData during new account creation
ankitrox Mar 4, 2024
4a01e3c
Fix: controller test
ankitrox Mar 4, 2024
aae8e1c
Do not throw error for no billing link
ankitrox Mar 5, 2024
1c10008
Update docblock
ankitrox Mar 5, 2024
c68a0a6
Merge branch 'develop' into feature/setup-google-ads-in-step1
ankitrox Mar 5, 2024
6c6b5ee
Merge branch 'feature/setup-google-ads-in-step1' of https://github.co…
ankitrox Mar 5, 2024
a743cb8
Fix modal not showing up.
asvinb Mar 6, 2024
6a09d6f
Merge branch 'update/2262-ads-accept-invite-flow' of github.com:wooco…
asvinb Mar 6, 2024
4c963cd
Start implementing feedback from CR.
asvinb Mar 6, 2024
5ed0c20
Save work in progress.
asvinb Mar 7, 2024
72be16b
Move Claim components within CreateButton.
asvinb Mar 7, 2024
00dc5d7
Remove unused hook.
asvinb Mar 7, 2024
14ca5e4
Fix: test test_setup_account_step_link_merchant_no_merchant_id
ankitrox Mar 8, 2024
c23eff6
Fix: test test_setup_account_step_link_ads_without_ads_id
ankitrox Mar 8, 2024
927e438
Update the state in DB
ankitrox Mar 8, 2024
961d2d9
Make tests for account linking consistent.
joemcgill Mar 8, 2024
b71e497
Ensure account IDs are present when linking Ads and MC
joemcgill Mar 8, 2024
e08dad5
Merge branch 'feature/setup-google-ads-in-step1' into update/2262-ads…
joemcgill Mar 11, 2024
31ab39a
Fix CS issues
joemcgill Mar 11, 2024
3fe26ce
Replace useGoogleAccountCheck hook
joemcgill Mar 11, 2024
99c5a94
Fix whitespace
joemcgill Mar 11, 2024
8f273de
Fix hook file path
joemcgill Mar 11, 2024
6c680ab
Update tests/Unit/Ads/AccountServiceTest.php
ankitrox Mar 12, 2024
51f4e7c
Better handle HTTP errors.
asvinb Mar 12, 2024
76a68cb
Merge branch 'update/2262-ads-accept-invite-flow' of github.com:wooco…
asvinb Mar 12, 2024
3c6f43c
Revert change.
asvinb Mar 12, 2024
5bc6b91
Fix test.
asvinb Mar 12, 2024
71f651c
Show connected MC when step is link_ads
joemcgill Mar 12, 2024
a3d758a
Enable continue button when both accounts are connected
joemcgill Mar 12, 2024
6ce5357
Add tests for Ads account claim modal
joemcgill Mar 12, 2024
b2644d3
Mark the linking step as complete when both ads and mechant ids present
ankitrox Mar 13, 2024
de64f57
Resolve conflicts: pull changes
ankitrox Mar 13, 2024
a05419e
Revert modal logic.
asvinb Mar 13, 2024
50a1cb2
Fix: tests
ankitrox Mar 13, 2024
51ec057
Adjust docs
ankitrox Mar 13, 2024
2924907
Update src/Ads/AccountService.php
ankitrox Mar 13, 2024
46c05b7
Update src/MerchantCenter/AccountService.php
ankitrox Mar 13, 2024
b8a2413
Update tests/Unit/MerchantCenter/AccountServiceTest.php
ankitrox Mar 13, 2024
508c468
Fix: account service test
ankitrox Mar 13, 2024
d72a7b8
Merge branch 'feature/setup-google-ads-in-step1' into update/2262-ads…
ankitrox Mar 13, 2024
2ce8cac
Update src/Ads/AccountService.php
ankitrox Mar 13, 2024
1fbb283
Delete ocid when ads account disconnected
ankitrox Mar 13, 2024
f2cff6f
Merge branch 'update/2262-ads-accept-invite-flow' of https://github.c…
ankitrox Mar 13, 2024
9911323
Use a separate mocked state
mikkamp Mar 13, 2024
619c437
Deep link billing url
ankitrox Mar 13, 2024
90c21a5
Change test method name
ankitrox Mar 13, 2024
c5e0d9a
Better way to implement the modal.
asvinb Mar 14, 2024
3b698dc
Merge branch 'update/2262-ads-accept-invite-flow' of github.com:wooco…
asvinb Mar 14, 2024
657bd45
Fix failing test.
asvinb Mar 14, 2024
cfbdb3b
Include last completed step in account-status callback
joemcgill Mar 14, 2024
e61f961
Update claim modal and notice
joemcgill Mar 14, 2024
0410d64
Update budget section description
joemcgill Mar 14, 2024
480f719
Fix JS tests
joemcgill Mar 14, 2024
7c59217
Trigger Ads process in a more stable manner.
asvinb Mar 15, 2024
b5e3829
Fix linting errors.
asvinb Mar 15, 2024
adf7786
Merge branch 'feature/setup-google-ads-in-step1' into update/2262-ads…
asvinb Mar 15, 2024
1b79f1c
Remove unused ProductFeedStatusSection component and related code.
asvinb Mar 15, 2024
5cb0e5b
Show CreateAccount when conversion_action is needed
joemcgill Mar 18, 2024
49f325e
Onboarding: Don't skip to step 2 if Ads is not connected.
joemcgill Mar 19, 2024
7db3b6e
Fix unit tests
joemcgill Mar 19, 2024
24c494e
Update step 4 label
joemcgill Mar 19, 2024
833eba1
Update step 4 label
joemcgill Mar 19, 2024
36e1c4d
Merge branch 'update/2262-ads-accept-invite-flow' into update/2262-in…
joemcgill Mar 19, 2024
370b1f8
Fix add-paid-campaigns tests
joemcgill Mar 19, 2024
c52523f
Fix race condition
joemcgill Mar 19, 2024
23359a5
Fix billing setup tests
joemcgill Mar 19, 2024
2ba66e2
Add unit tests
joemcgill Mar 19, 2024
be1896c
Update e2e tests with API changes for status
joemcgill Mar 19, 2024
9f3faab
E2E: Update step 3 & 4 text
joemcgill Mar 19, 2024
bb3a222
E2E: Fix Step 4 tests
joemcgill Mar 19, 2024
35ef563
Merge pull request #2320 from woocommerce/update/2270-fix-skipping-to…
joemcgill Mar 21, 2024
d40def2
Move ClaimTermsAndCreateAccountButton to its own file.
asvinb Mar 25, 2024
7b643e0
Remove unused CSS.
asvinb Mar 25, 2024
5b0db4e
Merge branch 'feature/setup-google-ads-in-step1' into update/2262-ads…
asvinb Mar 25, 2024
067a9b6
Return 428 errors for ads/account-status when Google or Ads is not se…
joemcgill Mar 25, 2024
ae2c89a
Fix PHPCS issues
joemcgill Mar 25, 2024
95298bc
Improve disabled logic for the setup accounts continue button.
joemcgill Mar 25, 2024
982fd77
Make sure ads-stepper cannot continue until account is claimed
joemcgill Mar 25, 2024
d22126a
Use step returned from account-status in NonConnected
joemcgill Mar 25, 2024
d9f73ea
Show success notice when Ads is set up before MC
joemcgill Mar 25, 2024
40148eb
Update `test_get_ads_account_has_access` test for the account controller
joemcgill Mar 25, 2024
136a25e
Deeplink to the payment page for accepted accounts
joemcgill Mar 26, 2024
d941c7e
Fix ocid fallback
joemcgill Mar 26, 2024
c3aa60d
Fix Ads success notice when no Google account is connected
joemcgill Mar 26, 2024
44c80c9
Merge branch 'update/2262-ads-accept-invite-flow' into update/2262-in…
joemcgill Mar 26, 2024
60e78d2
Merge branch 'update/2262-ads-accept-invite-flow' of github.com:wooco…
asvinb Mar 29, 2024
097e169
Create ClaimAccountButton component.
asvinb Mar 29, 2024
60fb0ed
Fix issues in e2e and remove duplication
ankitrox Mar 29, 2024
774adc5
Js lint fix
ankitrox Mar 29, 2024
d3f1b48
Fix exception when response.json() fails
puntope Mar 7, 2024
0b71ecf
Fix Uncaught TypeError
joemcgill Apr 1, 2024
bb66dd4
Don't return 428 responses from ads/account-status endpoint
joemcgill Apr 2, 2024
83af226
Fix PHPCS error
joemcgill Apr 2, 2024
db9d822
Update Value Prop card for paid ads
joemcgill Apr 2, 2024
6cf6471
Update benefits card copy
joemcgill Apr 2, 2024
8722631
Remove createInterpolateElement
joemcgill Apr 5, 2024
5d2a502
Remove 428 handling from `fetchGoogleAdsAccountStatus` action
joemcgill Apr 5, 2024
762c7c8
Show spinner if there is an error fetching the Ads account
joemcgill Apr 5, 2024
f9f8848
Remove unused deps
joemcgill Apr 5, 2024
3192374
Remove fetchWithHeaders from fetchGoogleAdsAccountStatus
joemcgill Apr 8, 2024
bcfdb49
Remove unused deps
joemcgill Apr 8, 2024
dd037f7
Fix apiFetch response shape
joemcgill Apr 8, 2024
ffaf347
Merge branch 'update/2262-ads-accept-invite-flow' into update/2262-in…
joemcgill Apr 8, 2024
cff3288
E2E: Fix account status shape in mocks
joemcgill Apr 8, 2024
0074f08
E2E update setup-mc step 4 tests
joemcgill Apr 8, 2024
d262920
Fix continue button during ads setup
joemcgill Apr 8, 2024
d33783b
E2E improve mocking of account status tests
joemcgill Apr 8, 2024
3f8094e
E2E docs improvements
joemcgill Apr 8, 2024
eea1d8e
E2E: Fix test descriptions
joemcgill Apr 8, 2024
957949a
Retun 428 from Ads setup when we don't have access
joemcgill Apr 14, 2024
7441afb
Consolidate logic for updating a newly created account
joemcgill Apr 15, 2024
f7d71b4
Address review feedback
joemcgill Apr 15, 2024
5c12ab7
Fix error handling in useUpsertAdsAccount hook.
joemcgill Apr 15, 2024
a2b44c7
Merge branch 'update/2262-ads-accept-invite-flow' into update/2262-in…
joemcgill Apr 15, 2024
5901afe
Update docblock for `useUpsertAdsAccount` hook
joemcgill Apr 16, 2024
bb39dd3
Update create/claim account flow
joemcgill Apr 16, 2024
f4e55be
Merge pull request #2270 from woocommerce/update/2262-ads-accept-invi…
joemcgill Apr 24, 2024
d63edd4
Update inline code comment
joemcgill Apr 24, 2024
b0a1bac
Merge pull request #2308 from woocommerce/update/2262-invite-modal-tests
joemcgill Apr 25, 2024
65f240f
Remove unneccessary inline comment
joemcgill Apr 25, 2024
dfd4075
Merge branch 'develop' into feature/setup-google-ads-in-step1
eason9487 May 16, 2024
f16a8b4
Merge pull request #2205 from woocommerce/feature/setup-google-ads-in…
eason9487 May 27, 2024
cdd6807
Add a retry mechanism to the `API\Google\Ads::get_merchant_link` method.
eason9487 May 27, 2024
6e54e69
Add a test for the retry mechanism of the `API\Google\Ads::get_mercha…
eason9487 May 27, 2024
a97041b
Simplify the loading state control during the Google Ads account crea…
eason9487 May 27, 2024
ddbd347
Parallel fetches Google Ads account and its status in the `useUpsertA…
eason9487 May 27, 2024
b62983b
Disable the "Or, use your existing Google Ads account" button while u…
eason9487 May 27, 2024
d23a5db
Merge pull request #2412 from woocommerce/tweak/retry-get-merchant-link
eason9487 May 29, 2024
b50c83e
Merge pull request #2413 from woocommerce/tweak/ads-account-create-an…
eason9487 May 29, 2024
c5fe2d8
Merge branch 'develop' into feature/seamlessly-conversion-tracking
eason9487 May 29, 2024
6278f3a
Adjust jest config and setup so that tests related to event tracking …
eason9487 May 29, 2024
5248319
Add a React hook `useEventPropertiesFilter` to handle event propertie…
eason9487 May 30, 2024
b771bb2
Add `context` and `step` event properties to Extension and Ads onboar…
eason9487 May 30, 2024
de339b0
Reuse `ClaimAccountButton` to reduce the duplicate implementation.
eason9487 May 29, 2024
b415243
Add event tracking to `ClaimAccountButton`.
eason9487 May 29, 2024
5930abc
Add `context` and `step` event properties to the click event tracking…
eason9487 May 30, 2024
2129e87
Make each filter namespace in `useEventPropertiesFilter` unique to av…
eason9487 May 31, 2024
a63df8d
Tweak the JSDoc of the `ClaimAccountButton` component.
eason9487 May 31, 2024
4a2bc0d
Add `context` and `step` event properties to the click event tracking…
eason9487 May 31, 2024
2ef11c7
Add `context` and `step` event properties to the click event tracking…
eason9487 May 31, 2024
9a997e2
Adjust `context` and add `step` event properties to the click event t…
eason9487 May 31, 2024
130d843
Remove the unused component `GoogleAdsAccountSection`.
eason9487 May 31, 2024
0e6b33d
Add global event properties to the tracking README file.
eason9487 Jun 3, 2024
8dd83ab
Add JS tests for the `useEventPropertiesFilter` hook.
eason9487 Jun 4, 2024
8348389
Rename `expectEventWithPropertiesFilter` function, add JSDoc and adju…
eason9487 Jun 5, 2024
1179f5b
Adjust the JSDoc of the `useEventPropertiesFilter` hook.
eason9487 Jun 5, 2024
fade6ca
Merge pull request #2419 from woocommerce/tweak/2215-event-tracking-p…
eason9487 Jun 5, 2024
2b6a746
Merge branch 'tweak/2215-event-tracking-part-1' into tweak/2215-event…
eason9487 Jun 5, 2024
086366d
Merge pull request #2421 from woocommerce/tweak/2215-event-tracking-p…
eason9487 Jun 5, 2024
63985d0
Merge branch 'develop' into feature/seamlessly-conversion-tracking
eason9487 Jun 5, 2024
340cb89
Update the `src/Tracking/README.md` file.
eason9487 Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ module.exports = {
additionalHooks: 'useSelect',
},
],
'jest/expect-expect': [
'warn',
{ assertFunctionNames: [ 'expect', 'expect[A-Z]\\w*' ] },
],
},
overrides: [
{
Expand Down
13 changes: 0 additions & 13 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ module.exports = {
wcAdminFeatures: {
navigation: false,
},
glaData: {
slug: 'gla',
mcSetupComplete: true,
mcSupportedCountry: true,
mcSupportedLanguage: true,
adsSetupComplete: true,
enableReports: true,
dateFormat: 'F j, Y',
timeFormat: 'g:i a',
initialWpData: {
version: '1.2.3',
},
},
},
timers: 'fake',
};
4 changes: 2 additions & 2 deletions js/src/components/account-card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ const appearanceDict = {
icon: googleMCLogo,
title: __( 'Google Merchant Center', 'google-listings-and-ads' ),
description: __(
'Required to sync products and list on Google',
'Required to sync products and list on Google.',
'google-listings-and-ads'
),
},
[ APPEARANCE.GOOGLE_ADS ]: {
icon: googleAdsLogo,
title: __( 'Google Ads', 'google-listings-and-ads' ),
description: __(
'Connect with millions of shoppers who are searching for products like yours and drive sales with Google.',
'Required to set up conversion measurement and create campaigns.',
'google-listings-and-ads'
),
},
Expand Down
8 changes: 8 additions & 0 deletions js/src/components/account-card/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
background-color: #f8ebea;
}

.components-notice.is-success {
background-color: #edfaef;
border: 0;
font-size: $helptext-font-size;
margin: 0 var(--large-gap) var(--main-gap);
padding: $grid-unit-20;
}

@media (max-width: $break-small) {
.components-card__body > .components-flex {
flex-direction: column;
Expand Down
55 changes: 55 additions & 0 deletions js/src/components/google-ads-account-card/claim-account-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* External dependencies
*/
import { noop } from 'lodash';

/**
* Internal dependencies
*/
import AppButton from '.~/components/app-button';
import getWindowFeatures from '.~/utils/getWindowFeatures';
import { FILTER_ONBOARDING } from '.~/utils/tracks';
import useGoogleAdsAccountStatus from '.~/hooks/useGoogleAdsAccountStatus';
import useEventPropertiesFilter from '.~/hooks/useEventPropertiesFilter';

/**
* Clicking on the button to open the invitation page for claiming the newly created Google Ads account.
*
* @event gla_open_ads_account_claim_invitation_button_click
* @property {string} [context] Indicates the place where the button is located.
* @property {string} [step] Indicates the step in the onboarding process.
*/

/**
* Renders a button for opening a pop-up window to claim the newly created Google Ads account.
*
* @fires gla_open_ads_account_claim_invitation_button_click When the user clicks on the button to claim the account.
*
* @param {Object} props React props.
* @param {Function} [props.onClick] Function called back when the button is clicked.
* @param {Object} props.restProps Props to be forwarded to AppButton.
*/
const ClaimAccountButton = ( { onClick = noop, ...restProps } ) => {
const { inviteLink } = useGoogleAdsAccountStatus();
const getEventProps = useEventPropertiesFilter( FILTER_ONBOARDING );

const handleClaimAccountClick = ( event ) => {
const { defaultView } = event.target.ownerDocument;
const features = getWindowFeatures( defaultView, 600, 800 );

defaultView.open( inviteLink, '_blank', features );

onClick( event );
};

return (
<AppButton
{ ...restProps }
eventName="gla_open_ads_account_claim_invitation_button_click"
eventProps={ getEventProps() }
onClick={ handleClaimAccountClick }
/>
);
};

export default ClaimAccountButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* External dependencies
*/
import '@testing-library/jest-dom';
import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { recordEvent } from '@woocommerce/tracks';

/**
* Internal dependencies
*/
import ClaimAccountButton from './claim-account-button';
import useGoogleAdsAccountStatus from '.~/hooks/useGoogleAdsAccountStatus';
import { FILTER_ONBOARDING } from '.~/utils/tracks';
import expectComponentToRecordEventWithFilteredProperties from '.~/tests/expectComponentToRecordEventWithFilteredProperties';

jest.mock( '.~/hooks/useGoogleAdsAccountStatus', () =>
jest.fn().mockName( 'useGoogleAdsAccountStatus' )
);

jest.mock( '@woocommerce/tracks', () => {
return {
recordEvent: jest.fn().mockName( 'recordEvent' ),
};
} );

describe( 'ClaimAccountButton', () => {
let windowOpen;

beforeEach( () => {
windowOpen = jest.spyOn( global, 'open' );

useGoogleAdsAccountStatus.mockReturnValue( {
inviteLink: 'https://example.com',
} );
} );

afterEach( () => {
windowOpen.mockReset();
recordEvent.mockClear();
} );

it( 'should render the specified text in the button', () => {
render(
<ClaimAccountButton>
Claim account in example.com
</ClaimAccountButton>
);

expect( screen.getByRole( 'button' ) ).toHaveTextContent(
'Claim account in example.com'
);
} );

it( 'should forward onClick callback', async () => {
const onClick = jest.fn();
render( <ClaimAccountButton onClick={ onClick } /> );

expect( onClick ).toHaveBeenCalledTimes( 0 );

await userEvent.click( screen.getByRole( 'button' ) );

expect( onClick ).toHaveBeenCalledTimes( 1 );
} );

it( 'should open the invitation link in a pop-up window', async () => {
render( <ClaimAccountButton /> );

expect( windowOpen ).toHaveBeenCalledTimes( 0 );

await userEvent.click( screen.getByRole( 'button' ) );

expect( windowOpen ).toHaveBeenCalledTimes( 1 );
expect( windowOpen ).toHaveBeenCalledWith(
'https://example.com',
'_blank',
// Ignore the value of the window features.
expect.any( String )
);
} );

it( 'should record click events and be aware of extra event properties from filters', async () => {
await expectComponentToRecordEventWithFilteredProperties(
ClaimAccountButton,
FILTER_ONBOARDING,
async () => await userEvent.click( screen.getByRole( 'button' ) ),
'gla_open_ads_account_claim_invitation_button_click',
[
{ context: 'setup-mc', step: '1' },
{ context: 'setup-ads', step: '2' },
]
);
} );
} );
68 changes: 68 additions & 0 deletions js/src/components/google-ads-account-card/claim-account-modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { useEffect } from '@wordpress/element';

/**
* Internal dependencies
*/
import useGoogleAdsAccountStatus from '.~/hooks/useGoogleAdsAccountStatus';
import AppModal from '.~/components/app-modal';
import ClaimAccountButton from './claim-account-button';

/**
* Renders a modal for opening a pop-up window to claim the newly created Google Ads account.
* The modal is displayed when the user has successfully created a Google Ads account and needs to claim it.
*
* @param {Object} props React props.
* @param {Function} props.onRequestClose Function called back when the modal is requested to be closed.
*/
const ClaimAccountModal = ( { onRequestClose } ) => {
const { hasAccess } = useGoogleAdsAccountStatus();

Check warning on line 22 in js/src/components/google-ads-account-card/claim-account-modal.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/google-ads-account-card/claim-account-modal.js#L22

Added line #L22 was not covered by tests

useEffect( () => {

Check warning on line 24 in js/src/components/google-ads-account-card/claim-account-modal.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/google-ads-account-card/claim-account-modal.js#L24

Added line #L24 was not covered by tests
// Close the modal if access has been granted.
if ( hasAccess ) {
onRequestClose();

Check warning on line 27 in js/src/components/google-ads-account-card/claim-account-modal.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/google-ads-account-card/claim-account-modal.js#L27

Added line #L27 was not covered by tests
}
}, [ onRequestClose, hasAccess ] );

return (

Check warning on line 31 in js/src/components/google-ads-account-card/claim-account-modal.js

View check run for this annotation

Codecov / codecov/patch

js/src/components/google-ads-account-card/claim-account-modal.js#L31

Added line #L31 was not covered by tests
<AppModal
className="gla-ads-invite-modal"
title={ __(
'Claim your Google Ads account',
'google-listings-and-ads'
) }
buttons={ [
<ClaimAccountButton
key="1"
isPrimary
onClick={ onRequestClose }
>
{ __(
'Claim account in Google Ads',
'google-listings-and-ads'
) }
</ClaimAccountButton>,
] }
onRequestClose={ onRequestClose }
>
<p>
{ __(
'Claiming your account lets you access Google Ads and sets up conversion measurement. You must claim your account in the next 20 days.',
'google-listings-and-ads'
) }
</p>
<p>
{ __(
'When you claim your account, you’ll be asked to set up billing. This step is optional and you only need to complete it if you want to create Google Ads campaigns. If you don’t want to set up billing, close the window after you’ve clicked ‘Continue’ on the next page.',
'google-listings-and-ads'
) }
</p>
</AppModal>
);
};

export default ClaimAccountModal;
36 changes: 36 additions & 0 deletions js/src/components/google-ads-account-card/claim-account/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { Fragment } from '@wordpress/element';

/**
* Internal dependencies
*/
import { useAppDispatch } from '.~/data';
import Section from '.~/wcdl/section';
import useWindowFocusCallbackIntervalEffect from '.~/hooks/useWindowFocusCallbackIntervalEffect';
import DisconnectAccount from '../disconnect-account';
import './index.scss';

const ClaimAccount = () => {
const { fetchGoogleAdsAccountStatus } = useAppDispatch();
useWindowFocusCallbackIntervalEffect( fetchGoogleAdsAccountStatus, 30 );

return (
<Fragment>
<p className="gla-ads-claim-account-notice">
{ __(
'Claim your new Google Ads account to complete this setup.',
'google-listings-and-ads'
) }
</p>

<Section.Card.Footer>
<DisconnectAccount />
</Section.Card.Footer>
</Fragment>
);
};

export default ClaimAccount;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gla-ads-claim-account-notice {
background-color: #ffeec1;
font-size: $helptext-font-size;
margin: 0 var(--large-gap) var(--large-gap);
padding: $grid-unit-20;
}
12 changes: 11 additions & 1 deletion js/src/components/google-ads-account-card/connect-ads/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ import Subsection from '.~/wcdl/subsection';
import useApiFetchCallback from '.~/hooks/useApiFetchCallback';
import useDispatchCoreNotices from '.~/hooks/useDispatchCoreNotices';
import useGoogleAdsAccount from '.~/hooks/useGoogleAdsAccount';
import useEventPropertiesFilter from '.~/hooks/useEventPropertiesFilter';
import AdsAccountSelectControl from './ads-account-select-control';
import { useAppDispatch } from '.~/data';
import { FILTER_ONBOARDING } from '.~/utils/tracks';
import './index.scss';

/**
* Clicking on the button to connect an existing Google Ads account.
*
* @event gla_ads_account_connect_button_click
* @property {number} id The account ID to be connected.
* @property {string} [context] Indicates the place where the button is located.
* @property {string} [step] Indicates the step in the onboarding process.
*/

/**
Expand All @@ -44,7 +49,9 @@ const ConnectAds = ( props ) => {
data: { id: value },
} );
const { refetchGoogleAdsAccount } = useGoogleAdsAccount();
const getEventProps = useEventPropertiesFilter( FILTER_ONBOARDING );
const { createNotice } = useDispatchCoreNotices();
const { fetchGoogleAdsAccountStatus } = useAppDispatch();

/**
* Boolean to display blurb message to advise users
Expand All @@ -62,6 +69,7 @@ const ConnectAds = ( props ) => {
setLoading( true );
try {
await fetchConnectAdsAccount();
await fetchGoogleAdsAccountStatus();
await refetchGoogleAdsAccount();
} catch ( error ) {
setLoading( false );
Expand Down Expand Up @@ -128,7 +136,9 @@ const ConnectAds = ( props ) => {
isSecondary
disabled={ ! value }
eventName="gla_ads_account_connect_button_click"
eventProps={ { id: Number( value ) } }
eventProps={ getEventProps( {
id: Number( value ),
} ) }
onClick={ handleConnectClick }
>
{ __( 'Connect', 'google-listings-and-ads' ) }
Expand Down
Loading
Loading