Apps Kit SDK logoApps Kit SDK
文档 · iOS 集成

6. AKS 事件与日志

6.1 日志记录与事件上报

swift
// Free-form debug log
AKSLogManager.shared.log(type: AppsKitSDKLogType.info, message: "Sync finished")

// Named log with a name + type + message
AKSLogManager.shared.log(name: "MyTag", type: AppsKitSDKLogType.warning, message: "Cache stale")

// AKS event tied to a screen context
AKSLogManager.shared.log(context: PlatformContext(delegate: nil), eventName: "e_home_btn_save")

// Same thing, built from screenId/eventType/name instead of a hand-rolled string
AKSLogManager.shared.log(
    context: PlatformContext(delegate: viewController),
    eventName: AKSEventCreator.shared.createEvent(screenId: screenId, eventType: AppsKitSDKEventType.screen, name: name)
)

// Fire a named Firebase event with parameters, from anywhere
AKSLogManager.shared.sendEvent(eventName: "custom_event_name", params: ["key": "value"])

// Purchase / subscription events
AKSLogManager.shared.sendPurchaseEvent(
    context: PlatformContext(delegate: nil),
    purchaseType: PurchaseType.subscription, // or .inApp
    productId: "premium_monthly",
    price: 4.99,
    currency: "USD",
    receiptId: receipt,
    uniqueTransactionId: transactionId,
    startDate: startDateIso,
    endDate: endDateIso
)

// Ad impression / mediation revenue logging
AKSLogManager.shared.logImpression(
    adUnit: adUnitId, adNetwork: "admob", adFormat: "interstitial",
    revenue: revenueString, currency: "USD",
    mediationABTestName: nil, mediationABTestVariant: nil
)

// SDK build/version banner
AKSLogManager.shared.logAarVersion()

AppsKitSDKLogType:.info、.error、.verbose、.warning、.description_。注意,description_ 末尾的下划线是刻意保留的,并非拼写错误:它用于避免与 NSObject/CustomStringConvertible 自身的 description 属性发生冲突。