core-outline 1.1.13 → 1.1.14

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 (3) hide show
  1. package/dist/index.es.js +621 -174
  2. package/dist/index.js +621 -174
  3. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -2,6 +2,393 @@ import React, { useState, useRef, useEffect } from 'react';
2
2
  import { v4 } from 'uuid';
3
3
  import { parse, installTimerFunctions, Socket as Socket$1, nextTick } from 'engine.io-client';
4
4
 
5
+ function _arrayLikeToArray(r, a) {
6
+ (null == a || a > r.length) && (a = r.length);
7
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
8
+ return n;
9
+ }
10
+ function _arrayWithHoles(r) {
11
+ if (Array.isArray(r)) return r;
12
+ }
13
+ function _arrayWithoutHoles(r) {
14
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
15
+ }
16
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
17
+ try {
18
+ var i = n[a](c),
19
+ u = i.value;
20
+ } catch (n) {
21
+ return void e(n);
22
+ }
23
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
24
+ }
25
+ function _asyncToGenerator(n) {
26
+ return function () {
27
+ var t = this,
28
+ e = arguments;
29
+ return new Promise(function (r, o) {
30
+ var a = n.apply(t, e);
31
+ function _next(n) {
32
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
33
+ }
34
+ function _throw(n) {
35
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
36
+ }
37
+ _next(void 0);
38
+ });
39
+ };
40
+ }
41
+ function _iterableToArray(r) {
42
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
43
+ }
44
+ function _iterableToArrayLimit(r, l) {
45
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
46
+ if (null != t) {
47
+ var e,
48
+ n,
49
+ i,
50
+ u,
51
+ a = [],
52
+ f = !0,
53
+ o = !1;
54
+ try {
55
+ if (i = (t = t.call(r)).next, 0 === l) {
56
+ if (Object(t) !== t) return;
57
+ f = !1;
58
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
59
+ } catch (r) {
60
+ o = !0, n = r;
61
+ } finally {
62
+ try {
63
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
64
+ } finally {
65
+ if (o) throw n;
66
+ }
67
+ }
68
+ return a;
69
+ }
70
+ }
71
+ function _nonIterableRest() {
72
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
+ }
74
+ function _nonIterableSpread() {
75
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
76
+ }
77
+ function _regeneratorRuntime() {
78
+ _regeneratorRuntime = function () {
79
+ return e;
80
+ };
81
+ var t,
82
+ e = {},
83
+ r = Object.prototype,
84
+ n = r.hasOwnProperty,
85
+ o = Object.defineProperty || function (t, e, r) {
86
+ t[e] = r.value;
87
+ },
88
+ i = "function" == typeof Symbol ? Symbol : {},
89
+ a = i.iterator || "@@iterator",
90
+ c = i.asyncIterator || "@@asyncIterator",
91
+ u = i.toStringTag || "@@toStringTag";
92
+ function define(t, e, r) {
93
+ return Object.defineProperty(t, e, {
94
+ value: r,
95
+ enumerable: !0,
96
+ configurable: !0,
97
+ writable: !0
98
+ }), t[e];
99
+ }
100
+ try {
101
+ define({}, "");
102
+ } catch (t) {
103
+ define = function (t, e, r) {
104
+ return t[e] = r;
105
+ };
106
+ }
107
+ function wrap(t, e, r, n) {
108
+ var i = e && e.prototype instanceof Generator ? e : Generator,
109
+ a = Object.create(i.prototype),
110
+ c = new Context(n || []);
111
+ return o(a, "_invoke", {
112
+ value: makeInvokeMethod(t, r, c)
113
+ }), a;
114
+ }
115
+ function tryCatch(t, e, r) {
116
+ try {
117
+ return {
118
+ type: "normal",
119
+ arg: t.call(e, r)
120
+ };
121
+ } catch (t) {
122
+ return {
123
+ type: "throw",
124
+ arg: t
125
+ };
126
+ }
127
+ }
128
+ e.wrap = wrap;
129
+ var h = "suspendedStart",
130
+ l = "suspendedYield",
131
+ f = "executing",
132
+ s = "completed",
133
+ y = {};
134
+ function Generator() {}
135
+ function GeneratorFunction() {}
136
+ function GeneratorFunctionPrototype() {}
137
+ var p = {};
138
+ define(p, a, function () {
139
+ return this;
140
+ });
141
+ var d = Object.getPrototypeOf,
142
+ v = d && d(d(values([])));
143
+ v && v !== r && n.call(v, a) && (p = v);
144
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
145
+ function defineIteratorMethods(t) {
146
+ ["next", "throw", "return"].forEach(function (e) {
147
+ define(t, e, function (t) {
148
+ return this._invoke(e, t);
149
+ });
150
+ });
151
+ }
152
+ function AsyncIterator(t, e) {
153
+ function invoke(r, o, i, a) {
154
+ var c = tryCatch(t[r], t, o);
155
+ if ("throw" !== c.type) {
156
+ var u = c.arg,
157
+ h = u.value;
158
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
159
+ invoke("next", t, i, a);
160
+ }, function (t) {
161
+ invoke("throw", t, i, a);
162
+ }) : e.resolve(h).then(function (t) {
163
+ u.value = t, i(u);
164
+ }, function (t) {
165
+ return invoke("throw", t, i, a);
166
+ });
167
+ }
168
+ a(c.arg);
169
+ }
170
+ var r;
171
+ o(this, "_invoke", {
172
+ value: function (t, n) {
173
+ function callInvokeWithMethodAndArg() {
174
+ return new e(function (e, r) {
175
+ invoke(t, n, e, r);
176
+ });
177
+ }
178
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
179
+ }
180
+ });
181
+ }
182
+ function makeInvokeMethod(e, r, n) {
183
+ var o = h;
184
+ return function (i, a) {
185
+ if (o === f) throw Error("Generator is already running");
186
+ if (o === s) {
187
+ if ("throw" === i) throw a;
188
+ return {
189
+ value: t,
190
+ done: !0
191
+ };
192
+ }
193
+ for (n.method = i, n.arg = a;;) {
194
+ var c = n.delegate;
195
+ if (c) {
196
+ var u = maybeInvokeDelegate(c, n);
197
+ if (u) {
198
+ if (u === y) continue;
199
+ return u;
200
+ }
201
+ }
202
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
203
+ if (o === h) throw o = s, n.arg;
204
+ n.dispatchException(n.arg);
205
+ } else "return" === n.method && n.abrupt("return", n.arg);
206
+ o = f;
207
+ var p = tryCatch(e, r, n);
208
+ if ("normal" === p.type) {
209
+ if (o = n.done ? s : l, p.arg === y) continue;
210
+ return {
211
+ value: p.arg,
212
+ done: n.done
213
+ };
214
+ }
215
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
216
+ }
217
+ };
218
+ }
219
+ function maybeInvokeDelegate(e, r) {
220
+ var n = r.method,
221
+ o = e.iterator[n];
222
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
223
+ var i = tryCatch(o, e.iterator, r.arg);
224
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
225
+ var a = i.arg;
226
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
227
+ }
228
+ function pushTryEntry(t) {
229
+ var e = {
230
+ tryLoc: t[0]
231
+ };
232
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
233
+ }
234
+ function resetTryEntry(t) {
235
+ var e = t.completion || {};
236
+ e.type = "normal", delete e.arg, t.completion = e;
237
+ }
238
+ function Context(t) {
239
+ this.tryEntries = [{
240
+ tryLoc: "root"
241
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
242
+ }
243
+ function values(e) {
244
+ if (e || "" === e) {
245
+ var r = e[a];
246
+ if (r) return r.call(e);
247
+ if ("function" == typeof e.next) return e;
248
+ if (!isNaN(e.length)) {
249
+ var o = -1,
250
+ i = function next() {
251
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
252
+ return next.value = t, next.done = !0, next;
253
+ };
254
+ return i.next = i;
255
+ }
256
+ }
257
+ throw new TypeError(typeof e + " is not iterable");
258
+ }
259
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
260
+ value: GeneratorFunctionPrototype,
261
+ configurable: !0
262
+ }), o(GeneratorFunctionPrototype, "constructor", {
263
+ value: GeneratorFunction,
264
+ configurable: !0
265
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
266
+ var e = "function" == typeof t && t.constructor;
267
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
268
+ }, e.mark = function (t) {
269
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
270
+ }, e.awrap = function (t) {
271
+ return {
272
+ __await: t
273
+ };
274
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
275
+ return this;
276
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
277
+ void 0 === i && (i = Promise);
278
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
279
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
280
+ return t.done ? t.value : a.next();
281
+ });
282
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
283
+ return this;
284
+ }), define(g, "toString", function () {
285
+ return "[object Generator]";
286
+ }), e.keys = function (t) {
287
+ var e = Object(t),
288
+ r = [];
289
+ for (var n in e) r.push(n);
290
+ return r.reverse(), function next() {
291
+ for (; r.length;) {
292
+ var t = r.pop();
293
+ if (t in e) return next.value = t, next.done = !1, next;
294
+ }
295
+ return next.done = !0, next;
296
+ };
297
+ }, e.values = values, Context.prototype = {
298
+ constructor: Context,
299
+ reset: function (e) {
300
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
301
+ },
302
+ stop: function () {
303
+ this.done = !0;
304
+ var t = this.tryEntries[0].completion;
305
+ if ("throw" === t.type) throw t.arg;
306
+ return this.rval;
307
+ },
308
+ dispatchException: function (e) {
309
+ if (this.done) throw e;
310
+ var r = this;
311
+ function handle(n, o) {
312
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
313
+ }
314
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
315
+ var i = this.tryEntries[o],
316
+ a = i.completion;
317
+ if ("root" === i.tryLoc) return handle("end");
318
+ if (i.tryLoc <= this.prev) {
319
+ var c = n.call(i, "catchLoc"),
320
+ u = n.call(i, "finallyLoc");
321
+ if (c && u) {
322
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
323
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
324
+ } else if (c) {
325
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
326
+ } else {
327
+ if (!u) throw Error("try statement without catch or finally");
328
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
329
+ }
330
+ }
331
+ }
332
+ },
333
+ abrupt: function (t, e) {
334
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
335
+ var o = this.tryEntries[r];
336
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
337
+ var i = o;
338
+ break;
339
+ }
340
+ }
341
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
342
+ var a = i ? i.completion : {};
343
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
344
+ },
345
+ complete: function (t, e) {
346
+ if ("throw" === t.type) throw t.arg;
347
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
348
+ },
349
+ finish: function (t) {
350
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
351
+ var r = this.tryEntries[e];
352
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
353
+ }
354
+ },
355
+ catch: function (t) {
356
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
357
+ var r = this.tryEntries[e];
358
+ if (r.tryLoc === t) {
359
+ var n = r.completion;
360
+ if ("throw" === n.type) {
361
+ var o = n.arg;
362
+ resetTryEntry(r);
363
+ }
364
+ return o;
365
+ }
366
+ }
367
+ throw Error("illegal catch attempt");
368
+ },
369
+ delegateYield: function (e, r, n) {
370
+ return this.delegate = {
371
+ iterator: values(e),
372
+ resultName: r,
373
+ nextLoc: n
374
+ }, "next" === this.method && (this.arg = t), y;
375
+ }
376
+ }, e;
377
+ }
378
+ function _slicedToArray(r, e) {
379
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
380
+ }
381
+ function _toConsumableArray(r) {
382
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
383
+ }
384
+ function _unsupportedIterableToArray(r, a) {
385
+ if (r) {
386
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
387
+ var t = {}.toString.call(r).slice(8, -1);
388
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
389
+ }
390
+ }
391
+
5
392
  var NodeType;
6
393
  (function (NodeType) {
7
394
  NodeType[NodeType["Document"] = 0] = "Document";
@@ -4595,11 +4982,11 @@ class BinaryReconstructor {
4595
4982
  }
4596
4983
 
4597
4984
  var parser = /*#__PURE__*/Object.freeze({
4598
- __proto__: null,
4599
- protocol: protocol,
4600
- get PacketType () { return PacketType; },
4601
- Encoder: Encoder,
4602
- Decoder: Decoder
4985
+ __proto__: null,
4986
+ protocol: protocol,
4987
+ get PacketType () { return PacketType; },
4988
+ Encoder: Encoder,
4989
+ Decoder: Decoder
4603
4990
  });
4604
4991
 
4605
4992
  function on(obj, ev, fn) {
@@ -5960,75 +6347,121 @@ Object.assign(lookup, {
5960
6347
  connect: lookup,
5961
6348
  });
5962
6349
 
5963
- const socket = lookup('http://localhost:8000');
6350
+ var socket = lookup('http://localhost:8000');
5964
6351
 
5965
- const CoreOutline = ({
5966
- children,
5967
- data_source_id,
5968
- data_source_secret
5969
- }) => {
5970
- const [events, setEvents] = useState([]);
5971
- const [replayEvents, setReplayEvents] = useState([]);
5972
- const recorderActive = useRef(false);
5973
- const [currentPage, setCurrentPage] = useState(window.location.href);
5974
- const [location, setLocation] = useState({
5975
- latitude: null,
5976
- longitude: null
5977
- });
5978
- const [browser, setBrowser] = useState(getBrowserInfo());
5979
- const [appToken, setAppToken] = useState('');
5980
- const [sessionId, setSessionId] = useState('');
5981
- async function authorizeApp(data_source_id, data_source_secret) {
5982
- const requestOptions = {
5983
- method: 'POST',
5984
- headers: {
5985
- 'Content-Type': 'application/json'
5986
- },
5987
- body: JSON.stringify({
5988
- data_source_id: data_source_id,
5989
- data_source_secret: data_source_secret
5990
- })
5991
- };
5992
- const response = fetch(`http://localhost:4000/data-source/authorize`, requestOptions).then(response => response.json()).then(data => {
5993
- setAppToken(data.app_token);
5994
- return data;
5995
- }).catch(error => {
5996
- console.error('Error:', error);
5997
- return error;
5998
- });
5999
- return response;
6352
+ var CoreOutline = function CoreOutline(_ref) {
6353
+ var children = _ref.children,
6354
+ data_source_id = _ref.data_source_id,
6355
+ data_source_secret = _ref.data_source_secret;
6356
+ var _useState = useState([]),
6357
+ _useState2 = _slicedToArray(_useState, 2),
6358
+ events = _useState2[0],
6359
+ setEvents = _useState2[1];
6360
+ var _useState3 = useState([]),
6361
+ _useState4 = _slicedToArray(_useState3, 2),
6362
+ replayEvents = _useState4[0],
6363
+ setReplayEvents = _useState4[1];
6364
+ var recorderActive = useRef(false);
6365
+ var _useState5 = useState(window.location.href),
6366
+ _useState6 = _slicedToArray(_useState5, 2),
6367
+ currentPage = _useState6[0],
6368
+ setCurrentPage = _useState6[1];
6369
+ var _useState7 = useState({
6370
+ latitude: null,
6371
+ longitude: null
6372
+ }),
6373
+ _useState8 = _slicedToArray(_useState7, 2),
6374
+ location = _useState8[0],
6375
+ setLocation = _useState8[1];
6376
+ var _useState9 = useState(getBrowserInfo()),
6377
+ _useState10 = _slicedToArray(_useState9, 2),
6378
+ browser = _useState10[0];
6379
+ _useState10[1];
6380
+ var _useState11 = useState(""),
6381
+ _useState12 = _slicedToArray(_useState11, 2);
6382
+ _useState12[0];
6383
+ var setAppToken = _useState12[1];
6384
+ var _useState13 = useState(v4()),
6385
+ _useState14 = _slicedToArray(_useState13, 2),
6386
+ sessionId = _useState14[0];
6387
+ _useState14[1];
6388
+ function authorizeApp(_x, _x2) {
6389
+ return _authorizeApp.apply(this, arguments);
6000
6390
  }
6001
- useEffect(async () => {
6002
- await authorizeApp(data_source_id, data_source_secret);
6003
- setSessionId(v4());
6004
- localStorage.setItem('coreOutlineSessionId', sessionId);
6005
- localStorage.setItem('coreOutlineDataSourceIdId', data_source_id);
6006
- console.log('Session', sessionId);
6007
- socket.send({
6008
- topic: 'session-data',
6009
- data_source_id: data_source_id,
6010
- session_id: sessionId,
6011
- start_date: new Date().toLocaleString(),
6012
- latitude: location.latitude,
6013
- longitude: location.longitude,
6014
- browser: browser,
6015
- event_id: 'SESSION_START'
6016
- });
6017
- return () => {
6018
- socket.send({
6019
- topic: 'session-data',
6020
- data_source_id: data_source_id,
6021
- session_id: sessionId,
6022
- start_date: new Date().toLocaleString(),
6023
- latitude: location.latitude,
6024
- longitude: location.longitude,
6025
- browser: browser,
6026
- event_id: 'SESSION_END'
6027
- });
6028
- };
6029
- }, []);
6030
- useEffect(() => {
6031
- const navigationEvent = {
6391
+ function _authorizeApp() {
6392
+ _authorizeApp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data_source_id, data_source_secret) {
6393
+ var requestOptions, response;
6394
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6395
+ while (1) switch (_context2.prev = _context2.next) {
6396
+ case 0:
6397
+ requestOptions = {
6398
+ method: "POST",
6399
+ headers: {
6400
+ "Content-Type": "application/json"
6401
+ },
6402
+ body: JSON.stringify({
6403
+ data_source_id: data_source_id,
6404
+ data_source_secret: data_source_secret
6405
+ })
6406
+ };
6407
+ response = fetch("http://localhost:4000/data-source/authorize", requestOptions).then(function (response) {
6408
+ return response.json();
6409
+ }).then(function (data) {
6410
+ setAppToken(data.app_token);
6411
+ return data;
6412
+ })["catch"](function (error) {
6413
+ console.error("Error:", error);
6414
+ return error;
6415
+ });
6416
+ return _context2.abrupt("return", response);
6417
+ case 3:
6418
+ case "end":
6419
+ return _context2.stop();
6420
+ }
6421
+ }, _callee2);
6422
+ }));
6423
+ return _authorizeApp.apply(this, arguments);
6424
+ }
6425
+ useEffect(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6426
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
6427
+ while (1) switch (_context.prev = _context.next) {
6428
+ case 0:
6429
+ _context.next = 2;
6430
+ return authorizeApp(data_source_id, data_source_secret);
6431
+ case 2:
6432
+ localStorage.setItem("coreOutlineSessionId", sessionId);
6433
+ localStorage.setItem("coreOutlineDataSourceIdId", data_source_id);
6434
+ console.log("Session", sessionId);
6435
+ socket.send({
6436
+ topic: "session-data",
6437
+ data_source_id: data_source_id,
6438
+ session_id: localStorage.getItem("coreOutlineSessionId"),
6439
+ start_date: new Date().toLocaleString(),
6440
+ latitude: location.latitude,
6441
+ longitude: location.longitude,
6442
+ browser: browser,
6443
+ event_id: "SESSION_START"
6444
+ });
6445
+ return _context.abrupt("return", function () {
6446
+ socket.send({
6447
+ topic: "session-data",
6448
+ data_source_id: data_source_id,
6449
+ session_id: localStorage.getItem("coreOutlineSessionId"),
6450
+ start_date: new Date().toLocaleString(),
6451
+ latitude: location.latitude,
6452
+ longitude: location.longitude,
6453
+ browser: browser,
6454
+ event_id: "SESSION_END"
6455
+ });
6456
+ });
6457
+ case 7:
6458
+ case "end":
6459
+ return _context.stop();
6460
+ }
6461
+ }, _callee);
6462
+ })), []);
6463
+ useEffect(function () {
6464
+ var navigationEvent = {
6032
6465
  type: 4,
6033
6466
  data: {
6034
6467
  href: window.location.href,
@@ -6037,65 +6470,72 @@ const CoreOutline = ({
6037
6470
  },
6038
6471
  timestamp: Date.now()
6039
6472
  };
6040
- const startTime = performance.now();
6041
- const observer = new MutationObserver(() => {
6042
- const endTime = performance.now();
6043
- const loadTime = endTime - startTime;
6473
+ var startTime = performance.now();
6474
+ var observer = new MutationObserver(function () {
6475
+ var endTime = performance.now();
6476
+ var loadTime = endTime - startTime;
6044
6477
  navigationEvent.data.loadTime = loadTime;
6045
- const hours = Math.floor(loadTime / 3600000);
6046
- const minutes = Math.floor(loadTime % 3600000 / 60000);
6047
- const seconds = Math.floor(loadTime % 60000 / 1000);
6048
- navigationEvent.data.loadTimeFormatted = `${hours} hours ${minutes} minutes ${seconds} seconds`;
6478
+ var hours = Math.floor(loadTime / 3600000);
6479
+ var minutes = Math.floor(loadTime % 3600000 / 60000);
6480
+ var seconds = Math.floor(loadTime % 60000 / 1000);
6481
+ navigationEvent.data.loadTimeFormatted = "".concat(hours, " hours ").concat(minutes, " minutes ").concat(seconds, " seconds");
6049
6482
  observer.disconnect();
6050
6483
  });
6051
6484
  observer.observe(document, {
6052
6485
  childList: true,
6053
6486
  subtree: true
6054
6487
  });
6055
- setEvents(prevEvents => [...prevEvents, navigationEvent]);
6056
- const handleNavigation = () => {
6488
+ setEvents(function (prevEvents) {
6489
+ return [].concat(_toConsumableArray(prevEvents), [navigationEvent]);
6490
+ });
6491
+ var handleNavigation = function handleNavigation() {
6057
6492
  setCurrentPage(window.location.href);
6058
6493
  socket.send({
6059
- topic: 'session-data',
6494
+ topic: "session-data",
6060
6495
  data_source_id: data_source_id,
6061
- session_id: sessionId,
6496
+ session_id: localStorage.getItem("coreOutlineSessionId"),
6062
6497
  start_date: new Date().toLocaleString(),
6063
6498
  latitude: location.latitude,
6064
6499
  longitude: location.longitude,
6065
6500
  browser: browser,
6066
6501
  page_name: window.location.href,
6067
- event_id: 'PAGE_NAVIGATION'
6502
+ event_id: "PAGE_NAVIGATION"
6068
6503
  });
6069
6504
  saveEvents(events);
6070
6505
  };
6071
- window.addEventListener('popstate', handleNavigation);
6072
- const originalPushState = window.history.pushState;
6073
- window.history.pushState = function (...args) {
6506
+ window.addEventListener("popstate", handleNavigation);
6507
+ var originalPushState = window.history.pushState;
6508
+ window.history.pushState = function () {
6509
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6510
+ args[_key] = arguments[_key];
6511
+ }
6074
6512
  originalPushState.apply(this, args);
6075
6513
  handleNavigation();
6076
6514
  };
6077
- return () => {
6078
- window.removeEventListener('popstate', handleNavigation);
6515
+ return function () {
6516
+ window.removeEventListener("popstate", handleNavigation);
6079
6517
  window.history.pushState = originalPushState;
6080
6518
  };
6081
6519
  }, [currentPage]);
6082
- useEffect(() => {
6083
- console.log('Location', location);
6520
+ useEffect(function () {
6521
+ console.log("Location", location);
6084
6522
  getLocation();
6085
6523
  }, []);
6086
- useEffect(() => {
6087
- let stopFn;
6524
+ useEffect(function () {
6525
+ var stopFn;
6088
6526
  if (!recorderActive.current) {
6089
6527
  stopFn = record({
6090
- emit(event) {
6091
- setReplayEvents(prevEvents => [...prevEvents, event]);
6528
+ emit: function emit(event) {
6529
+ setReplayEvents(function (prevEvents) {
6530
+ return [].concat(_toConsumableArray(prevEvents), [event]);
6531
+ });
6092
6532
  },
6093
6533
  maskAllInputs: false,
6094
6534
  maskTextSelector: null
6095
6535
  });
6096
6536
  recorderActive.current = true;
6097
6537
  }
6098
- return () => {
6538
+ return function () {
6099
6539
  if (stopFn) {
6100
6540
  stopFn();
6101
6541
  saveEvents(events);
@@ -6103,12 +6543,12 @@ const CoreOutline = ({
6103
6543
  }
6104
6544
  };
6105
6545
  }, []);
6106
- useEffect(() => {
6107
- let stopFn;
6546
+ useEffect(function () {
6547
+ var stopFn;
6108
6548
  if (!recorderActive.current) {
6109
6549
  stopFn = record({
6110
- emit(event) {
6111
- console.log('Event:', event);
6550
+ emit: function emit(event) {
6551
+ console.log("Event:", event);
6112
6552
  if (event.type == 3 && event.data.type == 2) {
6113
6553
  return;
6114
6554
  }
@@ -6122,16 +6562,18 @@ const CoreOutline = ({
6122
6562
  return;
6123
6563
  }
6124
6564
  if (event.type == 3 && event.data.type == 3) {
6125
- console.log('Contextmenu Event:', event);
6565
+ console.log("Contextmenu Event:", event);
6126
6566
  }
6127
- setEvents(prevEvents => [...prevEvents, event]);
6567
+ setEvents(function (prevEvents) {
6568
+ return [].concat(_toConsumableArray(prevEvents), [event]);
6569
+ });
6128
6570
  },
6129
6571
  maskAllInputs: false,
6130
6572
  maskTextSelector: null
6131
6573
  });
6132
6574
  recorderActive.current = true;
6133
6575
  }
6134
- return () => {
6576
+ return function () {
6135
6577
  if (stopFn) {
6136
6578
  stopFn();
6137
6579
  saveEvents(events);
@@ -6139,10 +6581,10 @@ const CoreOutline = ({
6139
6581
  }
6140
6582
  };
6141
6583
  }, []);
6142
- useEffect(() => {
6143
- const handleClick = event => {
6144
- console.log('Inner text:', event.target.innerText);
6145
- const clickEvent = {
6584
+ useEffect(function () {
6585
+ var handleClick = function handleClick(event) {
6586
+ console.log("Inner text:", event.target.innerText);
6587
+ var clickEvent = {
6146
6588
  type: EventType.IncrementalSnapshot,
6147
6589
  data: {
6148
6590
  source: IncrementalSource.MouseInteraction,
@@ -6153,139 +6595,144 @@ const CoreOutline = ({
6153
6595
  },
6154
6596
  timestamp: Date.now()
6155
6597
  };
6156
- const clickedElement = document.elementFromPoint(clickEvent.data.x, clickEvent.data.y);
6598
+ var clickedElement = document.elementFromPoint(clickEvent.data.x, clickEvent.data.y);
6157
6599
  if (clickedElement) {
6158
6600
  clickEvent.data.metadata = {
6159
- label: clickedElement.getAttribute('data-label') || clickedElement.innerText || null,
6160
- value: clickedElement.getAttribute('value') || clickedElement.innerText || null,
6161
- id: clickedElement.getAttribute('id') || clickedElement.innerText || null,
6162
- name: clickedElement.getAttribute('name') || clickedElement.innerText || null,
6163
- class: clickedElement.getAttribute('class') || clickedElement.innerText || null,
6601
+ label: clickedElement.getAttribute("data-label") || clickedElement.innerText || null,
6602
+ value: clickedElement.getAttribute("value") || clickedElement.innerText || null,
6603
+ id: clickedElement.getAttribute("id") || clickedElement.innerText || null,
6604
+ name: clickedElement.getAttribute("name") || clickedElement.innerText || null,
6605
+ "class": clickedElement.getAttribute("class") || clickedElement.innerText || null,
6164
6606
  tag: clickedElement.tagName,
6165
6607
  html: String(clickedElement.getHTML()),
6166
6608
  innerText: event.target.innerText
6167
6609
  };
6168
6610
  }
6169
- setEvents(prevEvents => [...prevEvents, clickEvent]);
6611
+ setEvents(function (prevEvents) {
6612
+ return [].concat(_toConsumableArray(prevEvents), [clickEvent]);
6613
+ });
6170
6614
  socket.send({
6171
- topic: 'session-data',
6615
+ topic: "session-data",
6172
6616
  data_source_id: data_source_id,
6173
- session_id: sessionId,
6617
+ session_id: localStorage.getItem("coreOutlineSessionId"),
6174
6618
  start_date: new Date().toLocaleString(),
6175
6619
  latitude: location.latitude,
6176
6620
  longitude: location.longitude,
6177
6621
  browser: browser,
6178
- event_id: 'ITEM_CLICKED'
6622
+ event_id: "ITEM_CLICKED"
6179
6623
  // item_clicked: event.target,
6180
6624
  });
6181
6625
  };
6182
- document.addEventListener('click', handleClick);
6183
- return () => {
6184
- document.removeEventListener('click', handleClick);
6626
+ document.addEventListener("click", handleClick);
6627
+ return function () {
6628
+ document.removeEventListener("click", handleClick);
6185
6629
  };
6186
6630
  }, []);
6187
6631
  function saveEvents(events) {
6188
- const requestOptions = {
6189
- method: 'PUT',
6632
+ var requestOptions = {
6633
+ method: "PUT",
6190
6634
  headers: {
6191
- 'Content-Type': 'application/json'
6635
+ "Content-Type": "application/json"
6192
6636
  },
6193
6637
  body: JSON.stringify(events)
6194
6638
  };
6195
- fetch(`http://localhost:5000/generate-s3-url/${data_source_id}/${sessionId}`).then(response => response.json()).then(data => {
6196
- const uploadURL = data.signed_url;
6639
+ fetch("http://localhost:5000/generate-s3-url/".concat(data_source_id, "/").concat(sessionId)).then(function (response) {
6640
+ return response.json();
6641
+ }).then(function (data) {
6642
+ var uploadURL = data.signed_url;
6197
6643
  return fetch(uploadURL, requestOptions);
6198
6644
  });
6199
6645
  }
6200
- function saveEventsLocally(type = 'formatted' ) {
6201
- let blob = '';
6202
- if (type === 'formatted') {
6646
+ function saveEventsLocally() {
6647
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "formatted" ;
6648
+ var blob = "";
6649
+ if (type === "formatted") {
6203
6650
  blob = new Blob([JSON.stringify(events, null, 2)], {
6204
- type: 'application/json'
6651
+ type: "application/json"
6205
6652
  });
6206
- } else if (type === 'raw') {
6653
+ } else if (type === "raw") {
6207
6654
  blob = new Blob([JSON.stringify(replayEvents, null, 2)], {
6208
- type: 'application/json'
6655
+ type: "application/json"
6209
6656
  });
6210
6657
  }
6211
- const url = URL.createObjectURL(blob);
6212
- const a = document.createElement('a');
6658
+ var url = URL.createObjectURL(blob);
6659
+ var a = document.createElement("a");
6213
6660
  a.href = url;
6214
- a.download = `${type}_events.json`;
6661
+ a.download = "".concat(type, "_events.json");
6215
6662
  a.click();
6216
6663
  URL.revokeObjectURL(url);
6217
6664
  }
6218
6665
  function getBrowserInfo() {
6219
- const userAgent = navigator.userAgent;
6220
- let browserName = 'Unknown';
6221
- if (userAgent.indexOf('Firefox') > -1) {
6222
- browserName = 'Firefox';
6223
- } else if (userAgent.indexOf('Opera') > -1 || userAgent.indexOf('OPR') > -1) {
6224
- browserName = 'Opera';
6225
- } else if (userAgent.indexOf('Chrome') > -1) {
6226
- browserName = 'Chrome';
6227
- } else if (userAgent.indexOf('Safari') > -1) {
6228
- browserName = 'Safari';
6229
- } else if (userAgent.indexOf('MSIE') > -1 || userAgent.indexOf('Trident/') > -1) {
6230
- browserName = 'Internet Explorer';
6666
+ var userAgent = navigator.userAgent;
6667
+ var browserName = "Unknown";
6668
+ if (userAgent.indexOf("Firefox") > -1) {
6669
+ browserName = "Firefox";
6670
+ } else if (userAgent.indexOf("Opera") > -1 || userAgent.indexOf("OPR") > -1) {
6671
+ browserName = "Opera";
6672
+ } else if (userAgent.indexOf("Chrome") > -1) {
6673
+ browserName = "Chrome";
6674
+ } else if (userAgent.indexOf("Safari") > -1) {
6675
+ browserName = "Safari";
6676
+ } else if (userAgent.indexOf("MSIE") > -1 || userAgent.indexOf("Trident/") > -1) {
6677
+ browserName = "Internet Explorer";
6231
6678
  }
6232
6679
  return browserName;
6233
6680
  }
6234
6681
  function getLocation() {
6235
6682
  if (navigator.geolocation) {
6236
- navigator.geolocation.getCurrentPosition(position => {
6683
+ navigator.geolocation.getCurrentPosition(function (position) {
6237
6684
  setLocation({
6238
6685
  latitude: position.coords.latitude,
6239
6686
  longitude: position.coords.longitude
6240
6687
  });
6241
- }, error => {
6242
- console.error('Error getting location:', error);
6688
+ }, function (error) {
6689
+ console.error("Error getting location:", error);
6243
6690
  });
6244
6691
  } else {
6245
- console.error('Geolocation is not supported by this browser.');
6692
+ console.error("Geolocation is not supported by this browser.");
6246
6693
  }
6247
6694
  }
6248
6695
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("button", {
6249
- onClick: () => {
6250
- saveEventsLocally('formatted');
6251
- saveEventsLocally('raw');
6696
+ onClick: function onClick() {
6697
+ saveEventsLocally("formatted");
6698
+ saveEventsLocally("raw");
6252
6699
  }
6253
6700
  }, "Save Events Locally"), children);
6254
6701
  };
6255
- const flag_item_clicked = item_id => {
6256
- const sessionId = localStorage.getItem('coreOutlineSessionId');
6257
- const dataSourceId = localStorage.getItem('coreOutlineDataSourceIdId');
6258
- console.log('Session', sessionId);
6259
- console.log('Data Source', dataSourceId);
6702
+ var flag_item_clicked = function flag_item_clicked(item_id) {
6703
+ var sessionId = localStorage.getItem("coreOutlineSessionId");
6704
+ var dataSourceId = localStorage.getItem("coreOutlineDataSourceIdId");
6705
+ console.log("Session", sessionId);
6706
+ console.log("Data Source", dataSourceId);
6260
6707
  socket.send({
6261
- topic: 'session-data',
6708
+ topic: "session-data",
6262
6709
  data_source_id: dataSourceId,
6263
- session_id: sessionId,
6710
+ session_id: localStorage.getItem("coreOutlineSessionId"),
6264
6711
  start_date: new Date().toLocaleString(),
6265
- event_id: 'PRODUCT_CLICKED',
6712
+ event_id: "PRODUCT_CLICKED",
6266
6713
  item_clicked: item_id
6267
6714
  });
6268
6715
  return {
6269
- status: 'success',
6270
- message: 'Item click flagged successfully.'
6716
+ status: "success",
6717
+ message: "Item click flagged successfully."
6271
6718
  };
6272
6719
  };
6273
- const flag_item_purchased = item_id => {
6274
- const sessionId = localStorage.getItem('coreOutlineSessionId');
6275
- const dataSourceId = localStorage.getItem('coreOutlineDataSourceIdId');
6276
- console.log('Session', sessionId);
6277
- console.log('Data Source', dataSourceId);
6720
+ var flag_item_purchased = function flag_item_purchased(item_id) {
6721
+ var sessionId = localStorage.getItem("coreOutlineSessionId");
6722
+ var dataSourceId = localStorage.getItem("coreOutlineDataSourceIdId");
6723
+ console.log("Session", sessionId);
6724
+ console.log("Data Source", dataSourceId);
6278
6725
  socket.send({
6279
- topic: 'session-data',
6726
+ topic: "session-data",
6280
6727
  data_source_id: dataSourceId,
6281
- session_id: sessionId,
6728
+ session_id: localStorage.getItem("coreOutlineSessionId"),
6282
6729
  start_date: new Date().toLocaleString(),
6283
- event_id: 'PRODUCT_PURCHASED',
6730
+ event_id: "PRODUCT_PURCHASED",
6284
6731
  item_clicked: item_id
6285
6732
  });
6286
6733
  return {
6287
- status: 'success',
6288
- message: 'Item purchase flagged successfully.'
6734
+ status: "success",
6735
+ message: "Item purchase flagged successfully."
6289
6736
  };
6290
6737
  };
6291
6738