From 7774b08bece754d1daa6cd7d67f20e8b1040b4b0 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 19 Jan 2024 00:33:20 -0300 Subject: [PATCH] fix samples with correct sentry version, add client --- CHANGELOG.md | 4 + example/ionic-angular-v2/ios/App/Podfile | 2 +- example/ionic-angular-v2/package.json | 3 +- example/ionic-angular-v2/yarn.lock | 230 +++++---- example/ionic-angular-v5/package.json | 3 +- example/ionic-angular-v5/yarn.lock | 230 +++++---- example/ionic-angular/package.json | 3 +- example/ionic-angular/src/app/app.module.ts | 1 - example/ionic-angular/yarn.lock | 230 +++++---- src/client.ts | 173 +++++++ src/integrations/rewriteframes.ts | 4 +- src/options.ts | 35 +- src/sdk.ts | 15 +- src/wrapper.ts | 3 +- test/client.test.ts | 510 ++++++++++++++++++++ test/testutils.ts | 72 +++ test/tracing/utils.ts | 18 + 17 files changed, 1249 insertions(+), 287 deletions(-) create mode 100644 src/client.ts create mode 100644 test/client.test.ts create mode 100644 test/testutils.ts create mode 100644 test/tracing/utils.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 21d13709..3cfeeac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add onReady callback that gets called after Native SDK init is called. + ### Dependencies - Bump Cocoa SDK from v8.8.0 to v8.18.0 ([#526](https://github.com/getsentry/sentry-capacitor/pull/526)) diff --git a/example/ionic-angular-v2/ios/App/Podfile b/example/ionic-angular-v2/ios/App/Podfile index b51e0dee..dba1d071 100644 --- a/example/ionic-angular-v2/ios/App/Podfile +++ b/example/ionic-angular-v2/ios/App/Podfile @@ -10,7 +10,7 @@ def capacitor_pods # Automatic Capacitor Pod dependencies, do not delete pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' - pod 'SentryCapacitor', :path => '../../node_modules/@sentry/capacitor' + pod 'SentryCapacitor', :path => '..\..\node_modules\@sentry\capacitor' # Do not delete end diff --git a/example/ionic-angular-v2/package.json b/example/ionic-angular-v2/package.json index 470350ff..a8a49ab3 100644 --- a/example/ionic-angular-v2/package.json +++ b/example/ionic-angular-v2/package.json @@ -14,9 +14,8 @@ "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic/angular": "^5.0.0", - "@sentry/angular-ivy": "7.81.1", + "@sentry/angular-ivy": "7.93.0", "@sentry/capacitor": "file:.yalc/@sentry/capacitor", - "@sentry/cli": "^2.21.3", "rxjs": "~6.5.5", "tslib": "^2.0.0", "zone.js": "~0.11.4" diff --git a/example/ionic-angular-v2/yarn.lock b/example/ionic-angular-v2/yarn.lock index a61ed897..89826ed4 100644 --- a/example/ionic-angular-v2/yarn.lock +++ b/example/ionic-angular-v2/yarn.lock @@ -1683,113 +1683,167 @@ "@angular-devkit/schematics" "17.0.2" jsonc-parser "3.2.0" -"@sentry-internal/tracing@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.81.1.tgz#1180365cd8a9e18cb0f92e1ea970161840ec0e2e" - integrity sha512-E5xm27xrLXL10knH2EWDQsQYh5nb4SxxZzJ3sJwDGG9XGKzBdlp20UUhKqx00wixooVX9uCj3e4Jg8SvNB1hKg== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/angular-ivy@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/angular-ivy/-/angular-ivy-7.81.1.tgz#6933dd62f7f064bb2da5ac8da8a7e27c6f1e10e8" - integrity sha512-GEVF/x7UYoVOEhaHDKf6j+ojnKb9RgWdcTSHyC3fgj7cLtZw3NChLmyzAL32No/YTYPydocSAttSGUJ1oC6a1Q== - dependencies: - "@sentry/browser" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" +"@sentry-internal/feedback@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.93.0.tgz#c6648ce625792c72d7afdbee8f5db878c7f16fee" + integrity sha512-4G7rMeQbYGfCHxEoFroABX+UREYc2BSbFqjLmLbIcWowSpgzcwweLLphWHKOciqK6f7DnNDK0jZzx3u7NrkWHw== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry-internal/tracing@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.93.0.tgz#8cee8b610695d828af75edd2929b64b7caf0385d" + integrity sha512-DjuhmQNywPp+8fxC9dvhGrqgsUb6wI/HQp25lS2Re7VxL1swCasvpkg8EOYP4iBniVQ86QK0uITkOIRc5tdY1w== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/angular-ivy@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/angular-ivy/-/angular-ivy-7.93.0.tgz#9d0df35ea6501025f6fa4da96c45be7f348c083f" + integrity sha512-G6N3bQFZfkWnECnZwva0CgSeiHgcw4H+22X0hWrbnLjPpkuYtMsJ7t+Pc1qnQcSEtEw6+Ckcx94RNpyyfdvzeQ== + dependencies: + "@sentry/browser" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" tslib "^2.4.1" -"@sentry/browser@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.81.1.tgz#5ee6ae3679ee80f444d2e8c5662430e7a734ae50" - integrity sha512-DNtS7bZEnFPKVoGazKs5wHoWC0FwsOFOOMNeDvEfouUqKKbjO7+RDHbr7H6Bo83zX4qmZWRBf8V+3n3YPIiJFw== +"@sentry/browser@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.93.0.tgz#acb559125ab0576091a3fc9718e520ba9b2eb1b9" + integrity sha512-MtLTcQ7y3rfk+aIvnnwCfSJvYhTJnIJi+Mf6y/ap6SKObdlsKMbQoJLlRViglGLq+nKxHLAvU0fONiCEmKfV6A== dependencies: - "@sentry-internal/tracing" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/replay" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + "@sentry-internal/feedback" "7.93.0" + "@sentry-internal/tracing" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/replay" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" "@sentry/capacitor@file:.yalc/@sentry/capacitor": - version "0.14.0" - dependencies: - "@sentry/browser" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/hub" "7.81.1" - "@sentry/integrations" "7.81.1" - "@sentry/tracing" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/cli@^2.21.3": - version "2.21.5" - resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.21.5.tgz#9ee4c51b267ac5ba8cdbf9bb9d4e8b74410d9669" - integrity sha512-RqKBqE10pb7zh0G/YiYVdX/MqenDYIgLGcaCqbszTAfW2SSLyp9EczsnmHtRgO1fO1OQq76+gaK7UdC1TEIGqQ== + version "0.15.0" + dependencies: + "@sentry/browser" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/hub" "7.93.0" + "@sentry/integrations" "7.93.0" + "@sentry/tracing" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/cli-darwin@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.25.2.tgz#9fd935aa0381acbf2e22aef23eddc90d6efc1d97" + integrity sha512-o1d5NnVUrc1dxDm56k7Co8tSTcOuxbApdxweVXXsiq20HblZCyIi7WxxRkAg4RfKx594sKGiw9uCVvECi+9UpA== + +"@sentry/cli-linux-arm64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.25.2.tgz#4a442d55f4e0a849b6faebd151d0d2277abf5de9" + integrity sha512-lm5jaigV6xu9Gwo0wNk+bX6yVkl5k3gNXcSXcKCISFo+Teb7Zhf9IyXANPm4VY2DdiZAjPJt8gS1bu+Mn7irtQ== + +"@sentry/cli-linux-arm@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-2.25.2.tgz#053430a6508450b382fc980195cbd5cc0fe90d86" + integrity sha512-n398jd87Ymejt5k/6RjCEjXAvntOWuqhBDANxzhgr5/9FzbODJ844g1mOpcxiIlduzKSzWlPbTEKQulMp2Mt4w== + +"@sentry/cli-linux-i686@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-2.25.2.tgz#ce72717f48890984a805c82d116a9da115fc53a1" + integrity sha512-/YYx2gfqO5mkxyBgFcnDbZzkZ2+2xNarwrqWcqq3Qw0XlO9DWAQB2G+twV1RW/UfSU6fFIWErn94efh2EWmyzQ== + +"@sentry/cli-linux-x64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-2.25.2.tgz#fb178ac3540f64595a17dd95b4b2071f18aa098a" + integrity sha512-rRafqy84R5mYA4JEfNsUeN10af5euJnK7fgqYM0mJIaplHC2YEXT9aUYWoryWPZiYqmdNUhsA6lX7iynSW9pZw== + +"@sentry/cli-win32-i686@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-2.25.2.tgz#e0d73977771a578439207ea7863cde422a6cfee2" + integrity sha512-plT/gi41F+67g9AwrEm4avRXnjCtHCcnRnJ6zPu/iINGap8mvYQJSU/qM0oGwV6hRGg3JJN66XIvJPIuIs8P8w== + +"@sentry/cli-win32-x64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-2.25.2.tgz#f21f71e7c2c60f99dd62c3360e4b0cda4f27d877" + integrity sha512-Mb6mAyPi9gIfpzF5MTk0JXgFP9nxka3Fb7JYn6AY4RW++sOjapkTrcXL2Gp3ZfQkWj5rFTgln4+eNmZPsD2gzA== + +"@sentry/cli@^2.21.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.25.2.tgz#7e8eec38c19ee27cb3f5c5a7ba3e80ad587c6517" + integrity sha512-lgt1QPaCfs/QZNXwyw3gvuBR2/CLwFSdU/oT7Bpxwizz8XVXhlKS98zJF1UVCy7SecsDSoOI0Z+B+X658cpquQ== dependencies: https-proxy-agent "^5.0.0" node-fetch "^2.6.7" progress "^2.0.3" proxy-from-env "^1.1.0" which "^2.0.2" - -"@sentry/core@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.81.1.tgz#082fd9122bf9a488c8e05b1754724ddbc2d5cf30" - integrity sha512-tU37yAmckOGCw/moWKSwekSCWWJP15O6luIq+u7wal22hE88F3Vc5Avo8SeF3upnPR+4ejaOFH+BJTr6bgrs6Q== - dependencies: - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/hub@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.81.1.tgz#c49bcc1894bfeb019811bac8e3b6fd81011b6f7c" - integrity sha512-25cvsI3HKiRLJBZGFC8ntuy7/yB8M1w8YLTjr3tIqydYmjFUX7f18w0iuWEtd204d8OQSPBJDapbGMdfkE5x6w== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/integrations@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.81.1.tgz#1b12c0cf3a7fa88224e86c0be46523ed7e3f3a43" - integrity sha512-DN5ONn0/LX5HHVPf1EBGHFssIZaZmLgkqUIeMqCNYBpB4DiOrJANnGwTcWKDPphqhdPxjnPv9AGRLaU0PdvvZQ== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + optionalDependencies: + "@sentry/cli-darwin" "2.25.2" + "@sentry/cli-linux-arm" "2.25.2" + "@sentry/cli-linux-arm64" "2.25.2" + "@sentry/cli-linux-i686" "2.25.2" + "@sentry/cli-linux-x64" "2.25.2" + "@sentry/cli-win32-i686" "2.25.2" + "@sentry/cli-win32-x64" "2.25.2" + +"@sentry/core@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.93.0.tgz#50a14bf305130dfef51810e4c97fcba4972a57ef" + integrity sha512-vZQSUiDn73n+yu2fEcH+Wpm4GbRmtxmnXnYCPgM6IjnXqkVm3awWAkzrheADblx3kmxrRiOlTXYHw9NTWs56fg== + dependencies: + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/hub@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.93.0.tgz#3db26f74dc1269650fa9ec553f0837af5caa0d30" + integrity sha512-gfPyT3DFGYYM5d+CHiS0YJHkIJHa8MKSfl32RkCMA5KQr9RF0H+GR5LZCinQOWq43fpsncSLyuoMfBjgbMLN+w== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/integrations@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.93.0.tgz#23ce18919e8b19f97b9b0fdf69d2ecaa6f1730ad" + integrity sha512-uGQ8+DiqUr6SbhdJJHyIqDJ6kHnFuSv8nZWtj2tJ1I8q8u8MX8t8Om6R/R4ap45gCkWg/zqZq7B+gQV6TYewjQ== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" localforage "^1.8.1" -"@sentry/replay@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.81.1.tgz#a656d55e2a00b34e42be6eeb79018d21efc223af" - integrity sha512-4ueT0C4bYjngN/9p0fEYH10dTMLovHyk9HxJ6zSTgePvGVexhg+cSEHXisoBDwHeRZVnbIvsVM0NA7rmEDXJJw== +"@sentry/replay@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.93.0.tgz#55e3c424cd5529041fbc987e4c2e74e30a94b1b8" + integrity sha512-dMlLU8v+OkUeGCrPvTu5NriH7BGj3el4rGHWWAYicfJ2QXqTTq50vfasQBP1JeVNcFqnf1y653TdEIvo4RH4tw== dependencies: - "@sentry-internal/tracing" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + "@sentry-internal/tracing" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" -"@sentry/tracing@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.81.1.tgz#274f76119cdc3e58a4767ce8085cfc73cea13330" - integrity sha512-of9WMu0XgEBl9onTEk8SMaxj4BUadaUvHH96T1OpRMjdyuCM/3u2mjCkh3ekINr3Fu/uT2kJ/kO3goUxfcdXIQ== +"@sentry/tracing@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.93.0.tgz#9785773049ae645cd0ee5b471e83a4dc9a79229c" + integrity sha512-n4XbAQ7e098Jzv4ZvpXAsFgM+XFfjhKci18r7s3UfDMnrB4FTCwhHZoeiygO8PZhB944mEFbNXNFhHkb8nTDbA== dependencies: - "@sentry-internal/tracing" "7.81.1" + "@sentry-internal/tracing" "7.93.0" -"@sentry/types@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.81.1.tgz#2b2551fc291e1089651fd574a68f7c4175878bd5" - integrity sha512-dvJvGyctiaPMIQqa46k56Re5IODWMDxiHJ1UjBs/WYDLrmWFPGrEbyJ8w8CYLhYA+7qqrCyIZmHbWSTRIxstHw== +"@sentry/types@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.93.0.tgz#d76d26259b40cd0688e1d634462fbff31476c1ec" + integrity sha512-UnzUccNakhFRA/esWBWP+0v7cjNg+RilFBQC03Mv9OEMaZaS29zSbcOGtRzuFOXXLBdbr44BWADqpz3VW0XaNw== -"@sentry/utils@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.81.1.tgz#42f3e77baf90205cec1f8599eb8445a6918030bd" - integrity sha512-gq+MDXIirHKxNZ+c9/lVvCXd6y2zaZANujwlFggRH2u9SRiPaIXVilLpvMm4uJqmqBMEcY81ArujExtHvkbCqg== +"@sentry/utils@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.93.0.tgz#36225038661fe977baf01e4695ef84794d591e45" + integrity sha512-Iovj7tUnbgSkh/WrAaMrd5UuYjW7AzyzZlFDIUrwidsyIdUficjCG2OIxYzh76H6nYIx9SxewW0R54Q6XoB4uA== dependencies: - "@sentry/types" "7.81.1" + "@sentry/types" "7.93.0" "@socket.io/component-emitter@~3.1.0": version "3.1.0" diff --git a/example/ionic-angular-v5/package.json b/example/ionic-angular-v5/package.json index e73daac8..d983e9d5 100644 --- a/example/ionic-angular-v5/package.json +++ b/example/ionic-angular-v5/package.json @@ -14,9 +14,8 @@ "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic/angular": "^5.0.0", - "@sentry/angular-ivy": "7.81.1", + "@sentry/angular-ivy": "7.93.0", "@sentry/capacitor": "file:.yalc/@sentry/capacitor", - "@sentry/cli": "^2.21.3", "rxjs": "~6.5.5", "tslib": "^2.0.0", "zone.js": "~0.11.4" diff --git a/example/ionic-angular-v5/yarn.lock b/example/ionic-angular-v5/yarn.lock index 878fbc61..5337b7de 100644 --- a/example/ionic-angular-v5/yarn.lock +++ b/example/ionic-angular-v5/yarn.lock @@ -1773,113 +1773,167 @@ "@angular-devkit/schematics" "17.0.1" jsonc-parser "3.2.0" -"@sentry-internal/tracing@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.81.1.tgz#1180365cd8a9e18cb0f92e1ea970161840ec0e2e" - integrity sha512-E5xm27xrLXL10knH2EWDQsQYh5nb4SxxZzJ3sJwDGG9XGKzBdlp20UUhKqx00wixooVX9uCj3e4Jg8SvNB1hKg== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/angular-ivy@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/angular-ivy/-/angular-ivy-7.81.1.tgz#6933dd62f7f064bb2da5ac8da8a7e27c6f1e10e8" - integrity sha512-GEVF/x7UYoVOEhaHDKf6j+ojnKb9RgWdcTSHyC3fgj7cLtZw3NChLmyzAL32No/YTYPydocSAttSGUJ1oC6a1Q== - dependencies: - "@sentry/browser" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" +"@sentry-internal/feedback@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.93.0.tgz#c6648ce625792c72d7afdbee8f5db878c7f16fee" + integrity sha512-4G7rMeQbYGfCHxEoFroABX+UREYc2BSbFqjLmLbIcWowSpgzcwweLLphWHKOciqK6f7DnNDK0jZzx3u7NrkWHw== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry-internal/tracing@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.93.0.tgz#8cee8b610695d828af75edd2929b64b7caf0385d" + integrity sha512-DjuhmQNywPp+8fxC9dvhGrqgsUb6wI/HQp25lS2Re7VxL1swCasvpkg8EOYP4iBniVQ86QK0uITkOIRc5tdY1w== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/angular-ivy@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/angular-ivy/-/angular-ivy-7.93.0.tgz#9d0df35ea6501025f6fa4da96c45be7f348c083f" + integrity sha512-G6N3bQFZfkWnECnZwva0CgSeiHgcw4H+22X0hWrbnLjPpkuYtMsJ7t+Pc1qnQcSEtEw6+Ckcx94RNpyyfdvzeQ== + dependencies: + "@sentry/browser" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" tslib "^2.4.1" -"@sentry/browser@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.81.1.tgz#5ee6ae3679ee80f444d2e8c5662430e7a734ae50" - integrity sha512-DNtS7bZEnFPKVoGazKs5wHoWC0FwsOFOOMNeDvEfouUqKKbjO7+RDHbr7H6Bo83zX4qmZWRBf8V+3n3YPIiJFw== +"@sentry/browser@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.93.0.tgz#acb559125ab0576091a3fc9718e520ba9b2eb1b9" + integrity sha512-MtLTcQ7y3rfk+aIvnnwCfSJvYhTJnIJi+Mf6y/ap6SKObdlsKMbQoJLlRViglGLq+nKxHLAvU0fONiCEmKfV6A== dependencies: - "@sentry-internal/tracing" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/replay" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + "@sentry-internal/feedback" "7.93.0" + "@sentry-internal/tracing" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/replay" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" "@sentry/capacitor@file:.yalc/@sentry/capacitor": - version "0.14.0" - dependencies: - "@sentry/browser" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/hub" "7.81.1" - "@sentry/integrations" "7.81.1" - "@sentry/tracing" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/cli@^2.21.3": - version "2.21.5" - resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.21.5.tgz#9ee4c51b267ac5ba8cdbf9bb9d4e8b74410d9669" - integrity sha512-RqKBqE10pb7zh0G/YiYVdX/MqenDYIgLGcaCqbszTAfW2SSLyp9EczsnmHtRgO1fO1OQq76+gaK7UdC1TEIGqQ== + version "0.15.0" + dependencies: + "@sentry/browser" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/hub" "7.93.0" + "@sentry/integrations" "7.93.0" + "@sentry/tracing" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/cli-darwin@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.25.2.tgz#9fd935aa0381acbf2e22aef23eddc90d6efc1d97" + integrity sha512-o1d5NnVUrc1dxDm56k7Co8tSTcOuxbApdxweVXXsiq20HblZCyIi7WxxRkAg4RfKx594sKGiw9uCVvECi+9UpA== + +"@sentry/cli-linux-arm64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.25.2.tgz#4a442d55f4e0a849b6faebd151d0d2277abf5de9" + integrity sha512-lm5jaigV6xu9Gwo0wNk+bX6yVkl5k3gNXcSXcKCISFo+Teb7Zhf9IyXANPm4VY2DdiZAjPJt8gS1bu+Mn7irtQ== + +"@sentry/cli-linux-arm@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-2.25.2.tgz#053430a6508450b382fc980195cbd5cc0fe90d86" + integrity sha512-n398jd87Ymejt5k/6RjCEjXAvntOWuqhBDANxzhgr5/9FzbODJ844g1mOpcxiIlduzKSzWlPbTEKQulMp2Mt4w== + +"@sentry/cli-linux-i686@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-2.25.2.tgz#ce72717f48890984a805c82d116a9da115fc53a1" + integrity sha512-/YYx2gfqO5mkxyBgFcnDbZzkZ2+2xNarwrqWcqq3Qw0XlO9DWAQB2G+twV1RW/UfSU6fFIWErn94efh2EWmyzQ== + +"@sentry/cli-linux-x64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-2.25.2.tgz#fb178ac3540f64595a17dd95b4b2071f18aa098a" + integrity sha512-rRafqy84R5mYA4JEfNsUeN10af5euJnK7fgqYM0mJIaplHC2YEXT9aUYWoryWPZiYqmdNUhsA6lX7iynSW9pZw== + +"@sentry/cli-win32-i686@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-2.25.2.tgz#e0d73977771a578439207ea7863cde422a6cfee2" + integrity sha512-plT/gi41F+67g9AwrEm4avRXnjCtHCcnRnJ6zPu/iINGap8mvYQJSU/qM0oGwV6hRGg3JJN66XIvJPIuIs8P8w== + +"@sentry/cli-win32-x64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-2.25.2.tgz#f21f71e7c2c60f99dd62c3360e4b0cda4f27d877" + integrity sha512-Mb6mAyPi9gIfpzF5MTk0JXgFP9nxka3Fb7JYn6AY4RW++sOjapkTrcXL2Gp3ZfQkWj5rFTgln4+eNmZPsD2gzA== + +"@sentry/cli@^2.21.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.25.2.tgz#7e8eec38c19ee27cb3f5c5a7ba3e80ad587c6517" + integrity sha512-lgt1QPaCfs/QZNXwyw3gvuBR2/CLwFSdU/oT7Bpxwizz8XVXhlKS98zJF1UVCy7SecsDSoOI0Z+B+X658cpquQ== dependencies: https-proxy-agent "^5.0.0" node-fetch "^2.6.7" progress "^2.0.3" proxy-from-env "^1.1.0" which "^2.0.2" - -"@sentry/core@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.81.1.tgz#082fd9122bf9a488c8e05b1754724ddbc2d5cf30" - integrity sha512-tU37yAmckOGCw/moWKSwekSCWWJP15O6luIq+u7wal22hE88F3Vc5Avo8SeF3upnPR+4ejaOFH+BJTr6bgrs6Q== - dependencies: - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/hub@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.81.1.tgz#c49bcc1894bfeb019811bac8e3b6fd81011b6f7c" - integrity sha512-25cvsI3HKiRLJBZGFC8ntuy7/yB8M1w8YLTjr3tIqydYmjFUX7f18w0iuWEtd204d8OQSPBJDapbGMdfkE5x6w== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/integrations@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.81.1.tgz#1b12c0cf3a7fa88224e86c0be46523ed7e3f3a43" - integrity sha512-DN5ONn0/LX5HHVPf1EBGHFssIZaZmLgkqUIeMqCNYBpB4DiOrJANnGwTcWKDPphqhdPxjnPv9AGRLaU0PdvvZQ== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + optionalDependencies: + "@sentry/cli-darwin" "2.25.2" + "@sentry/cli-linux-arm" "2.25.2" + "@sentry/cli-linux-arm64" "2.25.2" + "@sentry/cli-linux-i686" "2.25.2" + "@sentry/cli-linux-x64" "2.25.2" + "@sentry/cli-win32-i686" "2.25.2" + "@sentry/cli-win32-x64" "2.25.2" + +"@sentry/core@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.93.0.tgz#50a14bf305130dfef51810e4c97fcba4972a57ef" + integrity sha512-vZQSUiDn73n+yu2fEcH+Wpm4GbRmtxmnXnYCPgM6IjnXqkVm3awWAkzrheADblx3kmxrRiOlTXYHw9NTWs56fg== + dependencies: + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/hub@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.93.0.tgz#3db26f74dc1269650fa9ec553f0837af5caa0d30" + integrity sha512-gfPyT3DFGYYM5d+CHiS0YJHkIJHa8MKSfl32RkCMA5KQr9RF0H+GR5LZCinQOWq43fpsncSLyuoMfBjgbMLN+w== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/integrations@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.93.0.tgz#23ce18919e8b19f97b9b0fdf69d2ecaa6f1730ad" + integrity sha512-uGQ8+DiqUr6SbhdJJHyIqDJ6kHnFuSv8nZWtj2tJ1I8q8u8MX8t8Om6R/R4ap45gCkWg/zqZq7B+gQV6TYewjQ== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" localforage "^1.8.1" -"@sentry/replay@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.81.1.tgz#a656d55e2a00b34e42be6eeb79018d21efc223af" - integrity sha512-4ueT0C4bYjngN/9p0fEYH10dTMLovHyk9HxJ6zSTgePvGVexhg+cSEHXisoBDwHeRZVnbIvsVM0NA7rmEDXJJw== +"@sentry/replay@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.93.0.tgz#55e3c424cd5529041fbc987e4c2e74e30a94b1b8" + integrity sha512-dMlLU8v+OkUeGCrPvTu5NriH7BGj3el4rGHWWAYicfJ2QXqTTq50vfasQBP1JeVNcFqnf1y653TdEIvo4RH4tw== dependencies: - "@sentry-internal/tracing" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + "@sentry-internal/tracing" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" -"@sentry/tracing@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.81.1.tgz#274f76119cdc3e58a4767ce8085cfc73cea13330" - integrity sha512-of9WMu0XgEBl9onTEk8SMaxj4BUadaUvHH96T1OpRMjdyuCM/3u2mjCkh3ekINr3Fu/uT2kJ/kO3goUxfcdXIQ== +"@sentry/tracing@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.93.0.tgz#9785773049ae645cd0ee5b471e83a4dc9a79229c" + integrity sha512-n4XbAQ7e098Jzv4ZvpXAsFgM+XFfjhKci18r7s3UfDMnrB4FTCwhHZoeiygO8PZhB944mEFbNXNFhHkb8nTDbA== dependencies: - "@sentry-internal/tracing" "7.81.1" + "@sentry-internal/tracing" "7.93.0" -"@sentry/types@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.81.1.tgz#2b2551fc291e1089651fd574a68f7c4175878bd5" - integrity sha512-dvJvGyctiaPMIQqa46k56Re5IODWMDxiHJ1UjBs/WYDLrmWFPGrEbyJ8w8CYLhYA+7qqrCyIZmHbWSTRIxstHw== +"@sentry/types@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.93.0.tgz#d76d26259b40cd0688e1d634462fbff31476c1ec" + integrity sha512-UnzUccNakhFRA/esWBWP+0v7cjNg+RilFBQC03Mv9OEMaZaS29zSbcOGtRzuFOXXLBdbr44BWADqpz3VW0XaNw== -"@sentry/utils@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.81.1.tgz#42f3e77baf90205cec1f8599eb8445a6918030bd" - integrity sha512-gq+MDXIirHKxNZ+c9/lVvCXd6y2zaZANujwlFggRH2u9SRiPaIXVilLpvMm4uJqmqBMEcY81ArujExtHvkbCqg== +"@sentry/utils@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.93.0.tgz#36225038661fe977baf01e4695ef84794d591e45" + integrity sha512-Iovj7tUnbgSkh/WrAaMrd5UuYjW7AzyzZlFDIUrwidsyIdUficjCG2OIxYzh76H6nYIx9SxewW0R54Q6XoB4uA== dependencies: - "@sentry/types" "7.81.1" + "@sentry/types" "7.93.0" "@socket.io/component-emitter@~3.1.0": version "3.1.0" diff --git a/example/ionic-angular/package.json b/example/ionic-angular/package.json index e79c49e9..ce0691a2 100644 --- a/example/ionic-angular/package.json +++ b/example/ionic-angular/package.json @@ -14,9 +14,8 @@ "@ionic-native/splash-screen": "^5.0.0", "@ionic-native/status-bar": "^5.0.0", "@ionic/angular": "^5.0.0", - "@sentry/angular-ivy": "7.81.1", + "@sentry/angular-ivy": "7.93.0", "@sentry/capacitor": "file:.yalc/@sentry/capacitor", - "@sentry/cli": "^2.21.3", "rxjs": "~6.5.5", "tslib": "^2.0.0", "zone.js": "~0.11.4" diff --git a/example/ionic-angular/src/app/app.module.ts b/example/ionic-angular/src/app/app.module.ts index 05e36f95..9e3c67a7 100644 --- a/example/ionic-angular/src/app/app.module.ts +++ b/example/ionic-angular/src/app/app.module.ts @@ -5,7 +5,6 @@ import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx'; import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; import { Router } from "@angular/router"; - import { createErrorHandler, TraceService, routingInstrumentation, init as sentryAngularInit } from '@sentry/angular-ivy'; import * as Sentry from '@sentry/capacitor'; diff --git a/example/ionic-angular/yarn.lock b/example/ionic-angular/yarn.lock index 156fe7e4..ef25be3a 100644 --- a/example/ionic-angular/yarn.lock +++ b/example/ionic-angular/yarn.lock @@ -1772,113 +1772,167 @@ "@angular-devkit/schematics" "17.0.1" jsonc-parser "3.2.0" -"@sentry-internal/tracing@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.81.1.tgz#1180365cd8a9e18cb0f92e1ea970161840ec0e2e" - integrity sha512-E5xm27xrLXL10knH2EWDQsQYh5nb4SxxZzJ3sJwDGG9XGKzBdlp20UUhKqx00wixooVX9uCj3e4Jg8SvNB1hKg== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/angular-ivy@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/angular-ivy/-/angular-ivy-7.81.1.tgz#6933dd62f7f064bb2da5ac8da8a7e27c6f1e10e8" - integrity sha512-GEVF/x7UYoVOEhaHDKf6j+ojnKb9RgWdcTSHyC3fgj7cLtZw3NChLmyzAL32No/YTYPydocSAttSGUJ1oC6a1Q== - dependencies: - "@sentry/browser" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" +"@sentry-internal/feedback@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.93.0.tgz#c6648ce625792c72d7afdbee8f5db878c7f16fee" + integrity sha512-4G7rMeQbYGfCHxEoFroABX+UREYc2BSbFqjLmLbIcWowSpgzcwweLLphWHKOciqK6f7DnNDK0jZzx3u7NrkWHw== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry-internal/tracing@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.93.0.tgz#8cee8b610695d828af75edd2929b64b7caf0385d" + integrity sha512-DjuhmQNywPp+8fxC9dvhGrqgsUb6wI/HQp25lS2Re7VxL1swCasvpkg8EOYP4iBniVQ86QK0uITkOIRc5tdY1w== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/angular-ivy@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/angular-ivy/-/angular-ivy-7.93.0.tgz#9d0df35ea6501025f6fa4da96c45be7f348c083f" + integrity sha512-G6N3bQFZfkWnECnZwva0CgSeiHgcw4H+22X0hWrbnLjPpkuYtMsJ7t+Pc1qnQcSEtEw6+Ckcx94RNpyyfdvzeQ== + dependencies: + "@sentry/browser" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" tslib "^2.4.1" -"@sentry/browser@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.81.1.tgz#5ee6ae3679ee80f444d2e8c5662430e7a734ae50" - integrity sha512-DNtS7bZEnFPKVoGazKs5wHoWC0FwsOFOOMNeDvEfouUqKKbjO7+RDHbr7H6Bo83zX4qmZWRBf8V+3n3YPIiJFw== +"@sentry/browser@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.93.0.tgz#acb559125ab0576091a3fc9718e520ba9b2eb1b9" + integrity sha512-MtLTcQ7y3rfk+aIvnnwCfSJvYhTJnIJi+Mf6y/ap6SKObdlsKMbQoJLlRViglGLq+nKxHLAvU0fONiCEmKfV6A== dependencies: - "@sentry-internal/tracing" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/replay" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + "@sentry-internal/feedback" "7.93.0" + "@sentry-internal/tracing" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/replay" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" "@sentry/capacitor@file:.yalc/@sentry/capacitor": - version "0.14.0" - dependencies: - "@sentry/browser" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/hub" "7.81.1" - "@sentry/integrations" "7.81.1" - "@sentry/tracing" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/cli@^2.21.3": - version "2.21.5" - resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.21.5.tgz#9ee4c51b267ac5ba8cdbf9bb9d4e8b74410d9669" - integrity sha512-RqKBqE10pb7zh0G/YiYVdX/MqenDYIgLGcaCqbszTAfW2SSLyp9EczsnmHtRgO1fO1OQq76+gaK7UdC1TEIGqQ== + version "0.15.0" + dependencies: + "@sentry/browser" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/hub" "7.93.0" + "@sentry/integrations" "7.93.0" + "@sentry/tracing" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/cli-darwin@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.25.2.tgz#9fd935aa0381acbf2e22aef23eddc90d6efc1d97" + integrity sha512-o1d5NnVUrc1dxDm56k7Co8tSTcOuxbApdxweVXXsiq20HblZCyIi7WxxRkAg4RfKx594sKGiw9uCVvECi+9UpA== + +"@sentry/cli-linux-arm64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.25.2.tgz#4a442d55f4e0a849b6faebd151d0d2277abf5de9" + integrity sha512-lm5jaigV6xu9Gwo0wNk+bX6yVkl5k3gNXcSXcKCISFo+Teb7Zhf9IyXANPm4VY2DdiZAjPJt8gS1bu+Mn7irtQ== + +"@sentry/cli-linux-arm@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-2.25.2.tgz#053430a6508450b382fc980195cbd5cc0fe90d86" + integrity sha512-n398jd87Ymejt5k/6RjCEjXAvntOWuqhBDANxzhgr5/9FzbODJ844g1mOpcxiIlduzKSzWlPbTEKQulMp2Mt4w== + +"@sentry/cli-linux-i686@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-2.25.2.tgz#ce72717f48890984a805c82d116a9da115fc53a1" + integrity sha512-/YYx2gfqO5mkxyBgFcnDbZzkZ2+2xNarwrqWcqq3Qw0XlO9DWAQB2G+twV1RW/UfSU6fFIWErn94efh2EWmyzQ== + +"@sentry/cli-linux-x64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-2.25.2.tgz#fb178ac3540f64595a17dd95b4b2071f18aa098a" + integrity sha512-rRafqy84R5mYA4JEfNsUeN10af5euJnK7fgqYM0mJIaplHC2YEXT9aUYWoryWPZiYqmdNUhsA6lX7iynSW9pZw== + +"@sentry/cli-win32-i686@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-2.25.2.tgz#e0d73977771a578439207ea7863cde422a6cfee2" + integrity sha512-plT/gi41F+67g9AwrEm4avRXnjCtHCcnRnJ6zPu/iINGap8mvYQJSU/qM0oGwV6hRGg3JJN66XIvJPIuIs8P8w== + +"@sentry/cli-win32-x64@2.25.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-2.25.2.tgz#f21f71e7c2c60f99dd62c3360e4b0cda4f27d877" + integrity sha512-Mb6mAyPi9gIfpzF5MTk0JXgFP9nxka3Fb7JYn6AY4RW++sOjapkTrcXL2Gp3ZfQkWj5rFTgln4+eNmZPsD2gzA== + +"@sentry/cli@^2.21.2": + version "2.25.2" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.25.2.tgz#7e8eec38c19ee27cb3f5c5a7ba3e80ad587c6517" + integrity sha512-lgt1QPaCfs/QZNXwyw3gvuBR2/CLwFSdU/oT7Bpxwizz8XVXhlKS98zJF1UVCy7SecsDSoOI0Z+B+X658cpquQ== dependencies: https-proxy-agent "^5.0.0" node-fetch "^2.6.7" progress "^2.0.3" proxy-from-env "^1.1.0" which "^2.0.2" - -"@sentry/core@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.81.1.tgz#082fd9122bf9a488c8e05b1754724ddbc2d5cf30" - integrity sha512-tU37yAmckOGCw/moWKSwekSCWWJP15O6luIq+u7wal22hE88F3Vc5Avo8SeF3upnPR+4ejaOFH+BJTr6bgrs6Q== - dependencies: - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/hub@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.81.1.tgz#c49bcc1894bfeb019811bac8e3b6fd81011b6f7c" - integrity sha512-25cvsI3HKiRLJBZGFC8ntuy7/yB8M1w8YLTjr3tIqydYmjFUX7f18w0iuWEtd204d8OQSPBJDapbGMdfkE5x6w== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" - -"@sentry/integrations@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.81.1.tgz#1b12c0cf3a7fa88224e86c0be46523ed7e3f3a43" - integrity sha512-DN5ONn0/LX5HHVPf1EBGHFssIZaZmLgkqUIeMqCNYBpB4DiOrJANnGwTcWKDPphqhdPxjnPv9AGRLaU0PdvvZQ== - dependencies: - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + optionalDependencies: + "@sentry/cli-darwin" "2.25.2" + "@sentry/cli-linux-arm" "2.25.2" + "@sentry/cli-linux-arm64" "2.25.2" + "@sentry/cli-linux-i686" "2.25.2" + "@sentry/cli-linux-x64" "2.25.2" + "@sentry/cli-win32-i686" "2.25.2" + "@sentry/cli-win32-x64" "2.25.2" + +"@sentry/core@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.93.0.tgz#50a14bf305130dfef51810e4c97fcba4972a57ef" + integrity sha512-vZQSUiDn73n+yu2fEcH+Wpm4GbRmtxmnXnYCPgM6IjnXqkVm3awWAkzrheADblx3kmxrRiOlTXYHw9NTWs56fg== + dependencies: + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/hub@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-7.93.0.tgz#3db26f74dc1269650fa9ec553f0837af5caa0d30" + integrity sha512-gfPyT3DFGYYM5d+CHiS0YJHkIJHa8MKSfl32RkCMA5KQr9RF0H+GR5LZCinQOWq43fpsncSLyuoMfBjgbMLN+w== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" + +"@sentry/integrations@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.93.0.tgz#23ce18919e8b19f97b9b0fdf69d2ecaa6f1730ad" + integrity sha512-uGQ8+DiqUr6SbhdJJHyIqDJ6kHnFuSv8nZWtj2tJ1I8q8u8MX8t8Om6R/R4ap45gCkWg/zqZq7B+gQV6TYewjQ== + dependencies: + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" localforage "^1.8.1" -"@sentry/replay@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.81.1.tgz#a656d55e2a00b34e42be6eeb79018d21efc223af" - integrity sha512-4ueT0C4bYjngN/9p0fEYH10dTMLovHyk9HxJ6zSTgePvGVexhg+cSEHXisoBDwHeRZVnbIvsVM0NA7rmEDXJJw== +"@sentry/replay@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.93.0.tgz#55e3c424cd5529041fbc987e4c2e74e30a94b1b8" + integrity sha512-dMlLU8v+OkUeGCrPvTu5NriH7BGj3el4rGHWWAYicfJ2QXqTTq50vfasQBP1JeVNcFqnf1y653TdEIvo4RH4tw== dependencies: - "@sentry-internal/tracing" "7.81.1" - "@sentry/core" "7.81.1" - "@sentry/types" "7.81.1" - "@sentry/utils" "7.81.1" + "@sentry-internal/tracing" "7.93.0" + "@sentry/core" "7.93.0" + "@sentry/types" "7.93.0" + "@sentry/utils" "7.93.0" -"@sentry/tracing@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.81.1.tgz#274f76119cdc3e58a4767ce8085cfc73cea13330" - integrity sha512-of9WMu0XgEBl9onTEk8SMaxj4BUadaUvHH96T1OpRMjdyuCM/3u2mjCkh3ekINr3Fu/uT2kJ/kO3goUxfcdXIQ== +"@sentry/tracing@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.93.0.tgz#9785773049ae645cd0ee5b471e83a4dc9a79229c" + integrity sha512-n4XbAQ7e098Jzv4ZvpXAsFgM+XFfjhKci18r7s3UfDMnrB4FTCwhHZoeiygO8PZhB944mEFbNXNFhHkb8nTDbA== dependencies: - "@sentry-internal/tracing" "7.81.1" + "@sentry-internal/tracing" "7.93.0" -"@sentry/types@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.81.1.tgz#2b2551fc291e1089651fd574a68f7c4175878bd5" - integrity sha512-dvJvGyctiaPMIQqa46k56Re5IODWMDxiHJ1UjBs/WYDLrmWFPGrEbyJ8w8CYLhYA+7qqrCyIZmHbWSTRIxstHw== +"@sentry/types@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.93.0.tgz#d76d26259b40cd0688e1d634462fbff31476c1ec" + integrity sha512-UnzUccNakhFRA/esWBWP+0v7cjNg+RilFBQC03Mv9OEMaZaS29zSbcOGtRzuFOXXLBdbr44BWADqpz3VW0XaNw== -"@sentry/utils@7.81.1": - version "7.81.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.81.1.tgz#42f3e77baf90205cec1f8599eb8445a6918030bd" - integrity sha512-gq+MDXIirHKxNZ+c9/lVvCXd6y2zaZANujwlFggRH2u9SRiPaIXVilLpvMm4uJqmqBMEcY81ArujExtHvkbCqg== +"@sentry/utils@7.93.0": + version "7.93.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.93.0.tgz#36225038661fe977baf01e4695ef84794d591e45" + integrity sha512-Iovj7tUnbgSkh/WrAaMrd5UuYjW7AzyzZlFDIUrwidsyIdUficjCG2OIxYzh76H6nYIx9SxewW0R54Q6XoB4uA== dependencies: - "@sentry/types" "7.81.1" + "@sentry/types" "7.93.0" "@socket.io/component-emitter@~3.1.0": version "3.1.0" diff --git a/src/client.ts b/src/client.ts new file mode 100644 index 00000000..a6055eac --- /dev/null +++ b/src/client.ts @@ -0,0 +1,173 @@ +import { eventFromException, eventFromMessage } from '@sentry/browser'; +import { BaseClient } from '@sentry/core'; +import type { + Envelope, + Event, + EventHint, + Exception, + Outcome, + SeverityLevel, + Thread, + UserFeedback, +} from '@sentry/types'; +import { logger, SentryError } from '@sentry/utils'; + +import type { CapacitorClientOptions } from './options'; +import { NATIVE } from './wrapper'; + +/** + * The Sentry Capacitor SDK Client. + * + * @see CapacitorClientOptions for documentation on configuration options. + * @see SentryClient for usage documentation. + */ +export class CapacitorClient extends BaseClient { + private _outcomesBuffer: Outcome[]; + + /** + * Creates a new Capacitor SDK instance. + * @param options Configuration options for this SDK. + */ + public constructor(options: CapacitorClientOptions) { + options._metadata = options._metadata || {}; + // TODO: Implement defaultSdkInfo. + // options._metadata.sdk = options._metadata.sdk; || defaultSdkInfo; + super(options); + + this._outcomesBuffer = []; + + this._initNativeSdk() + .catch(_ => { + // Error is already captured on initNativeSdk + }); + } + + /** + * @inheritDoc + */ + public eventFromException(exception: unknown, hint: EventHint = {}): PromiseLike { + return eventFromException(this._options.stackParser, exception, hint, this._options.attachStacktrace); + } + + /** + * @inheritDoc + */ + public eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike { + return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace).then( + (event: Event) => { + // TMP! Remove this function once JS SDK uses threads for messages + if (!event.exception?.values || event.exception.values.length <= 0) { + return event; + } + const values = event.exception.values.map( + (exception: Exception): Thread => ({ + stacktrace: exception.stacktrace, + }), + ); + (event as { threads?: { values: Thread[] } }).threads = { values }; + delete event.exception; + return event; + }, + ); + } + + /** + * If native client is available it will trigger a native crash. + * Use this only for testing purposes. + */ + public nativeCrash(): void { + NATIVE.crash(); + } + + /// TODO: Implement close function/ + /** + * @inheritDoc + */ + public close(): PromiseLike { + // As super.close() flushes queued events, we wait for that to finish before closing the native SDK. + return super.close().then((_: boolean) => { + return false; // NATIVE.then(() => result) as PromiseLike; + }); + } + + /** + * Sends user feedback to Sentry. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + public captureUserFeedback(feedback: UserFeedback): void { + // TODO: Implement capture user feedback + throw new Error(`${feedback} captureUserFeedback not implemented.`); + } + + /** + * @inheritdoc + */ + protected _sendEnvelope(envelope: Envelope): void { + const outcomes = this._clearOutcomes(); + this._outcomesBuffer = mergeOutcomes(this._outcomesBuffer, outcomes); + + if (this._options.sendClientReports) { + // TODO: Implement Cleint Report. + // this._attachClientReportTo(this._outcomesBuffer, envelope as ClientReportEnvelope); + } + + let shouldClearOutcomesBuffer = true; + if (this._transport && this._dsn) { + this.emit('beforeEnvelope', envelope); + + this._transport.send(envelope).then(null, reason => { + if (reason instanceof SentryError) { + // SentryError is thrown by SyncPromise + shouldClearOutcomesBuffer = false; + // If this is called asynchronously we want the _outcomesBuffer to be cleared + logger.error('SentryError while sending event, keeping outcomes buffer:', reason); + } else { + logger.error('Error while sending event:', reason); + } + }); + } else { + logger.error('Transport disabled'); + } + + if (shouldClearOutcomesBuffer) { + this._outcomesBuffer = []; // if send fails synchronously the _outcomesBuffer will stay intact + } + } + + /** + * Starts native client with dsn and options + */ + private async _initNativeSdk(): Promise { + let didCallNativeInit = false; + + try { + didCallNativeInit = await NATIVE.initNativeSdk(this._options); + } catch (_) { + this._showCannotConnectDialog(); + } finally { + try { + this._options.onReady?.({ didCallNativeInit }); + } catch (error) { + logger.error('The OnReady callback threw an error: ', error); + } + } + } + + /** + * If the user is in development mode, and the native nagger is enabled then it will show an alert. + */ + private _showCannotConnectDialog(): void { + if (this._options.debug && this._options.enableNativeNagger) { + // eslint-disable-next-line no-console + console.log('Sentry Warning, could not connect to Sentry native SDK.\nIf you do not want to use the native component please pass `enableNative: false` in the options.\nVisit: https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/options/#hybrid-sdk-options for more details.'); + } + } + +// TODO: implement Attaches clients report. +} +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function mergeOutcomes(_outcomesBuffer: Outcome[], outcomes: Outcome[]): Outcome[] { + // TODO: Implement mergeOutComes. + throw new Error('Function not implemented.'); +} + diff --git a/src/integrations/rewriteframes.ts b/src/integrations/rewriteframes.ts index c13d098e..1e86b41b 100644 --- a/src/integrations/rewriteframes.ts +++ b/src/integrations/rewriteframes.ts @@ -1,5 +1,5 @@ import { RewriteFrames } from '@sentry/integrations'; -import type { StackFrame } from '@sentry/types'; +import type { Integration, StackFrame } from '@sentry/types'; import { getCurrentServerUrl } from '../utils/webViewUrl'; @@ -8,7 +8,7 @@ import { getCurrentServerUrl } from '../utils/webViewUrl'; * which appends app:// to the beginning of the filename * and removes the local server url prefixes. */ -export function createCapacitorRewriteFrames(): RewriteFrames { +export function createCapacitorRewriteFrames(): Integration { const rewriteFrames = new RewriteFrames({ iteratee: (frame: StackFrame) => { if (frame.filename) { diff --git a/src/options.ts b/src/options.ts index 39d74159..f31657a2 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,11 +1,8 @@ import type { BrowserOptions } from '@sentry/browser'; +import type { BrowserTransportOptions } from '@sentry/browser/types/transports/types'; +import type { ClientOptions } from '@sentry/types'; -/** - * Configuration options for the Sentry Capacitor SDK. - */ - -export interface CapacitorOptions - extends Omit { +export interface BaseCapacitorOptions{ /** * Enables crash reporting for native crashes. * Defaults to `true`. @@ -18,6 +15,15 @@ export interface CapacitorOptions */ enableNativeCrashHandling?: boolean; + /** + * Callback that is called after the Capacitor SDK on the JS Layer has made contact with the Native Layer. + */ + onReady?: (response: { + /** `true` if the native SDK has been initialized, `false` otherwise. */ + didCallNativeInit: boolean; + }) => void; + + /** Maximum time to wait to drain the request queue, before the process is allowed to exit. */ shutdownTimeout?: number; @@ -55,3 +61,20 @@ export interface CapacitorOptions * */ enableOutOfMemoryTracking?: boolean; } + +/** + * Configuration options for the Sentry Capacitor SDK. + */ +export interface CapacitorOptions extends Omit, BaseCapacitorOptions { } + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface CapacitorTransportOptions extends BrowserTransportOptions{ + /** + * @deprecated use `maxQueueSize` in the root of the SDK options. + */ + bufferSize?: number; +} + + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface CapacitorClientOptions extends ClientOptions, BaseCapacitorOptions { } diff --git a/src/sdk.ts b/src/sdk.ts index 0af0d057..dca1ef9c 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -3,11 +3,13 @@ import { defaultIntegrations, init as browserInit } from '@sentry/browser'; -import { Hub, makeMain } from '@sentry/core'; +import { Hub, initAndBind, makeMain } from '@sentry/core'; +import { CapacitorClient } from './client'; import { DeviceContext, EventOrigin, Release, SdkInfo } from './integrations'; -import { createCapacitorRewriteFrames } from './integrations/rewriteframes'; -import type { CapacitorOptions } from './options'; +// TODO: Fix RewriteFrames. +// import { createCapacitorRewriteFrames } from './integrations/rewriteframes'; +import type { CapacitorClientOptions, CapacitorOptions } from './options'; import { CapacitorScope } from './scope'; import { DEFAULT_BUFFER_SIZE, makeNativeTransport } from './transports/native'; import { makeUtf8TextEncoder } from './transports/TextEncoder'; @@ -42,7 +44,8 @@ export function init( finalOptions.defaultIntegrations = [ ...defaultIntegrations, - createCapacitorRewriteFrames(), + // TODO: Fix Rewrite Frames. + // createCapacitorRewriteFrames(), new Release(), new SdkInfo(), new EventOrigin(), @@ -73,11 +76,11 @@ export function init( ...finalOptions, enableAutoSessionTracking: NATIVE.platform !== 'web' && finalOptions.enableAutoSessionTracking, - } as CapacitorOptions; + } as CapacitorClientOptions; // We first initialize the NATIVE SDK to avoid the Javascript SDK to invoke any // feature from the NATIVE SDK without the options being set. - void NATIVE.initNativeSdk(mobileOptions); + initAndBind(CapacitorClient, mobileOptions); originalInit(browserOptions); } diff --git a/src/wrapper.ts b/src/wrapper.ts index ae3712c2..6b52a3b3 100644 --- a/src/wrapper.ts +++ b/src/wrapper.ts @@ -99,7 +99,8 @@ export const NATIVE = { // filter out all options that would crash native const filteredOptions = FilterNativeOptions(options); - return SentryCapacitor.initNativeSdk({ options: filteredOptions }); + const nativeIsReady = await SentryCapacitor.initNativeSdk({ options: filteredOptions }); + return nativeIsReady; }, /** diff --git a/test/client.test.ts b/test/client.test.ts new file mode 100644 index 00000000..cf3af434 --- /dev/null +++ b/test/client.test.ts @@ -0,0 +1,510 @@ +import type { Envelope, Transport } from '@sentry/types'; + +import { CapacitorClient } from '../src/client'; +import type { CapacitorClientOptions } from '../src/options'; +import { NativeTransport } from '../src/transports/native'; +import { NATIVE } from '../src/wrapper'; + +interface MockedCapacitor { + Platform: { + OS: 'mock'; + }; + Capacitor: { + isPluginAvailable: jest.Mock, + getPlatform: jest.Mock, + crash: jest.Mock; + captureEnvelope: jest.Mock; +}, +} + +jest.mock( + '@capacitor/core', + (): MockedCapacitor => ({ + Platform: { + OS: 'mock', + }, + Capacitor: { + isPluginAvailable: jest.fn(() => true), + getPlatform: jest.fn(() => 'android'), + crash: jest.fn(), + captureEnvelope: jest.fn(), + }, + }), +); + +jest.mock('../src/plugin', () => { + return { + SentryCapacitor: { + addBreadcrumb: jest.fn(), + captureEnvelope: jest.fn(envelope => Promise.resolve(envelope)), + crash: jest.fn(), + fetchNativeRelease: jest.fn(() => + Promise.resolve({ + build: '0.0.1', + id: 'test-mock', + version: '0.0.1', + }), + ), + fetchNativeDeviceContexts: jest.fn(() => + Promise.resolve({ + someContext: { + someValue: 0, + }, + }) + ), + getStringBytesLength: jest.fn(() => + Promise.resolve({ + value: 1, + }), + ), + initNativeSdk: jest.fn(() => Promise.resolve(true)), + setContext: jest.fn(() => Promise.resolve()), + setExtra: jest.fn(() => Promise.resolve()), + setTag: jest.fn(() => Promise.resolve()), + setUser: jest.fn(() => { + return; + }), + }, + }; +}); + +import * as Plugin from '../src/plugin'; + + +const EXAMPLE_DSN = 'https://6890c2f6677340daa4804f8194804ea2@o19635.ingest.sentry.io/148053'; + +const DEFAULT_OPTIONS: CapacitorClientOptions = { + enableNative: true, + enableNativeCrashHandling: true, + enableNativeNagger: true, + enableWatchdogTerminationTracking: true, + integrations: [], + transport: () => ({ + send: jest.fn(), + flush: jest.fn(), + }), + stackParser: jest.fn().mockReturnValue([]), +}; + +describe('Tests CapacitorClient', () => { + describe('initializing the client', () => { + test('client initializes', async () => { + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => new NativeTransport(), + }); + + await expect(client.eventFromMessage('test')).resolves.toBeDefined(); + }); + + test('invalid dsn is thrown', () => { + try { + new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: 'not a dsn', + transport: () => new NativeTransport(), + }); + } catch (e: any) { + expect(e.message).toBe('Invalid Sentry Dsn: not a dsn'); + } + }); + + test("undefined dsn doesn't crash", () => { + expect(() => { + const backend = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: undefined, + transport: () => new NativeTransport(), + }); + + return expect(backend.eventFromMessage('test')).resolves.toBeDefined(); + }).not.toThrow(); + }); + + test('use custom transport function', async () => { + const mySend = (_request: Envelope) => Promise.resolve(); + const myFlush = (timeout?: number) => Promise.resolve(Boolean(timeout)); + const myCustomTransportFn = (): Transport => ({ + send: mySend, + flush: myFlush, + }); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: myCustomTransportFn, + }); + // eslint-disable-next-line @typescript-eslint/unbound-method + expect(client.getTransport()?.flush).toBe(myFlush); + // eslint-disable-next-line @typescript-eslint/unbound-method + expect(client.getTransport()?.send).toBe(mySend); + }); + }); + + describe('onReady', () => { + test('calls onReady callback with true if Native SDK is initialized', done => { + new CapacitorClient( + mockedOptions({ + dsn: EXAMPLE_DSN, + enableNative: true, + onReady: ({ didCallNativeInit }) => { + expect(didCallNativeInit).toBe(true); + + done(); + }, + transport: () => new NativeTransport(), + }), + ); + }); + + test('calls onReady callback with false if Native SDK was not initialized', done => { + new CapacitorClient( + mockedOptions({ + dsn: EXAMPLE_DSN, + enableNative: false, + onReady: ({ didCallNativeInit }) => { + expect(didCallNativeInit).toBe(false); + + done(); + }, + transport: () => new NativeTransport(), + }), + ); + }); + + test('calls onReady callback with false if Native SDK failed to initialize', done => { + Plugin.SentryCapacitor.initNativeSdk = jest.fn(() => { + throw new Error(); + }); + + new CapacitorClient( + mockedOptions({ + dsn: EXAMPLE_DSN, + enableNative: true, + onReady: ({ didCallNativeInit }) => { + expect(didCallNativeInit).toBe(false); + + done(); + }, + transport: () => new NativeTransport(), + }), + ); + }); + }); + + describe('nativeCrash', () => { + test('calls NativeModules crash', () => { + NATIVE.enableNative = true; + + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + enableNative: true, + transport: () => new NativeTransport(), + }); + client.nativeCrash(); + + // eslint-disable-next-line @typescript-eslint/unbound-method + expect(Plugin.SentryCapacitor.crash).toBeCalled(); + }); + }); + + /* TODO: To be implemented + describe('UserFeedback', () => { + test('sends UserFeedback to native Layer', () => { + const mockTransportSend: jest.Mock = jest.fn(() => Promise.resolve()); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + }); + + client.captureUserFeedback({ + comments: 'Test Comments', + email: 'test@email.com', + name: 'Test User', + event_id: 'testEvent123', + }); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeHeader].event_id).toEqual('testEvent123'); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemHeader].type).toEqual( + 'user_report', + ); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload]).toEqual({ + comments: 'Test Comments', + email: 'test@email.com', + name: 'Test User', + event_id: 'testEvent123', + }); + }); + }); +*/ + + /* + TODO: FIX SdkInfo + describe('envelopeHeader SdkInfo', () => { + let mockTransportSend: jest.Mock; + let client: CapacitorClient; + + beforeEach(() => { + mockTransportSend = jest.fn(() => Promise.resolve()); + client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + }); + }); + + afterEach(() => { + mockTransportSend.mockClear(); + }); + + const expectedSdkInfo = { name: SDK_NAME, version: SDK_VERSION }; + const getSdkInfoFrom = (func: jest.Mock) => func.mock.calls[0][firstArg][envelopeHeader].sdk; + + test('send SdkInfo in the message envelope header', () => { + client.captureMessage('message_test_value'); + expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); + }); + + test('send SdkInfo in the exception envelope header', () => { + client.captureException(new Error()); + expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); + }); + + test('send SdkInfo in the event envelope header', () => { + client.captureEvent({}); + expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); + }); + + test('send SdkInfo in the session envelope header', () => { + client.captureSession(getMockSession()); + expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); + }); + + test('send SdkInfo in the user feedback envelope header', () => { + client.captureUserFeedback(getMockUserFeedback()); + expect(getSdkInfoFrom(mockTransportSend)).toStrictEqual(expectedSdkInfo); + }); + }); +*/ + /* TODO: Fix SDKInfo + describe('event data enhancement', () => { + test('event contains sdk default information', async () => { + const mockedSend = jest.fn, [Envelope]>().mockResolvedValue(undefined); + const mockedTransport = (): Transport => ({ + send: mockedSend, + flush: jest.fn().mockResolvedValue(true), + }); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: mockedTransport, + }); + + client.captureEvent({ message: 'test event' }); + + expect(mockedSend).toBeCalled(); + const actualEvent: Event | undefined = ( + mockedSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload] + ); + expect(actualEvent?.sdk?.packages).toEqual([ + { + name: SDK_PACKAGE_NAME, + version: SDK_VERSION, + }, + ]); + }); + + }); +*/ + describe('normalizes events', () => { + /* TODO: Fix later + test('handles circular input', async () => { + const mockedSend = jest.fn, [Envelope]>(); + const mockedTransport = (): Transport => ({ + send: mockedSend, + flush: jest.fn().mockResolvedValue(true), + }); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: mockedTransport, + }); + const circularEvent = { + extra: { + circular: {}, + }, + }; + circularEvent.extra.circular = circularEvent; + + client.captureEvent(circularEvent); + + expect(mockedSend).toBeCalled(); + const actualEvent: Event | undefined = ( + mockedSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload] + ); + expect(actualEvent?.extra).toEqual({ + circular: { + extra: '[Circular ~]', + }, + }); + }); + */ + }); + + /* TODO: To be fixed on Client Report implementation. + describe('clientReports', () => { + test('does not send client reports if disabled', () => { + const mockTransportSend = jest.fn((_envelope: Envelope) => Promise.resolve()); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendClientReports: false, + }); + + mockDroppedEvent(client); + + client.captureMessage('message_test_value'); + + expectOnlyMessageEventInEnvelope(mockTransportSend); + }); + + /* TODO: Implement Client Report + test('send client reports on event envelope', () => { + const mockTransportSend = jest.fn((_envelope: Envelope) => Promise.resolve()); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendClientReports: true, + }); + + mockDroppedEvent(client); + + client.captureMessage('message_test_value'); + + expect(mockTransportSend).toBeCalledTimes(1); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][1][envelopeItemHeader]).toEqual({ + type: 'client_report', + }); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][1][envelopeItemPayload]).toEqual( + expect.objectContaining({ + discarded_events: [ + { + reason: 'before_send', + category: 'error', + quantity: 1, + }, + ], + }), + ); + expect((client as unknown as { _outcomesBuffer: Outcome[] })._outcomesBuffer).toEqual([]); + }); + + test('does not send empty client report', () => { + const mockTransportSend = jest.fn((_envelope: Envelope) => Promise.resolve()); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendClientReports: true, + }); + + client.captureMessage('message_test_value'); + + expectOnlyMessageEventInEnvelope(mockTransportSend); + }); +*/ + /* + TODO: To be implemented + test('keeps outcomes in case envelope fails to send', () => { + const mockTransportSend = jest.fn((_envelope: Envelope) => rejectedSyncPromise(new SentryError('Test'))); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendClientReports: true, + }); + + mockDroppedEvent(client); + + client.captureMessage('message_test_value'); + + expect((client as unknown as { _outcomesBuffer: Outcome[] })._outcomesBuffer).toEqual([ + { reason: 'before_send', category: 'error', quantity: 1 }, + ]); + }); + */ + + /* + TODO: To be implemented. + test('sends buffered client reports on second try', () => { + const mockTransportSend = getSyncPromiseRejectOnFirstCall<[Envelope]>(new SentryError('Test')); + const client = new CapacitorClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendClientReports: true, + }); + + mockDroppedEvent(client); + client.captureMessage('message_test_value_1'); + mockDroppedEvent(client); + client.captureMessage('message_test_value_2'); + + expect(mockTransportSend).toBeCalledTimes(2); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems].length).toEqual(2); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][1][envelopeItemHeader]).toEqual({ + type: 'client_report', + }); + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][1][envelopeItemPayload]).toEqual( + expect.objectContaining({ + discarded_events: [ + { + reason: 'before_send', + category: 'error', + quantity: 2, + }, + ], + }), + ); + expect((client as unknown as { _outcomesBuffer: Outcome[] })._outcomesBuffer).toEqual([]); + }); + */ + }); + + + function mockedOptions(options: Partial): CapacitorClientOptions { + return { + integrations: [], + stackParser: jest.fn().mockReturnValue([]), + transport: () => ({ + send: jest.fn(), + flush: jest.fn(), + }), + ...options, + }; + } diff --git a/test/testutils.ts b/test/testutils.ts new file mode 100644 index 00000000..6a04e916 --- /dev/null +++ b/test/testutils.ts @@ -0,0 +1,72 @@ +import { Transaction } from '@sentry/core'; +import type { Session, UserFeedback } from '@sentry/types'; +import { rejectedSyncPromise } from '@sentry/utils'; + +import { getBlankTransactionContext } from './tracing/utils'; + +export type MockInterface = { + [K in keyof T]: T[K] extends (...args: infer A) => infer B ? jest.Mock : T[K]; +} & T; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function mockFunction any>(fn: T): jest.MockedFunction { + return fn as jest.MockedFunction; +} + +export const getMockTransaction = (name: string): Transaction => { + // TODO: V8 Fix + // eslint-disable-next-line deprecation/deprecation + const transaction = new Transaction(getBlankTransactionContext(name)); + + // Assume it's sampled + // TODO: V8 Fix + // eslint-disable-next-line deprecation/deprecation + transaction.sampled = true; + + return transaction; +}; + +export const firstArg = 0; +export const secondArg = 1; +export const envelopeHeader = 0; +export const envelopeItems = 1; +export const envelopeItemHeader = 0; +export const envelopeItemPayload = 1; + +export const getMockSession = (): Session => ({ + sid: 'sid_test_value', + init: true, + timestamp: -1, + started: -1, + status: 'ok', + errors: -1, + ignoreDuration: false, + release: 'release_test_value', + toJSON: () => ({ + init: true, + sid: 'sid_test_value', + timestamp: 'timestamp_test_value', + started: 'started_test_value', + status: 'ok', + errors: -1, + }), +}); + +export const getMockUserFeedback = (): UserFeedback => ({ + comments: 'comments_test_value', + email: 'email_test_value', + name: 'name_test_value', + event_id: 'event_id_test_value', +}); + +export const getSyncPromiseRejectOnFirstCall = (reason: unknown): jest.Mock => { + let shouldSyncReject = true; + return jest.fn((..._args: Y) => { + if (shouldSyncReject) { + shouldSyncReject = false; + return rejectedSyncPromise(reason); + } else { + return Promise.resolve(); + } + }); +}; diff --git a/test/tracing/utils.ts b/test/tracing/utils.ts new file mode 100644 index 00000000..6e2627dc --- /dev/null +++ b/test/tracing/utils.ts @@ -0,0 +1,18 @@ +import type { TransactionContext, TransactionSource } from '@sentry/types'; + +export const defaultTransactionSource: TransactionSource = 'component'; +export const customTransactionSource: TransactionSource = 'custom'; + +export const getBlankTransactionContext = (name: string): TransactionContext => { + return { + name: 'Route Change', + op: 'navigation', + tags: { + 'routing.instrumentation': name, + }, + data: {}, + metadata: { + source: defaultTransactionSource, + }, + }; +};