betaacid / expo-analytics

Google Analytics integration for use with React Native apps built on Expo
MIT License
288 stars 63 forks source link

When setting uid, uid is not contained in Analytics object #11

Closed mfru closed 6 years ago

mfru commented 6 years ago

I'm trying to send the uids of my users but having trouble with it.

Right now my code for initialising an Analytics object is this:

setGAInstanceWithUID(uid) {
    if (!uid) {
      console.warn("No uid was passed.");
      return;
    }

    if (uid === this._uid) {
      console.warn("uid already passed");
      return;
    }

    this._GAInstance = new ExpoAnalyticsProvider.Analytics(this._analyticsId, {
      uid,
    });
  }

I first thought that it is me, but when I test a fresh object like this:

 const analytics = new ExpoAnalyticsProvider.Analytics("test1234", {
      uid: "testUid",
    });

    console.log("Testing expo analytics", analytics);

the result is:

Testing expo analytics Analytics {
        customDimensions: [],
        propertyId: 'test1234',
        options: { debug: false },
        clientId: 'a01650bb-918d-40be-87be-cf376ab6189f',
        promiseGetWebViewUserAgentAsync: Promise { _40: 0, _65: 0, _55: null, _72: null } }

I looked through the expo-analytics source code, but did not find an error yet, so I'm wondering where the uid is getting lost.

It would be great if someone spotted something that might be off :)

ryanvanderpol commented 6 years ago

@mfru good question. at first glance, this seems like it should work as you expect. Can you try turning on debugging and see what the URL that gets constructed looks like?

strangeways commented 6 years ago

@mfru @ryanvanderpol The parameters don't get added to the object until Constants.getWebViewUserAgentAsync() resolves. Try:

analytics.promiseGetWebViewUserAgentAsync
.then(() => {
  console.log("Testing expo analytics", analytics);
});
mfru commented 6 years ago

Sorry for not answering, I am not involved in the project anymore, so I can't say if it resolves the issue.

Should I close it?