Skip to content

feat(powerbi): report errors to Sentry#846

Merged
rusko124 merged 3 commits into
masterfrom
feat/powerbi-sentry
Jun 19, 2026
Merged

feat(powerbi): report errors to Sentry#846
rusko124 merged 3 commits into
masterfrom
feat/powerbi-sentry

Conversation

@rusko124

@rusko124 rusko124 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

PR Type

Enhancement, Tests


Description

  • Add Power BI Sentry reporting

  • Report token and embed failures

  • Configure optional global Sentry DSN

  • Cover reporting paths in tests


Diagram Walkthrough

flowchart LR
  config["Sentry DSN setting"]
  setup["setupSentry initialization"]
  token["Token retrieval and refresh"]
  embed["Power BI embed errors"]
  sentry["Sentry error reporting"]
  ui["Existing error display"]

  config -- "enables" --> setup
  setup -- "initializes" --> sentry
  token -- "reports failures" --> sentry
  embed -- "reports events" --> sentry
  token -- "still renders" --> ui
  embed -- "still renders" --> ui
Loading

File Walkthrough

Relevant files
Enhancement
3 files
globals.d.ts
Extend Screenly settings module types                                       
+9/-14   
main.ts
Initialize Sentry during app startup                                         
+3/-0     
services.ts
Report Power BI failures to Sentry                                             
+7/-1     
Tests
1 files
services.test.ts
Add Sentry reporting unit coverage                                             
+42/-1   
Dependencies
1 files
package.json
Promote edge-apps dependency version                                         
+3/-3     
Configuration changes
2 files
screenly.yml
Add optional Sentry DSN setting                                                   
+11/-0   
screenly_qc.yml
Add QC Sentry DSN setting                                                               
+11/-0   

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 2dc69ac)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 Security concerns

Sensitive information exposure:
The PR sends the full screenly.settings.embed_url to Sentry context. Power BI embed URLs can include query parameters or identifiers that may be sensitive in some deployments, so this should be sanitized or reduced before reporting externally.

⚡ Recommended focus areas for review

Data Exposure

The full Power BI embed_url is attached to Sentry context. If a configured embed URL contains sensitive query parameters such as filters, customer identifiers, or other tenant-specific values, those values will be sent to the configured Sentry project with reported errors. Consider sanitizing the URL before adding it to Sentry context.

setupSentry('powerbi', { powerbi: { embed_url: screenly.settings.embed_url } })

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Sentry-based error reporting to the PowerBI edge app so embed/token failures and PowerBI runtime errors are captured centrally.

Changes:

  • Initialize Sentry in the app entrypoint and attach basic app context.
  • Report token refresh failures (deduped to the first failure in a streak), embed-token fetch failures, and PowerBI embed error events to Sentry.
  • Update unit tests to verify Sentry reporting behavior and adjust Screenly settings typing/deps.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
edge-apps/powerbi/src/services.ts Reports token-refresh, embed-token, and PowerBI embed errors via reportError.
edge-apps/powerbi/src/services.test.ts Mocks Sentry utilities and adds assertions for new reporting behavior.
edge-apps/powerbi/src/main.ts Calls setupSentry('powerbi', …) during startup.
edge-apps/powerbi/src/globals.d.ts Switches to module augmentation of @screenly/edge-apps settings typing.
edge-apps/powerbi/screenly.yml Adds a sentry_dsn setting to configure Sentry reporting.
edge-apps/powerbi/screenly_qc.yml Adds the same sentry_dsn setting for QC manifest.
edge-apps/powerbi/package.json Moves @screenly/edge-apps into runtime dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread edge-apps/powerbi/screenly.yml
Comment thread edge-apps/powerbi/screenly_qc.yml
@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 2dc69ac
Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Security
Redact telemetry URL

Avoid sending the full embed_url to Sentry because query strings or fragments can
contain customer-specific filters, identifiers, or other sensitive values. Redact
those parts before adding the URL to telemetry context.

edge-apps/powerbi/src/main.ts [6]

-setupSentry('powerbi', { powerbi: { embed_url: screenly.settings.embed_url } })
+const sentryEmbedUrl = screenly.settings.embed_url.replace(/[?#].*$/, '')
+setupSentry('powerbi', { powerbi: { embed_url: sentryEmbedUrl } })
Suggestion importance[1-10]: 8

__

Why: This is a valid security/privacy improvement because screenly.settings.embed_url may include query strings or fragments with customer-specific data that should not be sent to Sentry. The proposed change directly modifies the added setupSentry context line and preserves useful non-sensitive URL context.

Medium
Possible issue
Isolate telemetry failures

Make Sentry reporting best-effort so a failure inside reportError cannot prevent
retry scheduling, showError, or rethrowing the original token error. Wrap the
telemetry call and swallow synchronous throws and async rejections.

edge-apps/powerbi/src/services.ts [14-123]

 import { reportError } from '@screenly/edge-apps/utils'
 
+function reportErrorSafely(
+  error: Parameters<typeof reportError>[0],
+  context: Parameters<typeof reportError>[1],
+) {
+  try {
+    void Promise.resolve(reportError(error, context)).catch(() => {})
+  } catch {
+    // Keep telemetry failures from interrupting recovery paths.
+  }
+}
+
 ...
-        reportError(error, { source: 'token-refresh' })
+        reportErrorSafely(error, { source: 'token-refresh' })
 ...
-    reportError(error, { source: 'embed-token' })
+    reportErrorSafely(error, { source: 'embed-token' })
 ...
-    reportError(event.detail, { source: 'powerbi-embed' })
+    reportErrorSafely(event.detail, { source: 'powerbi-embed' })
Suggestion importance[1-10]: 7

__

Why: This is a valid robustness improvement: if reportError throws or rejects, it could interrupt retry scheduling in initTokenRefreshLoop or prevent showError and rethrow behavior in initializePowerBI. The suggestion spans multiple reportError call sites, and the proposed helper accurately addresses those added telemetry calls.

Medium

Previous suggestions

Suggestions up to commit d9dbac0
CategorySuggestion                                                                                                                                    Impact
Security
Sanitize reported URL

Avoid sending the full embed_url to Sentry because query strings or fragments can
contain sensitive tenant, filter, or token-like data. Report only the non-sensitive
URL components needed for debugging.

edge-apps/powerbi/src/main.ts [6]

-setupSentry('powerbi', { powerbi: { embed_url: screenly.settings.embed_url } })
+const embedUrl = new URL(screenly.settings.embed_url)
 
+setupSentry('powerbi', {
+  powerbi: { embed_url: `${embedUrl.origin}${embedUrl.pathname}` },
+})
+
Suggestion importance[1-10]: 8

__

Why: This is a relevant security/privacy improvement because screenly.settings.embed_url may include query parameters or fragments that should not be sent to Sentry. The proposed change correctly preserves useful non-sensitive URL context via origin and pathname, assuming embed_url is a valid absolute URL.

Medium
Possible issue
Isolate telemetry failures

Make Sentry reporting best-effort so a failure inside reportError cannot break token
refresh scheduling, mask the original embed-token error, or prevent showError from
rendering. Wrap both synchronous throws and rejected promises from reportError.

edge-apps/powerbi/src/services.ts [14-123]

 import { reportError } from '@screenly/edge-apps/utils'
+
+function safeReportError(error: unknown, context: Record<string, unknown>) {
+  try {
+    void Promise.resolve(reportError(error, context)).catch((reportingError) => {
+      console.warn('Failed to report error', reportingError)
+    })
+  } catch (reportingError) {
+    console.warn('Failed to report error', reportingError)
+  }
+}
 ...
-    reportError(error, { source: 'token-refresh' })
+    safeReportError(error, { source: 'token-refresh' })
 ...
-    reportError(error, { source: 'embed-token' })
+    safeReportError(error, { source: 'embed-token' })
 ...
-    reportError(event.detail, { source: 'powerbi-embed' })
+    safeReportError(event.detail, { source: 'powerbi-embed' })
Suggestion importance[1-10]: 7

__

Why: This is a valid robustness improvement: if reportError throws or rejects, it could currently interrupt token refresh scheduling, mask the original embed-token failure, or prevent showError from running. The suggested safeReportError wrapper is contextually accurate, though it is defensive error-handling rather than fixing a confirmed bug.

Medium

@rusko124 rusko124 marked this pull request as ready for review June 19, 2026 14:50
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 2dc69ac

@rusko124 rusko124 merged commit 5b56162 into master Jun 19, 2026
5 checks passed
@nicomiguelino nicomiguelino deleted the feat/powerbi-sentry branch June 19, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants