Firebase AB测试的变形比例不均衡

时间:2018-10-22 09:23:30

标签: ios firebase ab-testing firebase-remote-config firebase-ab-testing

我们对AB测试变体的不均衡存在疑问。从理论上讲,两种变体应几乎均等地暴露,这实际上与我们之前进行的AB测试相当有效。 ab test config 1 ab test config 2

您可以在屏幕快照中看到,当前用户总数为161k,变体版本为75.4k和85.9k。我们已经运行了几次该测试,但代码稍有更改,但是每次这种不均衡都同样出现。

在进行中的AB测试中,我们将远程配置参数“ ios_show_recent_searches_v2”空字符串设置为默认值。

运行带有激活事件的ab测试的代码如下:

@objc class FireBaseService: NSObject {
    struct Constants {
        static let recentSearchesABTestToggleKey: String = "ios_show_recent_searches_v2"
        static let abTestNotAvailableKey: String = "N/A"
    }

    @objc class func start() {
        FirebaseApp.configure()
        let remoteConfig = RemoteConfig.remoteConfig()

        let oldShowRecentSearches = showRecentSearches

        remoteConfig.fetch(withExpirationDuration: 0.0) { (status, error) -> Void in
            DispatchQueue.main.async {
                if status == .success {
                    remoteConfig.activateFetched()
                    FireBaseService.notifyRecentSearchesVisiblityChangeIfNeeded(oldValue: oldShowRecentSearches)
                    FireBaseService.sendRecentSearchesActivationEventIfNeeded()
                }
            }
        }
    }  

    private class func hasConfigs(for key: String) -> Bool {
        return (RemoteConfig.remoteConfig()[key].stringValue?.count ?? 0) > 0
    }
}

// MARK: - Recent Searches A/B Test
extension FireBaseService {

    @objc class var showRecentSearchesValue: String {
        if hasConfigs(for: Constants.recentSearchesABTestToggleKey) {
            return RemoteConfig.remoteConfig()[Constants.recentSearchesABTestToggleKey].stringValue ?? Constants.abTestNotAvailableKey
        }
        return Constants.abTestNotAvailableKey
    }

    class var showRecentSearches: Bool {
        return RemoteConfig.remoteConfig()[Constants.recentSearchesABTestToggleKey].boolValue
    }

    private class func sendRecentSearchesActivationEventIfNeeded() {
        if FireBaseService.showRecentSearchesValue != Constants.abTestNotAvailableKey {
            AnalyticsServiceAdapter.activateRecentSearchesExperiment()
        }
    }

    private class func notifyRecentSearchesVisiblityChangeIfNeeded(oldValue: Bool) {
        if oldValue != showRecentSearches {
            NotificationCenter.default.post(name: Notification.Name(FireBaseService.ShowRecentSearchesNotification), object: nil)
        }
    }
}

在应用程序启动时调用功能GEFireBaseService.start

0 个答案:

没有答案