Hi all, we’re having problems sending data to Fire...
# support
s
Hi all, we’re having problems sending data to FireBase/GA4 and AppsFlyer from a React-Native App. We successfully ingest the data but then can’t send it to the destinations. Not sure why/where we’re going wrong. These are the errors;
They both suggest a similar problem in that we are somehow not setting the IDs correctly, however we have set them up in the app and in RudderStack. How do we go about debugging this?
k
Hey @salmon-plastic-31303 , You can follow the documentation here regarding how to set the ID for Appsflyer
s
We’re doing that.
k
Regarding GA4 here
Can you share an example payload which is getting rejected with the above error in payload ?
s
Sure;
Copy code
{
  "type": "screen",
  "event": "UI",
  "sentAt": "2023-06-12T08:37:10.853Z",
  "userId": "79a82a70-ddd5-11ed-af54-4f419a486fc8",
  "channel": "mobile",
  "context": {
    "os": {
      "name": "iOS",
      "version": "16.4"
    },
    "app": {
      "name": "arnoldsDev",
      "build": "1",
      "version": "1.0.0",
      "namespace": "com.arnolds.dev"
    },
    "device": {
      "id": "619770c9-9d5e-47d3-b1c0-50cd123b2750",
      "name": "iPhone 14",
      "type": "iOS",
      "model": "iPhone",
      "manufacturer": "Apple",
      "attTrackingStatus": 0
    },
    "locale": "fi-US",
    "screen": {
      "width": 390,
      "height": 844,
      "density": 3
    },
    "traits": {
      "phone": "+3580440179929",
      "userId": "79a82a70-ddd5-11ed-af54-4f419a486fc8",
      "anonymousId": "619770c9-9d5e-47d3-b1c0-50cd123b2750"
    },
    "library": {
      "name": "rudder-ios-library",
      "version": "1.15.1"
    },
    "network": {
      "wifi": true,
      "cellular": false
    },
    "timezone": "Europe/Helsinki",
    "sessionId": 1686555568
  },
  "rudderId": "341ac75d-f852-47ed-83a8-84ac94d0023e",
  "messageId": "c8bc85e8-45c7-48d4-a444-1c377a1880f5",
  "timestamp": "2023-06-12T08:37:10.923Z",
  "properties": {
    "name": "UI",
    "automatic": true
  },
  "receivedAt": "2023-06-12T08:37:11.171Z",
  "request_ip": "87.95.56.65",
  "anonymousId": "619770c9-9d5e-47d3-b1c0-50cd123b2750",
  "integrations": {
    "All": true
  },
  "originalTimestamp": "2023-06-12T08:37:10.605Z"
}
k
I couldn't see externalId being present in the above payload. Can you share how you are setting externalId ?
s
Adding our dev @adventurous-petabyte-6019 to the conversation.
I believe though that we sent the event via device mode. Would we still therefore need to add externalId?
k
They are not needed if you use device mode
s
Yep we have the device mode ID set through the react-native library
screenshot_2023-06-08_at_18.14.13.png
We use the same ID in the RudderStack dashboard so we're unsure what the issue is.
a
@kind-carpenter-27609 hello! added code like in docs, but we have events error
Copy code
{
  "error": "Invalid app endpoint"
}
Copy code
useEffect(() => {
    const rudderInitialise = async () => {
      setOptions({
        // dev key from the appsflyer dashboard
        devKey: 'vegd7ZQCLsTv6SeR7X6erD',
        // whether we want to run the appsflyer SDK in the debug mode
        isDebug: true,
        // whether we want to register for the listeners which would return the conversion data
        onInstallConversionDataListener: true,
        // ID assigned by the Apple app store for any app which is either published or in the process of getting published
        appleAppId: '1667809195',
        // whether we want to register for the listeners which would return the deeplink data
        onDeepLinkListener: true,
        // the number of seconds for which the appsflyer iOS SDK should wait to allow the app to retrieve the user consent.
        timeToWaitForATTUserAuthorization: 60
      });
      await rudderClient.setup(Config.RUDDERSTACK_KEY, {
        dataPlaneUrl: Config.RUDDERSTACK_DATA_PLANE_URL,
        trackAppLifecycleEvents: true,
        recordScreenViews: true,
        withFactories: [appsflyer]
      });
      console.log('SDK is initalised');
    };

    rudderInitialise().catch(console.error);
  }, []);
k
@calm-yak-10773, can you look into this ? CC <!subteam^S04QT1G74Q3|@sdk-team>
c
Hey @salmon-plastic-31303 @adventurous-petabyte-6019 Can you please share the React-Native source write key (through DM). Also, could you please clarify the following points: 1. Which version of
@rudderstack/rudder-integration-firebase-react-native
package are you using? 2. Have you been able to observe any events in Firebase so far? 3. Have you been able to observe any events in AppsFlyer so far?
s
@adventurous-petabyte-6019 will tell you the package and share the write key. We have no events in either appflyer or firebase. However we have got them sent to BigQuery correctly as far as I can tell.
We can see the errors in RudderStack live events and event flow.
c
Regarding Firebase, are you getting any kind of error?
a
@calm-yak-10773 1. 1.0.17 2. appsflyer events with error - "error": "Invalid app endpoint"
c
Can you please share the writeKey @adventurous-petabyte-6019?
a
also I have warning
key - 2PanRSkXFC9pG8AqfwlWeyWRRwN
gratitude thank you 1
c
I’ve got the reason behind the error: Follow this step for `AppsFlyer`: 1. Please go to the RudderStack dashboard: https://app.rudderstack.com/ 2. Open your
AppsFlyer Staging
destination 3. Select
Configuration
tab 4. Navigate to bottom and set
Use device-mode to send events
option to
true
. Actually, for AppsFlyer you’ve connected the destination in
Cloud
mode, not in device mode. Hence you’re getting error. PS: If you would have connected any destination in device mode, you wouldn’t be able to see the live events tab for that destination. For other destination i.e., Firebase: 1. Actually, you’ve created a Google Analytics GA4 destination, instead of Firebase. 2. Google Analytics GA4 is a cloud mode destination hence this is also not working. 3. PS: Google Analytics GA4 and Firebase both are different destination in Rudderstack and Rudder React-Native only supports Firebase as a mobile device mode destination. 4. Kindly connect to Firebase and try again. I assume you’re attempting to send events in device mode and not in cloud mode.
a
button is disabled
c
Click on
Edit Configuration
on top right.
🙌 1
a
live events working only when device mode is disabled?
Screenshot 2023-06-12 at 15.38.19.png
c
Yes, live events works only when device mode is disabled or in other words, destination is connected in cloud mode. BTW, you can still the events in the source tab.
I’ve mentioned it previously:
PS: If you would have connected any destination in device mode, you wouldn’t be able to see the live events tab for that destination.
1
s
Thanks for this. So how do we know which is best? Cloud or device? For web properties tracking with ga4 I use device because cloud gave us no location data. At least not without setting up measurement protocol and our own scripts to track location. So does cloud work differently per app?
c
Which mode you choose depends on your specific needs. In cloud mode: • The events you make is sent to the RudderStack backend and it processes the events (i.e., transform as per destination requirements and apply transformation on the payload) and send it to the respective destination. • In this case, you don’t require destination SDK to be installed on the device. • You can also utilise transformation feature. • In this mode, application are lightweight, as you only need to install the RudderStack SDK and no other destination SDK is required. • If destination is only available in cloud mode then you have to proceed with it. In device mode, • The destination SDK is installed on your device. • All the events sent using Rudderstack SDKs undergo a transformation process to match the format expected by the destination SDKs. Subsequently, the transformed event payload is passed to the destination SDK, which then sends the event to its respective server. • Certain functionalities, such as push notifications or other specific features, are only available when you install the destination SDKs. To utilise these features, it is necessary to use a device mode connection. • If a destination does not support cloud mode, such as Firebase, it is necessary to proceed with the device mode for that specific destination.
s
This is a very complete answer thanks.
🙂 1
a
thank you! it's clear
🙂 1
@calm-yak-10773 hello again, we want to switch appsflyer to cloud mode it's my code, do I need to add another values to setOptions?
Copy code
useEffect(() => {
    const isProd = Config.ENV_MODE === 'Prod';

    const rudderInitialise = async () => {
      const appsFlyerId =
        await RudderIntegrationAppsflyerReactNative.getAppsFlyerId();
      console.log('appsFlyerId', appsFlyerId);
      setOptions({
        // dev key from the appsflyer dashboard
        devKey: Config.APPSFLYER_DEV_KEY,
        // whether we want to run the appsflyer SDK in the debug mode
        isDebug: !isProd,
        // whether we want to register for the listeners which would return the conversion data
        onInstallConversionDataListener: true,
        // ID assigned by the Apple app store for any app which is either published or in the process of getting published
        appleAppId: Config.APPSFLYER_APP_ID,
        // whether we want to register for the listeners which would return the deeplink data
        onDeepLinkListener: true,
        // the number of seconds for which the appsflyer iOS SDK should wait to allow the app to retrieve the user consent.
        timeToWaitForATTUserAuthorization: 60
      });

      await rudderClient.setup(Config.RUDDERSTACK_KEY, {
        dataPlaneUrl: Config.RUDDERSTACK_DATA_PLANE_URL,
        trackAppLifecycleEvents: true,
        recordScreenViews: true,
        withFactories: [appsflyer, firebase]
      });
    };
    rudderInitialise().catch(console.error);
  }, []);
c
Hey @adventurous-petabyte-6019, If you want to send events to AppsFlyer in cloud mode destination, you don’t require to use the
setOptions
. Also please remove
appsflyer
from the
withFactories
(this is only required in case AppsFlyer is connected in device mode). In short, to send events to AppsFlyer in Cloud mode, you’ll only require:
Copy code
await rudderClient.setup(Config.RUDDERSTACK_KEY, {
        dataPlaneUrl: Config.RUDDERSTACK_DATA_PLANE_URL,
        trackAppLifecycleEvents: true,
        recordScreenViews: true,
        withFactories: [firebase] // Note: Firebase is still connected in device mode
      });
To send events from React-Native -> AppsFlyer in cloud mode, refer to our doc: https://www.rudderstack.com/docs/destinations/streaming-destinations/appsflyer/#sending-events-via-rudderstack-cloud-mode As per the Rudder-AppsFlyer doc to send events to AppsFlyer in cloud mode you need to do following thing:
To send events to AppsFlyer via cloud mode, you need the AppsFlyer ID generated by the AppsFlyer SDK that is integrated with your app. See Obtaining the AppsFlyer ID for reference.
Which basically means you first need to directly install the AppsFlyer SDK on your app -> generate the
AppsFlyer ID
-> pass that ID using Identify call. After that only event would be delivered to AppsFlyer destinations.
1
a
or I can use - @rudderstack/rudder-integration-appsflyer-react-native'
also AppsFlyer ID I can get from appsflyer sdk right?
because that code not working
Copy code
import AppsFlyerIntegrationFactory from "@rudderstack/rudder-integration-appsflyer-react-native/src/bridge"
const appsFlyerId = await AppsFlyerIntegrationFactory.getAppsFlyerId()
c
You may use any of the packages you like. For AppsFlyer React-Native package, you may follow their doc: https://dev.appsflyer.com/hc/docs/rn_api#getappsflyeruid. In case you want to use our AppsFlyer React-Native package then you actually need to use the
setOptions
and then pass the AppsFlyer inside
withFactories
, as you did previously:
Copy code
await rudderClient.setup(Config.RUDDERSTACK_KEY, {
        dataPlaneUrl: Config.RUDDERSTACK_DATA_PLANE_URL,
        trackAppLifecycleEvents: true,
        recordScreenViews: true,
        withFactories: [appsflyer, firebase]
      });
After that you actually need to call:
Copy code
const appsFlyerId = await AppsFlyerIntegrationFactory.getAppsFlyerId()
also AppsFlyer ID I can get from appsflyer sdk right?
Yes definitely, this is not dependent on our packages. We are internally using the AppsFlyer SDK to fetch this ID.
a
but for cloud version I need to remove
Copy code
withFactories
and
Copy code
setOptions
ok, so for cloud version I need to stay
Copy code
await rudderClient.setup(Config.RUDDERSTACK_KEY, {
        dataPlaneUrl: Config.RUDDERSTACK_DATA_PLANE_URL,
        trackAppLifecycleEvents: true,
        recordScreenViews: true,
        withFactories: [firebase] // Note: Firebase is still connected in device mode
      });
2. add sdk react native appsflyer 3. pass appsflyer id from sdk
Copy code
"externalId": [
  {
    "id": "AppsFlyer_ID",
    "type": "appsflyerExternalId"
  }
]
I need to pass it in method identify?
Copy code
rudderClient.identify(
          data.id,
          {
            phone: data.phone
          },
          null
        );
c
The scenario is like this: • It is true that in cloud mode you don’t require
withFactories
. • Also to send events in device mode, you first need to enable it in your RudderStack dashboard. Unless you enable over there, no event can be sent to AppsFlyer in device mode, even if you use
setOptions
and
withFactories
. • In Cloud mode, actually AppsFlyer require AppsFlyer ID which could only be generated by their SDKs. ◦ In order to generate that, you’ve to follow the steps we suggested. ◦ Internally, we are simply initialising the AppsFlyer SDK and then fetching the ID using the API they’ve provided. ◦ This could only be done when you use
setOptions
and
withFactories
. (Please follow this steps) In order to send events to AppsFlyer Cloud mode use: • `setOptions`:
Copy code
// Setting options for initializing the appsflyer sdk
setOptions({
    // dev key from the appsflyer dashboard
    "devKey": "<dev_key>",
    // whether we want to run the appsflyer SDK in the debug mode
    "isDebug": true,
    // whether we want to register for the listeners which would return the conversion data
    "onInstallConversionDataListener": true,
    // ID assigned by the Apple app store for any app which is either published or in the process of getting published
    "appleAppId": "<apple_app_id>",
    // whether we want to register for the listeners which would return the deeplink data
    "onDeepLinkListener": true,
    // the number of seconds for which the appsflyer iOS SDK should wait to allow the app to retrieve the user consent.
    "timeToWaitForATTUserAuthorization": 60
})
• Then, initialise the SDK:
Copy code
await rudderClient.setup(Config.RUDDERSTACK_KEY, {
        dataPlaneUrl: Config.RUDDERSTACK_DATA_PLANE_URL,
        trackAppLifecycleEvents: true,
        recordScreenViews: true,
        withFactories: [appsflyer, firebase] // Note: AppsFlyer is present over here
      });
• Pass AppsFlyer ID in identify call, for the correct steps, refer to our doc here: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-react-native-sdk/#setting-a-custom-id
Copy code
const options = {
  "externalId": [
  {
    "id": "AppsFlyer_ID",
    "type": "appsflyerExternalId"
  }
  ]
}
rudderClient.identify(
  "1hKOmRA4GRlm",
  {
    email: "<mailto:alex@example.com|alex@example.com>",
    location: "UK",
  },
  options
)
Please Note: 1. Whenever you call our
RESET
API, it will clear the existing externalId, and then you again need to make an identify call with the externalId, otherwise event wouldn’t be sent.