Skip to content

Commit

Permalink
added helper functions and refactored MoesifSubscriber
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewtanner91 committed Mar 20, 2024
1 parent 7529798 commit f3010fb
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions src/EventSubscriber/MoesifSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ private function prepareData(Request $request, $response): array
'transfer_encoding' => 'json',
];

return [
$eventModel = [
'request' => $requestData,
'response' => $responseData,
// Include other necessary fields according to Moesif's API requirements
'user_id' => $this->identifyUserId($request, $response),
'session_token' => $this->identifySessionToken($request, $response),
'company_id' => $this->identifyCompanyId($request, $response),
'metadata' => $this->getMetadata($request, $response),
];

return $eventModel;
}

private function getIp(Request $request): ?string
Expand All @@ -91,27 +96,48 @@ private function getIp(Request $request): ?string
return $request->getClientIp();
}

private function identifyUserId(Request $request, $response): ?string
{
return null;
}

private function identifyCompanyId(Request $request, $response): ?string
{
return null;
}

private function identifySessionToken(Request $request, $response): ?string
{
return null;
}

private function getMetadata(Request $request, $response): ?array
{
return null;
}

private function skip(Request $request, $response): bool
{
return false;
}

private function maskRequestHeaders(array $headers): array
{
// Implement any logic needed to mask sensitive header information
return $headers;
}

private function maskResponseHeaders(array $headers): array
{
// Implement any logic needed to mask sensitive header information
return $headers;
}

private function maskRequestBody(string $body): ?string
{
// Optionally, implement logic to modify or mask sensitive request body content
return $body;
}

private function maskResponseBody(string $body): ?string
{
// Optionally, implement logic to modify or mask sensitive response body content
return $body;
}
}

0 comments on commit f3010fb

Please sign in to comment.