@stacksee/analytics 0.3.2 → 0.3.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/{client-yfDfetWt.js → client-bVe2QF_t.js} +17 -16
- package/dist/client.js +1 -1
- package/dist/environment-Bnc8FqHv.js +6 -0
- package/dist/index.js +1 -1
- package/dist/providers.js +110 -104
- package/dist/src/client.d.ts +1 -8
- package/dist/src/core/events/index.d.ts +7 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/providers/posthog/client.d.ts +0 -6
- package/dist/src/server.d.ts +1 -8
- package/dist/src/utils/environment.d.ts +18 -0
- package/dist/test/utils.test.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
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 f {
|
|
5
6
|
constructor(e) {
|
|
6
7
|
s(this, "providers", []);
|
|
7
8
|
s(this, "context", {});
|
|
@@ -12,7 +13,7 @@ class h {
|
|
|
12
13
|
this.providers = e.providers, e.defaultContext && (this.context = { ...e.defaultContext }), this.sessionId = this.generateSessionId();
|
|
13
14
|
}
|
|
14
15
|
async initialize() {
|
|
15
|
-
if (!this.initialized)
|
|
16
|
+
if (h() && !this.initialized)
|
|
16
17
|
return this.initializePromise ? this.initializePromise : (this.initializePromise = this._doInitialize(), this.initializePromise);
|
|
17
18
|
}
|
|
18
19
|
async _doInitialize() {
|
|
@@ -124,7 +125,7 @@ class h {
|
|
|
124
125
|
}
|
|
125
126
|
}
|
|
126
127
|
let n = null;
|
|
127
|
-
function
|
|
128
|
+
function m(t) {
|
|
128
129
|
if (n)
|
|
129
130
|
return console.warn("[Analytics] Already initialized"), n;
|
|
130
131
|
const e = {
|
|
@@ -132,7 +133,7 @@ function p(t) {
|
|
|
132
133
|
debug: t.debug,
|
|
133
134
|
enabled: t.enabled
|
|
134
135
|
};
|
|
135
|
-
return n = new
|
|
136
|
+
return n = new f(
|
|
136
137
|
e
|
|
137
138
|
), n.initialize().catch((i) => {
|
|
138
139
|
console.error("[Analytics] Failed to initialize:", i);
|
|
@@ -145,28 +146,28 @@ function o() {
|
|
|
145
146
|
);
|
|
146
147
|
return n;
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
+
function y(t, e) {
|
|
149
150
|
return o().track(t, e);
|
|
150
151
|
}
|
|
151
|
-
function
|
|
152
|
+
function w(t, e) {
|
|
152
153
|
o().identify(t, e);
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
+
function z(t) {
|
|
155
156
|
o().page(t);
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function v() {
|
|
158
159
|
o().reset();
|
|
159
160
|
}
|
|
160
|
-
function
|
|
161
|
+
function x() {
|
|
161
162
|
n = null;
|
|
162
163
|
}
|
|
163
164
|
export {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
f as B,
|
|
166
|
+
x as a,
|
|
167
|
+
m as c,
|
|
167
168
|
o as g,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
w as i,
|
|
170
|
+
z as p,
|
|
171
|
+
v as r,
|
|
172
|
+
y as t
|
|
172
173
|
};
|
package/dist/client.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as t, c as a, g as i, i as s, p as o, r as n, t as l } from "./client-
|
|
1
|
+
import { B as t, c as a, g as i, i as s, p as o, r as n, t as l } from "./client-bVe2QF_t.js";
|
|
2
2
|
import { ServerAnalytics as y, createServerAnalytics as v } from "./server.js";
|
|
3
3
|
import { BaseAnalyticsProvider as C, PostHogClientProvider as g, PostHogServerProvider as p } from "./providers.js";
|
|
4
4
|
export {
|
package/dist/providers.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var L = (s, r, e) =>
|
|
4
|
-
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var ue = (s, r, e) => r in s ? ae(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
+
var L = (s, r, e) => ue(s, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { i as U } from "./environment-Bnc8FqHv.js";
|
|
5
|
+
class Z {
|
|
5
6
|
constructor(r) {
|
|
6
7
|
L(this, "debug", !1);
|
|
7
8
|
L(this, "enabled", !0);
|
|
@@ -14,7 +15,7 @@ class X {
|
|
|
14
15
|
return this.enabled;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
class
|
|
18
|
+
class je extends Z {
|
|
18
19
|
constructor(e) {
|
|
19
20
|
super({ debug: e.debug, enabled: e.enabled });
|
|
20
21
|
L(this, "name", "PostHog-Client");
|
|
@@ -25,6 +26,10 @@ class xe extends X {
|
|
|
25
26
|
}
|
|
26
27
|
async initialize() {
|
|
27
28
|
if (this.isEnabled() && !this.initialized) {
|
|
29
|
+
if (!U()) {
|
|
30
|
+
this.log("Skipping initialization - not in browser environment");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
28
33
|
if (!this.config.apiKey || typeof this.config.apiKey != "string")
|
|
29
34
|
throw new Error("PostHog requires an apiKey");
|
|
30
35
|
try {
|
|
@@ -38,7 +43,7 @@ class xe extends X {
|
|
|
38
43
|
disable_cookie: this.config.disableCookie ?? !1,
|
|
39
44
|
persistence: this.config.persistenceType ?? "localStorage",
|
|
40
45
|
person_profiles: this.config.personProfiles ?? "identified_only"
|
|
41
|
-
}), this.posthog = e,
|
|
46
|
+
}), this.posthog = e, this.initialized = !0, this.log("Initialized successfully", this.config);
|
|
42
47
|
} catch (e) {
|
|
43
48
|
throw console.error("[PostHog-Client] Failed to initialize:", e), e;
|
|
44
49
|
}
|
|
@@ -62,7 +67,8 @@ class xe extends X {
|
|
|
62
67
|
this.posthog.capture(e.action, n), this.log("Tracked event", { event: e, context: t });
|
|
63
68
|
}
|
|
64
69
|
page(e, t) {
|
|
65
|
-
if (!this.isEnabled() || !this.initialized || !this.posthog)
|
|
70
|
+
if (!this.isEnabled() || !this.initialized || !this.posthog || !U())
|
|
71
|
+
return;
|
|
66
72
|
const n = {
|
|
67
73
|
...e,
|
|
68
74
|
...(t == null ? void 0 : t.page) && {
|
|
@@ -74,15 +80,15 @@ class xe extends X {
|
|
|
74
80
|
this.posthog.capture("$pageview", n), this.log("Tracked page view", { properties: e, context: t });
|
|
75
81
|
}
|
|
76
82
|
reset() {
|
|
77
|
-
!this.isEnabled() || !this.initialized || !this.posthog || (this.posthog.reset(), this.log("Reset user session"));
|
|
83
|
+
!this.isEnabled() || !this.initialized || !this.posthog || !U() || (this.posthog.reset(), this.log("Reset user session"));
|
|
78
84
|
}
|
|
79
85
|
}
|
|
80
|
-
var D = { exports: {} },
|
|
81
|
-
function
|
|
82
|
-
return
|
|
86
|
+
var D = { exports: {} }, le = D.exports, W;
|
|
87
|
+
function ce() {
|
|
88
|
+
return W || (W = 1, function(s, r) {
|
|
83
89
|
(function(t, n) {
|
|
84
90
|
s.exports = n();
|
|
85
|
-
})(typeof self < "u" ? self :
|
|
91
|
+
})(typeof self < "u" ? self : le, function() {
|
|
86
92
|
return (
|
|
87
93
|
/******/
|
|
88
94
|
function(e) {
|
|
@@ -596,18 +602,18 @@ function le() {
|
|
|
596
602
|
});
|
|
597
603
|
}(D)), D.exports;
|
|
598
604
|
}
|
|
599
|
-
var
|
|
600
|
-
return
|
|
605
|
+
var fe = ce(), $ = function(s, r) {
|
|
606
|
+
return $ = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, t) {
|
|
601
607
|
e.__proto__ = t;
|
|
602
608
|
} || function(e, t) {
|
|
603
609
|
for (var n in t)
|
|
604
610
|
Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
|
|
605
|
-
},
|
|
611
|
+
}, $(s, r);
|
|
606
612
|
};
|
|
607
613
|
function x(s, r) {
|
|
608
614
|
if (typeof r != "function" && r !== null)
|
|
609
615
|
throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
|
|
610
|
-
|
|
616
|
+
$(s, r);
|
|
611
617
|
function e() {
|
|
612
618
|
this.constructor = s;
|
|
613
619
|
}
|
|
@@ -623,7 +629,7 @@ var F = function() {
|
|
|
623
629
|
return r;
|
|
624
630
|
}, F.apply(this, arguments);
|
|
625
631
|
};
|
|
626
|
-
function
|
|
632
|
+
function he(s, r) {
|
|
627
633
|
var e = {};
|
|
628
634
|
for (var t in s)
|
|
629
635
|
Object.prototype.hasOwnProperty.call(s, t) && r.indexOf(t) < 0 && (e[t] = s[t]);
|
|
@@ -724,23 +730,23 @@ function E(s, r) {
|
|
|
724
730
|
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
725
731
|
}
|
|
726
732
|
}
|
|
727
|
-
function
|
|
733
|
+
function ee(s, r, e) {
|
|
728
734
|
for (var t = 0, n = r.length, i; t < n; t++)
|
|
729
735
|
(i || !(t in r)) && (i || (i = Array.prototype.slice.call(r, 0, t)), i[t] = r[t]);
|
|
730
736
|
return s.concat(i || Array.prototype.slice.call(r));
|
|
731
737
|
}
|
|
732
|
-
var
|
|
738
|
+
var z = "3.6.3", _;
|
|
733
739
|
(function(s) {
|
|
734
740
|
s.AnonymousId = "anonymous_id", s.DistinctId = "distinct_id", s.Props = "props", s.FeatureFlags = "feature_flags", s.FeatureFlagPayloads = "feature_flag_payloads", s.OverrideFeatureFlags = "override_feature_flags", s.Queue = "queue", s.OptedOut = "opted_out", s.SessionId = "session_id", s.SessionLastTimestamp = "session_timestamp", s.PersonProperties = "person_properties", s.GroupProperties = "group_properties", s.InstalledAppBuild = "installed_app_build", s.InstalledAppVersion = "installed_app_version";
|
|
735
741
|
})(_ || (_ = {}));
|
|
736
|
-
function
|
|
742
|
+
function de(s, r) {
|
|
737
743
|
if (!s)
|
|
738
744
|
throw new Error(r);
|
|
739
745
|
}
|
|
740
|
-
function
|
|
746
|
+
function pe(s) {
|
|
741
747
|
return s == null ? void 0 : s.replace(/\/+$/, "");
|
|
742
748
|
}
|
|
743
|
-
function
|
|
749
|
+
function ve(s, r) {
|
|
744
750
|
return r === void 0 && (r = {}), A(this, void 0, void 0, function() {
|
|
745
751
|
var e, t, n, i, o, u, l, c, h, g;
|
|
746
752
|
return E(this, function(d) {
|
|
@@ -771,18 +777,18 @@ function pe(s, r) {
|
|
|
771
777
|
});
|
|
772
778
|
});
|
|
773
779
|
}
|
|
774
|
-
function
|
|
780
|
+
function ge() {
|
|
775
781
|
return (/* @__PURE__ */ new Date()).getTime();
|
|
776
782
|
}
|
|
777
|
-
function
|
|
783
|
+
function B() {
|
|
778
784
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
779
785
|
}
|
|
780
|
-
function
|
|
786
|
+
function te(s, r) {
|
|
781
787
|
var e = setTimeout(s, r);
|
|
782
788
|
return e != null && e.unref && (e == null || e.unref()), e;
|
|
783
789
|
}
|
|
784
|
-
var M = String.fromCharCode,
|
|
785
|
-
function
|
|
790
|
+
var M = String.fromCharCode, H = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", R = {};
|
|
791
|
+
function ye(s, r) {
|
|
786
792
|
if (!R[s]) {
|
|
787
793
|
R[s] = {};
|
|
788
794
|
for (var e = 0; e < s.length; e++)
|
|
@@ -795,7 +801,7 @@ var j = {
|
|
|
795
801
|
if (s == null)
|
|
796
802
|
return "";
|
|
797
803
|
var r = j._compress(s, 6, function(e) {
|
|
798
|
-
return
|
|
804
|
+
return H.charAt(e);
|
|
799
805
|
});
|
|
800
806
|
switch (r.length % 4) {
|
|
801
807
|
default:
|
|
@@ -812,7 +818,7 @@ var j = {
|
|
|
812
818
|
},
|
|
813
819
|
decompressFromBase64: function(s) {
|
|
814
820
|
return s == null ? "" : s == "" ? null : j._decompress(s.length, 32, function(r) {
|
|
815
|
-
return
|
|
821
|
+
return ye(H, s.charAt(r));
|
|
816
822
|
});
|
|
817
823
|
},
|
|
818
824
|
compress: function(s) {
|
|
@@ -928,7 +934,7 @@ var j = {
|
|
|
928
934
|
n.push(c), t[u++] = g + c.charAt(0), o--, g = c, o == 0 && (o = Math.pow(2, l), l++);
|
|
929
935
|
}
|
|
930
936
|
}
|
|
931
|
-
},
|
|
937
|
+
}, we = (
|
|
932
938
|
/** @class */
|
|
933
939
|
function() {
|
|
934
940
|
function s() {
|
|
@@ -960,7 +966,7 @@ var j = {
|
|
|
960
966
|
* @copyright 2021-2023 LiosK
|
|
961
967
|
* @packageDocumentation
|
|
962
968
|
*/
|
|
963
|
-
var T = "0123456789abcdef",
|
|
969
|
+
var T = "0123456789abcdef", q = (
|
|
964
970
|
/** @class */
|
|
965
971
|
function() {
|
|
966
972
|
function s(r) {
|
|
@@ -1041,11 +1047,11 @@ var T = "0123456789abcdef", H = (
|
|
|
1041
1047
|
return 0;
|
|
1042
1048
|
}, s;
|
|
1043
1049
|
}()
|
|
1044
|
-
),
|
|
1050
|
+
), be = (
|
|
1045
1051
|
/** @class */
|
|
1046
1052
|
function() {
|
|
1047
1053
|
function s(r) {
|
|
1048
|
-
this.timestamp = 0, this.counter = 0, this.random = r ??
|
|
1054
|
+
this.timestamp = 0, this.counter = 0, this.random = r ?? me();
|
|
1049
1055
|
}
|
|
1050
1056
|
return s.prototype.generate = function() {
|
|
1051
1057
|
return this.generateOrResetCore(Date.now(), 1e4);
|
|
@@ -1066,25 +1072,25 @@ var T = "0123456789abcdef", H = (
|
|
|
1066
1072
|
this.counter++, this.counter > t && (this.timestamp++, this.resetCounter());
|
|
1067
1073
|
else
|
|
1068
1074
|
return;
|
|
1069
|
-
return
|
|
1075
|
+
return q.fromFieldsV7(this.timestamp, Math.trunc(this.counter / Math.pow(2, 30)), this.counter & Math.pow(2, 30) - 1, this.random.nextUint32());
|
|
1070
1076
|
}, s.prototype.resetCounter = function() {
|
|
1071
1077
|
this.counter = this.random.nextUint32() * 1024 + (this.random.nextUint32() & 1023);
|
|
1072
1078
|
}, s.prototype.generateV4 = function() {
|
|
1073
1079
|
var r = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
|
|
1074
|
-
return r[6] = 64 | r[6] >>> 4, r[8] = 128 | r[8] >>> 2,
|
|
1080
|
+
return r[6] = 64 | r[6] >>> 4, r[8] = 128 | r[8] >>> 2, q.ofInner(r);
|
|
1075
1081
|
}, s;
|
|
1076
1082
|
}()
|
|
1077
|
-
),
|
|
1083
|
+
), me = function() {
|
|
1078
1084
|
return {
|
|
1079
1085
|
nextUint32: function() {
|
|
1080
1086
|
return Math.trunc(Math.random() * 65536) * 65536 + Math.trunc(Math.random() * 65536);
|
|
1081
1087
|
}
|
|
1082
1088
|
};
|
|
1083
|
-
},
|
|
1084
|
-
return
|
|
1085
|
-
},
|
|
1086
|
-
return (
|
|
1087
|
-
},
|
|
1089
|
+
}, N, G = function() {
|
|
1090
|
+
return Fe().toString();
|
|
1091
|
+
}, Fe = function() {
|
|
1092
|
+
return (N || (N = new be())).generate();
|
|
1093
|
+
}, Pe = (
|
|
1088
1094
|
/** @class */
|
|
1089
1095
|
function(s) {
|
|
1090
1096
|
x(r, s);
|
|
@@ -1094,7 +1100,7 @@ var T = "0123456789abcdef", H = (
|
|
|
1094
1100
|
}
|
|
1095
1101
|
return r;
|
|
1096
1102
|
}(Error)
|
|
1097
|
-
),
|
|
1103
|
+
), _e = (
|
|
1098
1104
|
/** @class */
|
|
1099
1105
|
function(s) {
|
|
1100
1106
|
x(r, s);
|
|
@@ -1109,18 +1115,18 @@ var T = "0123456789abcdef", H = (
|
|
|
1109
1115
|
return r;
|
|
1110
1116
|
}(Error)
|
|
1111
1117
|
);
|
|
1112
|
-
function
|
|
1118
|
+
function J(s) {
|
|
1113
1119
|
return typeof s == "object" && (s.name === "PostHogFetchHttpError" || s.name === "PostHogFetchNetworkError");
|
|
1114
1120
|
}
|
|
1115
|
-
var
|
|
1121
|
+
var re = (
|
|
1116
1122
|
/** @class */
|
|
1117
1123
|
function() {
|
|
1118
1124
|
function s(r, e) {
|
|
1119
1125
|
var t, n, i, o, u;
|
|
1120
|
-
this.debugMode = !1, this.disableGeoip = !0, this.pendingPromises = {}, this._events = new
|
|
1126
|
+
this.debugMode = !1, this.disableGeoip = !0, this.pendingPromises = {}, this._events = new we(), de(r, "You must pass your PostHog project's api key."), this.apiKey = r, this.host = pe((e == null ? void 0 : e.host) || "https://app.posthog.com"), this.flushAt = e != null && e.flushAt ? Math.max(e == null ? void 0 : e.flushAt, 1) : 20, this.flushInterval = (t = e == null ? void 0 : e.flushInterval) !== null && t !== void 0 ? t : 1e4, this.captureMode = (e == null ? void 0 : e.captureMode) || "form", this._optoutOverride = (e == null ? void 0 : e.enable) === !1, this._retryOptions = {
|
|
1121
1127
|
retryCount: (n = e == null ? void 0 : e.fetchRetryCount) !== null && n !== void 0 ? n : 3,
|
|
1122
1128
|
retryDelay: (i = e == null ? void 0 : e.fetchRetryDelay) !== null && i !== void 0 ? i : 3e3,
|
|
1123
|
-
retryCheck:
|
|
1129
|
+
retryCheck: J
|
|
1124
1130
|
}, this.requestTimeout = (o = e == null ? void 0 : e.requestTimeout) !== null && o !== void 0 ? o : 1e4, this.disableGeoip = (u = e == null ? void 0 : e.disableGeoip) !== null && u !== void 0 ? u : !0;
|
|
1125
1131
|
}
|
|
1126
1132
|
return s.prototype.getCommonEventProperties = function() {
|
|
@@ -1273,10 +1279,10 @@ var te = (
|
|
|
1273
1279
|
this._events.emit(r, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
|
|
1274
1280
|
return;
|
|
1275
1281
|
}
|
|
1276
|
-
var o = F(F({}, e), { type: r, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: t != null && t.timestamp ? t == null ? void 0 : t.timestamp :
|
|
1282
|
+
var o = F(F({}, e), { type: r, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: t != null && t.timestamp ? t == null ? void 0 : t.timestamp : B(), uuid: t != null && t.uuid ? t.uuid : G() }), u = (i = t == null ? void 0 : t.disableGeoip) !== null && i !== void 0 ? i : this.disableGeoip;
|
|
1277
1283
|
u && (o.properties || (o.properties = {}), o.properties.$geoip_disable = !0), o.distinctId && (o.distinct_id = o.distinctId, delete o.distinctId);
|
|
1278
1284
|
var l = this.getPersistedProperty(_.Queue) || [];
|
|
1279
|
-
l.push({ message: o }), this.setPersistedProperty(_.Queue, l), this._events.emit(r, o), l.length >= this.flushAt && this.flush(), this.flushInterval && !this._flushTimer && (this._flushTimer =
|
|
1285
|
+
l.push({ message: o }), this.setPersistedProperty(_.Queue, l), this._events.emit(r, o), l.length >= this.flushAt && this.flush(), this.flushInterval && !this._flushTimer && (this._flushTimer = te(function() {
|
|
1280
1286
|
return n.flush();
|
|
1281
1287
|
}, this.flushInterval));
|
|
1282
1288
|
}, s.prototype.flushAsync = function() {
|
|
@@ -1299,12 +1305,12 @@ var te = (
|
|
|
1299
1305
|
}), o = {
|
|
1300
1306
|
api_key: this.apiKey,
|
|
1301
1307
|
batch: i,
|
|
1302
|
-
sent_at:
|
|
1308
|
+
sent_at: B()
|
|
1303
1309
|
}, u = function(d) {
|
|
1304
1310
|
d && e._events.emit("error", d), r == null || r(d, i), e._events.emit("flush", i);
|
|
1305
1311
|
};
|
|
1306
1312
|
this.getCustomUserAgent();
|
|
1307
|
-
var l = JSON.stringify(o), c = this.captureMode === "form" ? "".concat(this.host, "/e/?ip=1&_=").concat(
|
|
1313
|
+
var l = JSON.stringify(o), c = this.captureMode === "form" ? "".concat(this.host, "/e/?ip=1&_=").concat(ge(), "&v=").concat(this.getLibraryVersion()) : "".concat(this.host, "/batch/"), h = this.captureMode === "form" ? {
|
|
1308
1314
|
method: "POST",
|
|
1309
1315
|
mode: "no-cors",
|
|
1310
1316
|
credentials: "omit",
|
|
@@ -1332,7 +1338,7 @@ var te = (
|
|
|
1332
1338
|
return setTimeout(function() {
|
|
1333
1339
|
return h.abort();
|
|
1334
1340
|
}, c), h.signal;
|
|
1335
|
-
}), [4,
|
|
1341
|
+
}), [4, ve(function() {
|
|
1336
1342
|
return A(o, void 0, void 0, function() {
|
|
1337
1343
|
var l, c, h;
|
|
1338
1344
|
return E(this, function(g) {
|
|
@@ -1344,10 +1350,10 @@ var te = (
|
|
|
1344
1350
|
case 2:
|
|
1345
1351
|
return l = g.sent(), [3, 4];
|
|
1346
1352
|
case 3:
|
|
1347
|
-
throw c = g.sent(), new
|
|
1353
|
+
throw c = g.sent(), new _e(c);
|
|
1348
1354
|
case 4:
|
|
1349
1355
|
if (h = e.mode === "no-cors", !h && (l.status < 200 || l.status >= 400))
|
|
1350
|
-
throw new
|
|
1356
|
+
throw new Pe(l);
|
|
1351
1357
|
return [2, l];
|
|
1352
1358
|
}
|
|
1353
1359
|
});
|
|
@@ -1383,7 +1389,7 @@ var te = (
|
|
|
1383
1389
|
case 4:
|
|
1384
1390
|
return e.sent(), [3, 6];
|
|
1385
1391
|
case 5:
|
|
1386
|
-
if (r = e.sent(), !
|
|
1392
|
+
if (r = e.sent(), !J(r))
|
|
1387
1393
|
throw r;
|
|
1388
1394
|
return console.error("Error while shutting down PostHog", r), [3, 6];
|
|
1389
1395
|
case 6:
|
|
@@ -1432,7 +1438,7 @@ var te = (
|
|
|
1432
1438
|
}, r.prototype.on = function(e, t) {
|
|
1433
1439
|
return this._events.on(e, t);
|
|
1434
1440
|
}, r.prototype.reset = function(e) {
|
|
1435
|
-
var t =
|
|
1441
|
+
var t = ee([_.Queue], e || []);
|
|
1436
1442
|
this.clearProps();
|
|
1437
1443
|
for (var n = 0, i = Object.keys(_); n < i.length; n++) {
|
|
1438
1444
|
var o = i[n];
|
|
@@ -1629,8 +1635,8 @@ var te = (
|
|
|
1629
1635
|
}, r.prototype.overrideFeatureFlag = function(e) {
|
|
1630
1636
|
return e === null ? this.setPersistedProperty(_.OverrideFeatureFlags, null) : this.setPersistedProperty(_.OverrideFeatureFlags, e);
|
|
1631
1637
|
}, r;
|
|
1632
|
-
})(
|
|
1633
|
-
var
|
|
1638
|
+
})(re);
|
|
1639
|
+
var Se = (
|
|
1634
1640
|
/** @class */
|
|
1635
1641
|
function() {
|
|
1636
1642
|
function s() {
|
|
@@ -1642,14 +1648,14 @@ var _e = (
|
|
|
1642
1648
|
this._memoryStorage[r] = e !== null ? e : void 0;
|
|
1643
1649
|
}, s;
|
|
1644
1650
|
}()
|
|
1645
|
-
),
|
|
1651
|
+
), K = (
|
|
1646
1652
|
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
1647
1653
|
// @ts-ignore
|
|
1648
1654
|
typeof fetch < "u" ? fetch : typeof global.fetch < "u" ? global.fetch : void 0
|
|
1649
1655
|
);
|
|
1650
|
-
if (!
|
|
1651
|
-
var
|
|
1652
|
-
|
|
1656
|
+
if (!K) {
|
|
1657
|
+
var Ae = require("axios");
|
|
1658
|
+
K = function(s, r) {
|
|
1653
1659
|
return A(void 0, void 0, void 0, function() {
|
|
1654
1660
|
var e;
|
|
1655
1661
|
return E(this, function(t) {
|
|
@@ -1657,7 +1663,7 @@ if (!z) {
|
|
|
1657
1663
|
case 0:
|
|
1658
1664
|
return [
|
|
1659
1665
|
4,
|
|
1660
|
-
|
|
1666
|
+
Ae.request({
|
|
1661
1667
|
url: s,
|
|
1662
1668
|
headers: r.headers,
|
|
1663
1669
|
method: r.method.toLowerCase(),
|
|
@@ -1701,7 +1707,7 @@ if (!z) {
|
|
|
1701
1707
|
});
|
|
1702
1708
|
};
|
|
1703
1709
|
}
|
|
1704
|
-
var
|
|
1710
|
+
var ie = K, Ee = 1152921504606847e3, V = (
|
|
1705
1711
|
/** @class */
|
|
1706
1712
|
function(s) {
|
|
1707
1713
|
x(r, s);
|
|
@@ -1721,12 +1727,12 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
1721
1727
|
}
|
|
1722
1728
|
return r;
|
|
1723
1729
|
}(Error)
|
|
1724
|
-
),
|
|
1730
|
+
), Oe = (
|
|
1725
1731
|
/** @class */
|
|
1726
1732
|
function() {
|
|
1727
1733
|
function s(r) {
|
|
1728
|
-
var e = r.pollingInterval, t = r.personalApiKey, n = r.projectApiKey, i = r.timeout, o = r.host, u =
|
|
1729
|
-
this.debugMode = !1, this.pollingInterval = e, this.personalApiKey = t, this.featureFlags = [], this.featureFlagsByKey = {}, this.groupTypeMapping = {}, this.cohorts = {}, this.loadedSuccessfullyOnce = !1, this.timeout = i, this.projectApiKey = n, this.host = o, this.poller = void 0, this.fetch = u.fetch ||
|
|
1734
|
+
var e = r.pollingInterval, t = r.personalApiKey, n = r.projectApiKey, i = r.timeout, o = r.host, u = he(r, ["pollingInterval", "personalApiKey", "projectApiKey", "timeout", "host"]);
|
|
1735
|
+
this.debugMode = !1, this.pollingInterval = e, this.personalApiKey = t, this.featureFlags = [], this.featureFlagsByKey = {}, this.groupTypeMapping = {}, this.cohorts = {}, this.loadedSuccessfullyOnce = !1, this.timeout = i, this.projectApiKey = n, this.host = o, this.poller = void 0, this.fetch = u.fetch || ie, this.onError = u.onError, this.loadFeatureFlags();
|
|
1730
1736
|
}
|
|
1731
1737
|
return s.prototype.debug = function(r) {
|
|
1732
1738
|
r === void 0 && (r = !0), this.debugMode = r;
|
|
@@ -1857,7 +1863,7 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
1857
1863
|
} else
|
|
1858
1864
|
return this.matchFeatureFlagProperties(r, e, n);
|
|
1859
1865
|
}, s.prototype.matchFeatureFlagProperties = function(r, e, t) {
|
|
1860
|
-
for (var n, i = r.filters || {}, o = i.groups || [], u = !1, l = void 0, c =
|
|
1866
|
+
for (var n, i = r.filters || {}, o = i.groups || [], u = !1, l = void 0, c = ee([], o).sort(function(p, w) {
|
|
1861
1867
|
var y = !!p.variant, m = !!w.variant;
|
|
1862
1868
|
return y && m ? 0 : y ? -1 : m ? 1 : 0;
|
|
1863
1869
|
}), h = function(p) {
|
|
@@ -1888,15 +1894,15 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
1888
1894
|
if ((t.properties || []).length > 0) {
|
|
1889
1895
|
for (var o = 0, u = t.properties; o < u.length; o++) {
|
|
1890
1896
|
var l = u[o], c = l.type, h = !1;
|
|
1891
|
-
if (c === "cohort" ? h =
|
|
1897
|
+
if (c === "cohort" ? h = oe(l, n, this.cohorts) : h = ne(l, n), !h)
|
|
1892
1898
|
return !1;
|
|
1893
1899
|
}
|
|
1894
1900
|
if (i == null)
|
|
1895
1901
|
return !0;
|
|
1896
1902
|
}
|
|
1897
|
-
return !(i != null &&
|
|
1903
|
+
return !(i != null && Q(r.key, e) > i / 100);
|
|
1898
1904
|
}, s.prototype.getMatchingVariant = function(r, e) {
|
|
1899
|
-
var t =
|
|
1905
|
+
var t = Q(r.key, e, "variant"), n = this.variantLookupTable(r).find(function(i) {
|
|
1900
1906
|
return t >= i.valueMin && t < i.valueMax;
|
|
1901
1907
|
});
|
|
1902
1908
|
if (n)
|
|
@@ -1949,7 +1955,7 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
1949
1955
|
];
|
|
1950
1956
|
case 2:
|
|
1951
1957
|
if (t = u.sent(), t && t.status === 401)
|
|
1952
|
-
throw new
|
|
1958
|
+
throw new V("Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview");
|
|
1953
1959
|
return t && t.status !== 200 ? [
|
|
1954
1960
|
2
|
|
1955
1961
|
/*return*/
|
|
@@ -1965,7 +1971,7 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
1965
1971
|
5
|
|
1966
1972
|
];
|
|
1967
1973
|
case 4:
|
|
1968
|
-
return i = u.sent(), i instanceof
|
|
1974
|
+
return i = u.sent(), i instanceof V && ((e = this.onError) === null || e === void 0 || e.call(this, i)), [
|
|
1969
1975
|
3,
|
|
1970
1976
|
5
|
|
1971
1977
|
];
|
|
@@ -1988,9 +1994,9 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
1988
1994
|
headers: {
|
|
1989
1995
|
"Content-Type": "application/json",
|
|
1990
1996
|
Authorization: "Bearer ".concat(this.personalApiKey),
|
|
1991
|
-
"user-agent": "posthog-node/".concat(
|
|
1997
|
+
"user-agent": "posthog-node/".concat(z)
|
|
1992
1998
|
}
|
|
1993
|
-
}, t = null, this.timeout && typeof this.timeout == "number" && (n = new AbortController(), t =
|
|
1999
|
+
}, t = null, this.timeout && typeof this.timeout == "number" && (n = new AbortController(), t = te(function() {
|
|
1994
2000
|
n.abort();
|
|
1995
2001
|
}, this.timeout), e.signal = n.signal), i.label = 1;
|
|
1996
2002
|
case 1:
|
|
@@ -2021,12 +2027,12 @@ var re = z, Ae = 1152921504606847e3, J = (
|
|
|
2021
2027
|
}, s;
|
|
2022
2028
|
}()
|
|
2023
2029
|
);
|
|
2024
|
-
function
|
|
2030
|
+
function Q(s, r, e) {
|
|
2025
2031
|
e === void 0 && (e = "");
|
|
2026
|
-
var t =
|
|
2027
|
-
return t.update("".concat(s, ".").concat(r).concat(e)), parseInt(t.digest("hex").slice(0, 15), 16) /
|
|
2032
|
+
var t = fe.createHash();
|
|
2033
|
+
return t.update("".concat(s, ".").concat(r).concat(e)), parseInt(t.digest("hex").slice(0, 15), 16) / Ee;
|
|
2028
2034
|
}
|
|
2029
|
-
function
|
|
2035
|
+
function ne(s, r) {
|
|
2030
2036
|
var e = s.key, t = s.value, n = s.operator || "exact";
|
|
2031
2037
|
if (e in r) {
|
|
2032
2038
|
if (n === "is_not_set")
|
|
@@ -2061,9 +2067,9 @@ function ie(s, r) {
|
|
|
2061
2067
|
case "not_icontains":
|
|
2062
2068
|
return !String(i).toLowerCase().includes(String(t).toLowerCase());
|
|
2063
2069
|
case "regex":
|
|
2064
|
-
return
|
|
2070
|
+
return Y(String(t)) && String(i).match(String(t)) !== null;
|
|
2065
2071
|
case "not_regex":
|
|
2066
|
-
return
|
|
2072
|
+
return Y(String(t)) && String(i).match(String(t)) === null;
|
|
2067
2073
|
case "gt":
|
|
2068
2074
|
case "gte":
|
|
2069
2075
|
case "lt":
|
|
@@ -2078,24 +2084,24 @@ function ie(s, r) {
|
|
|
2078
2084
|
}
|
|
2079
2085
|
case "is_date_after":
|
|
2080
2086
|
case "is_date_before": {
|
|
2081
|
-
var c =
|
|
2082
|
-
if (c == null && (c =
|
|
2087
|
+
var c = Ce(String(t));
|
|
2088
|
+
if (c == null && (c = X(t)), c == null)
|
|
2083
2089
|
throw new C("Invalid date: ".concat(t));
|
|
2084
|
-
var h =
|
|
2090
|
+
var h = X(i);
|
|
2085
2091
|
return ["is_date_before"].includes(n) ? h < c : h > c;
|
|
2086
2092
|
}
|
|
2087
2093
|
default:
|
|
2088
2094
|
throw new C("Unknown operator: ".concat(n));
|
|
2089
2095
|
}
|
|
2090
2096
|
}
|
|
2091
|
-
function
|
|
2097
|
+
function oe(s, r, e) {
|
|
2092
2098
|
var t = String(s.value);
|
|
2093
2099
|
if (!(t in e))
|
|
2094
2100
|
throw new C("can't match cohort without a given cohort property value");
|
|
2095
2101
|
var n = e[t];
|
|
2096
|
-
return
|
|
2102
|
+
return se(n, r, e);
|
|
2097
2103
|
}
|
|
2098
|
-
function
|
|
2104
|
+
function se(s, r, e) {
|
|
2099
2105
|
if (!s)
|
|
2100
2106
|
return !0;
|
|
2101
2107
|
var t = s.type, n = s.values;
|
|
@@ -2106,7 +2112,7 @@ function oe(s, r, e) {
|
|
|
2106
2112
|
for (var o = 0, u = n; o < u.length; o++) {
|
|
2107
2113
|
var l = u[o];
|
|
2108
2114
|
try {
|
|
2109
|
-
var c =
|
|
2115
|
+
var c = se(l, r, e);
|
|
2110
2116
|
if (t === "AND") {
|
|
2111
2117
|
if (!c)
|
|
2112
2118
|
return !1;
|
|
@@ -2127,7 +2133,7 @@ function oe(s, r, e) {
|
|
|
2127
2133
|
var l = g[h];
|
|
2128
2134
|
try {
|
|
2129
2135
|
var c = void 0;
|
|
2130
|
-
l.type === "cohort" ? c =
|
|
2136
|
+
l.type === "cohort" ? c = oe(l, r, e) : c = ne(l, r);
|
|
2131
2137
|
var d = l.negation || !1;
|
|
2132
2138
|
if (t === "AND") {
|
|
2133
2139
|
if (!c && !d || c && d)
|
|
@@ -2146,14 +2152,14 @@ function oe(s, r, e) {
|
|
|
2146
2152
|
return t === "AND";
|
|
2147
2153
|
}
|
|
2148
2154
|
}
|
|
2149
|
-
function
|
|
2155
|
+
function Y(s) {
|
|
2150
2156
|
try {
|
|
2151
2157
|
return new RegExp(s), !0;
|
|
2152
2158
|
} catch {
|
|
2153
2159
|
return !1;
|
|
2154
2160
|
}
|
|
2155
2161
|
}
|
|
2156
|
-
function
|
|
2162
|
+
function X(s) {
|
|
2157
2163
|
if (s instanceof Date)
|
|
2158
2164
|
return s;
|
|
2159
2165
|
if (typeof s == "string" || typeof s == "number") {
|
|
@@ -2164,7 +2170,7 @@ function Y(s) {
|
|
|
2164
2170
|
} else
|
|
2165
2171
|
throw new C("The date provided ".concat(s, " must be a string, number, or date object"));
|
|
2166
2172
|
}
|
|
2167
|
-
function
|
|
2173
|
+
function Ce(s) {
|
|
2168
2174
|
var r = /^-?(?<number>[0-9]+)(?<interval>[a-z])$/, e = s.match(r), t = new Date((/* @__PURE__ */ new Date()).toISOString());
|
|
2169
2175
|
if (e) {
|
|
2170
2176
|
if (!e.groups)
|
|
@@ -2189,15 +2195,15 @@ function Oe(s) {
|
|
|
2189
2195
|
} else
|
|
2190
2196
|
return null;
|
|
2191
2197
|
}
|
|
2192
|
-
var
|
|
2198
|
+
var Ie = 30 * 1e3, ke = 50 * 1e3, Le = (
|
|
2193
2199
|
/** @class */
|
|
2194
2200
|
function(s) {
|
|
2195
2201
|
x(r, s);
|
|
2196
2202
|
function r(e, t) {
|
|
2197
2203
|
t === void 0 && (t = {});
|
|
2198
2204
|
var n = this, i;
|
|
2199
|
-
return t.captureMode = (t == null ? void 0 : t.captureMode) || "json", n = s.call(this, e, t) || this, n._memoryStorage = new
|
|
2200
|
-
pollingInterval: typeof t.featureFlagsPollingInterval == "number" ? t.featureFlagsPollingInterval :
|
|
2205
|
+
return t.captureMode = (t == null ? void 0 : t.captureMode) || "json", n = s.call(this, e, t) || this, n._memoryStorage = new Se(), n.options = t, t.personalApiKey && (n.featureFlagsPoller = new Oe({
|
|
2206
|
+
pollingInterval: typeof t.featureFlagsPollingInterval == "number" ? t.featureFlagsPollingInterval : Ie,
|
|
2201
2207
|
personalApiKey: t.personalApiKey,
|
|
2202
2208
|
projectApiKey: e,
|
|
2203
2209
|
timeout: (i = t.requestTimeout) !== null && i !== void 0 ? i : 1e4,
|
|
@@ -2206,20 +2212,20 @@ var Ce = 30 * 1e3, Ie = 50 * 1e3, ke = (
|
|
|
2206
2212
|
onError: function(o) {
|
|
2207
2213
|
n._events.emit("error", o);
|
|
2208
2214
|
}
|
|
2209
|
-
})), n.distinctIdHasSentFlagCalls = {}, n.maxCacheSize = t.maxCacheSize ||
|
|
2215
|
+
})), n.distinctIdHasSentFlagCalls = {}, n.maxCacheSize = t.maxCacheSize || ke, n;
|
|
2210
2216
|
}
|
|
2211
2217
|
return r.prototype.getPersistedProperty = function(e) {
|
|
2212
2218
|
return this._memoryStorage.getProperty(e);
|
|
2213
2219
|
}, r.prototype.setPersistedProperty = function(e, t) {
|
|
2214
2220
|
return this._memoryStorage.setProperty(e, t);
|
|
2215
2221
|
}, r.prototype.fetch = function(e, t) {
|
|
2216
|
-
return this.options.fetch ? this.options.fetch(e, t) :
|
|
2222
|
+
return this.options.fetch ? this.options.fetch(e, t) : ie(e, t);
|
|
2217
2223
|
}, r.prototype.getLibraryId = function() {
|
|
2218
2224
|
return "posthog-node";
|
|
2219
2225
|
}, r.prototype.getLibraryVersion = function() {
|
|
2220
|
-
return
|
|
2226
|
+
return z;
|
|
2221
2227
|
}, r.prototype.getCustomUserAgent = function() {
|
|
2222
|
-
return "posthog-node/".concat(
|
|
2228
|
+
return "posthog-node/".concat(z);
|
|
2223
2229
|
}, r.prototype.enable = function() {
|
|
2224
2230
|
return s.prototype.optIn.call(this);
|
|
2225
2231
|
}, r.prototype.disable = function() {
|
|
@@ -2528,9 +2534,9 @@ var Ce = 30 * 1e3, Ie = 50 * 1e3, ke = (
|
|
|
2528
2534
|
allGroupProperties: u
|
|
2529
2535
|
};
|
|
2530
2536
|
}, r;
|
|
2531
|
-
}(
|
|
2537
|
+
}(re)
|
|
2532
2538
|
);
|
|
2533
|
-
class
|
|
2539
|
+
class Re extends Z {
|
|
2534
2540
|
constructor(e) {
|
|
2535
2541
|
super({ debug: e.debug, enabled: e.enabled });
|
|
2536
2542
|
L(this, "name", "PostHog-Server");
|
|
@@ -2544,7 +2550,7 @@ class Me extends X {
|
|
|
2544
2550
|
if (!this.config.apiKey || typeof this.config.apiKey != "string")
|
|
2545
2551
|
throw new Error("PostHog requires an apiKey");
|
|
2546
2552
|
try {
|
|
2547
|
-
this.client = new
|
|
2553
|
+
this.client = new Le(this.config.apiKey, {
|
|
2548
2554
|
host: this.config.host || "https://app.posthog.com",
|
|
2549
2555
|
flushAt: 20,
|
|
2550
2556
|
flushInterval: 1e4
|
|
@@ -2605,7 +2611,7 @@ class Me extends X {
|
|
|
2605
2611
|
}
|
|
2606
2612
|
}
|
|
2607
2613
|
export {
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2614
|
+
Z as BaseAnalyticsProvider,
|
|
2615
|
+
je as PostHogClientProvider,
|
|
2616
|
+
Re as PostHogServerProvider
|
|
2611
2617
|
};
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { BrowserAnalytics } from './adapters/client/browser-analytics.js';
|
|
2
2
|
import { AnalyticsProvider } from './core/events/types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { EventMapFromCollection } from './core/events/index.js';
|
|
4
4
|
type DefaultEventMap = Record<string, Record<string, unknown>>;
|
|
5
|
-
type EventMapFromCollection<T> = T extends EventCollection<infer Events> ? {
|
|
6
|
-
[K in keyof Events as Events[K] extends {
|
|
7
|
-
name: infer N;
|
|
8
|
-
} ? N extends string ? N : never : never]: Events[K] extends {
|
|
9
|
-
properties: infer P;
|
|
10
|
-
} ? P : never;
|
|
11
|
-
} : never;
|
|
12
5
|
export interface ClientAnalyticsConfig {
|
|
13
6
|
providers?: AnalyticsProvider[];
|
|
14
7
|
debug?: boolean;
|
|
@@ -14,5 +14,12 @@ export type ExtractEventPropertiesFromCollection<T extends Record<string, {
|
|
|
14
14
|
name: TEventName;
|
|
15
15
|
}>["properties"];
|
|
16
16
|
export type EventCollection<T extends Record<string, CreateEventDefinition<string>>> = T;
|
|
17
|
+
export type EventMapFromCollection<T> = T extends EventCollection<infer Events> ? {
|
|
18
|
+
[K in keyof Events as Events[K] extends {
|
|
19
|
+
name: infer N;
|
|
20
|
+
} ? N extends string ? N : never : never]: Events[K] extends {
|
|
21
|
+
properties: infer P;
|
|
22
|
+
} ? P : never;
|
|
23
|
+
} : never;
|
|
17
24
|
export type AnyEventName = string;
|
|
18
25
|
export type AnyEventProperties = Record<string, unknown>;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { EventCategory, BaseEvent, EventContext, AnalyticsProvider, AnalyticsConfig, } from './core/events/types.js';
|
|
2
|
-
export type { CreateEventDefinition, ExtractEventNames, ExtractEventPropertiesFromCollection, EventCollection, AnyEventName, AnyEventProperties, } from './core/events/index.js';
|
|
2
|
+
export type { CreateEventDefinition, ExtractEventNames, ExtractEventPropertiesFromCollection, EventCollection, AnyEventName, AnyEventProperties, EventMapFromCollection, } from './core/events/index.js';
|
|
3
3
|
export { createAnalytics as createClientAnalytics, getAnalytics, track as trackClient, identify as identifyClient, page as pageClient, reset as resetClient, type ClientAnalyticsConfig, } from './client.js';
|
|
4
4
|
export { createServerAnalytics, ServerAnalytics, type ServerAnalyticsConfig, } from './server.js';
|
|
5
5
|
export { BaseAnalyticsProvider, PostHogClientProvider, PostHogServerProvider, type PostHogConfig, } from './providers/index.js';
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { BaseEvent, EventContext } from '../../core/events/types.js';
|
|
2
2
|
import { BaseAnalyticsProvider } from '../base.provider.js';
|
|
3
3
|
import { PostHogConfig } from './types.js';
|
|
4
|
-
import { PostHog } from 'posthog-js';
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
posthog?: PostHog;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
4
|
export declare class PostHogClientProvider extends BaseAnalyticsProvider {
|
|
11
5
|
name: string;
|
|
12
6
|
private posthog?;
|
package/dist/src/server.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { ServerAnalytics } from './adapters/server/server-analytics.js';
|
|
2
2
|
import { AnalyticsProvider } from './core/events/types.js';
|
|
3
|
-
import {
|
|
4
|
-
type EventMapFromCollection<T> = T extends EventCollection<infer Events> ? {
|
|
5
|
-
[K in keyof Events as Events[K] extends {
|
|
6
|
-
name: infer N;
|
|
7
|
-
} ? N extends string ? N : never : never]: Events[K] extends {
|
|
8
|
-
properties: infer P;
|
|
9
|
-
} ? P : never;
|
|
10
|
-
} : never;
|
|
3
|
+
import { EventMapFromCollection } from './core/events/index.js';
|
|
11
4
|
export interface ServerAnalyticsConfig {
|
|
12
5
|
providers?: AnalyticsProvider[];
|
|
13
6
|
debug?: boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment detection utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if we're running in a browser environment
|
|
6
|
+
* @returns true if running in browser, false if in Node.js or other environments
|
|
7
|
+
*/
|
|
8
|
+
export declare function isBrowser(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Check if we're running in a Node.js environment
|
|
11
|
+
* @returns true if running in Node.js, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
export declare function isNode(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if we're running in a server-side rendering context
|
|
16
|
+
* @returns true if likely in SSR context, false otherwise
|
|
17
|
+
*/
|
|
18
|
+
export declare function isSSR(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksee/analytics",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "A highly typed, provider-agnostic analytics library for TypeScript applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@changesets/cli": "^2.29.4",
|
|
48
48
|
"@svitejs/changesets-changelog-github-compact": "^1.2.0",
|
|
49
49
|
"@types/node": "^20.14.11",
|
|
50
|
-
"@vitest/coverage-v8": "
|
|
50
|
+
"@vitest/coverage-v8": "3.1.4",
|
|
51
51
|
"globals": "^15.8.0",
|
|
52
52
|
"jsdom": "^26.1.0",
|
|
53
53
|
"prettier": "^3.3.3",
|