mapp-intelligence-reactnative-plugin 1.0.1 → 1.0.2

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.
Files changed (38) hide show
  1. package/android/gradle.properties +3 -3
  2. package/android/src/main/java/com/mappinteligenceplugin/mapper/Util.kt +12 -4
  3. package/lib/commonjs/Converters.js +1 -1
  4. package/lib/commonjs/Converters.js.map +1 -1
  5. package/lib/commonjs/GlobalErrorHandler.js +2 -6
  6. package/lib/commonjs/GlobalErrorHandler.js.map +1 -1
  7. package/lib/commonjs/MappIntelligencePlugin.js +298 -0
  8. package/lib/commonjs/MappIntelligencePlugin.js.map +1 -0
  9. package/lib/commonjs/UseWebTracking.js +5 -9
  10. package/lib/commonjs/UseWebTracking.js.map +1 -1
  11. package/lib/commonjs/index.js +14 -390
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/promiseRejectionHandler.js.map +1 -1
  14. package/lib/module/Converters.js +1 -1
  15. package/lib/module/Converters.js.map +1 -1
  16. package/lib/module/GlobalErrorHandler.js +2 -6
  17. package/lib/module/GlobalErrorHandler.js.map +1 -1
  18. package/lib/module/MappIntelligencePlugin.js +292 -0
  19. package/lib/module/MappIntelligencePlugin.js.map +1 -0
  20. package/lib/module/UseWebTracking.js +5 -8
  21. package/lib/module/UseWebTracking.js.map +1 -1
  22. package/lib/module/index.js +2 -320
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/module/promiseRejectionHandler.js.map +1 -1
  25. package/lib/typescript/src/DataTypes.d.ts +6 -6
  26. package/lib/typescript/src/DataTypes.d.ts.map +1 -1
  27. package/lib/typescript/src/GlobalErrorHandler.d.ts.map +1 -1
  28. package/lib/typescript/src/MappIntelligencePlugin.d.ts +201 -0
  29. package/lib/typescript/src/MappIntelligencePlugin.d.ts.map +1 -0
  30. package/lib/typescript/src/UseWebTracking.d.ts.map +1 -1
  31. package/lib/typescript/src/index.d.ts +2 -200
  32. package/lib/typescript/src/index.d.ts.map +1 -1
  33. package/package.json +25 -21
  34. package/src/Converters.tsx +1 -1
  35. package/src/GlobalErrorHandler.tsx +3 -6
  36. package/src/MappIntelligencePlugin.tsx +394 -0
  37. package/src/UseWebTracking.tsx +12 -12
  38. package/src/index.tsx +2 -410
package/src/index.tsx CHANGED
@@ -1,414 +1,6 @@
1
- import { NativeModules, Platform } from 'react-native';
2
- import type {
3
- CampaignParameters,
4
- EcommerceParameters,
5
- EventParameters,
6
- ExceptionType,
7
- LogLevel,
8
- MediaEvent,
9
- PageParameters,
10
- SessionParameters,
11
- UserCategories,
12
- } from './DataTypes';
13
- import {
14
- convertCampaignParameters,
15
- convertEcommerceParameters,
16
- convertEventParameters,
17
- convertMediaEvent,
18
- convertPageParameters,
19
- convertSessionParamters,
20
- convertUserCategories,
21
- } from './Converters';
22
-
23
- const LINKING_ERROR =
24
- `The package 'mapp-intelligence-reactnative-plugin' doesn't seem to be linked. Make sure: \n\n` +
25
- Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
26
- '- You rebuilt the app after installing the package\n' +
27
- '- You are not using Expo Go\n';
28
-
29
- export const MappIntelligencePlugin = NativeModules.MappinteligencePlugin
30
- ? NativeModules.MappinteligencePlugin
31
- : new Proxy(
32
- {},
33
- {
34
- get() {
35
- throw new Error(LINKING_ERROR);
36
- },
37
- }
38
- );
39
-
40
- /**
41
- * Builds plugin with a provided configuration. After this method finishes, plugin is ready for use.
42
- * @returns result if method executed succesfully or not
43
- */
44
- export const build = (): Promise<number> => {
45
- console.log('build');
46
- return MappIntelligencePlugin.build();
47
- };
48
-
49
- /**
50
- * Initialize plugin with a provided trackIds and domain
51
- * @param trackIDs array of trackIds
52
- * @param domain tracking domain url
53
- * @returns result if method executed succesfully or not
54
- */
55
- export const initWithConfiguration = (
56
- trackIDs: number[],
57
- domain: string
58
- ): Promise<number> => {
59
- console.log('initWithConfiguration');
60
- return MappIntelligencePlugin.initWithConfiguration(trackIDs, domain);
61
- };
62
-
63
- /**
64
- * Set log level to define what will be logged to the console
65
- * @param level log level
66
- * @returns result if method executed succesfully or not
67
- */
68
- export const setLogLevel = (level: LogLevel): Promise<number> => {
69
- console.log('setLogLevel - ' + level.valueOf());
70
- return MappIntelligencePlugin.setLogLevel(level.valueOf());
71
- };
72
-
73
- /**
74
- * Set exception log level
75
- * @param level one of the predefined exception types
76
- * @returns result if method executed succesfully or not
77
- */
78
- export const setExceptionLogLevel = (level: ExceptionType): Promise<number> => {
79
- return MappIntelligencePlugin.setExceptionLogLevel(level);
80
- };
81
-
82
- /**
83
- * Sets interval in minutes, for periodic job to execute and send tracked requests to a server
84
- * @param interval number in minutes. The minimum is 15, limited by Android specification for a worker.
85
- * @returns result if method executed succesfully or not
86
- */
87
- export const setRequestInterval = (interval: number): Promise<number> => {
88
- console.log('setRequestInterval');
89
- return MappIntelligencePlugin.setRequestInterval(interval);
90
- };
91
-
92
- /**
93
- * If sets to true, request will be send in a batch (multiple records in single network call);
94
- * Otherwise records are sent one record by one network call.
95
- * @param enabled speciffy if batch is enabled or disabled
96
- * @returns result if method executed succesfully or not
97
- */
98
- export const setBatchSupportEnabled = (enabled: boolean): Promise<number> => {
99
- console.log('setBatchSupportEnabled');
100
- return MappIntelligencePlugin.setBatchSupportEnabled(enabled);
101
- };
102
-
103
- /**
104
- * iOS Only - Enable sending data while application is in a background state
105
- * @param enabled
106
- * @returns result if method executed succesfully or not
107
- */
108
- export const setEnableBackgroundSendout = (
109
- enabled: boolean
110
- ): Promise<number> => {
111
- console.log('setEnableBackgroundSendout');
112
- return MappIntelligencePlugin.setEnableBackgroundSendout(enabled);
113
- };
114
-
115
- /**
116
- * Set number of track records to send in a sigle batch request
117
- * @param size number of track records
118
- * @returns result if method executed succesfully or not
119
- */
120
- export const setBatchSupportSize = (size: number): Promise<number> => {
121
- console.log('setBatchSupportSize');
122
- return MappIntelligencePlugin.setBatchSupportSize(size);
123
- };
124
-
125
- /**
126
- * Requests are buffered in a queue before sending. This option set size of the queue.
127
- * @param numberOfRequsts size of a queue for buffering requests
128
- * @returns result if method executed succesfully or not
129
- */
130
- export const setRequestPerQueue = (
131
- numberOfRequsts: number
132
- ): Promise<number> => {
133
- console.log('setRequestPerQueue');
134
- return MappIntelligencePlugin.setRequestPerQueue(numberOfRequsts);
135
- };
136
-
137
- /**
138
- * Control if migration should be applied from a previos SDK version.
139
- * @param migrate true to apply migration on the initialization process; otherwise false
140
- * @returns result if method executed succesfully or not
141
- */
142
- export const setShouldMigrate = (migrate: boolean): Promise<number> => {
143
- console.log('setShouldMigrate');
144
- return MappIntelligencePlugin.setShouldMigrate(migrate);
145
- };
146
-
147
- /**
148
- * Based on the result of the user's conset to allow personalized tracking or not,
149
- * enable anonymous tracking when no consent. If enabled, everId will be deleted (and not generated until anonymous tracking is enabled)
150
- * @param anonymous true to enable anonymous tracking; false to disable it.
151
- * @returns result if method executed succesfully or not
152
- */
153
- export const setAnonymousTracking = (anonymous: boolean): Promise<number> => {
154
- console.log('setAnonymousTracking');
155
- return MappIntelligencePlugin.setAnonymousTracking(anonymous);
156
- };
157
-
158
- /**
159
- * Send application version as parameter in every request
160
- * @param flag - true to set sending application version in every request; otherwise false.
161
- * @returns result if method executed succesfully or not
162
- */
163
- export const setSendAppVersionInEveryRequest = (
164
- flag: boolean
165
- ): Promise<number> => {
166
- console.log('setSendAppVersionInEveryRequest');
167
- return MappIntelligencePlugin.setSendAppVersionInEveryRequest(flag);
168
- };
169
-
170
- /**
171
- * To enable user matching between Engage and Intelligence system
172
- * @param enabled true to enable user matching; false to disable it.
173
- * @returns result if method executed succesfully or not
174
- */
175
- export const setEnableUserMatching = (enabled: boolean): Promise<number> => {
176
- console.log('setEnableUserMatching');
177
- return MappIntelligencePlugin.setEnableUserMatching(enabled);
178
- };
179
-
180
- /**
181
- * Track single page by page name
182
- * @param pageTitle page name for tracking
183
- * @returns result if method executed succesfully or not
184
- */
185
- export const trackPage = (pageTitle: string): Promise<number> => {
186
- console.log('trackPage');
187
- return MappIntelligencePlugin.trackPage(pageTitle);
188
- };
189
-
190
- /**
191
- * Detailed page tracking with additional parameters that can be set to track
192
- * @param pageTitle - name of the page
193
- * @param pageParameters - parameters for the page
194
- * @param sessionParamters - parameters for the current session
195
- * @param userCategories - predefined user categories
196
- * @param ecommerceParameters - predefined eCommerce parameters
197
- * @param campaignParameters - predefined campaign parameters
198
- * @returns result if method executed succesfully or not
199
- */
200
- export const trackCustomPage = (
201
- pageTitle: string,
202
- pageParameters?: PageParameters | null,
203
- sessionParamters?: SessionParameters | null,
204
- userCategories?: UserCategories | null,
205
- ecommerceParameters?: EcommerceParameters | null,
206
- campaignParameters?: CampaignParameters | null
207
- ): Promise<number> => {
208
- console.log('trackCustomPage');
209
- return MappIntelligencePlugin.trackCustomPage(
210
- pageTitle,
211
- convertPageParameters(pageParameters),
212
- convertSessionParamters(sessionParamters),
213
- convertUserCategories(userCategories),
214
- convertEcommerceParameters(ecommerceParameters),
215
- convertCampaignParameters(campaignParameters)
216
- );
217
- };
218
-
219
- /**
220
- * Custom page tracking with option to track some custom parameters
221
- * @param pageTitle - name of the page
222
- * @param pageParameters - custom parameters that can be tracked
223
- * @returns result if method executed succesfully or not
224
- */
225
- export const trackPageWithCustomData = (
226
- pageTitle: string,
227
- pageParameters: Map<string, string> | null
228
- ): Promise<number> => {
229
- console.log('trackPageWithCustomData');
230
- const params = pageParameters?.entries();
231
- const data = params != null ? Object.fromEntries(params) : {};
232
- return MappIntelligencePlugin.trackPageWithCustomData(data, pageTitle);
233
- };
234
-
235
- /**
236
- * Track user action
237
- * @param name - action name
238
- * @param eventParameters - predefined event parameters
239
- * @param sessionParamters - predefined session parameters
240
- * @param userCategories - predefined user categories
241
- * @param ecommerceParameters - predefined ecommerce parameters
242
- * @param campaignParameters - predefined campaign parameters
243
- * @returns result if method executed succesfully or not
244
- */
245
- export const trackAction = (
246
- name: string,
247
- eventParameters?: EventParameters | null,
248
- sessionParamters?: SessionParameters | null,
249
- userCategories?: UserCategories | null,
250
- ecommerceParameters?: EcommerceParameters | null,
251
- campaignParameters?: CampaignParameters | null
252
- ): Promise<number> => {
253
- console.log('trackAction');
254
- return MappIntelligencePlugin.trackAction(
255
- name,
256
- convertEventParameters(eventParameters),
257
- convertSessionParamters(sessionParamters),
258
- convertUserCategories(userCategories),
259
- convertEcommerceParameters(ecommerceParameters),
260
- convertCampaignParameters(campaignParameters)
261
- );
262
- };
263
-
264
- /**
265
- * Track URL's with included deeplinks, media parameters
266
- * @param url single url that can contain some query parameters for tracking
267
- * @param mediaCode media code to track
268
- * @returns result if method executed succesfully or not
269
- */
270
- export const trackUrl = (
271
- url: string,
272
- mediaCode?: string | null
273
- ): Promise<number> => {
274
- return MappIntelligencePlugin.trackUrl(url, mediaCode);
275
- };
276
-
277
- /**
278
- * Track video or audio events - starting, playing, pausing/stoping, ending of playing
279
- * @param mediaEvent predefined events to track
280
- * @returns result if method executed succesfully or not
281
- */
282
- export const trackMedia = (mediaEvent: MediaEvent): Promise<number> => {
283
- console.log('Execute MediaEvent');
284
- return MappIntelligencePlugin.trackMedia(
285
- convertMediaEvent(mediaEvent as MediaEvent)
286
- );
287
- };
288
-
289
- /**
290
- * Record data about handled exceptions
291
- * @param e caught exception
292
- * @param stackTrace stack trace of the caught exception
293
- * @returns result if method executed succesfully or not
294
- */
295
- export const trackException = (
296
- e: Error,
297
- stackTrace?: string | null
298
- ): Promise<number> => {
299
- return MappIntelligencePlugin.trackException(
300
- e.name,
301
- e.message?.slice(0, 1000),
302
- stackTrace?.slice(0, 1000)
303
- );
304
- };
305
-
306
- /**
307
- * Record data about handled exception
308
- * @param name name or type of the exception if can be obtained
309
- * @param message message of the current caught exception
310
- * @param stackTrace stack trace of the caught exception
311
- * @returns result if method executed succesfully or not
312
- */
313
- export const trackExceptionWithName = (
314
- name: string,
315
- message: string,
316
- stackTrace?: string | null
317
- ): Promise<number> => {
318
- return MappIntelligencePlugin.trackException(
319
- name,
320
- message.slice(0, 1000),
321
- stackTrace?.slice(0, 1000)
322
- );
323
- };
324
-
325
- /**
326
- * Set unique everId as identifier for a single device/user
327
- * @param everId unique identifier in the tracking system
328
- * @returns result if method executed succesfully or not
329
- */
330
- export const setEverId = (everId?: String | null): Promise<number> => {
331
- console.log('setEverId');
332
- return MappIntelligencePlugin.setEverId(everId);
333
- };
334
-
335
- /**
336
- * Returns current everId of a device
337
- * @returns everId
338
- */
339
- export const getEverId = (): Promise<string> => {
340
- return MappIntelligencePlugin.getEverId();
341
- };
342
-
343
- /**
344
- * Check if plugin is initialized and ready to use
345
- * @returns true if plugin is ready to use; false otherwise.
346
- */
347
- export const isInitialized = (): Promise<boolean> => {
348
- return MappIntelligencePlugin.isInitialized();
349
- };
350
-
351
- /**
352
- * Temporary sessionId is used when anonymous tracking is enabled to provide
353
- * anonymous tracking of a single session
354
- * @param sessionId unique session identifier
355
- * @returns result if method executed succesfully or not
356
- */
357
- export const setTemporarySessionId = (
358
- sessionId?: String | null
359
- ): Promise<number> => {
360
- console.log('setTemporarySessionId');
361
- return MappIntelligencePlugin.setTemporarySessionId(sessionId);
362
- };
363
-
364
- /**
365
- * In some cases, it is necessary to exclude users completely from tracking.
366
- * For this purpose, the SDK provides an opt-out option.
367
- * Internally, calling this method will delete all current tracking data cached in the database (if sendCurrentData is set to false), cancel the sending of requests, terminate the WorkManager, and disable all incoming tracking requests.
368
- * @param sendData true to send recorded data before opt-out
369
- * @returns result if method executed succesfully or not
370
- */
371
- export const optOut = (sendData: boolean): Promise<number> => {
372
- return MappIntelligencePlugin.optOut(sendData);
373
- };
374
-
375
- /**
376
- * Disables opt-out, and resets tracking to enabled.
377
- * @param sendData true to send recorded data before opt-in
378
- * @returns result if method executed succesfully or not
379
- */
380
- export const optIn = (sendData: boolean): Promise<number> => {
381
- return MappIntelligencePlugin.optIn(sendData);
382
- };
383
-
384
- /**
385
- * Reset all webtrekk configuration. After this, new init with settings must be called before using plugin.
386
- * @returns result if method executed succesfully or not
387
- */
388
- export const reset = (): Promise<number> => {
389
- return MappIntelligencePlugin.reset();
390
- };
391
-
392
- /**
393
- * When called, data will be immediately sent.
394
- * The request will then be deleted from the database, cleaning it.
395
- * Please note that the application must be started and visible to use this method.
396
- * @returns result if method executed succesfully or not
397
- */
398
- export const sendRequestsAndClean = (): Promise<number> => {
399
- return MappIntelligencePlugin.sendRequestsAndClean();
400
- };
401
-
402
- /**
403
- * Get active configuration of the native SDK and returns it as a string
404
- * @returns string representation of the active configuration
405
- */
406
- export const printCurrentConfig = (): Promise<string> => {
407
- return MappIntelligencePlugin.getCurrentConfig();
408
- };
409
-
1
+ export { MappIntelligencePlugin } from './MappIntelligencePlugin';
410
2
  export * from './Converters';
411
3
  export * from './DataTypes';
412
4
  export * from './GlobalErrorHandler';
413
- export * from './UseWebTracking';
5
+ export { useWebTracking } from './UseWebTracking';
414
6
  export * from './promiseRejectionHandler';