Skip to content

Commit

Permalink
Implement the tracking of Headless requests to the FrontEndType header
Browse files Browse the repository at this point in the history
  • Loading branch information
khushboo-singhvi committed Feb 26, 2025
1 parent 129767b commit 889b2ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1196,8 +1196,9 @@ public function buildRequestHeaders($payment = null)
$frontendType = $payment->getAdditionalInformation(HeaderDataBuilderInterface::ADDITIONAL_DATA_FRONTEND_TYPE_KEY);
if (is_null($frontendType)) {
// Check the request URI
$requestUri = $this->request->getPathInfo();
if (str_contains($requestUri, '/graphql')) {
$requestPath = $this->request->getOriginalPathInfo();
$requestMethod = $this->request->getMethod();
if ($requestPath === '/graphql' && $requestMethod === 'POST') {
$frontendType = 'headless-graphql';
} else {
$frontendType = 'headless-rest';
Expand Down
4 changes: 3 additions & 1 deletion Test/Unit/Helper/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,10 @@ public function testBuildRequestHeadersWithNullFrontendTypeGraphQL(): void
->with(HeaderDataBuilderInterface::ADDITIONAL_DATA_FRONTEND_TYPE_KEY)
->willReturn(null);

$this->request->method('getPathInfo')
$this->request->method('getOriginalPathInfo')
->willReturn('/graphql');
$this->request->method('getMethod')
->willReturn('POST');

$headers = $this->dataHelper->buildRequestHeaders($this->paymentMock);

Expand Down

0 comments on commit 889b2ae

Please sign in to comment.