Skip to content

Commit

Permalink
Prevent fetching experiment if Tracks is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
IanRamosC committed Jul 17, 2024
1 parent d668932 commit 0e956d1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions projects/packages/explat/src/client/assignment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ const fetchExperimentAssignment =
experimentName: string;
anonId: string | null;
} ): Promise< unknown > => {
if ( ! anonId ) {
throw new Error( `Tracking is disabled, can't fetch experimentAssignment` );
}

const params = {
experiment_name: experimentName,
anon_id: anonId ?? undefined,
as_connected_user: asConnectedUser,
};

const assignmentsRequestUrl = addQueryArgs( 'jetpack/v4/explat/assignments', params );

return await apiFetch( { path: assignmentsRequestUrl } );
Expand Down

0 comments on commit 0e956d1

Please sign in to comment.