Metadata-Version: 2.4
Name: collective.sentry
Version: 2.0.0
Summary: Sentry integration for Zope 5 and Plone 6
Author: Andreas Jung
Author-email: info@zopyx.com
License: GPL-2.0-only
Project-URL: Code, https://github.com/collective/collective.sentry
Project-URL: Tracker, https://github.com/collective/collective.sentry/issues
Keywords: policy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Framework :: Plone
Classifier: Framework :: Plone :: 6.2
Classifier: Framework :: Zope
Classifier: Framework :: Zope :: 5
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: sentry-sdk>2.27.0
Requires-Dist: Zope
Provides-Extra: test
Requires-Dist: plone.app.testing; extra == "test"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: keywords
Dynamic: license
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

collective.sentry
=================

Sentry integration with Zope.

Quick start (zero config)
-------------------------

Install ``collective.sentry`` alongside your Zope/Plone instance and set::

    SENTRY_DSN=https://<key>@<host>/<project-id>

Optional environment variables:

- ``SENTRY_ENVIRONMENT`` — the environment tag (e.g. ``production``).
- ``SENTRY_PROJECT`` — set as tag ``project`` on every event.
- ``SENTRY_DISABLE`` — set to disable Sentry entirely.
- ``SENTRY_INTEGRATIONS`` — comma-separated dotted names of extra
  sentry-sdk integration classes (instantiated without arguments).
- ``SENTRY_MAX_LENGTH`` — maps to sentry-sdk's ``max_value_length``;
  unset keeps the SDK default.
- ``SENTRY_OPTIONAL`` — deprecated, ignored (a missing DSN just disables
  reporting).

In Plone the package is picked up automatically (z3c.autoinclude). On
plain Zope, import the package once at startup, e.g. from the WSGI
module::

    import collective.sentry  # noqa: F401

Own initialization (filtering etc.)
-----------------------------------

The env-var bootstrap steps aside when the SDK is already initialized, so
you can call ``sentry_sdk.init()`` yourself — for example to filter
scanner noise with ``before_send``, which since 2.0 belongs to you::

    import sentry_sdk
    from collective.sentry import ZopeIntegration

    def drop_scanner_noise(event, hint):
        # your filtering logic
        return event

    sentry_sdk.init(
        dsn="...",
        integrations=[ZopeIntegration()],
        before_send=drop_scanner_noise,
        ignore_errors=[KeyboardInterrupt],
    )

Run this before Zope loads the package ZCML (policy package module level,
or a paste filter in ``wsgi.ini``).

What gets reported
------------------

Unhandled publisher exceptions (via ``IPubFailure``) and ``logging``
errors, enriched per request with form data, cookies, lazy items, request
info and the authenticated user (email included when the user has PAS
properties, i.e. always in Plone). Passwords are filtered. Exception
types listed as ignored in the site's ``error_log`` are not reported.

Migrating from 1.x
------------------

- ``before_send`` is no longer occupied by this package; wrappers around
  ``collective.sentry.error_handler.before_send`` can be replaced by a
  plain ``before_send`` passed to your own ``sentry_sdk.init()``.
- ``collective.sentry.error_handler`` is deprecated (works, warns).
- ``SENTRY_INTEGRATIONS`` works again (it was silently broken since
  1.x/2022).
- ``SENTRY_MAX_LENGTH`` now only applies when explicitly set.
- ``plone.api`` is no longer a dependency; plain Zope 5 is supported.
- Transaction names are now the request path — review Sentry alert rules
  that filter on transaction.
- The deprecated ``error_handler.before_send`` shim only enriches — the
  ``error_log`` ignore check moved to the capture path (relevant only if
  you call the shim directly).
- ``extra["request"]["headers"]`` now contains proper header names
  (``HTTP_*`` transformed, non-header environ keys dropped, sensitive
  headers filtered) instead of the raw WSGI environ.

2.0.0 (2026-09-23)
------------------

Breaking changes:


- Rewrite as a proper sentry_sdk ZopeIntegration: per-request isolation
  scope with lazy enrichment, before_send freed for deployers, plone.api
  dependency dropped (plain Zope 5 supported), error_handler deprecated as
  BBB shim. SENTRY_MAX_LENGTH now only applies when explicitly set;
  SENTRY_OPTIONAL is deprecated and ignored.
  [jensens] (#40)


New features:


- Env-var bootstrap yields to a deployer's own sentry_sdk.init();
  SENTRY_INTEGRATIONS works again (silently broken since 2022, #40).
  [jensens] (#40)


Tests:


- Add unit and Plone functional test suites, plus a Zope-only tox env and
  CI job proving the package runs without Plone.
  [jensens] (#40)


Changelog
=========

1.0.0 (2026-06-17)
------------------

Breaking changes:


- Drop support for Plone 5.2 and Python 3.8. (#28)
- Replace ``pkg_resources`` namespace with PEP 420 native namespace.
  Support only Plone 6.2 and Python 3.10+. (#3928)


Bug fixes:


- Handle non exceptions that caused a traceback @gforcada (#29)


Internal:


- Update configuration files.
  Move to src-layout.
  [plone devs]


0.3.3 (unreleased)
------------------

- Nothing changed yet.


0.3.2 (2023-11-07)
------------------

- Fix SENTRY_MAX_LENGTH default value again.
  [Lunga001]

0.3.1 (2023-10-11)
------------------

- Fix SENTRY_MAX_LENGTH default value.
  [folix-01]


0.3.0 (2022-10-06)
------------------

- Add environment var to disable sentry integration. [krissik]


0.2.6 (2022-07-28)
------------------
- Fix a problem on `errorRaisedSubscriber` function that was missing the `exc_info` variable. [thomasmassmann]


0.2.5 (2022/07/26)
------------------

- Add optional environment parameter for Sentry integrations ("SENTRY_INTEGRATIONS", comma separated list)
  [2silver]
- Ensure all exceptions which should be ignored are actually ignored before sending them.
  [thomasmassmann]


0.2.4 (2020/09/07)
------------------

- Ignore exceptions that are ignored in the root Zope error_log.
  [maurits]


0.2.3 (2020/08/05)
------------------
- Fix error handling on zope site root
  [krissik]

0.2.2 (2020/07/13)
------------------
- Add check with error_log ignored_exceptions before send exceptions to sentry
  [eikichi18]

0.2.1 (2020/07/08)
------------------
- Add SENTRY_ENVIRONMENT option.
  [fulv]

0.2.0 (2019/11/28)
------------------
- Add optional environment parameter to set max length of stacktrace ("SENTRY_MAX_LENGTH", default is 512)
  [Thokas]

0.1.7 (2019/10/21)
------------------
- Make collective.sentry configuration optional (do not load if no **SENTRY_DSN**)
  [kiorky]

0.1 (2019/08/15)
----------------

- initial release

Contributors
------------

- Andreas Jung <info@zopyx.com>
- Thomas Kastenholz <github@kronix.eu>
