Segment-Optimizely-X
此 SDK 支持 Optimizely iOS v1.1.9。Segment 通过 Segment 云模式支持 Optimizely 的新版本。有关通过 Segment 云模式与 Optimizely 集成的更多信息,请参阅我们的文档。
示例
要运行示例项目,请克隆存储库,并在 Example 目录中首先运行 pod install
需求
安装
Segment-Optimizely-X 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile
pod "Segment-Optimizely-X"
使用方法
Objective-C
SEGAnalyticsConfiguration *configuration = [SEGAnalyticsConfiguration configurationWithWriteKey:@"<YOUR_WRITE_KEY>"];
configuration.trackApplicationLifecycleEvents = YES;
configuration.recordScreenViews = YES;
// Setup optimizely logger.
OPTLYLoggerDefault *optlyLogger = [[OPTLYLoggerDefault alloc] initWithLogLevel:OptimizelyLogLevelError];
// Create an Optimizely manager.
self.optlyManager = [OPTLYManager init:^(OPTLYManagerBuilder *_Nullable builder) {
builder.projectId = @"<YOUR_PROJECT_ID>";
builder.logger = optlyLogger;
}];
// Initialize an Optimizely client by asynchronously downloading the datafile.
[self.optlyManager initializeWithCallback:^(NSError *_Nullable error, OPTLYClient *_Nullable client) {
// Optimizely is now up and running. You can now configure any experiments, etc.
}];
[configuration use:[SEGOptimizelyXIntegrationFactory instanceWithOptimizely:self.optlyManager]];
[SEGAnalytics setupWithConfiguration:configuration];
Swift
let configuration = SEGAnalyticsConfiguration(writeKey: "<YOUR_WRITE_KEY>")
configuration.trackApplicationLifecycleEvents = true
configuration.recordScreenViews = true
let optlyLogger = OPTLYLoggerDefault(logLevel: .error)
optlyManager = OPTLYManager.instance(builderBlock: { (builder) in
builder?.projectId = "<YOUR_PROJECT_ID>"
builder?.logger = optlyLogger
})
optlyManager?.initialize(callback: { (error, optlyClient) in
// Optimizely is now up and running. You can now configure any experiments, etc.
})
configuration.use(SEGOptimizelyXIntegrationFactory.instance(withOptimizely: optlyManager))
SEGAnalytics.setup(with: configuration)
许可协议
Segment-Optimizely-X 在MIT许可下可用。有关更多信息,请参阅LICENSE文件。