aesirx-analytics 1.0.6 → 1.1.1

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 (70) hide show
  1. package/README.md +18 -9
  2. package/dist/analytics.js +11 -0
  3. package/dist/index.d.ts +44 -0
  4. package/dist/index.js +5 -0
  5. package/package.json +13 -36
  6. package/build/analytics.js +0 -1
  7. package/build/lib/bundles/bundle.esm.min.js +0 -2
  8. package/build/lib/bundles/bundle.esm.min.js.map +0 -1
  9. package/build/lib/cjs/AnalyticsNext/handle.js +0 -119
  10. package/build/lib/cjs/AnalyticsNext/handle.js.map +0 -1
  11. package/build/lib/cjs/AnalyticsNext/index.js +0 -51
  12. package/build/lib/cjs/AnalyticsNext/index.js.map +0 -1
  13. package/build/lib/cjs/AnalyticsReact/handle.js +0 -77
  14. package/build/lib/cjs/AnalyticsReact/handle.js.map +0 -1
  15. package/build/lib/cjs/AnalyticsReact/index.js +0 -51
  16. package/build/lib/cjs/AnalyticsReact/index.js.map +0 -1
  17. package/build/lib/cjs/analytics.js +0 -197
  18. package/build/lib/cjs/analytics.js.map +0 -1
  19. package/build/lib/cjs/index.js +0 -35
  20. package/build/lib/cjs/index.js.map +0 -1
  21. package/build/lib/cjs/utils/AnalyticsContextProvider.js +0 -39
  22. package/build/lib/cjs/utils/AnalyticsContextProvider.js.map +0 -1
  23. package/build/lib/cjs/utils/index.js +0 -202
  24. package/build/lib/cjs/utils/index.js.map +0 -1
  25. package/build/lib/cjs/utils/services.js +0 -51
  26. package/build/lib/cjs/utils/services.js.map +0 -1
  27. package/build/lib/esm/AnalyticsNext/handle.js +0 -124
  28. package/build/lib/esm/AnalyticsNext/handle.js.map +0 -1
  29. package/build/lib/esm/AnalyticsNext/index.js +0 -56
  30. package/build/lib/esm/AnalyticsNext/index.js.map +0 -1
  31. package/build/lib/esm/AnalyticsReact/handle.js +0 -82
  32. package/build/lib/esm/AnalyticsReact/handle.js.map +0 -1
  33. package/build/lib/esm/AnalyticsReact/index.js +0 -56
  34. package/build/lib/esm/AnalyticsReact/index.js.map +0 -1
  35. package/build/lib/esm/analytics.js +0 -198
  36. package/build/lib/esm/analytics.js.map +0 -1
  37. package/build/lib/esm/index.js +0 -35
  38. package/build/lib/esm/index.js.map +0 -1
  39. package/build/lib/esm/utils/AnalyticsContextProvider.js +0 -45
  40. package/build/lib/esm/utils/AnalyticsContextProvider.js.map +0 -1
  41. package/build/lib/esm/utils/index.js +0 -206
  42. package/build/lib/esm/utils/index.js.map +0 -1
  43. package/build/lib/esm/utils/services.js +0 -54
  44. package/build/lib/esm/utils/services.js.map +0 -1
  45. package/build/lib/types/AnalyticsNext/handle.d.ts +0 -3
  46. package/build/lib/types/AnalyticsNext/handle.d.ts.map +0 -1
  47. package/build/lib/types/AnalyticsNext/index.d.ts +0 -3
  48. package/build/lib/types/AnalyticsNext/index.d.ts.map +0 -1
  49. package/build/lib/types/AnalyticsReact/handle.d.ts +0 -3
  50. package/build/lib/types/AnalyticsReact/handle.d.ts.map +0 -1
  51. package/build/lib/types/AnalyticsReact/index.d.ts +0 -3
  52. package/build/lib/types/AnalyticsReact/index.d.ts.map +0 -1
  53. package/build/lib/types/index.d.ts +0 -5
  54. package/build/lib/types/index.d.ts.map +0 -1
  55. package/build/lib/types/index.min.js +0 -1
  56. package/build/lib/types/utils/AnalyticsContextProvider.d.ts +0 -3
  57. package/build/lib/types/utils/AnalyticsContextProvider.d.ts.map +0 -1
  58. package/build/lib/types/utils/index.d.ts +0 -5
  59. package/build/lib/types/utils/index.d.ts.map +0 -1
  60. package/build/lib/types/utils/services.d.ts +0 -2
  61. package/build/lib/types/utils/services.d.ts.map +0 -1
  62. package/src/AnalyticsNext/handle.js +0 -58
  63. package/src/AnalyticsNext/index.js +0 -30
  64. package/src/AnalyticsReact/handle.js +0 -39
  65. package/src/AnalyticsReact/index.js +0 -29
  66. package/src/analytics.js +0 -155
  67. package/src/index.js +0 -4
  68. package/src/utils/AnalyticsContextProvider.js +0 -17
  69. package/src/utils/index.js +0 -126
  70. package/src/utils/services.js +0 -20
@@ -1,126 +0,0 @@
1
- import { trackerService } from './services';
2
- import Bowser from 'bowser';
3
-
4
- const createRequest = (endpoint, task) => {
5
- return `${endpoint}/visitor/v1/${task}`;
6
- };
7
-
8
- /* FUNCTION */
9
- const initTracker = async (endpoint, url, referrer, user_agent) => {
10
- const { document } = window;
11
- const { pathname, search, origin } = location;
12
- url = `${origin}${pathname}${search}`;
13
- referrer = document.referrer;
14
- user_agent = window.navigator.userAgent;
15
- const browser = Bowser.parse(window.navigator.userAgent);
16
- const browser_name = browser?.browser?.name;
17
- const browser_version = browser?.browser?.version;
18
- const lang = window.navigator.userLanguage || window.navigator.language;
19
- const device = browser?.platform?.model ?? browser?.platform?.type;
20
- const domain = `${origin}`;
21
- const queryString = window.location.search;
22
- const urlParams = new URLSearchParams(queryString);
23
- let attributes = [];
24
- for (var key of urlParams.keys()) {
25
- if (key.startsWith('utm_')) {
26
- urlParams.get(key) && attributes.push({ name: key, value: urlParams.get(key) });
27
- }
28
- }
29
- if (!urlParams.get('event_uuid') && !urlParams.get('visitor_uuid')) {
30
- let ip = '';
31
- const response = await trackerService(createRequest(endpoint, 'init'), {
32
- url: url,
33
- referrer: referrer,
34
- user_agent: user_agent,
35
- ip: ip,
36
- domain: domain,
37
- browser_name: browser_name,
38
- browser_version: browser_version,
39
- lang: lang,
40
- device: device,
41
- event_name: 'visit',
42
- event_type: 'action',
43
- attributes: attributes,
44
- });
45
- return response;
46
- }
47
- };
48
-
49
- const startTracker = async (endpoint, event_uuid, visitor_uuid, referrer) => {
50
- const { location, document } = window;
51
- referrer = referrer
52
- ? location.protocol + '//' + location.host + referrer
53
- : document.referrer.split('?')[0];
54
- const url = location.protocol + '//' + location.host + location.pathname;
55
- const queryString = window.location.search;
56
- const urlParams = new URLSearchParams(queryString);
57
- const responseStart = await trackerService(createRequest(endpoint, 'start'), {
58
- ...(urlParams.get('event_uuid') && {
59
- event_uuid: urlParams.get('event_uuid'),
60
- }),
61
- ...(urlParams.get('visitor_uuid') && {
62
- visitor_uuid: urlParams.get('visitor_uuid'),
63
- }),
64
- ...(event_uuid && {
65
- event_uuid: event_uuid,
66
- }),
67
- ...(visitor_uuid && {
68
- visitor_uuid: visitor_uuid,
69
- }),
70
- referrer: referrer === '/' ? '' : referrer,
71
- url: url,
72
- });
73
-
74
- return responseStart;
75
- };
76
-
77
- const endTracker = async (endpoint, event_uuid, visitor_uuid) => {
78
- const queryString = window.location.search;
79
- const urlParams = new URLSearchParams(queryString);
80
- const responseEnd = await trackerService(createRequest(endpoint, 'end'), {
81
- ...(urlParams.get('event_uuid_start') && {
82
- event_uuid: urlParams.get('event_uuid_start'),
83
- }),
84
- ...(urlParams.get('visitor_uuid_start') && {
85
- visitor_uuid: urlParams.get('visitor_uuid_start'),
86
- }),
87
- ...(event_uuid && {
88
- event_uuid: event_uuid,
89
- }),
90
- ...(visitor_uuid && {
91
- visitor_uuid: visitor_uuid,
92
- }),
93
- });
94
- return responseEnd;
95
- };
96
-
97
- const trackEvent = async (endpoint, event_uuid, visitor_uuid, referrer, data) => {
98
- const { location, document } = window;
99
- referrer = referrer
100
- ? location.protocol + '//' + location.host + referrer
101
- : document.referrer.split('?')[0];
102
- const url = location.protocol + '//' + location.host + location.pathname;
103
- const queryString = window.location.search;
104
- const urlParams = new URLSearchParams(queryString);
105
- const responseStart = await trackerService(createRequest(endpoint, 'start'), {
106
- ...(urlParams.get('event_uuid') && {
107
- event_uuid: urlParams.get('event_uuid'),
108
- }),
109
- ...(urlParams.get('visitor_uuid') && {
110
- visitor_uuid: urlParams.get('visitor_uuid'),
111
- }),
112
- ...(event_uuid && {
113
- event_uuid: event_uuid,
114
- }),
115
- ...(visitor_uuid && {
116
- visitor_uuid: visitor_uuid,
117
- }),
118
- referrer: referrer === '/' ? '' : referrer,
119
- url: url,
120
- ...data,
121
- });
122
-
123
- return responseStart;
124
- };
125
-
126
- export { initTracker, startTracker, endTracker, trackEvent };
@@ -1,20 +0,0 @@
1
- /* SERVICES */
2
- let cache;
3
- const assign = (a, b) => {
4
- Object.keys(b).forEach((key) => {
5
- if (b[key] !== undefined) a[key] = b[key];
6
- });
7
- return a;
8
- };
9
-
10
- const trackerService = async (endpoint, payload) => {
11
- const fetchData = await fetch(endpoint, {
12
- method: 'POST',
13
- body: JSON.stringify(payload),
14
- headers: assign({ 'Content-Type': 'application/json' }, { ['x-tracker-cache']: cache }),
15
- });
16
- const response = await fetchData.json();
17
- return response;
18
- };
19
-
20
- export { trackerService };