Skip to content

Commit

Permalink
Merge pull request #6575 from google/fix/6372-getAnalyticsConfigByMea…
Browse files Browse the repository at this point in the history
…surementIDs

Fix typo in the getAnalyticsConfigByMeasurementIDs selector.
  • Loading branch information
techanvil authored Feb 10, 2023
2 parents 2e7ea25 + 7265b27 commit 8f76070
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
13 changes: 10 additions & 3 deletions assets/js/modules/analytics-4/datastore/webdatastreams.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,20 @@ const baseSelectors = {
return null;
}

// eslint-disable-next-line @wordpress/no-unused-vars-before-return
const datastreams =
select( MODULES_ANALYTICS_4 ).getWebDataStreamsBatch(
propertyIDs
);

const resolvedDataStreams = select(
MODULES_ANALYTICS_4
).hasFinishedResolution( 'getWebDataStreamsBatch', [
propertyIDs,
] );

// Return undefined if web data streams haven't been resolved yet.
if ( datastreams === undefined ) {
if ( ! resolvedDataStreams ) {
return undefined;
}

Expand All @@ -473,11 +480,11 @@ const baseSelectors = {
}

for ( const datastream of datastreams[ propertyID ] ) {
const { _id: webDataStreamID, webDataStream } = datastream;
const { _id: webDataStreamID, webStreamData } = datastream;
const {
defaultUri: defaultURI,
measurementId: measurementID, // eslint-disable-line sitekit/acronym-case
} = webDataStream;
} = webStreamData;

if ( ! measurementIDs.includes( measurementID ) ) {
continue;
Expand Down
34 changes: 27 additions & 7 deletions assets/js/modules/analytics-4/datastore/webdatastreams.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,14 @@ describe( 'modules/analytics-4 webdatastreams', () => {
1122334455: [
{
_id: '110',
webDataStream: {
webStreamData: {
defaultUri: 'http://example-1.test',
measurementId: 'G-1101', // eslint-disable-line sitekit/acronym-case
},
},
{
_id: '111',
webDataStream: {
webStreamData: {
defaultUri: 'http://example-2.test',
measurementId: 'G-1102', // eslint-disable-line sitekit/acronym-case
},
Expand All @@ -661,14 +661,14 @@ describe( 'modules/analytics-4 webdatastreams', () => {
1122334465: [
{
_id: '112',
webDataStream: {
webStreamData: {
defaultUri: 'http://example-3.test',
measurementId: 'G-1103', // eslint-disable-line sitekit/acronym-case
},
},
{
_id: '113',
webDataStream: {
webStreamData: {
defaultUri: 'http://example-4.test',
measurementId: 'G-1104', // eslint-disable-line sitekit/acronym-case
},
Expand All @@ -677,21 +677,21 @@ describe( 'modules/analytics-4 webdatastreams', () => {
1122334475: [
{
_id: '114',
webDataStream: {
webStreamData: {
defaultUri: 'http://example-5.test',
measurementId: 'G-1105', // eslint-disable-line sitekit/acronym-case
},
},
{
_id: '115',
webDataStream: {
webStreamData: {
defaultUri: 'http://example.com',
measurementId: 'G-1106', // eslint-disable-line sitekit/acronym-case
},
},
{
_id: '116',
webDataStream: {
webStreamData: {
defaultUri: 'http://example-7.test',
measurementId: 'G-1107', // eslint-disable-line sitekit/acronym-case
},
Expand Down Expand Up @@ -733,6 +733,11 @@ describe( 'modules/analytics-4 webdatastreams', () => {
.receiveGetWebDataStreamsBatch( datastreams, {
propertyIDs,
} );
registry
.dispatch( MODULES_ANALYTICS_4 )
.finishResolution( 'getWebDataStreamsBatch', [
propertyIDs,
] );

const config = registry
.select( MODULES_ANALYTICS_4 )
Expand All @@ -758,6 +763,11 @@ describe( 'modules/analytics-4 webdatastreams', () => {
.receiveGetWebDataStreamsBatch( datastreams, {
propertyIDs,
} );
registry
.dispatch( MODULES_ANALYTICS_4 )
.finishResolution( 'getWebDataStreamsBatch', [
propertyIDs,
] );

const config = registry
.select( MODULES_ANALYTICS_4 )
Expand All @@ -783,6 +793,11 @@ describe( 'modules/analytics-4 webdatastreams', () => {
.receiveGetWebDataStreamsBatch( datastreams, {
propertyIDs,
} );
registry
.dispatch( MODULES_ANALYTICS_4 )
.finishResolution( 'getWebDataStreamsBatch', [
propertyIDs,
] );

const config = registry
.select( MODULES_ANALYTICS_4 )
Expand All @@ -803,6 +818,11 @@ describe( 'modules/analytics-4 webdatastreams', () => {
.receiveGetWebDataStreamsBatch( datastreams, {
propertyIDs,
} );
registry
.dispatch( MODULES_ANALYTICS_4 )
.finishResolution( 'getWebDataStreamsBatch', [
propertyIDs,
] );

const config = registry
.select( MODULES_ANALYTICS_4 )
Expand Down

0 comments on commit 8f76070

Please sign in to comment.