Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions to clear breadcrumbs and bulk set tags and extras in the scope #852

Merged
merged 4 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix `TypeError` in `Sentry\Monolog\Handler` when the extra data array has numeric keys (#833).
- Changed type hint for both parameter and return value of `HubInterface::getCurrentHub` and `HubInterface::setCurrentHub()` methods (#849)
- Add the `setTags`, `setExtras` and `clearBreadcrumbs` methods to the `Scope` class (#852)

## 2.1.1 (2019-06-13)

Expand All @@ -26,6 +27,7 @@
- Add a Monolog handler (#808)
- Allow capturing the body of an HTTP request (#807)
- Capture exceptions during serialization, to avoid hard failures (#818)
- Mark Sentry internal frames when using `attach_stacktrace` as `in_app` `false` (786)

## 2.0.1 (2019-03-01)

Expand Down
1 change: 1 addition & 0 deletions src/State/Hub.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public static function setCurrent(HubInterface $hub): HubInterface
public function getIntegration(string $className): ?IntegrationInterface
{
$client = $this->getClient();

if (null !== $client) {
return $client->getIntegration($className);
}
Expand Down
40 changes: 40 additions & 0 deletions src/State/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ public function setTag(string $key, string $value): self
return $this;
}

/**
* Merges the given tags into the current tags context.
*
* @param array<string, string> $tags The tags to merge into the current context
*
* @return $this
*/
public function setTags(array $tags): self
{
$this->tags->merge($tags);

return $this;
}

/**
* Gets the tags contained in the tags context.
*
Expand Down Expand Up @@ -111,6 +125,20 @@ public function setExtra(string $key, $value): self
return $this;
}

/**
* Merges the given data into the current extras context.
*
* @param array<string, mixed> $extras Data to merge into the current context
*
* @return $this
*/
public function setExtras(array $extras): self
{
$this->extra->merge($extras);

return $this;
}

/**
* Gets the information contained in the extra context.
*
Expand Down Expand Up @@ -229,6 +257,18 @@ public function getBreadcrumbs(): array
return $this->breadcrumbs;
}

/**
* Clears all the breadcrumbs.
*
* @return $this
*/
public function clearBreadcrumbs(): self
{
$this->breadcrumbs = [];

return $this;
}

/**
* Adds a new event processor that will be called after {@see Scope::applyToEvent}
* finished its work.
Expand Down
Loading