LibHoney 1.0.0

LibHoney 1.0.0

测试已测试
语言语言 SwiftSwift
许可证 Apache 2
发布最新发布2017年11月
SwiftSwift 版本4.0
SPM支持 SPM

Chong Han Chua 维护。



LibHoney 1.0.0

  • GitHub 仓库
  • CocoaPods.org 页面

honeycombio

GitHub 仓库

LibHoney

一个用于向 Honeycomb 发送事件,由 Swift 编写的库。

安装

gem install cocoapods

Cocoapods

target '<Target name>' do
  # If you're using LibHoney with Objective-C, uncomment use_frameworks!
  # use_frameworks!  
  pod 'LibHoney', '~> 1.0'
end

CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它

pod install

要使用 CocoaPods 将 LibHoney 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它

然后运行以下命令

由于 LibHoney 依赖于 Alamofire,如果您在 Objective-C 中使用 LibHoney,您可能需要在 Pods 的构建设置中设置 Albania 的 SWIFT_VERSION 变量。

使用

Swift

import LibHoney

// ...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {    
    // other code...
    LibHoney.configure(writeKey: "<your write key>", dataset: "<your dataset name>")    
}

要使用 LibHoney,您必须首先使用您的 writeKey 和数据集名称配置库。

let event = LibHoney.shared?.newEvent()
event?.add(key: "stringValue", value: "Hello, world")
event?.add(key: "intValue", value: 199)
event?.add(key: "boolValue", value: true)
event?.add(key: "doubleValue", value: 3.14159)
LibHoney.shared?.send(event)

AppDelegate 内部 didFinishLaunchingWithOptions

要发送事件,只需创建一个新的事件并向其中添加字段

LibHoney.shared?.add(key: "user", value: "<user id>")

如果 LibHoney 未配置,则 LibHoney.shared 返回 null。使用上面的代码,您可以在调试环境中安全地跳过配置步骤。

LibHoney.shared?.collectDeviceStats = false

Objective-C

使用

Swift

@import LibHoney;

// ...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // other code...
    [LibHoney configureWithWriteKey:@"<your write key>" dataset:@"<your dataset name>"];    
}

要使用 LibHoney,您必须首先使用您的 writeKey 和数据集名称配置库。

HoneyEvent* event = [LibHoney.shared newEvent];
[event addKey: @"stringValue" stringValue: @"Hello, world"];
[event addKey: @"intValue" intValue: 199];
[event addKey: @"boolValue" boolValue: true];
[event addKey: @"doubleValue" doubleValue: 3.14159];
[LibHoney.shared send: event];

如果 LibHoney 未配置,则 LibHoney.shared 返回一个 nil 对象。

要发送事件,只需创建一个新的事件并向其中添加字段

[LibHoney.shared addKey:@"user" stringValue:@"<user Id>"];

如果 LibHoney 未配置,则 LibHoney.shared 返回 null。使用上面的代码,您可以在调试环境中安全地跳过配置步骤。

LibHoney.shared.collectDeviceStats = NO;

贡献

欢迎为 LibHoney 添加新功能、错误修复和其他更改。请打开问题或带有您的更改的拉取请求。请记住在Contributors文件中添加您的姓名!

所有贡献都将在 Apache License 2.0 下发布。