@inngageregistry/inngage-react 3.1.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inngageregistry/inngage-react",
3
- "version": "3.1.2",
3
+ "version": "3.2.0",
4
4
  "description": "Inngage Plugin for React Native applications for marketing campaign optimization using Push Notification.",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.d.ts",
package/src/Inngage.ts CHANGED
@@ -3,7 +3,7 @@ import DeviceInfo from "react-native-device-info";
3
3
  import * as RNLocalize from "react-native-localize";
4
4
  import AsyncStorage from '@react-native-async-storage/async-storage';
5
5
 
6
- import { formatDate, subscriptionRequestAdapter } from "./utils";
6
+ import { eventRequest, formatDate, subscriptionRequestAdapter } from "./utils";
7
7
  import notificationsListener, { notificationsListenerProps } from "./notificationsListener";
8
8
  import { subscriptionApi, eventsApi } from "./services/inngage";
9
9
 
@@ -87,6 +87,17 @@ interface SendEventProps {
87
87
  }
88
88
  },
89
89
  }
90
+
91
+ interface SendEventProps {
92
+ appToken: string,
93
+ identifier: string,
94
+ eventName: string,
95
+ conversionEvent?: boolean,
96
+ conversionValue?: number,
97
+ conversionNotId?: string,
98
+ eventValues?: any
99
+ }
100
+
90
101
  const Inngage = {
91
102
  // ------------ Register Notification Listener ------------//
92
103
  RegisterNotificationListener: async (props: notificationsListenerProps) => {
@@ -150,14 +161,36 @@ const Inngage = {
150
161
  return { subscribed: false };
151
162
  }
152
163
  },
153
- SendEvent: async (props: SendEventProps) => {
164
+
165
+ SendEvent: async ({
166
+ appToken,
167
+ identifier,
168
+ eventName,
169
+ conversionEvent,
170
+ conversionValue,
171
+ conversionNotId,
172
+ eventValues,
173
+ }: SendEventProps) => {
174
+
175
+ const rawRequest = {
176
+ newEventRequest: {
177
+ app_token: appToken,
178
+ identifier: identifier,
179
+ event_name: eventName,
180
+ conversion_event: conversionEvent ?? false,
181
+ conversion_value: conversionValue ?? 0,
182
+ conversion_notid: conversionNotId ?? '',
183
+ event_values: eventValues ?? {}
184
+ }
185
+ };
186
+
187
+ const request = eventRequest(rawRequest)
154
188
  try {
155
- return await eventsApi(props);
189
+ return await eventsApi(request);
156
190
  } catch (e) {
157
191
  console.error(e)
158
192
  return { subscribed: false };
159
193
  }
160
-
161
194
  }
162
195
  }
163
196
 
package/src/index.d.ts CHANGED
@@ -17,20 +17,13 @@ interface SubscriptionProps {
17
17
  }
18
18
 
19
19
  interface SendEventProps {
20
- newEventRequest: {
21
- app_token: string;
22
- identifier: string;
23
- event_name: string;
24
- conversion_event: boolean;
25
- conversion_value: number;
26
- conversion_notid: string;
27
- event_values: {
28
- nome_promo: string;
29
- categoria: string;
30
- foto_promo: string;
31
- redirect_link: string;
32
- };
33
- };
20
+ appToken: string,
21
+ identifier: string,
22
+ eventName: string,
23
+ conversionEvent?: boolean,
24
+ conversionValue?: number,
25
+ conversionNotId?: string,
26
+ eventValues?: any
34
27
  }
35
28
 
36
29
  declare const Inngage: {
package/src/utils.ts CHANGED
@@ -40,6 +40,10 @@ export const subscriptionRequestAdapter = (sdkRequest, useCustomData, customData
40
40
  };
41
41
  }
42
42
 
43
+ export const eventRequest = (request) => {
44
+ return { ...request }
45
+ }
46
+
43
47
  export const isEmpty = (obj: any) => {
44
48
  for (var prop in obj) {
45
49
  if (obj.hasOwnProperty(prop)) {