Skip to content

Commit

Permalink
Added constructNew to client to instantly maintain settings
Browse files Browse the repository at this point in the history
  • Loading branch information
redJ4y committed Feb 1, 2023
1 parent 133020e commit 7603163
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/RaygunClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,32 @@

// RaygunClient wrapper provides protected field access
class RaygunClient extends BaseRaygunClient {
/**
* Return a new copy of this client with new constructor arguments applied
*
* @param TransportInterface $transport
* @param bool $userTracking
*
* @return RaygunClient
*/
public function constructNew(TransportInterface $transport, bool $userTracking = true): RaygunClient {
$newClient = new RaygunClient($transport, !$userTracking);
$newClient->SetUser(
$this->user,
$this->firstName,
$this->fullName,
$this->email,
$this->isAnonymous,
$this->uuid
);
$newClient->setUserIdentifier($this->userIdentifier);
$newClient->SetVersion($this->version);
$newClient->SetGroupingKey($this->groupingKeyCallback);
$newClient->setFilterParams($this->filterParams);
$newClient->setFilterAllFormValues($this->filterAllFormValues);
return $newClient;
}

/**
* Get the transport being used by the client
*
Expand Down
2 changes: 1 addition & 1 deletion src/RaygunClientManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static function createNewInstance($async, $userTracking): void {
$transport->setLogger(self::$logger);
}

self::$instance = new RaygunClient($transport, !$userTracking);
self::$instance = self::$instance->constructNew($transport, $userTracking);
self::$currentAsyncState = $async;
}

Expand Down

0 comments on commit 7603163

Please sign in to comment.