### CocoaPods 集成 Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 在 Podfile 中添加依赖,然后执行 pod install 来集成 SolarEngineSDK。 ```ruby # Podfile platform :ios, '10.0' target 'YourApp' do pod 'SolarEngineSDKiOSInter' end ``` ```bash pod install ``` -------------------------------- ### Duration Event Tracking Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Records the duration of an event by pairing start and finish calls, automatically calculating and reporting the time spent. ```APIDOC ## Duration Event Tracking ### Description Records the duration of an event by using a pair of `eventStart:` and `eventFinish:properties:` calls. The SDK automatically calculates the time elapsed between these calls and reports it with the event. ### Methods - `eventStart:` - `eventFinish:properties:` ### Parameters - **eventStart:** - **event** (NSString) - Required - The name of the event to start timing. - **eventFinish:properties:** - **event** (NSString) - Required - The name of the event to finish timing. Must match the event name passed to `eventStart:`. - **properties** (NSDictionary) - Optional - A dictionary of key-value pairs to associate with the finished event. The SDK automatically adds the `duration` field. ### Request Example ```objc SolarEngineSDK *sdk = [SolarEngineSDK sharedInstance]; // Start timing when the user enters a level [sdk eventStart:@"level_play"]; // ... user plays the game ... // Finish timing and report the event when the user exits the level // The SDK automatically includes the 'duration' field [sdk eventFinish:@"level_play" properties:@{ @"level_id" : @(3), @"result" : @"win", @"score" : @(4500) }]; ``` ``` -------------------------------- ### SDK 初始化 Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 在 AppDelegate 的 application:didFinishLaunchingWithOptions: 中调用 startWithAppKey:userId:config: 方法初始化 SDK。必须在所有其他 SDK 方法之前调用。 ```objective-c #import - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // 构建配置对象 SEConfig *config = [[SEConfig alloc] init]; config.logEnabled = YES; // 开启本地调试日志(上线前关闭) config.isDebugModel = YES; // 开启 Debug 模式,可在后台实时查看数据(上线前关闭!) config.isGDPRArea = NO; // 是否为 GDPR 区域 config.autoTrackEventType = SEAutoTrackEventTypeAppClick | SEAutoTrackEventTypeAppViewScreen; // 开启自动追踪 // 远程参数配置(可选) SERemoteConfig *remoteConfig = [[SERemoteConfig alloc] init]; remoteConfig.enable = YES; remoteConfig.mergeType = SERCMergeTypeDefault; config.remoteConfig = remoteConfig; // 初始化 SDK [[SolarEngineSDK sharedInstance] startWithAppKey:@"your_app_key" userId:@"your_user_id" config:config]; return YES; } ``` -------------------------------- ### 记录时长事件 Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 配对使用 eventStart: 和 eventFinish:properties: 来记录事件的持续时长。SDK 会自动计算并上报两次调用之间的时长。 ```objective-c SolarEngineSDK *sdk = [SolarEngineSDK sharedInstance]; // 用户进入关卡时开始计时 [sdk eventStart:@"level_play"]; // ... 用户游戏中 ... // 用户退出关卡时结束并上报(SDK 自动附加 duration 字段) [sdk eventFinish:@"level_play" properties:@{ @"level_id" : @(3), @"result" : @"win", @"score" : @(4500) }]; ``` -------------------------------- ### SDK Initialization Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Initializes the SolarEngineSDK with your application key, user ID, and configuration settings. This must be called before any other SDK methods. ```APIDOC ## SDK Initialization ### Description Starts and initializes the SDK with the provided app key, user ID, and configuration object. This method must be called before any other SDK methods. ### Method `startWithAppKey:userId:config:` ### Parameters - **appKey** (NSString) - Required - Your unique application key. - **userId** (NSString) - Required - The unique identifier for the current user. - **config** (SEConfig) - Required - An `SEConfig` object containing various SDK settings. #### SEConfig Properties - **logEnabled** (BOOL) - Optional - Enables local debugging logs. Set to NO for production. - **isDebugModel** (BOOL) - Optional - Enables Debug mode for real-time data viewing in the backend. Set to NO for production. - **isGDPRArea** (BOOL) - Optional - Indicates if the user is in a GDPR-compliant region. Defaults to NO. - **autoTrackEventType** (SEAutoTrackEventType) - Optional - Specifies which automatic tracking events to enable (e.g., `SEAutoTrackEventTypeAppClick`, `SEAutoTrackEventTypeAppViewScreen`). - **remoteConfig** (SERemoteConfig) - Optional - Configuration for remote parameters. ### Request Example ```objc #import - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { SEConfig *config = [[SEConfig alloc] init]; config.logEnabled = YES; config.isDebugModel = YES; config.isGDPRArea = NO; config.autoTrackEventType = SEAutoTrackEventTypeAppClick | SEAutoTrackEventTypeAppViewScreen; SERemoteConfig *remoteConfig = [[SERemoteConfig alloc] init]; remoteConfig.enable = YES; remoteConfig.mergeType = SERCMergeTypeDefault; config.remoteConfig = remoteConfig; [[SolarEngineSDK sharedInstance] startWithAppKey:@"your_app_key" userId:@"your_user_id" config:config]; return YES; } ``` ``` -------------------------------- ### Set Attribution Callback and Track Attribution Events Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Set up a callback to receive server-side attribution results before initializing the SDK. Then, track attribution events using SEAppAttrEventAttribute. You can also actively retrieve cached attribution data. ```Objective-C // 1. 初始化前设置归因回调 [[SolarEngineSDK sharedInstance] setAttributionCallback:^(int code, NSDictionary * _Nullable attributionData) { if (code == 0) { NSLog(@"归因成功,数据: %@", attributionData); // 处理归因数据,例如记录到服务端 } else { NSLog(@"归因失败,错误码: %d", code); // code 1001: 网络错误 1002: 请求超限 1003: 请求过于频繁 1004: 超过15天 } }]; // 2. 上报归因事件 SEAppAttrEventAttribute *attrEvent = [[SEAppAttrEventAttribute alloc] init]; attrEvent.adNetwork = @"toutiao"; attrEvent.adAccountID = @"account_001"; attrEvent.adAccountName = @"测试投放账户"; attrEvent.adCampaignID = @"campaign_001"; attrEvent.adCampaignName = @"春节促销计划"; attrEvent.adOfferID = @"offer_001"; attrEvent.adCreativeID = @"creative_001"; attrEvent.adCreativeName = @"素材A-竖版"; attrEvent.attributionPlatform = @"appsflyer"; [[SolarEngineSDK sharedInstance] trackAppAttrWithAttributes:attrEvent]; // 3. 主动获取归因结果(如有) NSDictionary *data = [[SolarEngineSDK sharedInstance] getAttributionData]; if (data) { NSLog(@"已缓存归因数据: %@", data); } ``` -------------------------------- ### 上报自定义事件 Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 使用 track:withProperties: 方法上报自定义埋点事件。事件名支持大小写中英文、数字、下划线,长度不超过 40 个字符。 ```objective-c // 上报自定义"关卡完成"事件 [[SolarEngineSDK sharedInstance] track:@"level_complete" withProperties:@{ @"level_id" : @(5), @"score" : @(9800), @"time_spent" : @(120), // 单位:秒 @"is_perfect" : @(YES), @"character" : @"warrior" }]; // 上报"商品详情页浏览"事件 [[SolarEngineSDK sharedInstance] track:@"product_view" withProperties:@{ @"product_id" : @"SKU_001", @"product_name" : @"无线耳机", @"category" : @"电子产品", @"price" : @(299.0) }]; ``` -------------------------------- ### GDPR 合规设置 Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 使用 setGDPRArea: 方法动态设置 GDPR 区域限制。开启后 SDK 不会采集 IDFA 和 IDFV。 ```objective-c // 用户同意隐私协议后再初始化,或动态开关 GDPR 限制 BOOL isEUUser = YES; // 根据业务逻辑判断是否为欧盟用户 [[SolarEngineSDK sharedInstance] setGDPRArea:isEUUser]; ``` -------------------------------- ### 账户 ID 管理(登录/登出) Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 用户登录时调用 loginWithAccountID: 绑定账户 ID,退出时调用 logout 解除绑定。accountID 用于获取当前登录的账户 ID。 ```objective-c SolarEngineSDK *sdk = [SolarEngineSDK sharedInstance]; // 用户登录成功后绑定账户 ID [sdk loginWithAccountID:@"user_12345678"]; // 获取当前登录的账户 ID NSString *accountId = [sdk accountID]; NSLog(@"当前账户 ID: %@", accountId); // 输出: 当前账户 ID: user_12345678 // 用户退出登录,清除账户 ID [sdk logout]; ``` -------------------------------- ### Track In-App Purchase Events with Attributes Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Use SEIAPEventAttribute to encapsulate purchase information for tracking. Supports various payment methods and statuses. Use this for both successful and failed purchase scenarios. ```Objective-C SEIAPEventAttribute *iapAttr = [[SEIAPEventAttribute alloc] init]; iapAttr.productID = @"com.yourapp.coins_100"; iapAttr.productName = @"100金币礼包"; iapAttr.productCount = 1; iapAttr.orderId = @"ORDER_20240315_001"; iapAttr.payAmount = 6.0; iapAttr.currencyType = @"CNY"; // 遵循 ISO 4217 标准 iapAttr.payType = SEIAPEventPayTypeAlipay; // 支付宝支付 iapAttr.payStatus = SolarEngineIAPSuccess; // 支付成功 iapAttr.customProperties = @{ @"promotion_id" : @"PROMO_001" }; [[SolarEngineSDK sharedInstance] trackIAPWithAttributes:iapAttr]; // 支付失败场景 SEIAPEventAttribute *failAttr = [[SEIAPEventAttribute alloc] init]; failAttr.productID = @"com.yourapp.vip_month"; failAttr.productName = @"月度会员"; failAttr.productCount = 1; failAttr.orderId = @"ORDER_20240315_002"; failAttr.payAmount = 30.0; failAttr.currencyType = @"CNY"; failAttr.payType = SEIAPEventPayTypeApplePay; failAttr.payStatus = SolarEngineIAPFail; failAttr.failReason = @"余额不足"; [[SolarEngineSDK sharedInstance] trackIAPWithAttributes:failAttr]; ``` -------------------------------- ### Track Ad Impression Events with Attributes Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Record detailed information about ad impressions, including type, network, and eCPM, for ad monetization analysis. Ensure 'rendered' is set to YES for successful impressions. ```Objective-C SEAdImpressionEventAttribute *adAttr = [[SEAdImpressionEventAttribute alloc] init]; adAttr.adType = 1; // 1: 激励视频 adAttr.adNetworkPlatform = @"csj"; // 穿山甲国内版 adAttr.adNetworkAppID = @"your_csj_app_id"; adAttr.adNetworkPlacementID = @"placement_001"; adAttr.ecpm = 15.5; // 每千次展示收入(元) adAttr.currency = @"CNY"; adAttr.mediationPlatform = @"custom"; // 无聚合平台时填 "custom" adAttr.rendered = YES; adAttr.customProperties = @{ @"ad_scene" : @"game_over" }; [[SolarEngineSDK sharedInstance] trackAdImpressionWithAttributes:adAttr]; ``` -------------------------------- ### Track User Registration Events Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Record user registration behavior and method to analyze conversion rates across different channels. Ensure 'registerType' does not exceed 32 characters. ```Objective-C SERegisterEventAttribute *regAttr = [[SERegisterEventAttribute alloc] init]; regAttr.registerType = @"phone"; // 注册类型,不超过 32 字符 regAttr.registerStatus = @"success"; // 注册状态 regAttr.customProperties = @{ @"channel" : @"organic" }; [[SolarEngineSDK sharedInstance] trackRegisterWithAttributes:regAttr]; ``` -------------------------------- ### 访客 ID 管理 Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt 使用 setVisitorID: 设置未登录用户的自定义标识符,并使用 visitorID 获取当前访客 ID。getDistinctId 用于获取 SDK 内部唯一标识。 ```objective-c SolarEngineSDK *sdk = [SolarEngineSDK sharedInstance]; // 设置访客 ID(未登录用户标识) [sdk setVisitorID:@"visitor_abc123"]; // 获取当前访客 ID NSString *visitorId = [sdk visitorID]; NSLog(@"当前访客 ID: %@", visitorId); // 输出: 当前访客 ID: visitor_abc123 // 获取 distinctId(SDK 内部唯一标识,用于事件关联) NSString *distinctId = [sdk getDistinctId]; NSLog(@"distinctId: %@", distinctId); ``` -------------------------------- ### Track Ad Click Events with Attributes Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Record user ad click behavior to calculate Click-Through Rate (CTR). This event should be used in conjunction with ad impression events. ```Objective-C SEAdClickEventAttribute *clickAttr = [[SEAdClickEventAttribute alloc] init]; clickAttr.adType = 5; // 5: Banner clickAttr.adNetworkPlatform = @"admob"; // AdMob clickAttr.adNetworkPlacementID = @"banner_placement_002"; clickAttr.mediationPlatform = @"applovin"; clickAttr.customProperties = @{ @"ad_position" : @"bottom" }; [[SolarEngineSDK sharedInstance] trackAdClickWithAttributes:clickAttr]; ``` -------------------------------- ### trackRegisterWithAttributes: Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports user registration events. Records the method of registration to analyze conversion rates across different channels. ```APIDOC ## trackRegisterWithAttributes: ### Description Reports user registration events. Records the method of registration to analyze conversion rates across different channels. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Parameters #### Request Body (Implicit via `SERegisterEventAttribute` object) - **registerType** (string) - The type of registration (e.g., "phone"), max 32 characters. - **registerStatus** (string) - The status of the registration (e.g., "success"). - **customProperties** (NSDictionary, Optional) - Additional custom key-value pairs. ### Request Example ```objc SERegisterEventAttribute *regAttr = [[SERegisterEventAttribute alloc] init]; regAttr.registerType = @"phone"; // 注册类型,不超过 32 字符 regAttr.registerStatus = @"success"; // 注册状态 regAttr.customProperties = @{ @"channel" : @"organic" }; [[SolarEngineSDK sharedInstance] trackRegisterWithAttributes:regAttr]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### trackLoginWithAttributes: Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports user login events. Records the method of login and is used in conjunction with account ID binding. ```APIDOC ## trackLoginWithAttributes: ### Description Reports user login events. Records the method of login and is used in conjunction with account ID binding. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Parameters #### Request Body (Implicit via `SELoginEventAttribute` object) - **loginType** (string) - The type of login (e.g., "wechat"). - **loginStatus** (string) - The status of the login (e.g., "success"). - **customProperties** (NSDictionary, Optional) - Additional custom key-value pairs. ### Request Example ```objc SELoginEventAttribute *loginAttr = [[SELoginEventAttribute alloc] init]; loginAttr.loginType = @"wechat"; // 微信登录 loginAttr.loginStatus = @"success"; loginAttr.customProperties = @{ @"is_first_login" : @(NO) }; [[SolarEngineSDK sharedInstance] trackLoginWithAttributes:loginAttr]; // Also update SDK account ID [[SolarEngineSDK sharedInstance] loginWithAccountID:@"user_wechat_openid_xxx"]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### trackAppAttrWithAttributes: / setAttributionCallback: / getAttributionData Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports attribution data for ad campaigns and retrieves server-side attribution results via a callback. The callback must be set before initialization. ```APIDOC ## Attribution Events ### Description Reports attribution data for ad campaigns and retrieves server-side attribution results via a callback. The callback must be set before initialization. ### Methods - `setAttributionCallback:`: Sets a callback to receive attribution results. - `trackAppAttrWithAttributes:`: Reports attribution event data. - `getAttributionData`: Retrieves cached attribution data. ### Endpoint N/A (SDK Methods) ### Parameters #### `setAttributionCallback:` - **callback** (block) - A block that takes an integer `code` and an optional `NSDictionary` `attributionData`. - `code`: 0 for success, non-zero for failure (e.g., 1001: Network error, 1002: Request limit exceeded, 1003: Request too frequent, 1004: Exceeded 15 days). - `attributionData`: Dictionary containing attribution information on success. #### `trackAppAttrWithAttributes:` (Implicit via `SEAppAttrEventAttribute` object) - **adNetwork** (string) - The advertising network. - **adAccountID** (string) - The advertising account ID. - **adAccountName** (string) - The advertising account name. - **adCampaignID** (string) - The advertising campaign ID. - **adCampaignName** (string) - The advertising campaign name. - **adOfferID** (string) - The advertising offer ID. - **adCreativeID** (string) - The advertising creative ID. - **adCreativeName** (string) - The advertising creative name. - **attributionPlatform** (string) - The attribution platform used (e.g., "appsflyer"). #### `getAttributionData` No parameters. ### Request Example ```objc // 1. Initialize attribution callback [[SolarEngineSDK sharedInstance] setAttributionCallback:^(int code, NSDictionary * _Nullable attributionData) { if (code == 0) { NSLog(@"归因成功,数据: %@", attributionData); // Process attribution data, e.g., log to server } else { NSLog(@"归因失败,错误码: %d", code); // code 1001: 网络错误 1002: 请求超限 1003: 请求过于频繁 1004: 超过15天 } }]; // 2. Report attribution event SEAppAttrEventAttribute *attrEvent = [[SEAppAttrEventAttribute alloc] init]; attrEvent.adNetwork = @"toutiao"; attrEvent.adAccountID = @"account_001"; attrEvent.adAccountName = @"测试投放账户"; attrEvent.adCampaignID = @"campaign_001"; attrEvent.adCampaignName = @"春节促销计划"; attrEvent.adOfferID = @"offer_001"; attrEvent.adCreativeID = @"creative_001"; attrEvent.adCreativeName = @"素材A-竖版"; attrEvent.attributionPlatform = @"appsflyer"; [[SolarEngineSDK sharedInstance] trackAppAttrWithAttributes:attrEvent]; // 3. Actively get attribution results (if available) NSDictionary *data = [[SolarEngineSDK sharedInstance] getAttributionData]; if (data) { NSLog(@"已缓存归因数据: %@", data); } ``` ### Response - **`setAttributionCallback:`**: No direct response, results are delivered via the callback. - **`trackAppAttrWithAttributes:`**: No direct response. - **`getAttributionData`**: Returns an NSDictionary containing cached attribution data, or nil if no data is available. ``` -------------------------------- ### Track User Login Events and Update Account ID Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Record user login behavior and method, used in conjunction with account ID binding. This snippet also shows how to update the SDK's account ID. ```Objective-C SELoginEventAttribute *loginAttr = [[SELoginEventAttribute alloc] init]; loginAttr.loginType = @"wechat"; // 微信登录 loginAttr.loginStatus = @"success"; loginAttr.customProperties = @{ @"is_first_login" : @(NO) }; [[SolarEngineSDK sharedInstance] trackLoginWithAttributes:loginAttr]; // 同时更新 SDK 账户 ID [[SolarEngineSDK sharedInstance] loginWithAccountID:@"user_wechat_openid_xxx"]; ``` -------------------------------- ### trackIAPWithAttributes: Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports in-app purchase events. Encapsulates purchase information using SEIAPEventAttribute objects, supporting various payment methods and status enumerations. ```APIDOC ## trackIAPWithAttributes: ### Description Reports in-app purchase events. Encapsulates purchase information using `SEIAPEventAttribute` objects, supporting various payment methods and status enumerations. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Parameters #### Request Body (Implicit via `SEIAPEventAttribute` object) - **productID** (string) - Description of the purchased product. - **productName** (string) - Name of the purchased product. - **productCount** (integer) - Number of products purchased. - **orderId** (string) - Unique identifier for the order. - **payAmount** (float) - The amount paid. - **currencyType** (string) - Currency type, following ISO 4217 standard. - **payType** (SEIAPEventPayType) - The payment method used (e.g., Alipay, ApplePay). - **payStatus** (SolarEngineIAPStatus) - The status of the payment (e.g., Success, Fail). - **failReason** (string, Optional) - Reason for payment failure, if applicable. - **customProperties** (NSDictionary, Optional) - Additional custom key-value pairs. ### Request Example ```objc SEIAPEventAttribute *iapAttr = [[SEIAPEventAttribute alloc] init]; iapAttr.productID = @"com.yourapp.coins_100"; iapAttr.productName = @"100金币礼包"; iapAttr.productCount = 1; iapAttr.orderId = @"ORDER_20240315_001"; iapAttr.payAmount = 6.0; iapAttr.currencyType = @"CNY"; // 遵循 ISO 4217 标准 iapAttr.payType = SEIAPEventPayTypeAlipay; // 支付宝支付 iapAttr.payStatus = SolarEngineIAPSuccess; // 支付成功 iapAttr.customProperties = @{ @"promotion_id" : @"PROMO_001" }; [[SolarEngineSDK sharedInstance] trackIAPWithAttributes:iapAttr]; // 支付失败场景 SEIAPEventAttribute *failAttr = [[SEIAPEventAttribute alloc] init]; failAttr.productID = @"com.yourapp.vip_month"; failAttr.productName = @"月度会员"; failAttr.productCount = 1; failAttr.orderId = @"ORDER_20240315_002"; failAttr.payAmount = 30.0; failAttr.currencyType = @"CNY"; failAttr.payType = SEIAPEventPayTypeApplePay; failAttr.payStatus = SolarEngineIAPFail; failAttr.failReason = @"余额不足"; [[SolarEngineSDK sharedInstance] trackIAPWithAttributes:failAttr]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### Account ID Management (Login/Logout) Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Associates a user's account ID with their session upon login and clears it upon logout. ```APIDOC ## Account ID Management (Login/Logout) ### Description Binds the account ID upon user login and unbinds it upon logout. This method associates the anonymous visitor ID with the logged-in account ID for consistent tracking. ### Methods - `loginWithAccountID:` - `accountID` - `logout` ### Parameters - **loginWithAccountID:** - **accountID** (NSString) - Required - The unique identifier for the logged-in user account. ### Request Example ```objc SolarEngineSDK *sdk = [SolarEngineSDK sharedInstance]; // Bind account ID after user successfully logs in [sdk loginWithAccountID:@"user_12345678"]; // Get the current logged-in account ID NSString *accountId = [sdk accountID]; NSLog(@"Current account ID: %@", accountId); // Output: Current account ID: user_12345678 // Clear account ID when the user logs out [sdk logout]; ``` ``` -------------------------------- ### trackAdImpressionWithAttributes: Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports monetization ad impression events. Records detailed information for each ad exposure, including ad type, monetization platform, and eCPM, for ad revenue analysis. ```APIDOC ## trackAdImpressionWithAttributes: ### Description Reports monetization ad impression events. Records detailed information for each ad exposure, including ad type, monetization platform, and eCPM, for ad revenue analysis. ### Method Objective-C ### Endpoint N/A (SDK Method) ### Parameters #### Request Body (Implicit via `SEAdImpressionEventAttribute` object) - **adType** (integer) - Type of the ad (e.g., 1 for Rewarded Video). - **adNetworkPlatform** (string) - The ad network platform (e.g., "csj"). - **adNetworkAppID** (string) - App ID for the ad network. - **adNetworkPlacementID** (string) - Placement ID for the ad. - **ecpm** (float) - eCPM (effective Cost Per Mille), revenue per thousand impressions (in currency units). - **currency** (string) - Currency of the eCPM value, following ISO 4217 standard. - **mediationPlatform** (string) - Mediation platform used (e.g., "custom" if no mediation). - **rendered** (boolean) - Indicates if the ad was rendered. - **customProperties** (NSDictionary, Optional) - Additional custom key-value pairs. ### Request Example ```objc SEAdImpressionEventAttribute *adAttr = [[SEAdImpressionEventAttribute alloc] init]; adAttr.adType = 1; // 1: 激励视频 adAttr.adNetworkPlatform = @"csj"; // 穿山甲国内版 adAttr.adNetworkAppID = @"your_csj_app_id"; adAttr.adNetworkPlacementID = @"placement_001"; adAttr.ecpm = 15.5; // 每千次展示收入(元) adAttr.currency = @"CNY"; adAttr.mediationPlatform = @"custom"; // 无聚合平台时填 "custom" adAttr.rendered = YES; adAttr.customProperties = @{ @"ad_scene" : @"game_over" }; [[SolarEngineSDK sharedInstance] trackAdImpressionWithAttributes:adAttr]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### Custom Event Tracking Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports custom events with associated properties to track specific user actions within the application. ```APIDOC ## Custom Event Tracking ### Description Reports arbitrary business events with associated properties. Event names must be alphanumeric with underscores, not starting with an underscore, and up to 40 characters long. ### Method `track:withProperties:` ### Parameters - **event** (NSString) - Required - The name of the event to track. Must be 40 characters or less and contain only alphanumeric characters and underscores, not starting with an underscore. - **properties** (NSDictionary) - Optional - A dictionary of key-value pairs representing the properties associated with the event. ### Request Example ```objc // Track a custom 'level_complete' event [[SolarEngineSDK sharedInstance] track:@"level_complete" withProperties:@{ @"level_id" : @(5), @"score" : @(9800), @"time_spent" : @(120), // in seconds @"is_perfect" : @(YES), @"character" : @"warrior" }]; // Track a 'product_view' event [[SolarEngineSDK sharedInstance] track:@"product_view" withProperties:@{ @"product_id" : @"SKU_001", @"product_name" : @"Wireless Earphones", @"category" : @"Electronics", @"price" : @(299.0) }]; ``` ``` -------------------------------- ### Visitor ID Management Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Sets and retrieves a custom visitor ID for tracking anonymous users across sessions before they log in. ```APIDOC ## Visitor ID Management ### Description Sets and retrieves a visitor ID used to identify anonymous users. This allows for cross-session tracking before a user logs in by assigning a custom identifier. ### Methods - `setVisitorID:` - `visitorID` - `getDistinctId` ### Parameters - **setVisitorID:** - **visitorID** (NSString) - Required - The custom identifier for the anonymous user. ### Request Example ```objc SolarEngineSDK *sdk = [SolarEngineSDK sharedInstance]; // Set visitor ID for an anonymous user [sdk setVisitorID:@"visitor_abc123"]; // Get the current visitor ID NSString *visitorId = [sdk visitorID]; NSLog(@"Current visitor ID: %@", visitorId); // Output: Current visitor ID: visitor_abc123 // Get the SDK's internal distinct ID NSString *distinctId = [sdk getDistinctId]; NSLog(@"distinctId: %@", distinctId); ``` ``` -------------------------------- ### trackAdClickWithAttributes: Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Reports monetization ad click events. Records user clicks on ads, used in conjunction with ad impression events to calculate Click-Through Rate (CTR). ```APIDOC ## trackAdClickWithAttributes: ### Description Reports monetization ad click events. Records user clicks on ads, used in conjunction with ad impression events to calculate Click-Through Rate (CTR). ### Method Objective-C ### Endpoint N/A (SDK Method) ### Parameters #### Request Body (Implicit via `SEAdClickEventAttribute` object) - **adType** (integer) - Type of the ad (e.g., 5 for Banner). - **adNetworkPlatform** (string) - The ad network platform (e.g., "admob"). - **adNetworkPlacementID** (string) - Placement ID for the ad. - **mediationPlatform** (string) - Mediation platform used (e.g., "applovin"). - **customProperties** (NSDictionary, Optional) - Additional custom key-value pairs. ### Request Example ```objc SEAdClickEventAttribute *clickAttr = [[SEAdClickEventAttribute alloc] init]; clickAttr.adType = 5; // 5: Banner clickAttr.adNetworkPlatform = @"admob"; // AdMob clickAttr.adNetworkPlacementID = @"banner_placement_002"; clickAttr.mediationPlatform = @"applovin"; clickAttr.customProperties = @{ @"ad_position" : @"bottom" }; [[SolarEngineSDK sharedInstance] trackAdClickWithAttributes:clickAttr]; ``` ### Response N/A (SDK Method) ``` -------------------------------- ### GDPR Compliance Setting Source: https://context7.com/solarengine-sdk/solarenginesdk-ios-inter/llms.txt Dynamically sets whether the current user is in a GDPR area. When enabled, the SDK will not collect IDFA and IDFV. ```APIDOC ## GDPR Compliance Setting ### Description Dynamically sets the GDPR area restriction. When enabled, the SDK will not collect IDFA and IDFV, suitable for scenarios requiring runtime adjustment of compliance policies. ### Method `setGDPRArea:` ### Parameters - **isGDPRArea** (BOOL) - Required - YES if the user is in a GDPR area, NO otherwise. ### Request Example ```objc // Set GDPR restriction dynamically based on user consent or location BOOL isEUUser = YES; // Determine based on business logic [[SolarEngineSDK sharedInstance] setGDPRArea:isEUUser]; ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.