react-native-aws-mobile-analytics icon indicating copy to clipboard operation
react-native-aws-mobile-analytics copied to clipboard

[Function:(AMA.Manager).recordEvent: Client is not initialized]

Open Msspl-PrashenjeetRoy opened this issue 7 years ago • 3 comments

I am testing https://github.com/innFactory/react-native-aws-mobile-analytics demo app and changed the appId to mine. When clicking on Send an event button it showing xcode console with this text [Function:(AMA.Manager).recordEvent: Client is not initialized].

Can you just tell me is it a issue with config or something else. Till then I am waiting for 60minutes. As it's saying it will take 60 minutes minimum to show in aws.

Msspl-PrashenjeetRoy avatar Oct 24 '17 10:10 Msspl-PrashenjeetRoy

@jona7o Can you please tell me, How do I get the data in AWS dashboard. It's not coming. Is it the right library to work with react native & aws mobile analytics.

What I did: 1- I download your demo app. 2- npm install it. 3- link it. 4- run it with my appId (which I created in aws mobile analytics)

Where I am wrong and how do I fix it.

my MobileAnalytics.js file

import AWS from "aws-sdk/dist/aws-sdk-react-native";
import AMA from "react-native-aws-mobile-analytics";
import {
    Platform,
} from 'react-native';
import DeviceInfo from "react-native-device-info";

AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    region: 'us-east-1',
    IdentityPoolId: 'xxxx-just-hidin-it-confidential-xxxx', // using the pool id from aws 
});


let options = {
    appId: 'xxxx-just-hidin-it-confidential-xxxx', // using appid from aws mobile analytics
    appTitle : "Example App", 
    appVersionName: '1.0.0',
    platform : Platform.OS === 'ios' ? 'iPhoneOS' : 'Android',
    appPackageName: 'org.reactjs.native.example.analyticsDemo'
};

const MobileAnalyticsClient  = new AMA.Manager(options);

export default MobileAnalyticsClient;

Msspl-PrashenjeetRoy avatar Oct 24 '17 12:10 Msspl-PrashenjeetRoy

@Msspl-PrashenjeetRoy hi and thanks for your issue.

Yepp, this lib is for AWS Mobile Analytics to measure Daily/Monthly Users and so on and have this stats in your dashboard.

Did you run it on iOS or Android?

It's important to know that the cognito credetials are the "global mobile analytics" of aws not yours. It's for aws internal. So please use following:

AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    region: 'us-east-1',
    IdentityPoolId: 'us-east-1:4c6d17ff-9eb1-4805-914d-8db8536ab130',
});

spoeck avatar Oct 25 '17 12:10 spoeck

@spoeck I was testing on iOS simulator. I am using cognito credetials from aws dashboard.

Added a newapp there inside aws mobile analytics and got the credential in Javascript tab (implementation tabs for all platform). I am working with react native that's why I used the credential from javascript tab. Also using IdentityPoolId from aws app.

You are suggesting me to use

AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    region: 'us-east-1',
    IdentityPoolId: 'us-east-1:4c6d17ff-9eb1-4805-914d-8db8536ab130',
});

But IdentityPoolId must be unique right? from app to app it must be different right? Am I correct!

Msspl-PrashenjeetRoy avatar Oct 27 '17 06:10 Msspl-PrashenjeetRoy