core-outline 0.0.2 → 0.0.3

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/dist/index.es.js CHANGED
@@ -1 +1,113 @@
1
- const t=require("uuid");async function e(){return await(async({url:t,service:e,body:s,params:i,method:n})=>await fetch(t).then((function(t){return t.json()})).then((function(t){return console.log(t),t})))({url:"http://ip-api.com/json",method:"get"})}const{userAgent:s}=navigator;let i="mobile";const n=t=>{i=t};s.includes("Mobi")?n("mobile"):n("desktop");const a=async()=>{let s=await e(),n={session_id:t.v4(),start_time:Date.now(),end_time:null,device:i};return n={...n,...s},console.log(n),n},{io:o}=require("socket.io-client"),c=o("http://localhost:4000");const r=async(t,e)=>{let s={};var i;return s={session_id:t,start_date:Date.now(),end_date:null,page_name:e},i={topic:"page-data",data:s},c.emit("dataEvent",i),s},{io:l}=require("socket.io-client"),d=l("http://localhost:4000");function u(t){d.emit("dataEvent",t)}const h=async t=>{u({topic:"target-data",session_id:t})},p=async(t,e)=>{u({topic:"click-data",session_id:t,item_id:e})};class _{constructor(t,e){this.access_key=t,this.secret_id=e,this.sessionDetails=a(),this.startSession=a,this.pageDetails=r(sessionDetails?.session_id,{}),this.updatePage=r,this.targetReached=h,this.registerClick=p}endSession(){this.sessionDetails.end_time=Date.now()}}export{_ as default};
1
+ const uuid = require('uuid');
2
+ function createSessionUUID() {
3
+ return uuid.v4();
4
+ }
5
+ const makeRequest = async ({
6
+ url,
7
+ service,
8
+ body,
9
+ params,
10
+ method
11
+ }) => {
12
+ const res = await fetch(url).then(function (response) {
13
+ return response.json();
14
+ }).then(function (json) {
15
+ console.log(json);
16
+ return json;
17
+ });
18
+ return res;
19
+ };
20
+ async function getSessionLocation() {
21
+ const res = await makeRequest({
22
+ url: "http://ip-api.com/json",
23
+ method: 'get'
24
+ });
25
+ return res;
26
+ }
27
+ const {
28
+ userAgent
29
+ } = navigator;
30
+ let device = "mobile";
31
+ const setDevice = dev => {
32
+ device = dev;
33
+ };
34
+ userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
35
+ const getDeviceInfo = () => {
36
+ return device;
37
+ };
38
+ const startSession = async () => {
39
+ let loc = await getSessionLocation();
40
+ let session = {
41
+ "session_id": createSessionUUID(),
42
+ "start_time": Date.now(),
43
+ "end_time": null,
44
+ "device": getDeviceInfo()
45
+ };
46
+ session = {
47
+ ...session,
48
+ ...loc
49
+ };
50
+ console.log(session);
51
+ return session;
52
+ };
53
+
54
+ const {
55
+ io: io$1
56
+ } = require('socket.io-client');
57
+ const socket$1 = io$1('http://localhost:4000');
58
+ function streamData$1(data) {
59
+ socket$1.emit('dataEvent', data);
60
+ }
61
+ const updatePage = async (session_id, location) => {
62
+ let page = {};
63
+ page = {
64
+ "session_id": session_id,
65
+ "start_date": Date.now(),
66
+ "end_date": null,
67
+ "page_name": location
68
+ };
69
+ streamData$1({
70
+ "topic": "page-data",
71
+ "data": page
72
+ });
73
+ return page;
74
+ };
75
+
76
+ const {
77
+ io
78
+ } = require('socket.io-client');
79
+ const socket = io('http://localhost:4000');
80
+ function streamData(data) {
81
+ socket.emit('dataEvent', data);
82
+ }
83
+ const targetReached = async session_id => {
84
+ streamData({
85
+ "topic": "target-data",
86
+ "session_id": session_id
87
+ });
88
+ };
89
+ const registerClick = async (session_id, item_id) => {
90
+ streamData({
91
+ "topic": "click-data",
92
+ "session_id": session_id,
93
+ "item_id": item_id
94
+ });
95
+ };
96
+
97
+ class CoreOutline {
98
+ constructor(access_key, secret_id) {
99
+ this.access_key = access_key;
100
+ this.secret_id = secret_id;
101
+ this.sessionDetails = startSession();
102
+ this.startSession = startSession;
103
+ this.pageDetails = updatePage(sessionDetails?.session_id, {});
104
+ this.updatePage = updatePage;
105
+ this.targetReached = targetReached;
106
+ this.registerClick = registerClick;
107
+ }
108
+ endSession() {
109
+ this.sessionDetails.end_time = Date.now();
110
+ }
111
+ }
112
+
113
+ export { CoreOutline };
package/dist/index.js CHANGED
@@ -1 +1,117 @@
1
- "use strict";const t=require("uuid");async function e(){return await(async({url:t,service:e,body:s,params:i,method:n})=>await fetch(t).then((function(t){return t.json()})).then((function(t){return console.log(t),t})))({url:"http://ip-api.com/json",method:"get"})}const{userAgent:s}=navigator;let i="mobile";const n=t=>{i=t};s.includes("Mobi")?n("mobile"):n("desktop");const o=async()=>{let s=await e(),n={session_id:t.v4(),start_time:Date.now(),end_time:null,device:i};return n={...n,...s},console.log(n),n},{io:a}=require("socket.io-client"),c=a("http://localhost:4000");const r=async(t,e)=>{let s={};var i;return s={session_id:t,start_date:Date.now(),end_date:null,page_name:e},i={topic:"page-data",data:s},c.emit("dataEvent",i),s},{io:l}=require("socket.io-client"),d=l("http://localhost:4000");function u(t){d.emit("dataEvent",t)}const h=async t=>{u({topic:"target-data",session_id:t})},p=async(t,e)=>{u({topic:"click-data",session_id:t,item_id:e})};module.exports=class{constructor(t,e){this.access_key=t,this.secret_id=e,this.sessionDetails=o(),this.startSession=o,this.pageDetails=r(sessionDetails?.session_id,{}),this.updatePage=r,this.targetReached=h,this.registerClick=p}endSession(){this.sessionDetails.end_time=Date.now()}};
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const uuid = require('uuid');
6
+ function createSessionUUID() {
7
+ return uuid.v4();
8
+ }
9
+ const makeRequest = async ({
10
+ url,
11
+ service,
12
+ body,
13
+ params,
14
+ method
15
+ }) => {
16
+ const res = await fetch(url).then(function (response) {
17
+ return response.json();
18
+ }).then(function (json) {
19
+ console.log(json);
20
+ return json;
21
+ });
22
+ return res;
23
+ };
24
+ async function getSessionLocation() {
25
+ const res = await makeRequest({
26
+ url: "http://ip-api.com/json",
27
+ method: 'get'
28
+ });
29
+ return res;
30
+ }
31
+ const {
32
+ userAgent
33
+ } = navigator;
34
+ let device = "mobile";
35
+ const setDevice = dev => {
36
+ device = dev;
37
+ };
38
+ userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
39
+ const getDeviceInfo = () => {
40
+ return device;
41
+ };
42
+ const startSession = async () => {
43
+ let loc = await getSessionLocation();
44
+ let session = {
45
+ "session_id": createSessionUUID(),
46
+ "start_time": Date.now(),
47
+ "end_time": null,
48
+ "device": getDeviceInfo()
49
+ };
50
+ session = {
51
+ ...session,
52
+ ...loc
53
+ };
54
+ console.log(session);
55
+ return session;
56
+ };
57
+
58
+ const {
59
+ io: io$1
60
+ } = require('socket.io-client');
61
+ const socket$1 = io$1('http://localhost:4000');
62
+ function streamData$1(data) {
63
+ socket$1.emit('dataEvent', data);
64
+ }
65
+ const updatePage = async (session_id, location) => {
66
+ let page = {};
67
+ page = {
68
+ "session_id": session_id,
69
+ "start_date": Date.now(),
70
+ "end_date": null,
71
+ "page_name": location
72
+ };
73
+ streamData$1({
74
+ "topic": "page-data",
75
+ "data": page
76
+ });
77
+ return page;
78
+ };
79
+
80
+ const {
81
+ io
82
+ } = require('socket.io-client');
83
+ const socket = io('http://localhost:4000');
84
+ function streamData(data) {
85
+ socket.emit('dataEvent', data);
86
+ }
87
+ const targetReached = async session_id => {
88
+ streamData({
89
+ "topic": "target-data",
90
+ "session_id": session_id
91
+ });
92
+ };
93
+ const registerClick = async (session_id, item_id) => {
94
+ streamData({
95
+ "topic": "click-data",
96
+ "session_id": session_id,
97
+ "item_id": item_id
98
+ });
99
+ };
100
+
101
+ class CoreOutline {
102
+ constructor(access_key, secret_id) {
103
+ this.access_key = access_key;
104
+ this.secret_id = secret_id;
105
+ this.sessionDetails = startSession();
106
+ this.startSession = startSession;
107
+ this.pageDetails = updatePage(sessionDetails?.session_id, {});
108
+ this.updatePage = updatePage;
109
+ this.targetReached = targetReached;
110
+ this.registerClick = registerClick;
111
+ }
112
+ endSession() {
113
+ this.sessionDetails.end_time = Date.now();
114
+ }
115
+ }
116
+
117
+ exports.CoreOutline = CoreOutline;
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "core-outline",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "NPM package for react",
5
- "main": "dist/index.js",
6
- "module": "dist/index.es.js",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.es.js",
7
7
  "scripts": {
8
8
  "build-lib": "rollup -c",
9
9
  "test": "echo \"Error: no test specified\" && exit 1"
package/rollup.config.js CHANGED
@@ -29,7 +29,7 @@ export default [
29
29
  }),
30
30
  external(),
31
31
  resolve(),
32
- terser(),
32
+ // terser(),
33
33
  ]
34
34
  }
35
35
  ];
package/src/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import startSession from "./services/session/start-session";
2
2
  import updatePage from "./services/page/update-page";
3
3
  import { targetReached, registerClick } from "./services/target/update-target"
4
- class CoreOutline {
4
+
5
+ export class CoreOutline {
5
6
  constructor(access_key, secret_id) {
6
7
  this.access_key = access_key;
7
8
  this.secret_id = secret_id;
@@ -16,5 +17,4 @@ class CoreOutline {
16
17
  this.sessionDetails.end_time = Date.now()
17
18
  }
18
19
  }
19
-
20
- export default CoreOutline
20
+