iidrak-analytics-react 1.2.4

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 (37) hide show
  1. package/README.md +170 -0
  2. package/index.d.ts +1 -0
  3. package/index.js +4 -0
  4. package/metastreamio/metastreamio.account.js +65 -0
  5. package/metastreamio/metastreamio.cart.js +192 -0
  6. package/metastreamio/metastreamio.constants.js +256 -0
  7. package/metastreamio/metastreamio.date.js +41 -0
  8. package/metastreamio/metastreamio.environment.js +406 -0
  9. package/metastreamio/metastreamio.interface.js +591 -0
  10. package/metastreamio/metastreamio.logger.js +150 -0
  11. package/metastreamio/metastreamio.network.js +313 -0
  12. package/metastreamio/metastreamio.provider.js +50 -0
  13. package/metastreamio/metastreamio.queue.js +68 -0
  14. package/metastreamio/metastreamio.recorder.js +157 -0
  15. package/metastreamio/metastreamio.session.js +150 -0
  16. package/metastreamio/metastreamio.user.js +79 -0
  17. package/metastreamio/metastreamio.userproperties.js +76 -0
  18. package/metastreamio/metastreamio.utility.js +206 -0
  19. package/metastreamio/models/constructor.app.js +24 -0
  20. package/metastreamio/models/constructor.config.js +33 -0
  21. package/metastreamio/models/constructor.user.js +30 -0
  22. package/metastreamio/models/event.account.balance.js +12 -0
  23. package/metastreamio/models/event.account.js +22 -0
  24. package/metastreamio/models/event.appinfo.js +28 -0
  25. package/metastreamio/models/event.appperformance.js +25 -0
  26. package/metastreamio/models/event.cart.js +19 -0
  27. package/metastreamio/models/event.cartitem.js +34 -0
  28. package/metastreamio/models/event.device.js +55 -0
  29. package/metastreamio/models/event.event.js +88 -0
  30. package/metastreamio/models/event.network.js +27 -0
  31. package/metastreamio/models/event.parameter.js +12 -0
  32. package/metastreamio/models/event.parameters.js +38 -0
  33. package/metastreamio/models/event.session.js +24 -0
  34. package/metastreamio/models/event.session.utm.js +37 -0
  35. package/metastreamio/models/event.userproperty.js +14 -0
  36. package/metastreamio/string.format.js +7 -0
  37. package/package.json +21 -0
@@ -0,0 +1,33 @@
1
+ export class ConfigConstructorModel {
2
+ constructor({
3
+ logging = null,
4
+ loggingLevel = null,
5
+ loggingCategories = null,
6
+ loggingAlwaysWarn = null,
7
+ loggingAlwaysError = null,
8
+ sessionLength = null,
9
+ silentMode = null,
10
+ allowTrackCategories = [],
11
+ } = {}) {
12
+ this.logging = logging;
13
+ this.loggingLevel = loggingLevel;
14
+ this.loggingCategories = loggingCategories;
15
+ this.loggingAlwaysWarn = loggingAlwaysWarn;
16
+ this.loggingAlwaysError = loggingAlwaysError;
17
+ this.sessionLength = sessionLength;
18
+ this.silentMode = silentMode;
19
+ this.allowTrackCategories = allowTrackCategories;
20
+ }
21
+ json() {
22
+ return {
23
+ logging: this.logging,
24
+ loggingLevel: this.loggingLevel,
25
+ loggingCategories: this.loggingCategories,
26
+ loggingAlwaysWarn: this.loggingAlwaysWarn,
27
+ loggingAlwaysError: this.loggingAlwaysError,
28
+ sessionLength: this.sessionLength,
29
+ silentMode: this.silentMode,
30
+ allowTrackCategories: this.allowTrackCategories,
31
+ };
32
+ }
33
+ }
@@ -0,0 +1,30 @@
1
+ export class UserConstructorModel {
2
+ constructor({
3
+ guestMode = null,
4
+ newCart = null,
5
+ user_id = null,
6
+ ciam_id = null,
7
+ email_id = null,
8
+ country = null,
9
+ cart_id = null,
10
+ } = {}) {
11
+ this.guestMode = guestMode;
12
+ this.newCart = newCart;
13
+ this.user_id = user_id;
14
+ this.ciam_id = ciam_id;
15
+ this.cart_id = cart_id;
16
+ this.country = country;
17
+ this.email_id = email_id;
18
+ }
19
+ json() {
20
+ return {
21
+ guestMode: this.guestMode,
22
+ newCart: this.newCart,
23
+ user_id: this.user_id,
24
+ ciam_id: this.ciam_id,
25
+ country: this.country,
26
+ cart_id: this.cart_id,
27
+ email_id: this.email_id,
28
+ };
29
+ }
30
+ }
@@ -0,0 +1,12 @@
1
+ export class AccountBalanceModel {
2
+ constructor({account = null, balance = null} = {}) {
3
+ this.account = account;
4
+ this.balance = balance;
5
+ }
6
+ json() {
7
+ return {
8
+ account: this.account,
9
+ balance: this.balance,
10
+ };
11
+ }
12
+ }
@@ -0,0 +1,22 @@
1
+ export class AccountModel {
2
+ constructor({type = null, balances = {}} = {}) {
3
+ this.type = type;
4
+ this.balances = balances;
5
+ }
6
+ json() {
7
+ return {
8
+ type: this.type,
9
+ balances: this.balances,
10
+ };
11
+ }
12
+ list() {
13
+ let ls = [];
14
+ for (let account in this.balances) {
15
+ ls.push({
16
+ account: account,
17
+ balance: this.balances[account].balance,
18
+ });
19
+ }
20
+ return ls;
21
+ }
22
+ }
@@ -0,0 +1,28 @@
1
+ export class AppInfoModel {
2
+ constructor({
3
+ first_installation_time = null,
4
+ id = null,
5
+ installation_id = null,
6
+ install_referrer = null,
7
+ last_update_time = null,
8
+ version = null,
9
+ } = {}) {
10
+ this.first_installation_time = first_installation_time;
11
+ this.id = id;
12
+ this.installation_id = installation_id;
13
+ this.install_referrer = install_referrer;
14
+ this.last_update_time = last_update_time;
15
+ this.version = version;
16
+ }
17
+
18
+ json() {
19
+ return {
20
+ first_installation_time: this.first_installation_time,
21
+ id: this.id,
22
+ installation_id: this.installation_id,
23
+ install_referrer: this.install_referrer,
24
+ last_update_time: this.last_update_time,
25
+ version: this.version,
26
+ };
27
+ }
28
+ }
@@ -0,0 +1,25 @@
1
+ export class AppPerformanceModel {
2
+ constructor({
3
+ battery_low_power_mode = null,
4
+ battery_percentage = null,
5
+ battery_state = null,
6
+ data_down_kb = null,
7
+ data_up_kb = null,
8
+ } = {}) {
9
+ this.battery_low_power_mode = battery_low_power_mode;
10
+ this.battery_percentage = battery_percentage;
11
+ this.battery_state = battery_state;
12
+ this.data_down_kb = data_down_kb;
13
+ this.data_up_kb = data_up_kb;
14
+ }
15
+
16
+ json() {
17
+ return {
18
+ battery_low_power_mode: this.battery_low_power_mode,
19
+ battery_percentage: this.battery_percentage,
20
+ battery_state: this.battery_state,
21
+ data_down_kb: this.data_down_kb,
22
+ data_up_kb: this.data_up_kb,
23
+ };
24
+ }
25
+ }
@@ -0,0 +1,19 @@
1
+ export class CartModel {
2
+ constructor({id = null, items = {}} = {}) {
3
+ this.id = id;
4
+ this.items = items;
5
+ }
6
+ json() {
7
+ return {
8
+ id: this.id,
9
+ items: this.items,
10
+ };
11
+ }
12
+ list() {
13
+ let _return = [];
14
+ for (let id in this.items) {
15
+ _return.push(this.items[id]);
16
+ }
17
+ return _return;
18
+ }
19
+ }
@@ -0,0 +1,34 @@
1
+ export class CartItemModel {
2
+ constructor({
3
+ id = null,
4
+ name = null,
5
+ type = null,
6
+ validity = null,
7
+ value = null,
8
+ price = null,
9
+ quantity = null,
10
+ recipients = [],
11
+ } = {}) {
12
+ this.id = id;
13
+ this.name = name;
14
+ this.type = type;
15
+ this.validity = validity;
16
+ this.value = value;
17
+ this.price = price;
18
+ this.quantity = quantity;
19
+ this.recipients = recipients;
20
+ }
21
+
22
+ json() {
23
+ return {
24
+ price: this.price,
25
+ id: this.id,
26
+ name: this.name,
27
+ type: this.type,
28
+ validity: this.validity,
29
+ value: this.value,
30
+ quantity: this.quantity,
31
+ recipients: this.recipients,
32
+ };
33
+ }
34
+ }
@@ -0,0 +1,55 @@
1
+ export class DeviceModel {
2
+ constructor({
3
+ brand = null,
4
+ device_type = null,
5
+ model = null,
6
+ operating_system = null,
7
+ operating_system_version = null,
8
+ pin_or_fingerprint_set = null,
9
+ screen_height = null,
10
+ screen_width = null,
11
+ storage_free = null,
12
+ storage_total = null,
13
+ supported_architectures = null,
14
+ timezone_offset_sec = null,
15
+ total_memory = null,
16
+ unique_device_id = null,
17
+ used_memory = null,
18
+ } = {}) {
19
+ this.brand = brand;
20
+ this.device_type = device_type;
21
+ this.model = model;
22
+ this.operating_system = operating_system;
23
+ this.operating_system_version = operating_system_version;
24
+ this.pin_or_fingerprint_set = pin_or_fingerprint_set;
25
+ this.screen_height = screen_height;
26
+ this.screen_width = screen_width;
27
+ this.storage_free = storage_free;
28
+ this.storage_total = storage_total;
29
+ this.supported_architectures = supported_architectures;
30
+ this.timezone_offset_sec = timezone_offset_sec;
31
+ this.total_memory = total_memory;
32
+ this.unique_device_id = unique_device_id;
33
+ this.used_memory = used_memory;
34
+ }
35
+
36
+ json() {
37
+ return {
38
+ brand: this.brand,
39
+ device_type: this.device_type,
40
+ model: this.model,
41
+ operating_system: this.operating_system,
42
+ operating_system_version: this.operating_system_version,
43
+ pin_or_fingerprint_set: this.pin_or_fingerprint_set,
44
+ screen_height: this.screen_height,
45
+ screen_width: this.screen_width,
46
+ storage_free: this.storage_free,
47
+ storage_total: this.storage_total,
48
+ supported_architectures: this.supported_architectures,
49
+ timezone_offset_sec: this.timezone_offset_sec,
50
+ total_memory: this.total_memory,
51
+ unique_device_id: this.unique_device_id,
52
+ used_memory: this.used_memory,
53
+ };
54
+ }
55
+ }
@@ -0,0 +1,88 @@
1
+ import { AppInfoModel } from "./event.appinfo.js";
2
+ import { AppPerformanceModel } from "./event.appperformance.js";
3
+ import { DeviceModel } from "./event.device.js";
4
+ import { NetworkInfoModel } from "./event.network";
5
+ import { SessionModel } from "./event.session.js";
6
+
7
+ export class EventModel {
8
+ constructor({
9
+ account_balances = {},
10
+ account_type = null,
11
+ app = null,
12
+ app_environment = null,
13
+ app_info = new AppInfoModel(),
14
+ app_performance = new AppPerformanceModel(),
15
+ cart = {},
16
+ cart_id = null,
17
+ channel = null,
18
+ ciam_id = null,
19
+ client_event_date = null,
20
+ client_event_timestamp = null,
21
+ device = new DeviceModel(),
22
+ device_token = null,
23
+ email_id = null,
24
+ event_name = null,
25
+ event_params = {},
26
+ network = new NetworkInfoModel(),
27
+ session = new SessionModel(),
28
+ transaction_id = null,
29
+ user_country = null,
30
+ user_id = null,
31
+ user_properties = null,
32
+ } = {}) {
33
+ this.account_balances = account_balances;
34
+ this.account_type = account_type;
35
+ this.app = app;
36
+ this.app_environment = app_environment;
37
+ this.app_info = app_info;
38
+ this.app_performance = app_performance;
39
+ this.cart = cart;
40
+ this.cart_id = cart_id;
41
+ this.channel = channel;
42
+ this.ciam_id = ciam_id;
43
+ this.device = device;
44
+ this.device_token = device_token;
45
+ this.email_id = email_id;
46
+ this.channel = channel;
47
+ this.client_event_date = client_event_date;
48
+ this.client_event_timestamp = client_event_timestamp;
49
+ this.event_name = event_name;
50
+ this.event_params = event_params;
51
+ this.network = network;
52
+ this.session = session;
53
+ this.transaction_id = transaction_id;
54
+ this.user_country = user_country;
55
+ this.user_id = user_id;
56
+ this.user_properties = user_properties;
57
+ }
58
+
59
+ json() {
60
+ return {
61
+ project_id: this.app,
62
+ environment: this.app_environment,
63
+ event: {
64
+ account_balances: this.account_balances,
65
+ account_type: this.account_type,
66
+ app_info: this.app_info,
67
+ app_performance: this.app_performance,
68
+ cart: this.cart,
69
+ cart_id: this.cart_id,
70
+ channel: this.channel,
71
+ ciam_id: this.ciam_id,
72
+ client_event_date: this.client_event_date,
73
+ client_event_timestamp: this.client_event_timestamp,
74
+ device: this.device,
75
+ device_token: this.device_token,
76
+ email_id: this.email_id,
77
+ event_name: this.event_name,
78
+ event_params: this.event_params,
79
+ network: this.network,
80
+ session: this.session,
81
+ transaction_id: this.transaction_id,
82
+ user_country: this.user_country,
83
+ user_id: this.user_id,
84
+ user_properties: this.user_properties,
85
+ },
86
+ };
87
+ }
88
+ }
@@ -0,0 +1,27 @@
1
+ export class NetworkInfoModel {
2
+ constructor({
3
+ carrier = null,
4
+ carrier_iso_country_code = null,
5
+ cellular_generation = null,
6
+ mobile_country_code = null,
7
+ mobile_network_code = null,
8
+ network_state_type = null,
9
+ } = {}) {
10
+ this.carrier = carrier;
11
+ this.carrier_iso_country_code = carrier_iso_country_code;
12
+ this.cellular_generation = cellular_generation;
13
+ this.mobile_country_code = mobile_country_code;
14
+ this.mobile_network_code = mobile_network_code;
15
+ this.network_state_type = network_state_type;
16
+ }
17
+ json() {
18
+ return {
19
+ carrier: this.carrier,
20
+ carrier_iso_country_code: this.carrier_iso_country_code,
21
+ cellular_generation: this.cellular_generation,
22
+ mobile_country_code: this.mobile_country_code,
23
+ mobile_network_code: this.mobile_network_code,
24
+ network_state_type: this.network_state_type,
25
+ };
26
+ }
27
+ }
@@ -0,0 +1,12 @@
1
+ export class EventParameterModel {
2
+ constructor({key = null, value = null} = {}) {
3
+ this.key = key;
4
+ this.value = value;
5
+ }
6
+ json() {
7
+ return {
8
+ key: this.key,
9
+ value: this.value,
10
+ };
11
+ }
12
+ }
@@ -0,0 +1,38 @@
1
+ export class EventParametersModel {
2
+ constructor({parameters = {}} = {}) {
3
+ this.parameters = parameters;
4
+ }
5
+ json() {
6
+ return {
7
+ parameters: this.parameters,
8
+ };
9
+ }
10
+ type(value) {
11
+ switch (typeof value) {
12
+ case 'number':
13
+ if (Math.ceil(parseFloat(value)) === value) {
14
+ return 'integer';
15
+ } else {
16
+ return 'float';
17
+ }
18
+ break;
19
+ default:
20
+ return typeof value;
21
+ }
22
+ }
23
+ list() {
24
+ let ls = [];
25
+ try {
26
+ for (param in this.parameters) {
27
+ console.error('PARAM', param);
28
+ let _ = {};
29
+ _.key = param;
30
+ _.value = {[this.type(value)]: this.parameters.param.value};
31
+ ls.push(_);
32
+ }
33
+ } catch (err) {
34
+ console.error('list()', err);
35
+ }
36
+ return ls;
37
+ }
38
+ }
@@ -0,0 +1,24 @@
1
+ import {UtmModel} from './event.session.utm.js';
2
+
3
+ export class SessionModel {
4
+ constructor({
5
+ id = null,
6
+ source = null,
7
+ start_time = null,
8
+ utm = new UtmModel(),
9
+ } = {}) {
10
+ this.id = id;
11
+ this.source = source;
12
+ this.start_time = start_time;
13
+ this.utm = utm;
14
+ }
15
+
16
+ json() {
17
+ return {
18
+ id: this.id,
19
+ source: this.source,
20
+ start_time: this.start_time,
21
+ utm: this.utm,
22
+ };
23
+ }
24
+ }
@@ -0,0 +1,37 @@
1
+ export class UtmModel {
2
+ constructor({
3
+ utm_source = null,
4
+ utm_medium = null,
5
+ utm_campaign = null,
6
+ utm_term = null,
7
+ utm_content = null,
8
+ } = {}) {
9
+ this.utm_source = utm_source;
10
+ this.utm_medium = utm_medium;
11
+ this.utm_campaign = utm_campaign;
12
+ this.utm_term = utm_term;
13
+ this.utm_content = utm_content;
14
+ }
15
+
16
+ json() {
17
+ return {
18
+ utm_campaign: this.utm_campaign,
19
+ utm_content: this.utm_content,
20
+ utm_medium: this.utm_medium,
21
+ utm_source: this.utm_source,
22
+ utm_term: this.utm_term,
23
+ };
24
+ }
25
+
26
+ list() {
27
+ let utm = Object.keys(this);
28
+ let list = [];
29
+ for (let property of utm) {
30
+ list.push({
31
+ key: property,
32
+ value: this[property],
33
+ });
34
+ }
35
+ return list;
36
+ }
37
+ }
@@ -0,0 +1,14 @@
1
+ export class UserPropertyModel {
2
+ constructor({key = null, value_type = null, value = null} = {}) {
3
+ this.key = key;
4
+ this.value_type = value_type;
5
+ this.value = value;
6
+ this.value_type_value = {[this.value_type]: value};
7
+ }
8
+ json() {
9
+ return {
10
+ key: this.key,
11
+ value: this.value_type_value,
12
+ };
13
+ }
14
+ }
@@ -0,0 +1,7 @@
1
+ export const strf = (String.prototype.format = function () {
2
+ var a = this;
3
+ for (var k in arguments) {
4
+ a = a.replace(new RegExp("\\{" + k + "\\}", "g"), arguments[k]);
5
+ }
6
+ return a;
7
+ });
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "iidrak-analytics-react",
3
+ "version": "1.2.4",
4
+ "description": "react native client for metastreamio",
5
+ "peerDependencies": {
6
+ "@react-native-async-storage/async-storage": ">=2.2.0",
7
+ "@react-native-community/netinfo": ">=11.5.2",
8
+ "react": ">=18.0.0",
9
+ "react-native": ">=0.70.0",
10
+ "react-native-device-info": ">=10.0.0",
11
+ "react-native-view-shot": ">=3.0.0"
12
+ },
13
+ "dependencies": {
14
+ "string-format": "^0.5.0",
15
+ "uuid": "^8.3.2"
16
+ },
17
+ "main": "index.js",
18
+ "repository": "https://github.com/analyticsdept/metastreamio-reactjs.git",
19
+ "author": "analyticsdept <analyticsdept@gmail.com>",
20
+ "license": "MIT"
21
+ }