@prism-analytics/browser 0.0.2 → 0.0.4
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.d.mts +0 -14
- package/dist/index.d.ts +0 -14
- package/dist/index.js +22 -2
- package/dist/index.mjs +22 -2
- package/package.json +12 -3
package/dist/index.d.mts
CHANGED
|
@@ -151,20 +151,6 @@ type BrowserPrismClient = PrismClient & {
|
|
|
151
151
|
}): CaptureResult;
|
|
152
152
|
} | null;
|
|
153
153
|
};
|
|
154
|
-
/**
|
|
155
|
-
* Create the minimal browser client (task-9 §11): a thin runtime adapter
|
|
156
|
-
* over the @prism-analytics/core engine. The core owns ALL queueing, consent,
|
|
157
|
-
* sanitization, session, authentication, and retry semantics — this
|
|
158
|
-
* package only translates browser primitives (fetch transport, local
|
|
159
|
-
* storage, timers, lifecycle events) into the runtime seam.
|
|
160
|
-
*
|
|
161
|
-
* - Fails loudly outside a browser (no half-working Node import).
|
|
162
|
-
* - Requires an explicit runtime `endpoint`.
|
|
163
|
-
* - Storage denial (privacy modes) degrades to the core's in-memory
|
|
164
|
-
* queue — never a crash.
|
|
165
|
-
* - Unload flushes use an AUTHENTICATED fetch keepalive — never an
|
|
166
|
-
* unauthenticated sendBeacon fallback.
|
|
167
|
-
*/
|
|
168
154
|
declare function createBrowserClient(options: BrowserClientOptions): Promise<BrowserPrismClient>;
|
|
169
155
|
|
|
170
156
|
export { type BrowserCaptureResult, type BrowserClientOptions, type BrowserErrorReporter, type BrowserErrorReporterOptions, type BrowserPageViewController, type BrowserPrismClient, type ErrorCaptureOptions, capturePageContext, createBrowserClient, createBrowserErrorReporter, normalizeErrorValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -151,20 +151,6 @@ type BrowserPrismClient = PrismClient & {
|
|
|
151
151
|
}): CaptureResult;
|
|
152
152
|
} | null;
|
|
153
153
|
};
|
|
154
|
-
/**
|
|
155
|
-
* Create the minimal browser client (task-9 §11): a thin runtime adapter
|
|
156
|
-
* over the @prism-analytics/core engine. The core owns ALL queueing, consent,
|
|
157
|
-
* sanitization, session, authentication, and retry semantics — this
|
|
158
|
-
* package only translates browser primitives (fetch transport, local
|
|
159
|
-
* storage, timers, lifecycle events) into the runtime seam.
|
|
160
|
-
*
|
|
161
|
-
* - Fails loudly outside a browser (no half-working Node import).
|
|
162
|
-
* - Requires an explicit runtime `endpoint`.
|
|
163
|
-
* - Storage denial (privacy modes) degrades to the core's in-memory
|
|
164
|
-
* queue — never a crash.
|
|
165
|
-
* - Unload flushes use an AUTHENTICATED fetch keepalive — never an
|
|
166
|
-
* unauthenticated sendBeacon fallback.
|
|
167
|
-
*/
|
|
168
154
|
declare function createBrowserClient(options: BrowserClientOptions): Promise<BrowserPrismClient>;
|
|
169
155
|
|
|
170
156
|
export { type BrowserCaptureResult, type BrowserClientOptions, type BrowserErrorReporter, type BrowserErrorReporterOptions, type BrowserPageViewController, type BrowserPrismClient, type ErrorCaptureOptions, capturePageContext, createBrowserClient, createBrowserErrorReporter, normalizeErrorValue };
|
package/dist/index.js
CHANGED
|
@@ -761,6 +761,25 @@ function createBrowserErrorReporter(options) {
|
|
|
761
761
|
|
|
762
762
|
// src/index.ts
|
|
763
763
|
var import_core4 = require("@prism-analytics/core");
|
|
764
|
+
function normalizeEndpoint(raw) {
|
|
765
|
+
try {
|
|
766
|
+
const url = new URL(raw);
|
|
767
|
+
const originalPath = url.pathname;
|
|
768
|
+
url.pathname = url.pathname.replace(/\/api\/v2\/ingest\/?$/, "");
|
|
769
|
+
url.search = "";
|
|
770
|
+
url.hash = "";
|
|
771
|
+
const normalized = url.origin + url.pathname.replace(/\/$/, "");
|
|
772
|
+
const trimmedRaw = raw.replace(/\/$/, "");
|
|
773
|
+
if (normalized !== trimmedRaw) {
|
|
774
|
+
console.warn(
|
|
775
|
+
`[prism] endpoint normalized: "${raw}" -> "${normalized}" (SDK appends /api/v2/ingest \u2014 use the bare origin)`
|
|
776
|
+
);
|
|
777
|
+
}
|
|
778
|
+
return normalized;
|
|
779
|
+
} catch (e) {
|
|
780
|
+
return raw.replace(/\/$/, "");
|
|
781
|
+
}
|
|
782
|
+
}
|
|
764
783
|
function createBrowserClient(options) {
|
|
765
784
|
return __async(this, null, function* () {
|
|
766
785
|
if (typeof window === "undefined") {
|
|
@@ -773,10 +792,11 @@ function createBrowserClient(options) {
|
|
|
773
792
|
"endpoint is required \u2014 choose the ingestion origin at runtime"
|
|
774
793
|
);
|
|
775
794
|
}
|
|
795
|
+
const endpoint = normalizeEndpoint(options.endpoint);
|
|
776
796
|
const runtime = createBrowserRuntime();
|
|
777
797
|
const client = yield (0, import_core3.createPrismClient)({
|
|
778
798
|
sourceKey: options.sourceKey,
|
|
779
|
-
endpoint
|
|
799
|
+
endpoint,
|
|
780
800
|
runtime,
|
|
781
801
|
collection: __spreadValues({
|
|
782
802
|
// Session-scoped identity by default (§4): the browser default
|
|
@@ -797,7 +817,7 @@ function createBrowserClient(options) {
|
|
|
797
817
|
client: coreClient,
|
|
798
818
|
options: options.pageViews,
|
|
799
819
|
sourceKey: options.sourceKey,
|
|
800
|
-
endpoint
|
|
820
|
+
endpoint
|
|
801
821
|
});
|
|
802
822
|
browserClient.pageViews = {
|
|
803
823
|
mode: tracker.mode,
|
package/dist/index.mjs
CHANGED
|
@@ -745,6 +745,25 @@ function createBrowserErrorReporter(options) {
|
|
|
745
745
|
|
|
746
746
|
// src/index.ts
|
|
747
747
|
import { framesFromStack as framesFromStack2 } from "@prism-analytics/core";
|
|
748
|
+
function normalizeEndpoint(raw) {
|
|
749
|
+
try {
|
|
750
|
+
const url = new URL(raw);
|
|
751
|
+
const originalPath = url.pathname;
|
|
752
|
+
url.pathname = url.pathname.replace(/\/api\/v2\/ingest\/?$/, "");
|
|
753
|
+
url.search = "";
|
|
754
|
+
url.hash = "";
|
|
755
|
+
const normalized = url.origin + url.pathname.replace(/\/$/, "");
|
|
756
|
+
const trimmedRaw = raw.replace(/\/$/, "");
|
|
757
|
+
if (normalized !== trimmedRaw) {
|
|
758
|
+
console.warn(
|
|
759
|
+
`[prism] endpoint normalized: "${raw}" -> "${normalized}" (SDK appends /api/v2/ingest \u2014 use the bare origin)`
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
return normalized;
|
|
763
|
+
} catch (e) {
|
|
764
|
+
return raw.replace(/\/$/, "");
|
|
765
|
+
}
|
|
766
|
+
}
|
|
748
767
|
function createBrowserClient(options) {
|
|
749
768
|
return __async(this, null, function* () {
|
|
750
769
|
if (typeof window === "undefined") {
|
|
@@ -757,10 +776,11 @@ function createBrowserClient(options) {
|
|
|
757
776
|
"endpoint is required \u2014 choose the ingestion origin at runtime"
|
|
758
777
|
);
|
|
759
778
|
}
|
|
779
|
+
const endpoint = normalizeEndpoint(options.endpoint);
|
|
760
780
|
const runtime = createBrowserRuntime();
|
|
761
781
|
const client = yield createPrismClient({
|
|
762
782
|
sourceKey: options.sourceKey,
|
|
763
|
-
endpoint
|
|
783
|
+
endpoint,
|
|
764
784
|
runtime,
|
|
765
785
|
collection: __spreadValues({
|
|
766
786
|
// Session-scoped identity by default (§4): the browser default
|
|
@@ -781,7 +801,7 @@ function createBrowserClient(options) {
|
|
|
781
801
|
client: coreClient,
|
|
782
802
|
options: options.pageViews,
|
|
783
803
|
sourceKey: options.sourceKey,
|
|
784
|
-
endpoint
|
|
804
|
+
endpoint
|
|
785
805
|
});
|
|
786
806
|
browserClient.pageViews = {
|
|
787
807
|
mode: tracker.mode,
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prism-analytics/browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
6
|
+
"build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts",
|
|
7
7
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
8
8
|
"lint": "tsc",
|
|
9
9
|
"test": "vitest run",
|
|
@@ -37,5 +37,14 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"description": "Prism Analytics SDK for the browser"
|
|
40
|
+
"description": "Prism Analytics SDK for the browser",
|
|
41
|
+
"homepage": "https://prism-analytics-docs.vercel.app/docs/start/javascript-sdk",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/OrekuD/prism.git",
|
|
45
|
+
"directory": "packages/browser"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/OrekuD/prism/issues"
|
|
49
|
+
}
|
|
41
50
|
}
|