@extn/segi-js 0.2.8 → 0.2.11

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.js CHANGED
@@ -55,7 +55,18 @@ function buildEvent(state2, base) {
55
55
  }
56
56
 
57
57
  // src/transport.ts
58
+
59
+
60
+
58
61
  var _segishared = require('@extn/segi-shared');
62
+ function resolveIngestUrl(endpoint) {
63
+ const raw = endpoint && endpoint.trim() || _segishared.SEGI_DEFAULT_INGEST_ENDPOINT;
64
+ if (/\/api\/ingest\/events\/?$/.test(raw)) {
65
+ return raw.replace(/\/+$/, "");
66
+ }
67
+ const base = raw.replace(/\/+$/, "").replace(/\/api\/ingest$/, "").replace(/\/api$/, "");
68
+ return `${base || _segishared.SEGI_DEFAULT_API_BASE}/api/ingest/events`;
69
+ }
59
70
  var warnedKeys = /* @__PURE__ */ new Set();
60
71
  function warnOnce(key, message) {
61
72
  if (warnedKeys.has(key)) return;
@@ -74,7 +85,7 @@ function describeStatus(status) {
74
85
  return "ingest returned a non-2xx response";
75
86
  }
76
87
  function send(endpoint, projectKey, event) {
77
- const url = endpoint || _segishared.SEGI_DEFAULT_INGEST_ENDPOINT;
88
+ const url = resolveIngestUrl(endpoint);
78
89
  if (!url || !projectKey) {
79
90
  warnOnce(
80
91
  "missing-config",
package/dist/index.mjs CHANGED
@@ -55,7 +55,18 @@ function buildEvent(state2, base) {
55
55
  }
56
56
 
57
57
  // src/transport.ts
58
- import { SEGI_DEFAULT_INGEST_ENDPOINT } from "@extn/segi-shared";
58
+ import {
59
+ SEGI_DEFAULT_API_BASE,
60
+ SEGI_DEFAULT_INGEST_ENDPOINT
61
+ } from "@extn/segi-shared";
62
+ function resolveIngestUrl(endpoint) {
63
+ const raw = endpoint && endpoint.trim() || SEGI_DEFAULT_INGEST_ENDPOINT;
64
+ if (/\/api\/ingest\/events\/?$/.test(raw)) {
65
+ return raw.replace(/\/+$/, "");
66
+ }
67
+ const base = raw.replace(/\/+$/, "").replace(/\/api\/ingest$/, "").replace(/\/api$/, "");
68
+ return `${base || SEGI_DEFAULT_API_BASE}/api/ingest/events`;
69
+ }
59
70
  var warnedKeys = /* @__PURE__ */ new Set();
60
71
  function warnOnce(key, message) {
61
72
  if (warnedKeys.has(key)) return;
@@ -74,7 +85,7 @@ function describeStatus(status) {
74
85
  return "ingest returned a non-2xx response";
75
86
  }
76
87
  function send(endpoint, projectKey, event) {
77
- const url = endpoint || SEGI_DEFAULT_INGEST_ENDPOINT;
88
+ const url = resolveIngestUrl(endpoint);
78
89
  if (!url || !projectKey) {
79
90
  warnOnce(
80
91
  "missing-config",
@@ -351,6 +351,16 @@ async function activateReplay(args) {
351
351
  clickCount: 0,
352
352
  recordingEnabled: true
353
353
  };
354
+ let lastSessionBump = Date.now();
355
+ const bumpIfStale = () => {
356
+ const now = Date.now();
357
+ if (now - lastSessionBump < 6e4) return;
358
+ lastSessionBump = now;
359
+ bumpSessionActivity();
360
+ };
361
+ for (const ev of ["mousedown", "keydown", "scroll", "touchstart"]) {
362
+ window.addEventListener(ev, bumpIfStale, { passive: true, capture: true });
363
+ }
354
364
  const w = window;
355
365
  const scheduleRrwebStart = (run) => {
356
366
  let fired = false;
@@ -506,6 +516,7 @@ var replayApi = {
506
516
  */
507
517
  notifyRouteChange(url, title) {
508
518
  if (!active) return;
519
+ bumpSessionActivity();
509
520
  const nowBlocked = isPathBlocked(active.options, location.pathname);
510
521
  if (nowBlocked) {
511
522
  if (!active.paused) {
@@ -351,6 +351,16 @@ async function activateReplay(args) {
351
351
  clickCount: 0,
352
352
  recordingEnabled: true
353
353
  };
354
+ let lastSessionBump = Date.now();
355
+ const bumpIfStale = () => {
356
+ const now = Date.now();
357
+ if (now - lastSessionBump < 6e4) return;
358
+ lastSessionBump = now;
359
+ bumpSessionActivity();
360
+ };
361
+ for (const ev of ["mousedown", "keydown", "scroll", "touchstart"]) {
362
+ window.addEventListener(ev, bumpIfStale, { passive: true, capture: true });
363
+ }
354
364
  const w = window;
355
365
  const scheduleRrwebStart = (run) => {
356
366
  let fired = false;
@@ -506,6 +516,7 @@ var replayApi = {
506
516
  */
507
517
  notifyRouteChange(url, title) {
508
518
  if (!active) return;
519
+ bumpSessionActivity();
509
520
  const nowBlocked = isPathBlocked(active.options, location.pathname);
510
521
  if (nowBlocked) {
511
522
  if (!active.paused) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extn/segi-js",
3
- "version": "0.2.8",
3
+ "version": "0.2.11",
4
4
  "description": "Browser JavaScript SDK for the segi error monitoring service",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",