Before initiating the firing of your events, it's crucial to ensure that these events have been properly set up in the Netmera Panel. This step is essential to guarantee that your events are accurately tracked and managed. For comprehensive guidance on how to create and configure your custom events, please consult the detailed instructions provided in the Creating Custom Events guide.
If events provided by the SDK do not completely satisfy your needs, you can also generate your own event classes using Netmera Dashboard. If the custom event is to be created on the Netmera, it must first be defined in the panel.
You may extend your custom event subclass from one of the built-in event subclasses, or from the base NetmeraEvent class. You can select the data type of the parameters, make them array or set them as mandatory. If you do not send a mandatory parameter you will get error (bad request) and your request will be rejected.
In the end, Netmera Dashboard will automatically generate source files for your custom event, so that you can just add them to your project and use without any hassle.
You send events easily with the following code patterns,
// Generate event instance// This can be any NetmeraEvent subclasslet event =NetmeraLoginEvent(userId:"USER_ID")// Send eventNetmera.send(event!)
// Generate event instance
// This can be any NetmeraEvent subclass
NetmeraLoginEvent *event = [NetmeraLoginEvent eventWithUserId:@"USER_ID"];
// Send event
[Netmera sendEvent:event];
// Generate event instance// This can be any NetmeraEvent subclass// Send eventvar event: NetmeraEventLogin=NetmeraEventLogin("USER_ID") // Send event
// Generate event instance// This can be any NetmeraEvent subclassNetmeraEventLogin event =newNetmeraEventLogin("USER_ID");// Send eventNetmera.sendEvent(event);
After you add the source files to your project, you can fire that custom events like the codes below,
Generated Code Import:
When you create an event on the panel, you will receive a code. You are supposed to import the code the panel created for you in your project. Below you will see examples.
var event =SampleEvent()event.intParameter =2147483647event.stringParameter ="String Parameter"event.stringArrayParameter = ["Member1", "Member2"]event.doubleParameter =7.99event.booleanParameter =true//true or falseevent.longParameter =9223372036854775807event.dateParameter =Date()event.timestampParameter =Date()Netmera.send(event)
SampleEvent event =newSampleEvent();event.setIntParameter(34);event.setIntParameter(2147483647);event.setStringParameter("String Parameter");List<String> myArray =newArrayList<>();myArray.add("Member1");myArray.add("Member2");event.setStringArrayParameter(myArray);event.setDoubleParameter(7.99);event.setBooleanParameter(true); //true or falseevent.setLongParameter(9223372036854775807L);event.setDateParameter(newDate());event.setTimestampParameter(newDate());Netmera.sendEvent(event);
Important Note
If you need to edit your event, add or change any event attributes you should always manage custom events and event attributes from Netmera Dashboard. Event attributes without SerializedName anotations, will be rejected.
When you have multiple applications within the Netmera Panel, you have the capability to import events that were initially generated for one application into another. This feature allows you to efficiently share and utilize events across different applications within the Netmera ecosystem.
How to Import Events?
To import your events into different applications, follow these simple instructions. Start by navigating to the "Developers" section and selecting "Events."
From there, click on "Import Event Definition" Next, choose the "Application Name" from which you want to transfer events. In the list of custom events below, carefully select the specific event you wish to import.
To complete the process, click the "Import" button, which you'll find in the "Action" section.