{"id":14966742,"url":"https://github.com/notamedia/yii2-sentry","last_synced_at":"2025-04-13T02:23:42.573Z","repository":{"id":3099868,"uuid":"48437899","full_name":"notamedia/yii2-sentry","owner":"notamedia","description":"Sentry logger for Yii2","archived":false,"fork":false,"pushed_at":"2023-11-07T06:59:00.000Z","size":57,"stargazers_count":125,"open_issues_count":14,"forks_count":53,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T04:35:33.993Z","etag":null,"topics":["sentry","yii2-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notamedia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-22T14:57:37.000Z","updated_at":"2025-01-28T10:17:00.000Z","dependencies_parsed_at":"2024-06-18T13:58:19.067Z","dependency_job_id":"578450c3-a6d8-40af-a1a1-011752076388","html_url":"https://github.com/notamedia/yii2-sentry","commit_stats":{"total_commits":80,"total_committers":16,"mean_commits":5.0,"dds":0.55,"last_synced_commit":"24c1be71f2f9193c3c62b2def3fc4b32b3276c1b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notamedia%2Fyii2-sentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notamedia%2Fyii2-sentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notamedia%2Fyii2-sentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notamedia%2Fyii2-sentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notamedia","download_url":"https://codeload.github.com/notamedia/yii2-sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248655016,"owners_count":21140411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sentry","yii2-extension"],"created_at":"2024-09-24T13:36:52.799Z","updated_at":"2025-04-13T02:23:42.541Z","avatar_url":"https://github.com/notamedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Sentry](https://sentry.io) logger for Yii2\n\n[![Build Status](https://travis-ci.org/notamedia/yii2-sentry.svg)](https://travis-ci.org/notamedia/yii2-sentry)\n[![Latest Stable Version](https://poser.pugx.org/notamedia/yii2-sentry/v/stable)](https://packagist.org/packages/notamedia/yii2-sentry) \n[![Total Downloads](https://poser.pugx.org/notamedia/yii2-sentry/downloads)](https://packagist.org/packages/notamedia/yii2-sentry) \n[![License](https://poser.pugx.org/notamedia/yii2-sentry/license)](https://packagist.org/packages/notamedia/yii2-sentry)\n\n## Installation\n\n```bash\ncomposer require notamedia/yii2-sentry\n```\n\nAdd target class in the application config:\n\n```php\nreturn [\n    'components' =\u003e [\n\t    'log' =\u003e [\n\t\t    'traceLevel' =\u003e YII_DEBUG ? 3 : 0,\n\t\t    'targets' =\u003e [\n\t\t\t    [\n\t\t\t\t    'class' =\u003e 'notamedia\\sentry\\SentryTarget',\n\t\t\t\t    'dsn' =\u003e 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',\n\t\t\t\t    'levels' =\u003e ['error', 'warning'],\n\t\t\t\t    // Write the context information (the default is true):\n\t\t\t\t    'context' =\u003e true,\n\t\t\t\t    // Additional options for `Sentry\\init`:\n\t\t\t\t    'clientOptions' =\u003e ['release' =\u003e 'my-project-name@2.3.12']\n\t\t\t    ],\n\t\t    ],\n\t    ],\n    ],\n];\n```\n\n## Usage\n\nWriting simple message:\n\n```php\n\\Yii::error('message', 'category');\n```\n\nWriting messages with extra data:\n\n```php\n\\Yii::warning([\n    'msg' =\u003e 'message',\n    'extra' =\u003e 'value',\n], 'category');\n```\n\n### Extra callback\n\n`extraCallback` property can modify extra's data as callable function:\n \n```php\n    'targets' =\u003e [\n        [\n            'class' =\u003e 'notamedia\\sentry\\SentryTarget',\n            'dsn' =\u003e 'http://2682ybvhbs347:235vvgy465346@sentry.io/1',\n            'levels' =\u003e ['error', 'warning'],\n            'context' =\u003e true, // Write the context information. The default is true.\n            'extraCallback' =\u003e function ($message, $extra) {\n                // some manipulation with data\n                $extra['some_data'] = \\Yii::$app-\u003esomeComponent-\u003esomeMethod();\n                return $extra;\n            }\n        ],\n    ],\n```\n\n### Tags\n\nWriting messages with additional tags. If need to add additional tags for event, add `tags` key in message. Tags are various key/value pairs that get assigned to an event, and can later be used as a breakdown or quick access to finding related events.\n\nExample:\n\n```php\n\\Yii::warning([\n    'msg' =\u003e 'message',\n    'extra' =\u003e 'value',\n    'tags' =\u003e [\n        'extraTagKey' =\u003e 'extraTagValue',\n    ]\n], 'category');\n```\n\nMore about tags see https://docs.sentry.io/learn/context/#tagging-events\n\n### Additional context\n\nYou can add additional context (such as user information, fingerprint, etc) by calling `\\Sentry\\configureScope()` before logging.\nFor example in main configuration on `beforeAction` event (real place will dependant on your project):\n```php\nreturn [\n    // ...\n    'on beforeAction' =\u003e function (\\yii\\base\\ActionEvent $event) {\n        /** @var \\yii\\web\\User $user */\n        $user = Yii::$app-\u003ehas('user', true) ? Yii::$app-\u003eget('user', false) : null;\n        if ($user \u0026\u0026 ($identity = $user-\u003egetIdentity(false))) {\n            \\Sentry\\configureScope(function (\\Sentry\\State\\Scope $scope) use ($identity) {\n                $scope-\u003esetUser([\n                    // User ID and IP will be added by logger automatically\n                    'username' =\u003e $identity-\u003eusername,\n                    'email' =\u003e $identity-\u003eemail,\n                ]);\n            });\n        }\n    \n        return $event-\u003eisValid;\n    },\n    // ...\n];\n```\n\n## Log levels\n\nYii2 log levels converts to Sentry levels:\n\n```\n\\yii\\log\\Logger::LEVEL_ERROR =\u003e 'error',\n\\yii\\log\\Logger::LEVEL_WARNING =\u003e 'warning',\n\\yii\\log\\Logger::LEVEL_INFO =\u003e 'info',\n\\yii\\log\\Logger::LEVEL_TRACE =\u003e 'debug',\n\\yii\\log\\Logger::LEVEL_PROFILE_BEGIN =\u003e 'debug',\n\\yii\\log\\Logger::LEVEL_PROFILE_END =\u003e 'debug',\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotamedia%2Fyii2-sentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotamedia%2Fyii2-sentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotamedia%2Fyii2-sentry/lists"}