The Event object helps you create custom events and event parameters in different data types. This article explains how you can build events and parameters in various data types.
Set tag event
This method returns a new chainable Insider event object in which you can add parameters.
| Parameter | Data Type |
|---|---|
| eventName | String |
Method Signature
static tagEvent(name: string): RNInsiderEventMethod Example
// You can create an event without parameters and call the build method
RNInsider.tagEvent('eventname').build();
// You can create an event, then add parameters and call the build method
RNInsider.tagEvent('eventname').addParameterWithInt('key', 10).build();
// You can create an object and add the parameters later
var insiderExampleEvent = RNInsider.tagEvent('eventname');
// Do not forget to call build method once you are done with parameters
// Otherwise your event will be ignored
insiderExampleEvent.build();Build event
This method allows you to build your Insider event object.
Method Signature
build()Method Example
insiderExampleEvent.build();Set string parameter
This method allows you to set the string parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | String |
The value can be up to 50,000 characters. For arrays, the limit applies to each string. An event with a longer value isn't recorded.
Method Signature
addParameterWithString(key: string, value: string)Method Example
// You can create an event then add parameters and call the build method
RNInsider.tagEvent('eventname').addParameterWithString('key', 'value');
// You can create an object and add the parameters later
var insiderExampleEvent = RNInsider.tagEvent('eventname');
insiderExampleEvent.addParameterWithString('key', 'value');
// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();Set integer parameter
This method allows you to set the integer parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Integer |
Method Signature
addParameterWithInt(key: string, value: number)Method Example
// You can create an event then add parameters and call the build method
RNInsider.tagEvent('eventname').addParameterWithInt('key', 10);
// You can create an object and add the parameters later
var insiderExampleEvent = RNInsider.tagEvent('eventname');
insiderExampleEvent.addParameterWithInt('key', 10);
// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();Set double parameter
This method allows you to set the double parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Double |
Method Signature
addParameterWithDouble(key: string, value: number)Method Example
// You can create an event then add parameters and call the build method
RNInsider.tagEvent('eventname').addParameterWithDouble('key', 10.5);
// You can create an object and add the parameters later
var insiderExampleEvent = RNInsider.tagEvent('eventname');
insiderExampleEvent.addParameterWithDouble('key', 10.5);
// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();
Set date parameter
This method allows you to set the date parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Date |
Method Signature
addParameterWithDate(key: string, value: Date)Method Example
// You can create an event then add parameters and call the build method
RNInsider.tagEvent('eventname').addParameterWithDate('key', new Date());
// You can create an object and add the parameters later
var insiderExampleEvent = RNInsider.tagEvent('eventname');
insiderExampleEvent.addParameterWithDate('key', new Date());
// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();Set array of string parameter
This method allows you to set the array of string parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Array (of string) |
The value can be up to 50,000 characters. For arrays, the limit applies to each string. An event with a longer value isn't recorded.
Method Signature
addParameterWithStringArray(key: string, value: Array<string>): InsiderEventMethod Example
const stringArray = ['value1', 'value2', 'value3'];
RNInsider.tagEvent('eventName')
.addParameterWithStringArray('key', stringArray)
.build();Set array of number parameter
This method allows you to set the array of number parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | Number |
| value | Array (of number) |
Method Signature
addParameterWithNumericArray(key: string, value: Array<number>): InsiderEventMethod Example
const numberArray = [5, 3.14, 100];
RNInsider.tagEvent('eventName')
.addParameterWithNumericArray('key', numberArray)
.build();Set boolean parameter
This method allows you to set the boolean parameter of your Insider event object.
| Parameter | Data Type |
|---|---|
| key | String |
| value | Boolean |
Method Signature
addParameterWithBoolean(key: string, value: boolean)Method Example
// You can create an event then add parameters and call the build method
RNInsider.tagEvent('eventname').addParameterWithBoolean('key', true);
// You can create an object and add the parameters later
var insiderExampleEvent = RNInsider.tagEvent('eventname');
insiderExampleEvent.addParameterWithBoolean('key', true);
// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();Add an Array of Objects event parameter
Use this method to attach a list of objects to an event as a parameter. Define the event parameter in the panel first; see Create an Array of Objects Attribute.
Rules for object values:
- Object keys must match ^[a-z][0-9a-z_]*$. Invalid keys are dropped and named in a console warning; the rest of the call is still sent.
- An attribute or parameter key that is empty, whitespace-only, or does not match the same pattern (e.g., camelCase cartItems) is refused with a console warning; the parameter is dropped, and the event is still sent.
- A string value longer than 500 characters is dropped with its key.
- A nested object can hold only plain values; an object inside a nested object is dropped with its key. For example, { a: { b: 1 } } is sent as is, while in { a: { b: { c: 1 }, d: 2 } } b is dropped, and a is sent with d only.
- A Set<string> or Set<number> value is sent as an array. Empty or mixed Sets and empty arrays are dropped; undefined property values are skipped.
- Invalid dates are dropped per entry; the rest of the call is still sent.
Call addParameterWithObjectArray on an event to attach one object or a list of objects as a parameter. A single object is sent as a one-element list.
| Parameter | Data Type | Description |
|---|---|---|
| key | string | Key of the Array of Objects event parameter defined in the panel. |
| value | InsiderObject | InsiderObject[] | The object or list of objects to send. |
Method Signature
addParameterWithObjectArray(key: string, value: InsiderObject | InsiderObject[]): this;Method Example
import Insider from 'react-native-insider';
Insider.tagEvent('purchase_completed')
.addParameterWithObjectArray('c_order_lines', [
{ sku: 'SKU-1', qty: 2, unit_price: 19.9 },
{ sku: 'SKU-2', qty: 1, unit_price: 5.5 },
])
.build();Array of Objects event parameters are insert-only. A list that carries nothing adds no parameter, and a console warning says so.