core-outline 0.0.4 → 0.0.6

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,6 +1,10 @@
1
1
  const uuid = require('uuid');
2
- function createSessionUUID() {
3
- return uuid.v4();
2
+ const {
3
+ io: io$2
4
+ } = require('socket.io-client');
5
+ const socket$2 = io$2('http://localhost:4000');
6
+ function streamData$2(data) {
7
+ socket$2.emit('dataEvent', data);
4
8
  }
5
9
  const makeRequest = async ({
6
10
  url,
@@ -24,21 +28,10 @@ async function getSessionLocation() {
24
28
  });
25
29
  return res;
26
30
  }
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
31
  const startSession = async () => {
39
32
  let loc = await getSessionLocation();
40
33
  let session = {
41
- "session_id": createSessionUUID(),
34
+ "session_id": uuid.v4(),
42
35
  "start_time": Date.now(),
43
36
  "end_time": null,
44
37
  "device": getDeviceInfo()
@@ -48,6 +41,10 @@ const startSession = async () => {
48
41
  ...loc
49
42
  };
50
43
  console.log(session);
44
+ streamData$2({
45
+ "topic": "session-data",
46
+ "data": session
47
+ });
51
48
  return session;
52
49
  };
53
50
 
@@ -100,7 +97,7 @@ class CoreOutline {
100
97
  this.secret_id = secret_id;
101
98
  this.sessionDetails = startSession();
102
99
  this.startSession = startSession;
103
- this.pageDetails = updatePage(sessionDetails?.session_id, {});
100
+ this.pageDetails = updatePage(this.sessionDetails?.session_id, {});
104
101
  this.updatePage = updatePage;
105
102
  this.targetReached = targetReached;
106
103
  this.registerClick = registerClick;
package/dist/index.js CHANGED
@@ -3,8 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const uuid = require('uuid');
6
- function createSessionUUID() {
7
- return uuid.v4();
6
+ const {
7
+ io: io$2
8
+ } = require('socket.io-client');
9
+ const socket$2 = io$2('http://localhost:4000');
10
+ function streamData$2(data) {
11
+ socket$2.emit('dataEvent', data);
8
12
  }
9
13
  const makeRequest = async ({
10
14
  url,
@@ -28,21 +32,10 @@ async function getSessionLocation() {
28
32
  });
29
33
  return res;
30
34
  }
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
35
  const startSession = async () => {
43
36
  let loc = await getSessionLocation();
44
37
  let session = {
45
- "session_id": createSessionUUID(),
38
+ "session_id": uuid.v4(),
46
39
  "start_time": Date.now(),
47
40
  "end_time": null,
48
41
  "device": getDeviceInfo()
@@ -52,6 +45,10 @@ const startSession = async () => {
52
45
  ...loc
53
46
  };
54
47
  console.log(session);
48
+ streamData$2({
49
+ "topic": "session-data",
50
+ "data": session
51
+ });
55
52
  return session;
56
53
  };
57
54
 
@@ -104,7 +101,7 @@ class CoreOutline {
104
101
  this.secret_id = secret_id;
105
102
  this.sessionDetails = startSession();
106
103
  this.startSession = startSession;
107
- this.pageDetails = updatePage(sessionDetails?.session_id, {});
104
+ this.pageDetails = updatePage(this.sessionDetails?.session_id, {});
108
105
  this.updatePage = updatePage;
109
106
  this.targetReached = targetReached;
110
107
  this.registerClick = registerClick;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-outline",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "NPM package for react",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.es.js",
package/src/index.js CHANGED
@@ -8,7 +8,7 @@ export class CoreOutline {
8
8
  this.secret_id = secret_id;
9
9
  this.sessionDetails = startSession();
10
10
  this.startSession = startSession;
11
- this.pageDetails = updatePage(sessionDetails?.session_id, {}, "");
11
+ this.pageDetails = updatePage(this.sessionDetails?.session_id, {}, "");
12
12
  this.updatePage = updatePage;
13
13
  this.targetReached = targetReached;
14
14
  this.registerClick = registerClick;
@@ -1,15 +1,5 @@
1
- const { userAgent } = navigator;
2
- let device="mobile"
3
-
4
- const setDevice=(dev)=>{
5
- device=dev
6
- }
7
-
8
- userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
9
-
10
-
11
1
  const getDeviceInfo=()=>{
12
- console.log(userAgent);
2
+ let device = "mobile"
13
3
  return device
14
4
  }
15
5
 
@@ -1,8 +1,9 @@
1
1
  const uuid = require('uuid')
2
+ const { io} = require('socket.io-client');
3
+ const socket = io('http://localhost:4000');
2
4
 
3
- function createSessionUUID()
4
- {
5
- return uuid.v4()
5
+ function streamData(data){
6
+ socket.emit('dataEvent', data);
6
7
  }
7
8
 
8
9
  const makeRequest = async ({
@@ -28,24 +29,11 @@ async function getSessionLocation()
28
29
  return res
29
30
  }
30
31
 
31
- const { userAgent } = navigator;
32
- let device="mobile"
33
-
34
- const setDevice=(dev)=>{
35
- device=dev
36
- }
37
-
38
- userAgent.includes("Mobi") ? setDevice("mobile") : setDevice("desktop");
39
-
40
-
41
- const getDeviceInfo=()=>{
42
- return device
43
- }
44
32
 
45
33
  const startSession = async() =>{
46
34
  let loc = await getSessionLocation()
47
35
  let session = {
48
- "session_id": createSessionUUID(),
36
+ "session_id": uuid.v4(),
49
37
  "start_time": Date.now(),
50
38
  "end_time" : null,
51
39
  "device": getDeviceInfo(),
@@ -53,6 +41,8 @@ const startSession = async() =>{
53
41
  session = { ...session, ...loc}
54
42
  console.log(session)
55
43
 
44
+ streamData({"topic":"session-data", "data" : session })
45
+
56
46
  return session
57
47
  }
58
48