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

Issue / 10272 Update PAX Success "Show Me" CTA Link #10378

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f560273
Merge branch 'develop' of github.com:google/site-kit-wp into develop.
10upsimon Mar 5, 2025
0b3b43f
Merge branch 'develop' of github.com:google/site-kit-wp into develop.
10upsimon Mar 6, 2025
076b0c1
Update PAX Integrator pinned version.
10upsimon Mar 7, 2025
a8a8c4e
Add new Ads settings and owned settings.
10upsimon Mar 7, 2025
15648db
Add validation rules for new PAX settings.
10upsimon Mar 7, 2025
d28b2ce
Add validation rules for new PAX settings.
10upsimon Mar 7, 2025
6897a30
Add new PAX ads settings to base ads datastore partial.
10upsimon Mar 7, 2025
51defea
Add new PAX settings invariant checks to validateCanSubmitChanges wit…
10upsimon Mar 7, 2025
75cd947
Update onCampaignCreated callback to handle saving of newly added PAX…
10upsimon Mar 7, 2025
7baf653
Update PAXSetupSuccessSubtleNotification component for link to extern…
10upsimon Mar 7, 2025
b6d2740
Add invariant test cases for newly added ads PAX settings.
10upsimon Mar 7, 2025
871ddf5
Update PHP test for default ads settings.
10upsimon Mar 7, 2025
12ad048
Remove invariant and validation checks for newly added PAX ads settin…
10upsimon Mar 7, 2025
ab7e29d
Reinstate certain PAX validation rules.
10upsimon Mar 7, 2025
b51f704
Remove unneeded settings from owned settings.
10upsimon Mar 7, 2025
242bddc
Fix since tag.
10upsimon Mar 7, 2025
89d220b
Move deps to correct group.
10upsimon Mar 7, 2025
cf1245c
Update since tags for Ads settings methods.
10upsimon Mar 7, 2025
c97e4cf
Fix since tag in validation.js.
10upsimon Mar 10, 2025
f289f15
Highlight changed fields in get_owned_keys() in since tag.
10upsimon Mar 10, 2025
65f4a81
Match owned settings in base.js to those defined in settings.php.
10upsimon Mar 10, 2025
8db6f01
Bump google-pax-sdk to 1.1.2.
10upsimon Mar 10, 2025
80aa83d
Udpate package lock file.
10upsimon Mar 10, 2025
7583b81
Update package lock file.
10upsimon Mar 10, 2025
cab0cf0
Update package lock file.
10upsimon Mar 10, 2025
695b0ff
Merge branch 'develop' of github.com:google/site-kit-wp into develop.
10upsimon Mar 10, 2025
8f10af6
Merge in branch develop.
10upsimon Mar 10, 2025
96495b5
Update package lock file.
10upsimon Mar 10, 2025
b98a9cc
Force global npm install to fix workspace error.
10upsimon Mar 10, 2025
9432d3c
Force global npm install to fix workspace error.
10upsimon Mar 10, 2025
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
6 changes: 6 additions & 0 deletions .github/workflows/compressed-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ jobs:
node-version-file: '.nvmrc'
cache: 'npm'

# nvm@7 is the minimum version required for npm workspace support.
# This is needed to prevent js lint failures due to module resolution to the workspace packages.
# This can be removed once our node base version comes with nvm@7 or greater.
- name: Install npm Globally
run: npm run install-global-npm

- uses: preactjs/compressed-size-action@v2
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,48 +25,48 @@ import PropTypes from 'prop-types';
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
import { useCallback } from '@wordpress/element';

/**
* Internal dependencies
*/
import { useDispatch } from 'googlesitekit-data';
import { CORE_NOTIFICATIONS } from '../../../../googlesitekit/notifications/datastore/constants';
import { getNavigationalScrollTop } from '../../../../util/scroll';
import { MODULES_ADS } from '../../datastore/constants';
import { CORE_USER } from '../../../../googlesitekit/datastore/user/constants';
import SubtleNotification from '../../../../googlesitekit/notifications/components/layout/SubtleNotification';
import useQueryArg from '../../../../hooks/useQueryArg';
import { useBreakpoint } from '../../../../hooks/useBreakpoint';
import Dismiss from '../../../../googlesitekit/notifications/components/common/Dismiss';
import CTALinkSubtle from '../../../../googlesitekit/notifications/components/common/CTALinkSubtle';

export default function PAXSetupSuccessSubtleNotification( {
id,
Notification,
} ) {
const breakpoint = useBreakpoint();

const { dismissNotification } = useDispatch( CORE_NOTIFICATIONS );

const [ , setNotification ] = useQueryArg( 'notification' );

const dismissNotice = () => {
const dismissNotice = useCallback( () => {
setNotification( undefined );
};

const scrollToWidget = ( event ) => {
event.preventDefault();
}, [ setNotification ] );

setTimeout( () => {
const widgetClass = '.googlesitekit-widget--partnerAdsPAX';
const accountSelectorWrappedAccountOverviewURL = useSelect( ( select ) => {
const accountOverviewURL =
select( MODULES_ADS ).getAccountOverviewURL();

global.scrollTo( {
top: getNavigationalScrollTop( widgetClass, breakpoint ),
behavior: 'smooth',
} );
if ( !! accountOverviewURL ) {
return select( CORE_USER ).getAccountChooserURL(
accountOverviewURL
);
}
} );

dismissNotice();
dismissNotification( id );
}, 50 );
};
const onPrimaryCTAClickCallback = useCallback( () => {
dismissNotice();
dismissNotification( id );
}, [ dismissNotice, dismissNotification, id ] );

return (
<Notification>
Expand All @@ -91,7 +91,9 @@ export default function PAXSetupSuccessSubtleNotification( {
<CTALinkSubtle
id={ id }
ctaLabel={ __( 'Show me', 'google-site-kit' ) }
onCTAClick={ scrollToWidget }
ctaLink={ accountSelectorWrappedAccountOverviewURL }
onCTAClick={ onPrimaryCTAClickCallback }
isCTALinkExternal
/>
}
/>
Expand Down
16 changes: 14 additions & 2 deletions assets/js/modules/ads/components/setup/SetupMainPAX.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,15 @@ export default function SetupMainPAX( { finishSetup } ) {
} );

const { navigateTo } = useDispatch( CORE_LOCATION );
const { setPaxConversionID, setExtCustomerID, submitChanges } =
useDispatch( MODULES_ADS );
const {
setPaxConversionID,
setCustomerID,
setExtCustomerID,
setFormattedExtCustomerID,
setUserID,
setAccountOverviewURL,
submitChanges,
} = useDispatch( MODULES_ADS );

useMount( () => {
if ( PAX_SETUP_STEP.FINISHED === showPaxAppStep ) {
Expand All @@ -128,6 +135,7 @@ export default function SetupMainPAX( { finishSetup } ) {
const { accountService, conversionTrackingIdService } =
paxAppRef.current.getServices();
const customerData = await accountService.getAccountId( {} );
const googleAdsURLData = await accountService.getGoogleAdsUrl( {} );
const conversionTrackingData =
await conversionTrackingIdService.getConversionTrackingId( {} );

Expand All @@ -138,8 +146,12 @@ export default function SetupMainPAX( { finishSetup } ) {
return;
}

setUserID( customerData.userId );
setCustomerID( customerData.customerId );
setExtCustomerID( customerData.externalCustomerId );
setFormattedExtCustomerID( customerData.formattedExternalCustomerId );
setPaxConversionID( conversionTrackingData.conversionTrackingId );
setAccountOverviewURL( googleAdsURLData.accountOverviewUrl );
/* eslint-enable sitekit/acronym-case */

// Here we save settings right away but leave final navigation to `onSetupComplete`.
Expand Down
12 changes: 11 additions & 1 deletion assets/js/modules/ads/datastore/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,23 @@ import {
} from './settings';

const baseModuleStore = Modules.createModuleStore( 'ads', {
ownedSettingsSlugs: [ 'conversionID', 'paxConversionID', 'extCustomerID' ],
ownedSettingsSlugs: [
'conversionID',
'paxConversionID',
'extCustomerID',
'customerID',
'userID',
],
storeName: MODULES_ADS,
settingSlugs: [
'conversionID',
'ownerID',
'paxConversionID',
'customerID',
'extCustomerID',
'formattedExtCustomerID',
'userID',
'accountOverviewURL',
],
requiresSetup: true,
submitChanges,
Expand Down
2 changes: 1 addition & 1 deletion includes/Modules/Ads.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected function setup_assets() {
'googlesitekit-ads-pax-integrator',
array(
// When updating, mirror the fixed version for google-pax-sdk in package.json.
'src' => 'https://www.gstatic.com/pax/1.1.0/pax_integrator.js',
'src' => 'https://www.gstatic.com/pax/1.1.3/pax_integrator.js',
'execution' => 'async',
'dependencies' => array(
'googlesitekit-ads-pax-config',
Expand Down
14 changes: 11 additions & 3 deletions includes/Modules/Ads/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,19 @@ public function register() {
*
* @since 1.122.0
* @since 1.126.0 Added new settings fields for PAX.
* @since n.e.x.t Added new settings fields for PAX.
*
* @return array An array of default settings values.
*/
protected function get_default() {
return array(
'conversionID' => '',
'paxConversionID' => '',
'extCustomerID' => '',
'conversionID' => '',
'paxConversionID' => '',
'customerID' => '',
'extCustomerID' => '',
'formattedExtCustomerID' => '',
'userID' => '',
'accountOverviewURL' => '',
);
}

Expand All @@ -58,6 +63,7 @@ protected function get_default() {
*
* @since 1.122.0
* @since 1.126.0 Added new settings fields for PAX.
* @since n.e.x.t Added customerID & userID settings fields for PAX.
*
* @return array An array of keys for owned settings.
*/
Expand All @@ -66,6 +72,8 @@ public function get_owned_keys() {
'conversionID',
'paxConversionID',
'extCustomerID',
'customerID',
'userID',
);
}
}
28 changes: 21 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"fs-extra": "^9.0.1",
"git-repo-info": "^2.1.1",
"glob-to-regexp": "^0.4.1",
"google-pax-sdk": "1.1.0",
"google-pax-sdk": "1.1.2",
"husky": "^3.1.0",
"jest": "^26.6.3",
"jest-localstorage-mock": "^2.4.2",
Expand Down
10 changes: 7 additions & 3 deletions tests/phpunit/integration/Modules/Ads/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public function test_get_default() {

$this->assertEqualSetsWithIndex(
array(
'conversionID' => '',
'paxConversionID' => '',
'extCustomerID' => '',
'conversionID' => '',
'paxConversionID' => '',
'customerID' => '',
'extCustomerID' => '',
'formattedExtCustomerID' => '',
'userID' => '',
'accountOverviewURL' => '',
),
get_option( Settings::OPTION )
);
Expand Down
Loading