리액트 네이티브 SDK 메서드 레퍼런스
이 포괄적인 참조 문서에서는 모바일 앱 트래킹을 위해 Singular SDK에서 사용 가능한 모든 메서드를 설명합니다. SDK는 초기화, 사용자 식별, 이벤트 추적, 구매 보고, 어트리뷰션, 데이터 개인정보 보호 규정 준수 및 설정을 위한 기능을 제공합니다. 각 메서드에는 개발자가 Singular의 SDK 기능을 애플리케이션에 연동하는 데 도움이 되는 설명, 서명, 실제 사용 예시가 함께 제공됩니다.
adRevenue
Singular.adRevenue Method
자세한 광고 데이터 정보로 광고 구매 이벤트를 추적합니다.
시그니처
static adRevenue(adData: SingularAdData): void
사용 예시
// Create ad data object
const adData = new SingularAdData()
.withAdPlatform("AdMob")
.withAdType("Rewarded")
.withAdNetworkName("Google")
.withCurrency("USD")
.withRevenue(0.05);
// Track ad revenue event
Singular.adRevenue(adData);
clearGlobalProperties
Singular.clearGlobalProperties Method
이전에 설정한 모든 글로벌 속성을 제거합니다.
시그니처
static clearGlobalProperties(): void
사용 예시
// Clear all global properties, for example when a user logs out
Singular.clearGlobalProperties();
createReferrerShortLink
Singular.createReferrerShortLink Method
공유 및 어트리뷰션에 사용할 수 있는 리퍼러 정보가 포함된 짧은 링크를 생성합니다.
서명
static createReferrerShortLink(baseLink: string, referrerName: string, referrerId: string, passthroughParams: SerializableObject, completionHandler: (result: string, error: string) => void): void
사용 예시
Singular.createReferrerShortLink(
"https://sample.sng.link/B4tbm/v8fp?_dl=https%3A%2F%2Fabc.com",
"John Doe", // Referrer Name
"aq239897", // Referrer ID
{ "channel": "sms", "campaign": "summer_promo" }, // Passthrough parameters
(shortLinkURL, error) => { if (error) {
console.error("Error creating short link:", error); return; }
console.log("Generated short link:", shortLinkURL);
// Share the link with users
}
);
customRevenue
Singular.customRevenue Method
지정된 이벤트 이름, 통화 및 금액으로 사용자 지정 구매 이벤트를 추적합니다.
- 사용자 지정 구매 이벤트 이름은 32개의 ASCII 문자로 제한됩니다. ASCII가 아닌 문자의 경우 UTF-8로 변환하면 32바이트로 제한됩니다.
-
통화 코드는 모두 대문자이어야 하며 세 글자로 구성된 ISO 4217 통화 코드를 준수해야 합니다.
서명
static customRevenue(eventName: string, currency: string, amount: number): void
사용 예시
// Track a custom revenue event
Singular.customRevenue("premium_subscription", "USD", 9.99);
customRevenueWithArgs
Singular.customRevenueWithArgs Method
지정된 이벤트 이름, 통화, 금액 및 추가 사용자 지정 속성을 사용하여 사용자 지정 구매 이벤트를 추적합니다.
- 사용자 지정 구매 이벤트 이름은 32개의 ASCII 문자로 제한됩니다. ASCII가 아닌 문자의 경우 UTF-8로 변환하면 32바이트로 제한됩니다.
- 이벤트 속성 이름과 속성 값은 500자로 제한됩니다.
-
통화 코드는 모두 대문자이어야 하며 3글자로 구성된 ISO 4217 통화 코드를 준수해야 합니다.
서명
static customRevenueWithArgs(eventName: string, currency: string, amount: number, args: SerializableObject): void
사용 예시
// Track a custom revenue event with additional parameters
Singular.customRevenueWithArgs(
"in_app_purchase",
"USD",
5.99,
{
"product_id": "com.app.gems_pack_small",
"quantity": 1,
"transaction_id": "T12345678",
"receipt_id": "R98765432"
}
);
event
Singular.event Method
Singular의 SDK로 간단한 사용자 지정 이벤트를 추적합니다.
- 이벤트 이름은 32개의 ASCII 문자로 제한됩니다. ASCII가 아닌 문자의 경우 UTF-8로 변환하면 32바이트로 제한됩니다.
서명
static event(eventName: string): void
사용 예시
// Track a simple event
Singular.event("level_completed");
eventWithArgs
Singular.eventWithArgs Method
Singular의 SDK로 추가 속성이 있는 사용자 지정 이벤트를 추적합니다.
- 이벤트 이름은 32개의 ASCII 문자로 제한됩니다. ASCII가 아닌 문자의 경우, UTF-8로 변환하면 32바이트로 제한됩니다.
- 이벤트 속성 이름과 속성 값은 500자로 제한됩니다.
서명
static eventWithArgs(eventName: string, args: SerializableObject): void
사용 예
// Track an event with additional parameters
Singular.eventWithArgs(
"level_completed",
{
"level_number": 5,
"difficulty": "hard",
"time_spent": 120,
"score": 9500
}
);
getLimitDataSharing
Singular.getLimitDataSharing Method
사용자의 현재 데이터 공유 제한 상태를 가져옵니다.
서명
static getLimitDataSharing(): boolean
사용 예
// Check if data sharing is limited
const isLimited = Singular.getLimitDataSharing();
console.log("Data sharing limitation status:", isLimited);
// Use the status to adjust app behavior
if (isLimited) {
// Adjust functionality for users with limited data sharing
}
getGlobalProperties
Singular.getGlobalProperties Method
현재 설정된 모든 전역 속성을 가져옵니다.
서명
static getGlobalProperties(): Map<string, string>
사용 예시
// Get all global properties
const properties = Singular.getGlobalProperties();
// Iterate through properties
properties.forEach((value, key) => {
console.log(${key}: ${value});
});
inAppPurchase
Singular.inAppPurchase Method
이 방법을 사용하려면 앱에서 트랜잭션을 관리하기 위해 React Native의 인앱 구매 패키지를 사용해야 합니다.
구매 세부 정보가 포함된 인앱 구매 이벤트를 추적합니다.
- 이벤트 이름은 32개의 ASCII 문자로 제한됩니다. ASCII가 아닌 문자의 경우 UTF-8로 변환하면 32바이트로 제한됩니다.
서명
static inAppPurchase(eventName: string, purchase: SingularPurchase): void
사용 예시
// Add the Singular Purchase Class imports
import {
Singular,
SingularConfig,
Events,
SingularPurchase,
SingularIOSPurchase,
SingularAndroidPurchase } from 'singular-react-native';
// Create purchase object
let singularPurchase = null;
if (Platform.OS === 'ios') {
singularPurchase = new SingularIOSPurchase(
product.revenue,
product.currency,
purchase.productId,
purchase.transactionId,
purchase.transactionReceipt,
);
} else if (Platform.OS === 'android'){
singularPurchase = new SingularAndroidPurchase(
product.revenue,
product.currency,
purchase.transactionReceipt,
purchase.signatureAndroid,
);
}
// Track in-app purchase
Singular.inAppPurchase('iap_purchase', singularPurchase);
inAppPurchaseWithArgs
Singular.inAppPurchaseWithArgs Method
이 방법을 사용하려면 앱에서 트랜잭션을 관리하기 위해 React Native의 인앱 구매 패키지를 사용해야 합니다.
구매 세부 정보 및 추가 사용자 정의 속성으로 인앱 구매 이벤트를 추적합니다.
- 이벤트 이름은 32개의 ASCII 문자로 제한됩니다. ASCII가 아닌 문자의 경우 UTF-8로 변환하면 32바이트로 제한됩니다.
- 이벤트 속성 이름과 속성 값은 500자로 제한됩니다.
서명
static inAppPurchaseWithArgs(eventName: string, purchase: SingularPurchase, args: SerializableObject): void
사용 예시
// Add the Singular Purchase Class imports
import {
Singular,
SingularConfig,
Events,
SingularPurchase,
SingularIOSPurchase,
SingularAndroidPurchase } from 'singular-react-native';
// Create purchase object
let singularPurchase = null;
if (Platform.OS === 'ios') {
singularPurchase = new SingularIOSPurchase(
product.revenue,
product.currency,
purchase.productId,
purchase.transactionId,
purchase.transactionReceipt,
);
} else if (Platform.OS === 'android'){
singularPurchase = new SingularAndroidPurchase(
product.revenue,
product.currency,
purchase.transactionReceipt,
purchase.signatureAndroid,
);
}
// Track in-app purchase with additional attributes
Singular.inAppPurchaseWithArgs(
"iap_purchase",
singularPurchase,
{
"is_first_purchase": true,
"subscription_type": "yearly",
"discount_applied": "holiday_special",
"previous_subscription": "monthly"
}
);
init
Singular.init Method
제공된 구성으로 Singular SDK를 초기화합니다. config 파라미터는 SingularConfig 객체이며, 생성자( new SingularConfig(apikey: string, secret: string))를 사용하여 유효한 SDK Key (apiKey) 및 Secret (secret) 로 인스턴스화해야 합니다.
서명
static init(config: SingularConfig): void
사용 예시
// Create configuration
const config = new SingularConfig('SDK KEY', 'SDK SECRET')
.withCustomUserId("user123")
.withSessionTimeoutInSec(60)
.withLimitDataSharing(false)
.withSingularLink((params) => {
// Handle deep link parameters
console.log("Deep link received:", params);
});
// Initialize Singular SDK
Singular.init(config);
isAllTrackingStopped
Singular.isAllTrackingStopped Method
SDK에서 모든 추적이 중지되었는지 확인합니다.
서명
static isAllTrackingStopped(): boolean
사용 예시
// Check if tracking is currently stopped
const isTrackingStopped = Singular.isAllTrackingStopped();
// Adjust UI based on tracking status
if (isTrackingStopped) {
console.log("All tracking is currently stopped");
// Update UI to reflect tracking status
} else {
console.log("Tracking is active");
}
limitDataSharing
Singular.limitDataSharing Method
현재 사용자의 데이터 공유를 제한하며, 일반적으로 CCPA 준수를 위해 사용됩니다.
서명
static limitDataSharing(shouldLimitDataSharing: boolean): void
사용 예
// To limit data sharing (e.g., when user opts out)
Singular.limitDataSharing(true);
// To enable full data sharing (e.g., when user opts in)
Singular.limitDataSharing(false);
resumeAllTracking
Singular.resumeAllTracking Method
중지된 모든 추적 활동을 재개합니다.
서명
static resumeAllTracking(): void
사용 예시
// Resume tracking when user opts back in
Singular.resumeAllTracking();
console.log("Tracking has been resumed");
// Update UI to reflect that tracking is now active
revenue
Singular.revenue Method
지정된 통화와 금액으로 간단한 구매 이벤트를 추적합니다.
-
통화 코드는 모두 대문자이어야 하며 세 글자로 구성된 ISO 4217 통화 코드를 준수해야 합니다.
서명
static revenue(currency: string, amount: number): void
사용 예시
// Track a simple revenue event
Singular.revenue("USD", 19.99);
revenueWithArgs
Singular.revenueWithArgs Method
지정된 통화, 금액 및 추가 사용자 지정 속성으로 구매 이벤트를 추적합니다.
- 이벤트 속성 이름과 속성 값은 500자로 제한됩니다.
-
통화 코드는 모두 대문자이어야 하며 3글자로 구성된 ISO 4217 통화 코드를 준수해야 합니다.
서명
static revenueWithArgs(currency: string, amount: number, args: SerializableObject): void
사용 예
// Track a revenue event with additional parameters
Singular.revenueWithArgs(
"EUR",
9.99,
{
"subscription_type": "monthly",
"is_promotional": false,
"user_tier": "premium",
"payment_method": "credit_card"
}
);
setCustomUserId
Singular.setCustomUserId Method
현재 사용자에 대한 사용자 지정 사용자 ID를 Singular의 SDK와 함께 사용할 수 있도록 설정합니다.
서명
static setCustomUserId(customUserId: string): void
사용 예시
// Set the custom user ID after user logs in
Singular.setCustomUserId("user_123456");
setDeviceCustomUserId
Singular.setDeviceCustomUserId Method
엔터프라이즈 기능: 크로스 플랫폼 추적을 위해 사용자 지정 사용자 ID를 현재 디바이스와 연결합니다.
서명
static setDeviceCustomUserId(customUserId: string): void
사용 예시
// Set a device-level custom user ID
Singular.setDeviceCustomUserId("device_user_987654");
setGlobalProperty
Singular.setGlobalProperty Method
이후의 모든 이벤트와 함께 전송될 글로벌 속성을 설정합니다.
서명
static setGlobalProperty(key: string, value: string, overrideExisting: boolean): boolean
사용 예
// Set a global property that will be included with all events
const wasSet = Singular.setGlobalProperty("user_tier", "premium", true);
// Set another global property without overriding if it exists
Singular.setGlobalProperty("app_version", "2.1.3", false);
if (wasSet) {
console.log("Global property was set successfully");
}
setUninstallToken
Singular.setUninstallToken Method
푸시 알림을 통한 제거 추적을 위한 디바이스 토큰을 설정합니다.
서명
static setUninstallToken(token: string): void
사용 예시
// Set the device token for uninstall tracking
// This is typically obtained from the platform's push notification service
const deviceToken = "a1b2c3d4e5f6g7h8i9j0..."; // FCM or APNS token
Singular.setUninstallToken(deviceToken);
skanGetConversionValue
Singular.skanGetConversionValue Method
현재 SKAdNetwork 전환 값을 가져옵니다(iOS만 해당).
서명
static skanGetConversionValue(): number | null
사용 예시
// Get the current SKAdNetwork conversion value
const conversionValue = Singular.skanGetConversionValue();
if (conversionValue !== null) {
console.log("Current conversion value:", conversionValue);
} else {
console.log("Conversion value not available");
}
skanRegisterAppForAdNetworkAttribution
Singular.skanRegisterAppForAdNetworkAttribution Method
앱을 SKAdNetwork 어트리뷰션에 등록합니다(iOS만 해당).
서명
static skanRegisterAppForAdNetworkAttribution(): void
사용 예시
// Register app for SKAdNetwork attribution
// This is typically called early in the app lifecycle
Singular.skanRegisterAppForAdNetworkAttribution();
skanUpdateConversionValue
Singular.skanUpdateConversionValue Method
SKAdNetwork 전환 값을 업데이트합니다(iOS만 해당).
서명
static skanUpdateConversionValue(conversionValue: number): boolean
사용 예시
// Update the SKAdNetwork conversion value
// Value must be between 0-63
const wasUpdated = Singular.skanUpdateConversionValue(12);
if (wasUpdated) {
console.log("Conversion value was updated successfully");
} else {
console.log("Failed to update conversion value");
}
skanUpdateConversionValues
Singular.skanUpdateConversionValues Method
미세, 거친, 잠금 창을 포함한 SKAdNetwork 4.0 변환 값을 업데이트합니다(iOS 16.1 이상만 해당).
서명
static skanUpdateConversionValues(conversionValue: number, coarse: number, lock: boolean): void
사용 예시
// Update SKAdNetwork 4.0 conversion values
// Fine value: 0-63
// Coarse value: 0-2 (Low, Medium, High)
// Lock: whether to lock the postback window
Singular.skanUpdateConversionValues(45, 2, false);
// Example with named constants for clarity
const FINE_VALUE = 45;
const COARSE_VALUE_HIGH = 2;
const LOCK_WINDOW = false;
Singular.skanUpdateConversionValues(FINE_VALUE, COARSE_VALUE_HIGH, LOCK_WINDOW);
stopAllTracking
Singular.stopAllTracking Method
SDK의 모든 추적 활동을 중지합니다.
서명
static stopAllTracking(): void
사용 예시
// Stop all tracking when user opts out
Singular.stopAllTracking();
console.log("All tracking has been stopped");
// Update UI to reflect that tracking is now disabled
trackingOptIn
Singular.trackingOptIn Method
분석 및 어트리뷰션 목적으로 사용자를 추적하도록 설정합니다.
서명
static trackingOptIn(): void
사용 예시
// Call when user has consented to tracking
Singular.trackingOptIn();
console.log("User has opted into tracking");
trackingUnder13
Singular.trackingUnder13 Method
사용자를 13세 미만으로 표시하여 COPPA에 따라 데이터 수집을 제한합니다.
서명
static trackingUnder13(): void
사용 예
// If user is determined to be under 13 years old
Singular.trackingUnder13();
console.log("User marked as under 13, GDPR_UNDER_13 flag applied");
unsetCustomUserId
Singular.unsetCustomUserId Method
이전에 설정한 사용자 지정 사용자 ID를 Singular 추적에서 제거합니다.
서명
static unsetCustomUserId(): void
사용 예
// Remove the custom user ID when user logs out
Singular.unsetCustomUserId();
console.log("Custom user ID has been removed");
unsetGlobalProperty
Singular.unsetGlobalProperty Method
이전에 설정된 전역 속성을 제거합니다.
서명
static unsetGlobalProperty(key: string): void
사용 예
// Remove a global property that is no longer needed
Singular.unsetGlobalProperty("temporary_campaign_id");
console.log("Global property has been removed");