@stacksee/analytics 0.3.4 → 0.4.2
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/{client-bVe2QF_t.js → client-CyxgEISv.js} +35 -24
- package/dist/client.js +8 -7
- package/dist/index.js +15 -14
- package/dist/providers.js +4 -2615
- package/dist/server-BKqARaUf.js +174 -0
- package/dist/server.js +18 -9
- package/dist/src/adapters/client/browser-analytics.d.ts +2 -1
- package/dist/src/adapters/server/server-analytics.d.ts +4 -1
- package/dist/src/client/index.d.ts +2 -2
- package/dist/src/client.d.ts +5 -1
- package/dist/src/core/events/types.d.ts +2 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/providers/base.provider.d.ts +2 -1
- package/dist/src/providers/index.d.ts +2 -1
- package/dist/src/providers/posthog/client.d.ts +5 -3
- package/dist/src/providers/posthog/server.d.ts +5 -3
- package/dist/src/server/index.d.ts +1 -1
- package/dist/test/mock-provider.d.ts +7 -2
- package/package.json +3 -3
- package/readme.md +40 -2
- package/dist/module-BfXpy-Wp.js +0 -4198
- package/dist/src/providers/posthog/types.d.ts +0 -27
|
@@ -2,7 +2,7 @@ var c = Object.defineProperty;
|
|
|
2
2
|
var u = (t, e, i) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
3
3
|
var s = (t, e, i) => u(t, typeof e != "symbol" ? e + "" : e, i);
|
|
4
4
|
import { i as h } from "./environment-Bnc8FqHv.js";
|
|
5
|
-
class
|
|
5
|
+
class p {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
s(this, "providers", []);
|
|
8
8
|
s(this, "context", {});
|
|
@@ -52,7 +52,7 @@ class f {
|
|
|
52
52
|
timestamp: Date.now(),
|
|
53
53
|
userId: this.userId,
|
|
54
54
|
sessionId: this.sessionId
|
|
55
|
-
},
|
|
55
|
+
}, o = this.providers.map(async (d) => {
|
|
56
56
|
try {
|
|
57
57
|
await d.track(r, this.context);
|
|
58
58
|
} catch (l) {
|
|
@@ -62,11 +62,11 @@ class f {
|
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
|
-
await Promise.all(
|
|
65
|
+
await Promise.all(o);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
pageView(e) {
|
|
68
68
|
this.ensureInitialized().catch((i) => {
|
|
69
|
-
console.error("[Analytics] Failed to initialize during
|
|
69
|
+
console.error("[Analytics] Failed to initialize during pageView:", i);
|
|
70
70
|
}), this.updateContext({
|
|
71
71
|
page: {
|
|
72
72
|
path: window.location.pathname,
|
|
@@ -75,7 +75,14 @@ class f {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
for (const i of this.providers)
|
|
78
|
-
i.
|
|
78
|
+
i.pageView(e, this.context);
|
|
79
|
+
}
|
|
80
|
+
pageLeave(e) {
|
|
81
|
+
this.ensureInitialized().catch((i) => {
|
|
82
|
+
console.error("[Analytics] Failed to initialize during pageLeave:", i);
|
|
83
|
+
});
|
|
84
|
+
for (const i of this.providers)
|
|
85
|
+
i.pageLeave && i.pageLeave(e, this.context);
|
|
79
86
|
}
|
|
80
87
|
reset() {
|
|
81
88
|
this.userId = void 0, this.sessionId = this.generateSessionId();
|
|
@@ -83,14 +90,14 @@ class f {
|
|
|
83
90
|
e.reset();
|
|
84
91
|
}
|
|
85
92
|
updateContext(e) {
|
|
86
|
-
var i, r,
|
|
93
|
+
var i, r, o;
|
|
87
94
|
this.context = {
|
|
88
95
|
...this.context,
|
|
89
96
|
...e,
|
|
90
97
|
page: e.page ? {
|
|
91
98
|
path: e.page.path || ((i = this.context.page) == null ? void 0 : i.path) || window.location.pathname,
|
|
92
99
|
title: e.page.title || ((r = this.context.page) == null ? void 0 : r.title),
|
|
93
|
-
referrer: e.page.referrer || ((
|
|
100
|
+
referrer: e.page.referrer || ((o = this.context.page) == null ? void 0 : o.referrer)
|
|
94
101
|
} : this.context.page,
|
|
95
102
|
device: {
|
|
96
103
|
...this.context.device,
|
|
@@ -133,41 +140,45 @@ function m(t) {
|
|
|
133
140
|
debug: t.debug,
|
|
134
141
|
enabled: t.enabled
|
|
135
142
|
};
|
|
136
|
-
return n = new
|
|
143
|
+
return n = new p(
|
|
137
144
|
e
|
|
138
145
|
), n.initialize().catch((i) => {
|
|
139
146
|
console.error("[Analytics] Failed to initialize:", i);
|
|
140
147
|
}), n;
|
|
141
148
|
}
|
|
142
|
-
function
|
|
149
|
+
function a() {
|
|
143
150
|
if (!n)
|
|
144
151
|
throw new Error(
|
|
145
152
|
"[Analytics] Not initialized. Call createAnalytics() first."
|
|
146
153
|
);
|
|
147
154
|
return n;
|
|
148
155
|
}
|
|
156
|
+
function v(t, e) {
|
|
157
|
+
return a().track(t, e);
|
|
158
|
+
}
|
|
149
159
|
function y(t, e) {
|
|
150
|
-
|
|
160
|
+
a().identify(t, e);
|
|
151
161
|
}
|
|
152
|
-
function w(t
|
|
153
|
-
|
|
162
|
+
function w(t) {
|
|
163
|
+
a().pageView(t);
|
|
154
164
|
}
|
|
155
165
|
function z(t) {
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
function v() {
|
|
159
|
-
o().reset();
|
|
166
|
+
a().pageLeave(t);
|
|
160
167
|
}
|
|
161
168
|
function x() {
|
|
169
|
+
a().reset();
|
|
170
|
+
}
|
|
171
|
+
function A() {
|
|
162
172
|
n = null;
|
|
163
173
|
}
|
|
164
174
|
export {
|
|
165
|
-
|
|
166
|
-
|
|
175
|
+
p as B,
|
|
176
|
+
z as a,
|
|
177
|
+
A as b,
|
|
167
178
|
m as c,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
179
|
+
a as g,
|
|
180
|
+
y as i,
|
|
181
|
+
w as p,
|
|
182
|
+
x as r,
|
|
183
|
+
v as t
|
|
173
184
|
};
|
package/dist/client.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as s, c as t, g as c, i, a as n, p as r, r as l, b as y, t as g } from "./client-CyxgEISv.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
s as createAnalytics,
|
|
4
|
+
t as createClientAnalytics,
|
|
5
5
|
c as getAnalytics,
|
|
6
6
|
i as identify,
|
|
7
|
-
n as
|
|
8
|
-
r as
|
|
9
|
-
l as
|
|
10
|
-
y as
|
|
7
|
+
n as pageLeave,
|
|
8
|
+
r as pageView,
|
|
9
|
+
l as reset,
|
|
10
|
+
y as resetAnalyticsInstance,
|
|
11
|
+
g as track
|
|
11
12
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { ServerAnalytics as y, createServerAnalytics as
|
|
3
|
-
import {
|
|
1
|
+
import { B as r, c as t, g as s, i, a as n, p as o, r as l, t as c } from "./client-CyxgEISv.js";
|
|
2
|
+
import { ServerAnalytics as y, createServerAnalytics as C } from "./server.js";
|
|
3
|
+
import { B as p, P as A, a as P } from "./server-BKqARaUf.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
p as BaseAnalyticsProvider,
|
|
6
|
+
r as BrowserAnalytics,
|
|
7
|
+
A as PostHogClientProvider,
|
|
8
|
+
P as PostHogServerProvider,
|
|
9
9
|
y as ServerAnalytics,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
l as
|
|
10
|
+
t as createClientAnalytics,
|
|
11
|
+
C as createServerAnalytics,
|
|
12
|
+
s as getAnalytics,
|
|
13
|
+
i as identifyClient,
|
|
14
|
+
n as pageLeaveClient,
|
|
15
|
+
o as pageViewClient,
|
|
16
|
+
l as resetClient,
|
|
17
|
+
c as trackClient
|
|
17
18
|
};
|