Skip to content

[공통] GTM Dynatrace 태그 ReferenceError 수정#1279

Open
dooohun wants to merge 1 commit into
developfrom
fix/sentry-7566813565
Open

[공통] GTM Dynatrace 태그 ReferenceError 수정#1279
dooohun wants to merge 1 commit into
developfrom
fix/sentry-7566813565

Conversation

@dooohun

@dooohun dooohun commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What is this PR? 🔍

  • 기능 :
  • issue : #

Changes 📝

  • dtrum 호출 전 존재 여부 체크 추가 (typeof dtrum !== 'undefined')

  • 관련 파일 2개 수정

  • Sentry: https://sentry.io/issues/7566813565

  • Environment: stage

  • 자동 분석 브랜치: fix/sentry-7566813565

Precaution

AI 테스트 중...

✔️ Please check if the PR fulfills these requirements

  • It's submitted to the correct branch, not the develop branch unconditionally?
  • If on a hotfix branch, ensure it targets main?
  • There are no warning message when you run yarn lint

Summary by CodeRabbit

  • 버그 수정
    • 특정 서드파티 서비스 관련 에러를 오류 모니터링에서 자동으로 필터링하여 불필요한 경고 감소
    • Dynatrace RUM 통합 안정성 개선으로 스크립트 로드 실패 시에도 안정적으로 작동

- _document.tsx: GTM보다 먼저 dtrum stub을 주입해 ReferenceError 방지
- instrumentation-client.ts: ignoreErrors에 dtrum 패턴 추가 (안전망)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

GTM에서 Dynatrace RUM 스크립트가 로드되지 않을 때 발생하는 dtrum is not defined 오류에 대응하여, _document.tsx<Head>window.dtrum 스텁 스크립트를 추가하고, Sentry 설정에 해당 오류를 무시하는 ignoreErrors 패턴을 추가합니다.

Changes

Dynatrace RUM 오류 억제

Layer / File(s) Summary
window.dtrum 스텁 삽입 및 Sentry 필터 추가
src/pages/_document.tsx, src/instrumentation-client.ts
_document.tsx<Head> 안에 window.dtrum = window.dtrum || {} 인라인 스크립트(dangerouslySetInnerHTML)를 삽입하여 전역 참조 오류를 사전 차단하고, instrumentation-client.tsSentry.initignoreErrors: [/dtrum is not defined/] 옵션을 추가하여 해당 오류가 Sentry에 집계되지 않도록 처리합니다.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 GTM Dynatrace 태그와 관련된 ReferenceError 수정이라는 주요 변경사항을 명확하고 간결하게 요약하고 있습니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sentry-7566813565

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/instrumentation-client.ts`:
- Around line 12-14: The ignoreErrors regex pattern for dtrum errors is too
narrow and doesn't account for browser-specific variations in error messages
(such as Safari variants), causing Sentry to still capture these errors. Broaden
the regex pattern in the ignoreErrors array to match multiple variations of the
dtrum error message that might occur across different browsers, ensuring that
all common variants of the same underlying error are caught and filtered
appropriately.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8e5da3af-bbb4-45ff-9e67-c854440d1a8a

📥 Commits

Reviewing files that changed from the base of the PR and between 6a0239c and be5f9fb.

📒 Files selected for processing (2)
  • src/instrumentation-client.ts
  • src/pages/_document.tsx

Comment on lines +12 to +14
// GTM이 Dynatrace RUM 태그를 실행할 때 dtrum 스크립트가 없으면 발생하는 서드파티 에러
ignoreErrors: [/dtrum is not defined/],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

ignoreErrors 패턴이 너무 좁아 동일 원인 에러가 일부 남을 수 있습니다.

현재 정규식 하나만으로는 브라우저별 메시지 변형(예: Safari 계열)을 놓쳐 Sentry 노이즈가 계속 발생할 수 있습니다.

확장 예시
-  ignoreErrors: [/dtrum is not defined/],
+  ignoreErrors: [
+    /dtrum is not defined/i,
+    /can't find variable:\s*dtrum/i,
+    /\bdtrum\b.*\bundefined\b/i,
+  ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// GTM이 Dynatrace RUM 태그를 실행할 때 dtrum 스크립트가 없으면 발생하는 서드파티 에러
ignoreErrors: [/dtrum is not defined/],
// GTM이 Dynatrace RUM 태그를 실행할 때 dtrum 스크립트가 없으면 발생하는 서드파티 에러
ignoreErrors: [
/dtrum is not defined/i,
/can't find variable:\s*dtrum/i,
/\bdtrum\b.*\bundefined\b/i,
],
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/instrumentation-client.ts` around lines 12 - 14, The ignoreErrors regex
pattern for dtrum errors is too narrow and doesn't account for browser-specific
variations in error messages (such as Safari variants), causing Sentry to still
capture these errors. Broaden the regex pattern in the ignoreErrors array to
match multiple variations of the dtrum error message that might occur across
different browsers, ensuring that all common variants of the same underlying
error are caught and filtered appropriately.

@ParkSungju01 ParkSungju01 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.

수고하셨습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants