amplitude / unity-plugin

Official Amplitude Unity Plugin
https://developers.amplitude.com/docs/unity
MIT License
44 stars 34 forks source link

Can't get past "Listen for Event" for Unity source setup #91

Closed kyleqian closed 2 years ago

kyleqian commented 2 years ago

I'm trying to do the initial setup steps for the Unity SDK to connect it with my account, but I can't get past the part of the setup where I log my first event.

Expected Behavior

Amplitude setup page receives the log event from my editor, updates, and lets me continue setting up my project.

Current Behavior

Nothing happens.

Possible Solution

n/a

Steps to Reproduce

  1. Log in Monobehaviour, in editor:
    private async void Awake() {
        var amplitude_ = Amplitude.getInstance();
        amplitude_.setServerUrl("https://api2.amplitude.com");
        amplitude_.logging = true;
        amplitude_.trackSessionEvents(true);
        amplitude_.init({API KEY});
        amplitude_.logEvent("EVENT_NAME_HERE"); // Confirmed this logs "C# sendEvent EVENT_NAME_HERE" into console
    |
  2. See C# sendEvent EVENT_NAME_HERE and C# init {API KEY} in the Unity console.
  3. Spinning "Listening…" doesn't update on site.

Environment

dantetam commented 2 years ago

Hello @kyleqian ,

1) Confirm that you are using the correct API key. 2) Sometimes the events are slow to update. On the left sidebar of the Amplitude website, click on User & Account Look-Up Screen Shot 2021-09-22 at 8 38 14 AM

Check this, as well as the workspace field that says Events This Month on the project dashboard area. Screen Shot 2021-09-22 at 8 41 53 AM

kyleqian commented 2 years ago

I wasn't able to see any of the dashboard until I set up a working data source, so I just did it with the HTTP api via curl. That worked, which confirms that the key is correct and that my computer is capable of sending log events (so probably the issue is local to my Unity setup?).

On the Unity setup page I still see this, without any change: Screen Shot 2021-09-22 at 11 25 57

I see this on my dashboard (the one event there is the one that went through testing the HTTP api. Elsewhere it also says Events this month is just 1): Screen Shot 2021-09-22 at 11 26 16

This is my Unity console:

Screen Shot 2021-09-22 at 11 33 30
dantetam commented 2 years ago

Hello @kyleqian ,

You should configure the app to build on Android or iOS. Our Unity SDK does not work for pure desktop yet. See Build Settings and then Switch Platform. You see should output in logcat or xcode for the respective mobile platform

kyleqian commented 2 years ago

The project is already set for iOS - but you're saying it isn't possible to test in the editor, and that it only works once I build to a device? Is there no way to make it work in the editor besides, say, using the HTTP api then?

dantetam commented 2 years ago

Yes, do not test in the Unity editor. On say a MacBook with an iOS Unity app, you may emulate a device to test on with xcode. Otherwise, I assume you are some other platform, and need to test some other way.

kyleqian commented 2 years ago

I see, I think that needs to be clearer in the setup, that you can't do this from the editor: Screen Shot 2021-09-22 at 12 45 55

dantetam commented 2 years ago

I agree with you. I'll update this source as well as the Developer Docs for Unity. Will close this issue when I'm done

dantetam commented 2 years ago

It's been fixed some time ago. Thank you for the callout @kyleqian

SirPax commented 2 years ago

I'm having the same problem but with Android. AND when running from Android device (not in editor).

console says "event sent" but the setup page keeps at "Listening...".

Any help would be greatly appreciated.