Skip to main content

As discussed in the post linked below which seems to have comments closed, the migration guide points to the Firebase docs for tracking StoreKit 2 transactions in Firebase.

However, it’s not clear from the sample code provided by Google/Firebase how this would integrate with RevenueCat exactly.

Does it matter if `await transaction.finish()` is called after `Analytics.logTransaction(transaction)`?

Guidance appreciated. Thank you.

func purchaseSomeProduct(_ product: Product) {

// Purchase a Product. This is mostly standard boilerplate StoreKit 2
// code, except for the Analytics.logTransaction() call.
let result = try await product.purchase()

switch result {
case .success(let verification):
let transaction = try checkVerified(verification)

// Call this Firebase API to log the in-app purchase event.
// NOTE: How do we hook in to this specific point via RevenueCat?
Analytics.logTransaction(transaction)

await transaction.finish()
...
}

 

 

 

 My current implementation pulls the transaction out after a successful purchase but, if I understand correctly, this occurs after RevenueCat’s internal call to `await transaction.finish()` and it’s unclear whether or not Firebase is expecting this.

 

let purchaseInfo = try await revenueCat.purchase(product: product)
if let storeKitTransaction = purchaseInfo.transaction?.sk2Transaction {
Analytics.logTransaction(storeKitTransaction)
}

 


Hi @Tristan,

Thanks for pointing out that the other post was closed, I just replied there.

To answer your question, I’m unsure if Firebase requires you to send the transaction before RevenueCat finishes it. I’d ask them or a Firebase expert. I will say that RevenueCat finishes transactions as soon as they’re made, so that by the time you get a result from purchaseProduct, the transaction is finished.

You may also want to take a look at our native Firebase integration instead of using logTransactions manually.


 My current implementation pulls the transaction out after a successful purchase but, if I understand correctly, this occurs after RevenueCat’s internal call to `await transaction.finish()` and it’s unclear whether or not Firebase is expecting this.

 

let purchaseInfo = try await revenueCat.purchase(product: product)
if let storeKitTransaction = purchaseInfo.transaction?.sk2Transaction {
Analytics.logTransaction(storeKitTransaction)
}

 

I tried this approach but I don’t see the default in-app-purchase event on Firebase. Does it work for you @Tristan ?


@userfromfuture looking at my results so far, no. There are some events that are coming through, but the vast majority have been dropped.

 

@sharif perhaps this should be clarified in the migration guide?


We have the same issue. We have integrated RevenueCat with Firebase (No need for extenson for Firestore).

Few of rc_trial events arriving but many events are not sent. Also we need native in_app_purchase event which we cannot log. 

Is there a way to switch back to Store Kit 1? Or how to solve this properly. I saw few more people are complaining about this in RevenueCat forums.

 

 


We also have the RevenueCat/Firebase integration running and I can see that at least the rc_trial_start event is tallying with what we’re seeing elsewhere.

If you wanted to use SK1 in the meantime you could simply revert to 4.x.x RC?


We don’t want to downgrade the RevenueCat, I was wondering if there is a flag or something to use StoreKit for now until they fix the issue.

Have you tried setting up Firebase Extension for RevenueCat to receive native in_app_purchase event? Would it help?

@sharif we need your support.


We don’t want to downgrade the RevenueCat, I was wondering if there is a flag or something to use StoreKit for now until they fix the issue.

I’m not sure, but I don’t think so.

Have you tried setting up Firebase Extension for RevenueCat to receive native in_app_purchase event? Would it help?

I haven’t, but as far as I’m aware it sends through events with names that can’t be modified. There appears to be some inconsistency though. For example, the `purchase` event isn’t prefixed with `rc_` for some reason.


Few of rc_trial events arriving but many events are not sent. Also we need native in_app_purchase event which we cannot log. 

Follow-up to this: I’m now noticing events appear in GA4 but aren’t logged as conversions in Google Ads. I’m not sure why attribution doesn’t work with the recommended Firebase integration. Any ideas @sharif?

 


How do you track purchase conversion in Google Ads @Tristan ? Since in_app_purchase event is missing I am wondering how to setup install campaigns with a correct conversion parameter for optimized campaigns?


@userfromfuture unfortunately, the way RevenueCat sends events to Google Analytics means that it’s not possible to use server side generated events as Google Ads conversion goals. With the current implementation, conversion goals that are tied to RevenueCat generated events will show as having ‘No Recent Conversions’ indefinitely.