Title: There are not 'document.scripts' in mini-program environment · Issue #3705 · getsentry/sentry-javascript · GitHub
Open Graph Title: There are not 'document.scripts' in mini-program environment · Issue #3705 · getsentry/sentry-javascript
X Title: There are not 'document.scripts' in mini-program environment · Issue #3705 · getsentry/sentry-javascript
Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javascript/releases Provide a link to the aff...
Open Graph Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas...
X Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/3705
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"There are not 'document.scripts' in mini-program environment","articleBody":"\u003c!-- Requirements: please go through this checklist before opening a new issue -->\r\n\r\n- [x] Review the documentation: https://docs.sentry.io/\r\n- [x] Search for existing issues: https://github.com/getsentry/sentry-javascript/issues\r\n- [ ] Use the latest release: https://github.com/getsentry/sentry-javascript/releases\r\n- [ ] Provide a link to the affected event from your Sentry account\r\n\r\n## Package + Version\r\n\r\n- [x] `@sentry/browser`\r\n- [x] `@sentry/node`\r\n- [ ] `raven-js`\r\n- [ ] `raven-node` _(raven for node)_\r\n- [x] `@sentry/tracing`\r\n\r\n### Version:\r\n\r\n```\r\n6.4.1\r\n```\r\n\r\n## Description\r\n\r\nUse '@sentry/tracing' in mini-program environment, when call `Sentry.startTransaction` on a page launch at the first time, whould catch the error as below: \r\n\r\n```\r\nTypeError: Cannot read property 'length' of undefined\r\n at MetricsInstrumentation.define.push../node_modules/@sentry/tracing/esm/browser/metrics.js.MetricsInstrumentation.addPerformanceEntries (common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:6416)\r\n at common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:6315\r\n at IdleTransaction.define.push../node_modules/@sentry/tracing/esm/idletransaction.js.IdleTransaction.finish (common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:7949)\r\n at Function.\u003canonymous> (common.js?t=wechat&s=1623694839553&v=ba7f9072bea7d2c8b9666326b3c638e8:7932)\r\n at :12319/appservice/\u003csetTimeout callback function>\r\n at VM214 WAService.js:2\r\n at VM214 WAService.js:2(env: macOS,mp,1.05.2105170; lib: 2.17.0)\r\n```\r\n\r\nCheck this error in file `/node_modules/@sentry/tracing/esm/browser/metrics.js`: \r\n\r\n```javascript\r\n // line 34\r\n if (global.document) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\r\n for (var i = 0; i \u003c document.scripts.length; i++) { // => There are not document.scripts in mini-program\r\n // We go through all scripts on the page and look for 'data-entry'\r\n // We remember the name and measure the time between this script finished loading and\r\n // our mark 'sentry-tracing-init'\r\n if (document.scripts[i].dataset.entry === 'true') {\r\n entryScriptSrc = document.scripts[i].src;\r\n break;\r\n }\r\n }\r\n }\r\n```\r\n\r\nI think should change `if (global.document)` to `if (global.document && document.scripts != null)` will fix this issue.\r\n\r\n","author":{"url":"https://github.com/janpoem","@type":"Person","name":"janpoem"},"datePublished":"2021-06-18T09:34:17Z","url":"https://github.com/getsentry/sentry-javascript/issues/3705"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1b53a5a5-8a22-ff91-ba8d-3b6e921564c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D10E:30975F:476C76:62409F:6B0451E5 |
| html-safe-nonce | c133f8794e444150675aad6a4bd15dd287a04d1931eec56810fa5c71f5c15615 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTBFOjMwOTc1Rjo0NzZDNzY6NjI0MDlGOjZCMDQ1MUU1IiwidmlzaXRvcl9pZCI6IjI5MTcxODA4NDY2NTAzNzI4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f0e814133c3bc3c8ec5f70575144d2172d342101605bb81307879c55c181c5e0 |
| hovercard-subject-tag | issue:924725711 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/3705/issue_layout |
| twitter:image | https://opengraph.githubassets.com/14ba509dc148a784880ba4d089cad412b58b7122e86980726f4fe157b689fefc/getsentry/sentry-javascript/issues/3705 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/14ba509dc148a784880ba4d089cad412b58b7122e86980726f4fe157b689fefc/getsentry/sentry-javascript/issues/3705 |
| og:image:alt | Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | janpoem |
| hostname | github.com |
| expected-hostname | github.com |
| None | 910ca0e260cfec6aff11407d8dc6a0d3a4cd381a2ec9ada56627b063426892a0 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e086f9b7e88322eb2b41885a6ad425b215737fa5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width