Hi guys. I’m having an issue with event tracking. ...
# support
b
Hi guys. I’m having an issue with event tracking. The project uses React Native and Expo. During the RudderStack initialization, I get the application lifecycle events in the console. However, I can’t capture the event that I’m triggering. Can anyone suggest what I might be doing wrong?
Copy code
export const rudderInitialise = async () => {
    try {
        await rudderClient.setup('MY_KEY', {
            dataPlaneUrl: 'MY_DATA_PLANE_URL',
        });
        await rudderClient.optOut(true);
        console.log('Rudder SDK is initalised');
    } catch (error) {
        console.log(error);
    }
};

export const trackScreen = (route: string) => {
    rudderClient.screen(route);
};

export const trackError = (error: AxiosError<ResponseError>) => {
    const originalConfig = error.config;
    const statusCode = error?.response?.status;
    const errorMassage = error?.response?.data.message;

    rudderClient.track('API ERROR', {
        errorCode: statusCode,
        url: originalConfig.url,
        message: errorMassage,
    });
};
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
Hi Andrew which console are you taking about? Also are you setting withTrackLifecycleEvents as false? `However, I can’t capture the event that I’m triggering`⁣ Are you unable to see the application life cycle events in the source-live events?
b
Hi @shy-kite-21035. Thank you for the quick response! I can see the lifecycle events in the source-live events (it’s like a test to see if the client is initialized). But I don’t see the other events that I’m tracking in the app. I can’t figure out what I’m doing wrong.
It seems as if the client instance I’m referencing after initialization isn’t initialized. At the same time, my dev console suggests otherwise. )))
m
Do you see any errors being logged? You can use the LOG_LEVEL: debug to do so https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-react-native-sdk/#debugging
👍 1
b
I’ll check and get back to you. Thank you
image.png
image.png
m
Could this be a scoping issue? Since you are calling it in the Try {} catch block? Also can you try calling the rudderInitialize() function within useEffects() as shown here
b
My problem in optOut. ))) Solved. Thanks man
m
Cool :)