Hello, I'm trying to setup Rudderstack into my Uni...
# support
c
Hello, I'm trying to setup Rudderstack into my Unity project, I've put this code in Awake function:
RudderClient.SerializeSqlite();
RudderConfig config = new RudderConfigBuilder()
.WithDataPlaneUrl("https://***.dataplane.rudderstack.com")
.Build();
RudderClient rudderClient = RudderClient.GetInstance("********Dc6wXH5V1VZ4MTAUQ4", config);
Debug.Log(rudderClient);
but
rudderClient
object still has the value null.. is that normal? if not what's went wrong?
I added
.WithLogLevel(RudderLogLevel.VERBOSE)
and this is the logs:
c
Can you please try making a sample track calls, refer the doc: https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-unity-sdk/#track And let us know if that works or not.
c
I did and the code worked without errors but no events found in the dashboard
c
Please raise a Bug report for this issue by following the link to our GitHub issue page: https://github.com/rudderlabs/rudder-sdk-unity/issues/new/choose
c
Alright thanks. I got this error now:
Object reference not set to an instance of an object
on the track line. I think it's because of the null object of RudderClient, is that can help with anything?
private void UserVisit()
{
string userName = PlayerPrefs.GetString("Username");
string userEmail = PlayerPrefs.GetString("email");
string colorPicked = PlayerPrefs.GetString("Color"); ;
string clientVersion = Application.version.ToString();
string platform = Application.platform.ToString();
DateTime visitTime = DateTime.Now;
// create event properties
Dictionary<string, object> eventProperties = new Dictionary<string, object>
{
{ "color_picked", colorPicked },
{ "ip_address", ipAddress },
{ "country", userCountry },
{ "platform", platform },
{ "client-version", clientVersion },
{ "visit_time", visitTime.ToString() }
};
// create user properties
Dictionary<string, object> userProperties = new Dictionary<string, object>
{
{ "user_name", userName },
{ "user_email", userEmail }
};
// create message to track
RudderMessageBuilder builder = new RudderMessageBuilder();
builder.WithEventName("Player-Visit-WEB");
builder.WithEventProperties(eventProperties);
builder.WithUserProperties(userProperties);
Debug.Log("Sending tracking event...");
try
{
rudderClient.Track(builder.Build());
Debug.Log("Tracking event sent successfully");
Destroy(this);
}
catch (Exception ex)
{
Debug.LogError("Failed to send tracking event: " + ex.Message);
}
}
This is the Track code
c
Let's put all the info in the GitHub issue (link shared above), we will investigate the issue and let you know.
c
Alright I will, Thanks. BTW the project I work on is for WebGL, is that a problem for RudderStack SDK?
c
Actually, I’m not a Unity SDK developer, so I cannot assist you properly with the above question. Once you create the issue, the concerned team member will look into it and assist you with the answer. Please include above queries as well while creating issue.
👍 1