Skip to content

Commit

Permalink
Revert "Add $kochavaDeviceId attribution convenience method (#4238)" (
Browse files Browse the repository at this point in the history
#4265)

This reverts commit 871a785.
  • Loading branch information
tonidero authored Sep 11, 2024
1 parent 659b5de commit f2ce441
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 121 deletions.
13 changes: 0 additions & 13 deletions Sources/Purchasing/Purchases/Attribution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,6 @@ public extension Attribution {
self.subscriberAttributesManager.setCleverTapID(cleverTapID, appUserID: appUserID)
}

/**
* Subscriber attribute associated with the Kochava Device ID for the user.
* Recommended for the RevenueCat Kochava integration.
*
* #### Related Articles
* - [Kochava RevenueCat Integration](https://docs.revenuecat.com/docs/kochava)
*
* - Parameter kochavaDeviceID: Empty String or `nil` will delete the subscriber attribute.
*/
@objc func setKochavaDeviceID(_ kochavaDeviceID: String?) {
self.subscriberAttributesManager.setKochavaDeviceID(kochavaDeviceID, appUserID: appUserID)
}

/**
* Subscriber attribute associated with the Mixpanel Distinct ID for the user.
* Optional for the RevenueCat Mixpanel integration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ enum ReservedSubscriberAttribute: String {
case oneSignalUserID = "$onesignalUserId"
case airshipChannelID = "$airshipChannelId"
case cleverTapID = "$clevertapId"
case kochavaDeviceID = "$kochavaDeviceId"
case mixpanelDistinctID = "$mixpanelDistinctId"
case firebaseAppInstanceID = "$firebaseAppInstanceId"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ class SubscriberAttributesManager {
setReservedAttribute(.cleverTapID, value: cleverTapID, appUserID: appUserID)
}

func setKochavaDeviceID(_ kochavaDeviceID: String?, appUserID: String) {
setReservedAttribute(.kochavaDeviceID, value: kochavaDeviceID, appUserID: appUserID)
}

func setMixpanelDistinctID(_ mixpanelDistinctID: String?, appUserID: String) {
setReservedAttribute(.mixpanelDistinctID, value: mixpanelDistinctID, appUserID: appUserID)
}
Expand Down
2 changes: 0 additions & 2 deletions Tests/APITesters/AllAPITests/ObjcAPITester/RCAttributionAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ + (void)checkAPI {
[a setOnesignalUserID: @""];
[a setCleverTapID: nil];
[a setCleverTapID: @""];
[a setKochavaDeviceID:nil];
[a setKochavaDeviceID:@""];
[a setMixpanelDistinctID: nil];
[a setMixpanelDistinctID: @""];
[a setFirebaseAppInstanceID: nil];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ func checkAttributionAPI() {
attribution.setCleverTapID("")
attribution.setCleverTapID(nil)

attribution.setKochavaDeviceID("")
attribution.setKochavaDeviceID(nil)

attribution.setMixpanelDistinctID("")
attribution.setMixpanelDistinctID(nil)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct SubscriberAttributesView: View {
case setAppsflyerID
case setAirshipChannelID
case setCleverTapID
case setKochavaDeviceID
case setMparticleID
case setOnesignalID
case setFBAnonymousID
Expand Down Expand Up @@ -143,8 +142,6 @@ struct SubscriberAttributesView: View {
Purchases.shared.attribution.setAirshipChannelID(self.otherValue)
case .setCleverTapID:
Purchases.shared.attribution.setCleverTapID(self.otherValue)
case .setKochavaDeviceID:
Purchases.shared.attribution.setKochavaDeviceID(self.otherValue)
case .setMparticleID:
Purchases.shared.attribution.setMparticleID(self.otherValue)
case .setOnesignalID:
Expand Down
12 changes: 0 additions & 12 deletions Tests/UnitTests/Mocks/MockSubscriberAttributesManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,6 @@ class MockSubscriberAttributesManager: SubscriberAttributesManager {
invokedSetCleverTapIDParametersList.append((cleverTapID, appUserID))
}

var invokedSetKochavaDeviceID = false
var invokedSetKochavaDeviceIDCount = 0
var invokedSetKochavaDeviceIDParameters: (KochavaDeviceID: String?, appUserID: String?)?
var invokedSetKochavaDeviceIDParametersList = [(KochavaDeviceID: String?, appUserID: String?)]()

override func setKochavaDeviceID(_ kochavaDeviceID: String?, appUserID: String) {
invokedSetKochavaDeviceID = true
invokedSetKochavaDeviceIDCount += 1
invokedSetKochavaDeviceIDParameters = (kochavaDeviceID, appUserID)
invokedSetKochavaDeviceIDParametersList.append((kochavaDeviceID, appUserID))
}

var invokedSetMixpanelDistinctID = false
var invokedSetMixpanelDistinctIDCount = 0
var invokedSetMixpanelDistinctIDParameters: (mixpanelDistinctID: String?, appUserID: String?)?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,6 @@ class PurchasesSubscriberAttributesTests: TestCase {
.to(equal((nil, purchases.appUserID)))
}

func testSetAndClearKochavaDeviceID() {
setupPurchases()
purchases.attribution.setKochavaDeviceID("kochava")
purchases.attribution.setKochavaDeviceID(nil)
expect(self.mockSubscriberAttributesManager.invokedSetKochavaDeviceIDParametersList[0])
.to(equal(("kochava", purchases.appUserID)))
expect(self.mockSubscriberAttributesManager.invokedSetKochavaDeviceIDParametersList[1])
.to(equal((nil, purchases.appUserID)))
}

func testSetAndClearMixpanelDistinctID() {
setupPurchases()
purchases.attribution.setMixpanelDistinctID("mixp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,79 +1134,6 @@ class SubscriberAttributesManagerTests: TestCase {
checkDeviceIdentifiersAreNotSet()
}
// endregion
// region kochavaDeviceID
func testSetKochavaDeviceID() throws {
let kochavaDeviceID = "kochavaDeviceID"

self.subscriberAttributesManager.setKochavaDeviceID(kochavaDeviceID, appUserID: "kratos")
expect(self.mockDeviceCache.invokedStoreCount) == 1

let invokedParams = try XCTUnwrap(self.mockDeviceCache.invokedStoreParameters)
let receivedAttribute = invokedParams.attribute

expect(receivedAttribute.key) == "$kochavaDeviceId"
expect(receivedAttribute.value) == kochavaDeviceID
expect(receivedAttribute.isSynced) == false
}

func testSetKochavaDeviceIDSetsEmptyIfNil() throws {
let kochavaDeviceID = "kochavaDeviceID"

self.subscriberAttributesManager.setKochavaDeviceID(kochavaDeviceID, appUserID: "kratos")
self.subscriberAttributesManager.setKochavaDeviceID(nil, appUserID: "kratos")

expect(self.mockDeviceCache.invokedStoreCount) == 2

let invokedParams = try XCTUnwrap(self.mockDeviceCache.invokedStoreParameters)
let receivedAttribute = invokedParams.attribute

expect(receivedAttribute.key) == "$kochavaDeviceId"
expect(receivedAttribute.value) == ""
expect(receivedAttribute.isSynced) == false
}

func testSetKochavaDeviceIDSkipsIfSameValue() {
let kochavaDeviceID = "kochavaDeviceID"

self.mockDeviceCache.stubbedSubscriberAttributeResult = SubscriberAttribute(withKey: "$kochavaDeviceId",
value: kochavaDeviceID)
self.subscriberAttributesManager.setKochavaDeviceID(kochavaDeviceID, appUserID: "kratos")

expect(self.mockDeviceCache.invokedStoreCount) == 0
}

func testSetKochavaDeviceIDOverwritesIfNewValue() throws {
let oldSyncTime = Date()
let kochavaDeviceID = "kochavaDeviceID"

self.mockDeviceCache.stubbedSubscriberAttributeResult = SubscriberAttribute(withKey: "$kochavaDeviceId",
value: "old_id",
isSynced: true,
setTime: oldSyncTime)

self.subscriberAttributesManager.setKochavaDeviceID(kochavaDeviceID, appUserID: "kratos")

expect(self.mockDeviceCache.invokedStoreCount) == 1

let invokedParams = try XCTUnwrap(self.mockDeviceCache.invokedStoreParameters)
let receivedAttribute = invokedParams.attribute

expect(receivedAttribute.key) == "$kochavaDeviceId"
expect(receivedAttribute.value) == kochavaDeviceID
expect(receivedAttribute.isSynced) == false
expect(receivedAttribute.setTime) > oldSyncTime
}

func testSetKochavaDeviceIDDoesNotSetDeviceIdentifiers() {
let kochavaDeviceID = "kochavaDeviceID"
self.subscriberAttributesManager.setKochavaDeviceID(kochavaDeviceID, appUserID: "kratos")
expect(self.mockDeviceCache.invokedStoreCount) == 1

expect(self.mockDeviceCache.invokedStoreParametersList.count) == 1

checkDeviceIdentifiersAreNotSet()
}
// endregion
// region MixpanelDistinctID
func testSetMixpanelDistinctID() throws {
let mixpanelDistinctID = "mixpanelDistinctID"
Expand Down

0 comments on commit f2ce441

Please sign in to comment.