DataCortex 1.0.5

DataCortex 1.0.5

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2019年5月

Jim Lake 维护。



  • Yanko Bolanos 和 Jim Lake

cortex-ios-sdk

Data Cortex iOS SDK

使用方法

要运行示例项目,请克隆仓库,并首先从 Example 目录运行 pod install

需求

安装

cortex-ios-sdk 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile

pod "DataCortex"

确保您的 Info.plist 文件中包含以下内容

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
   <key>api.data-cortex.com</key>
   <dict>
    <key>NSTemporaryThirdPartyExceptionRequiresForwardSecrecy</key>
    <false/>
   </dict>
  </dict>
</dict>

初始化库

通常,您需要在AppDelegate.m文件中初始化库。参考文献:application:willFinishLaunchingWithOptions:

#import <DataCortex/DataCortex.h>

#define DC_API_KEY @"YOUR_API_KEY"
#define DC_ORG @"your_org_name"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  // Initialize the library with your DC_API_KEY
  [DataCortex sharedInstanceWithAPIKey:YOUR_API_KEY forOrg:DC_ORG];

  // To get your instance later
  DataCortex *dc = [DataCortex sharedInstance];

//...

}

您还可以指定自己的DAU追踪时区,否则我们默认为UTC。

  // Initialize the library with your DC_API_KEY
  [DataCortex sharedInstanceWithAPIKey:YOUR_API_KEY
                                forOrg:DC_ORG
                           dauTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"PST"]];

用户追踪

如果您有追踪用户ID或其他标识符,请将其添加到数据中枢,以便跨多个设备和平台汇总用户的用法。

  DataCortex *dc = [DataCortex sharedInstance];

  // User identified by Numeric ID
  [dc setUserTag:@1234];
  // User identified by unique string
  [dc setUserTag:@"xzy123"];

事件追踪

事件追踪是您在数据中枢SDK中使用的主要方式。请参考您的追踪规范以获取每个事件中使用的参数。

  DataCortex *dc = [DataCortex sharedInstance];

  // With all taxonomy
  [dc eventWithProperties:@{
    @"kingdom": @"kingdom",
    @"phylum": @"phylum",
    @"class": @"class",
    @"order": @"order",
    @"family": @"family",
    @"genus": @"genus",
    @"species": @"species",
  }];

  // With all taxonomy and floats
  [dc eventWithProperties:@{
    @"kingdom": @"kingdom",
    @"phylum": @"phylum",
    @"class": @"class",
    @"order": @"order",
    @"family": @"family",
    @"genus": @"genus",
    @"species": @"species",
    @"float1": @123,
    @"float2": @1.5,
    @"float3": @100000,
    @"float4": @0.0,
  }];

经济追踪

经济追踪与事件追踪非常相似,但增加了几个额外的必填元素。具体为spendAmountspendCurrency。还增加了一个可选的spendType

  DataCortex *dc = [DataCortex sharedInstance];

  [dc economyWithProperties:@{
      @"kingdom": @"kingdom",
      @"phylum": @"phylum",
      @"class": @"class",
      @"order": @"order",
      @"family": @"family",
      @"genus": @"genus",
      @"species": @"species",
    }
    spendAmount: @9.99
    spendCurrency: @"USD"
    spendType: @"coinPurchase"
  }];

  [dc economyWithProperties:@{
      @"kingdom": @"buildings",
      @"phylum": @"barn",
      @"class": @"red",
    }
    spendAmount: @10
    spendCurrency: @"coins"
  }];