{"id":18441633,"url":"https://github.com/stefanwalther/circleci-angular-sentry","last_synced_at":"2025-04-14T17:56:26.471Z","repository":{"id":38700965,"uuid":"207038031","full_name":"stefanwalther/circleci-angular-sentry","owner":"stefanwalther","description":"Test a build for Angular with uploads of sourcemaps to sentry.io","archived":false,"fork":false,"pushed_at":"2023-01-07T09:28:50.000Z","size":1931,"stargazers_count":0,"open_issues_count":25,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T20:12:00.285Z","etag":null,"topics":["angular","circleci","sentry"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefanwalther.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-07T23:42:30.000Z","updated_at":"2021-08-04T21:20:28.000Z","dependencies_parsed_at":"2023-02-06T19:32:01.448Z","dependency_job_id":null,"html_url":"https://github.com/stefanwalther/circleci-angular-sentry","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanwalther%2Fcircleci-angular-sentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanwalther%2Fcircleci-angular-sentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanwalther%2Fcircleci-angular-sentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanwalther%2Fcircleci-angular-sentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanwalther","download_url":"https://codeload.github.com/stefanwalther/circleci-angular-sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248932698,"owners_count":21185370,"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":["angular","circleci","sentry"],"created_at":"2024-11-06T06:38:53.739Z","updated_at":"2025-04-14T17:56:26.434Z","avatar_url":"https://github.com/stefanwalther.png","language":"TypeScript","readme":"# circleci-angular-sentry\n\n\u003e Test a build for Angular with uploads of sourcemaps to sentry.io\n\n---\n\n## Purpose\n\nThis is a sample repository how to build a docker image for a Angular project and after successful build create a new release for sentry.io plus upload the necessary sourcemap files.\n\n## Implementation Instructions\n\n\u003cdetails\u003e\n\u003csummary\u003eInstall necessary dependencies\u003c/summary\u003e\n\n```js\nnpm install cross-env --save-dev\nnpm install replace --save-dev\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges in ./.circleci/config.yml\u003c/summary\u003e\n\n**Add sentry-release task in `./.circleci/config.yml`**\n\n```yaml\n  - run:\n      name: sentry.io release\n      command: make sentry-release\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges in makefile\u003c/summary\u003e\n\n**Ensure the following header:**\n\n```bash\nifeq ($(CIRCLE_SHA1),)\nRELEASE_VERSION := $(shell git describe --always --long)\nelse\nRELEASE_VERSION := $(CIRCLE_SHA1)\nendif\n\nDOCKER_ORG=stefanwalther\nDOCKER_REPO=circleci-angular-sentry\n```\n\n**Change build task:**\n\n````bash\nbuild:\t\t\t\t\t\t\t\t## Build the docker image (prod)\n\tNODE_VER=$(NODE_VER)\n\t@echo 'RELEASE_VERSION: $(RELEASE_VERSION)'\n\t@echo 'OS: $(OS_NAME)'\n\t@echo '---'\n\n\tdocker build --build-arg release_version=$(RELEASE_VERSION) -t $(DOCKER_ORG)/$(DOCKER_REPO) -f Dockerfile.prod .\n.PHONY: build\n````\n\n**Add `sentry-release` task:**\n\n```bash\nsentry-release:\t\t\t\t\t\t## Do the sentry release\n\texport DEBUG=1; \\\n\texport SENTRY_AUTH_TOKEN=$(CIRCLECI_ANGULAR_SENTRY_API_TOKEN); \\\n\texport SENTRY_ORG=stefanwalther; \\\n\texport SENTRY_PROJECT=circleci-angular-sentry; \\\n\texport GITHUB_PROJECT=stefanwalther/circleci-angular-sentry; \\\n\texport SENTRY_PROJECT_VERSION=$(shell node -e \"console.log(require('./package.json').name)\")@$(shell node -e \"console.log(require('./package.json').version)\"); \\\n\texport SENTRY_LOG_LEVEL=debug; \\\n\texport RELEASE_VERSION=$(RELEASE_VERSION); \\\n\tdocker-compose --f=./docker-compose.sentry.yaml run sentry-cli\n\t#\u0026\u0026 docker-compose --f=./docker-compose.sentry.yaml down -t 0;\n.PHONY: sentry-release\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges in ./Dockerfile.prod\u003c/summary\u003e\n\nHandle the build-argument after the first `FROM` statement in `Dockerfile.prod`:\n\n```bash\nARG release_version=not_set\nENV RELEASE_VERSION=$release_version\n```\n\nUse the `build:prod` instead of the `build` task\n\n```bash\nRUN npm run build:prod\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges on CircleCI\u003c/summary\u003e\n\nAdd the environment variable `CIRCLECI_ANGULAR_SENTRY_API_TOKEN` to CircleCI.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCreate the docker-compose.sentry.yml file\u003c/summary\u003e\n\n```yaml\nversion: '2'\n\nservices:\n\n  app:\n    image: stefanwalther/circleci-angular-sentry\n    container_name: app\n    ports:\n      - \"8080:80\"\n    volumes:\n      - app-volume:/usr/share/nginx/html\n\n  sentry-cli:\n    image: getsentry/sentry-cli\n    container_name: sentry-cli\n    tty: true\n    depends_on:\n      - app\n    environment:\n      - DEBUG=true\n      - SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}\n      - SENTRY_PROJECT_VERSION=${SENTRY_PROJECT_VERSION}\n      - SENTRY_ORG=${SENTRY_ORG}\n      - SENTRY_PROJECT=${SENTRY_PROJECT}\n      - SENTRY_LOG_LEVEL=${SENTRY_LOG_LEVEL}\n      - RELEASE_VERSION=${RELEASE_VERSION}\n      - GITHUB_PROJECT=${GITHUB_PROJECT}\n      - PROJECT_DIR=/work\n    volumes:\n      - app-volume/:/work\n      - ./config/sentry-cli/:/work/sentry-cli/\n    command: \u003e\n      sh -c \"sh ./sentry-cli/sentry-cli-init.sh\"\n\nvolumes:\n  app-volume:\n\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAdd the ./config/sentry-cli/sentry-cli-init.sh file\u003c/summary\u003e\n\nSee [here](./config/sentry-cli/sentry-cli-init.sh)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges in angular.json\u003c/summary\u003e\n\n**Check that in `angular.json` the following section looks as follows**\n\n```json\n\n\"configurations\": {\n    \"production\": {\n      \"fileReplacements\": [\n        {\n          \"replace\": \"src/environments/environment.ts\",\n          \"with\": \"src/environments/environment.prod.ts\"\n        }\n      ],\n      \"optimization\": true,\n      \"outputHashing\": \"all\",\n      // See here: https://medium.com/angular-athens/make-angulars-source-code-available-to-sentry-with-gitlab-ci-b3020bd60ae6\n      \"sourceMap\": {\n        \"hidden\": true,\n        \"scripts\": true,\n        \"styles\": true\n      },\n      \"extractCss\": true,\n      \"namedChunks\": false,\n      \"aot\": true,\n      \"extractLicenses\": false,\n    }\n  }\n\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAngular: Environment settings\u003c/summary\u003e\n\n**environment.ts settings**\n\n_environment.ts:_\n```typescript\nexport const environment = {\n  production: true,\n  version: '%RELEASE_VERSION%'\n};\n```\n\n_environment.prod.ts:_\n```typescript\nexport const environment = {\n  production: true,\n  version: '%RELEASE_VERSION%'\n};\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges in package.json\u003c/summary\u003e\n\n**Adapt scripts in [package.json](./package.json)**\n\n```js\n    \"prebuild\": \"replace '%RELEASE_VERSION%' $RELEASE_VERSION src/environments/environment.prod.ts\",\n    \"postbuild\": \"replace $RELEASE_VERSION '%RELEASE_VERSION%' src/environments/environment.prod.ts\",\n    \"build:prod\": \"cross-env RELEASE_VERSION=${RELEASE_VERSION:=unknown} ng build --prod --output-path=dist --source-map\",\n    \"prebuild:prod\": \"cross-env RELEASE_VERSION=${RELEASE_VERSION:=unknown} echo \\\"src/environments/environment.prod.ts: Replacing %RELEASE_VERSION% with '$RELEASE_VERSION'\\\" \u0026\u0026 replace '%RELEASE_VERSION%' $RELEASE_VERSION src/environments/environment.prod.ts\",\n    \"postbuild:prod\": \"cross-env RELEASE_VERSION=${RELEASE_VERSION:=unknown} echo \\\"src/environments/environment.prod.ts: Resetting RELEASE_VERSION\\\" \u0026\u0026 replace $RELEASE_VERSION '%RELEASE_VERSION%' src/environments/environment.prod.ts\",\n  \n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eChanges in [sentry-error-handler.ts](./src/_lib/sentry-error-handler.ts)\u003c/summary\u003e\n\n```typescript\nimport {environment} from 'src/environments/environment';\n```\n\n```typescript\nSentry.init({\n    dsn: this.settingsService.settings.sentryDsn,\n    environment: this.settingsService.settings.environment,\n    release: `${environment.version}`\n    });\n```\n\n\u003c/details\u003e\n\n## About\n\n### Author\n**Stefan Walther**\n\n* [twitter.com/waltherstefan](http://twitter.com/waltherstefan)  \n* [github.com/stefanwalther](http://github.com/stefanwalther) \n* [linkedin.com/in/stefanwalther](https://www.linkedin.com/in/stefanwalther/)  \n* [stefanwalther.io](http://stefanwalther.io) - Private blog\n\n### Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/stefanwalther/circleci-angular-sentry/issues). The process for contributing is outlined below:\n\n1. Create a fork of the project\n2. Work on whatever bug or feature you wish\n3. Create a pull request (PR)\n\nI cannot guarantee that I will merge all PRs but I will evaluate them all.\n\n### License\nMIT\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on September 26, 2019._\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanwalther%2Fcircleci-angular-sentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanwalther%2Fcircleci-angular-sentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanwalther%2Fcircleci-angular-sentry/lists"}