Links

Fire Events

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.
You can follow Developers -> Events and click the Create New Event button to generate your custom event.
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.

Pre-defined Events

You send events easily with the following code patterns,
Swift
Objective-C
Kotlin
Java
Flutter
React Native
Cordova
Web
// Generate event instance
// This can be any NetmeraEvent subclass
let event = NetmeraLoginEvent(userId: "USER_ID")
// Send event
Netmera.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 event
var event: NetmeraEventLogin = NetmeraEventLogin("USER_ID") // Send event
// Generate event instance
// This can be any NetmeraEvent subclass
NetmeraEventLogin event = new NetmeraEventLogin("USER_ID");
// Send event
Netmera.sendEvent(event);
void sendLoginEvent() {
NetmeraEventLogin loginEvent = new NetmeraEventLogin();
Netmera.sendEvent(loginEvent);
}
const sendLoginEvent = () => {
const loginEvent = new LoginEvent();
loginEvent.setUserId(<userId>);
Netmera.sendEvent(loginEvent)
}
After React Native 1.5.0 Update:
With the React Native version 1.5.0 update, events are now extended from NetmeraEvent:
import {NetmeraEvent} from "react-native-netmera";
class LoginEvent extends NetmeraEvent {
code = "n:cl";
set userId(userId) {
this.uid = userId
}
set userIda(userId) {
this.uida = userId
}
set userIdax(userId) {
this.uidas = userId
}
}
You add following class to your project:
export class LoginEvent extends NetmeraEvent {
private code = "n:cl"
private uid: string;
set userId(value: string) {
this.uid = value
}
}
You can trigger event as following:
let loginEvent = new LoginEvent();
loginEvent.userId = "SampleUserId";
this.netmera.sendEvent(loginEvent);
You can add the default events to your code with javascript or you can also create the payload for that event.
netmera.push(function (api) {
const LoginEvent = {
code: "n:cl",
uid : userId,
fl : utmSource,
fo : utmMedium,
fp : utmCampaign,
};
api.sendEvent(LoginEvent);
});

Custom Events

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.
Swift
Objective-C
Android
Flutter
React Native
var event = SampleEvent()
event.intParameter = 2147483647
event.stringParameter = "String Parameter"
event.stringArrayParameter = ["Member1", "Member2"]
event.doubleParameter = 7.99
event.booleanParameter = true //true or false
event.longParameter = 9223372036854775807
event.dateParameter = Date()
event.timestampParameter = Date()
Netmera.send(event)
SampleEvent *event = [SampleEvent event];
event.intParameter = 2147483647;
event.stringParameter = @"String Parameter";
event.stringArrayParameter = @[@"Member1", @"Member2"];
event.doubleParameter = 7.99;
event.booleanParameter = true; //true or false
event.longParameter = 9223372036854775807;
event.dateParameter = [NSDate date];
event.timestampParameter = [NSDate date];
[Netmera sendEvent:event];
SampleEvent event = new SampleEvent();
event.setIntParameter(34);
event.setIntParameter(2147483647);
event.setStringParameter("String Parameter");
List<String> myArray = new ArrayList<>();
myArray.add("Member1");
myArray.add("Member2");
event.setStringArrayParameter(myArray);
event.setDoubleParameter(7.99);
event.setBooleanParameter(true); //true or false
event.setLongParameter(9223372036854775807L);
event.setDateParameter(new Date());
event.setTimestampParameter(new Date());
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.
import 'package:netmera_flutter_sdk/events/media/NetmeraEvent.dart'; import 'package:quiver/core.dart';
import 'dart:core';
class SampleEvent extends NetmeraEvent{
final String _EVENT_CODE = "puzzf";
SampleEvent() : super();
@override
String eventCode() {
return _EVENT_CODE;
}
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> map = super.toJson();
return map;
}
}
const sendSampleEvent = () => {
const sampleEvent = new SampleEvent();
sampleEvent.sampleAttribute = "SampleAttribute";
Netmera.sendEvent(sampleEvent);
}

Import Event Definition

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.