• English日本語한국어
  • 로그인지금 시작하기

이 한글 문서는 사용자의 편의를 위해 기계 번역되었습니다.

영문본과 번역본이 일치하지 않는 경우 영문본이 우선합니다. 보다 자세한 내용은 이 페이지를 방문하시기 바랍니다.

문제 신고

Capacitor용 New Relic 소개

iOS 및 Android용 공식 New Relic Capacitor 플러그인을 사용하면 개발자가 모바일 에이전트를 Capacitor 애플리케이션 에 쉽게 포함할 수 있습니다. JavaScript로 작성된 플러그인은 New Relic의 기본 에이전트를 자동으로 포함하여 모바일 모니터링 및 성능 가시성을 제공합니다.

특징

New Relic Capacitor 플러그인은 다음을 수행합니다.

  • Capacitor를 통해 구축된 모바일 애플리케이션을 자동으로 계측
  • 자바스크립트 오류 캡처
  • 분산 추적 생성
  • 약속 거부 추적(JavaScript에서 처리되지 않은 예외)
  • 콘솔 로그로 경고 및 오류 추적
  • 상호 작용 및 해당 시퀀스 캡처
  • 사용자 세션 추적

자세한 내용 은 Github의 New Relic Capacitor 플러그인을 참조하십시오.

요구 사항

Capacitor 플러그인을 설치하기 전에 앱이 다음 요구 사항을 충족하는지 확인하십시오.

설치

bash
$
npm install @newrelic/newrelic-capacitor-plugin
$
npx cap sync

이온 커패시터 설정

main.ts (Angular 또는 Vue) 또는 index.tsx (React)에서 앱 초기화 시 New Relic 에이전트를 시작할 수 있습니다. 다음 코드를 추가하여 NewRelic을 시작합니다(적절한 애플리케이션 토큰을 넣는 것을 잊지 마십시오).

import { NewRelicCapacitorPlugin, NREnums, AgentConfiguration } from '@newrelic/newrelic-capacitor-plugin';
import { Capacitor } from '@capacitor/core';
var appToken;
if(Capacitor.getPlatform() === 'ios') {
appToken = '<IOS-APP-TOKEN>';
} else {
appToken = '<ANDROID-APP-TOKEN>';
}
if(Capacitor.getPlatform() === 'ios') {
appToken = '<IOS-APP-TOKEN>';
} else {
appToken = '<ANDROID-APP-TOKEN>';
}
let agentConfig : AgentConfiguration = {
//Android Specific
// Optional:Enable or disable collection of event data.
analyticsEventEnabled: true,
// Optional:Enable or disable crash reporting.
crashReportingEnabled: true,
// Optional:Enable or disable interaction tracing. Trace instrumentation still occurs, but no traces are harvested. This will disable default and custom interactions.
interactionTracingEnabled: true,
// Optional:Enable or disable reporting successful HTTP requests to the MobileRequest event type.
networkRequestEnabled: true,
// Optional:Enable or disable reporting network and HTTP request errors to the MobileRequestError event type.
networkErrorRequestEnabled: true,
// Optional:Enable or disable capture of HTTP response bodies for HTTP error traces, and MobileRequestError events.
httpResponseBodyCaptureEnabled: true,
// Optional:Enable or disable agent logging.
loggingEnabled: true,
// Optional:Specifies the log level. Omit this field for the default log level.
// Options include: ERROR (least verbose), WARNING, INFO, VERBOSE, AUDIT (most verbose).
logLevel: NREnums.LogLevel.INFO,
// iOS Specific
// Optional:Enable/Disable automatic instrumentation of WebViews
webViewInstrumentation: true,
// Optional:Set a specific collector address for sending data. Omit this field for default address.
// collectorAddress: "",
// Optional:Set a specific crash collector address for sending crashes. Omit this field for default address.
// crashCollectorAddress: ""
// Optional:Enable or disable sending JS console logs to New Relic.
sendConsoleEvents: true
}
NewRelicCapacitorPlugin.start({appKey:appToken, agentConfiguration:agentConfig})

AppToken은 플랫폼에 따라 다릅니다. Android 및 iOS 앱에 대해 별도의 토큰을 생성해야 합니다.

안드로이드 설정

  1. New Relic 네이티브 Android 에이전트를 설치합니다( 지침은 여기 참조 ).

  2. 업데이트 build.gradle :

    buildscript {
    ...
    repositories {
    ...
    mavenCentral()
    }
    dependencies {
    ...
    classpath "com.newrelic.agent.android:agent-gradle-plugin:6.11.1"
    }
    }
  3. 업데이트 app/build.gradle :

    apply plugin: "com.android.application"
    apply plugin: 'newrelic' // <-- add this
  4. 다음 줄을 AndroidManifest.xml 에 추가하여 앱이 인터넷 및 ACCESS_NETWORK_STATE 권한을 요청하는지 확인하세요.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

패키지를 자동으로 연결하려면 프로젝트를 다시 빌드하십시오.

bash
$
# Android apps
$
ionic capacitor run android
$
$
# iOS apps
$
ionic capacitor run ios

API 호출

Capacitor 플러그인은 iOS 및 Android SDK 에이전트와 동일한 API 호출을 사용합니다. iOS SDK 문서 또는 Android SDK 문서를참조하십시오.

커패시터 관련 오류의 경우 다음과 같이 NewRelicCapacitorPlugin.recordError 를 호출할 수 있습니다.

try {
throw new Error('Example error message');
} catch (error: any) {
NewRelicCapacitorPlugin.recordError({
name: error.name,
message: error.message,
stack: error.stack,
isFatal: false,
});
}

자바스크립트 오류

커패시터 플러그인 v1.2.0 이상:

자바스크립트 오류는 Handled Exceptions 탭에서 또는 MobileHandledException 이벤트로 볼 수 있습니다. 이 쿼리를 사용하여 NRQL 탐색기에서 이러한 오류를 볼 수도 있습니다.

다음 쿼리를 실행하여 이러한 오류를 찾을 수도 있습니다.

SELECT * FROM `MobileHandledException` SINCE 24 hours ago

커패시터 플러그인 v1.1.1 이하:

Capacitor 플러그인은 JavaScript 오류에 대한 사용자 정의 이벤트를 생성하고 이를 New Relic에 보고합니다. UI에서 사용자 지정 대시보드를 사용하여 이러한 JavaScript 오류 이벤트를 추적할 수 있습니다.

사용자 정의 대시보드를 생성하려면:

  1. one.newrelic.com 으로 이동합니다.

  2. 쿼리 빌더 를 클릭합니다.

  3. 다음 쿼리를 실행합니다.

    SELECT * FROM `JS Errors`
  4. Add to dashboard [대시보드에 추가를]클릭합니다.

one.newrelic.com > Query builder : Query builder 를 사용하여 Capacitor 앱에서 JavaScript 오류를 추적하기 위한 맞춤형 대시보드를 생성합니다.

대시보드를 시작하는 데 도움이 필요한 경우 대시보드 소개 를참조하십시오.

Copyright © 2023 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.