posthog-js-lite 3.3.0 → 3.4.1
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/lib/index.cjs.js +32 -3
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +14 -1
- package/lib/index.esm.js +32 -3
- package/lib/index.esm.js.map +1 -1
- package/lib/posthog-core/src/index.d.ts +14 -1
- package/lib/posthog-core/src/utils.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Next
|
|
2
2
|
|
|
3
|
+
# 3.4.1 - 2025-02-20
|
|
4
|
+
|
|
5
|
+
## Fixed
|
|
6
|
+
|
|
7
|
+
1. fix: handle cases when non Error is passed to `captureException`
|
|
8
|
+
|
|
9
|
+
# 3.4.0 - 2025-02-20
|
|
10
|
+
|
|
11
|
+
## Added
|
|
12
|
+
|
|
13
|
+
1. Adds the ability to capture user feedback in LLM Observability using the `captureTraceFeedback` and `captureTraceMetric` methods.
|
|
14
|
+
|
|
3
15
|
# 3.3.0 - 2025-02-06
|
|
4
16
|
|
|
5
17
|
## Added
|
package/README.md
CHANGED
|
@@ -71,5 +71,5 @@ posthog.onFeatureFlag('my-feature-flag', (value) => {
|
|
|
71
71
|
|
|
72
72
|
// Opt users in or out, persisting across sessions (default is they are opted in)
|
|
73
73
|
posthog.optOut() // Will stop tracking
|
|
74
|
-
posthog.optIn() // Will
|
|
74
|
+
posthog.optIn() // Will start tracking
|
|
75
75
|
```
|
package/lib/index.cjs.js
CHANGED
|
@@ -66,6 +66,9 @@ function safeSetTimeout(fn, timeout) {
|
|
|
66
66
|
t?.unref && t?.unref();
|
|
67
67
|
return t;
|
|
68
68
|
}
|
|
69
|
+
const isError = (x) => {
|
|
70
|
+
return x instanceof Error;
|
|
71
|
+
};
|
|
69
72
|
function getFetch() {
|
|
70
73
|
return typeof fetch !== 'undefined' ? fetch : typeof global.fetch !== 'undefined' ? global.fetch : undefined;
|
|
71
74
|
}
|
|
@@ -1490,6 +1493,7 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1490
1493
|
this.setPersistedProperty(PostHogPersistedProperty[key], null);
|
|
1491
1494
|
}
|
|
1492
1495
|
}
|
|
1496
|
+
this.reloadFeatureFlags();
|
|
1493
1497
|
});
|
|
1494
1498
|
}
|
|
1495
1499
|
getCommonEventProperties() {
|
|
@@ -1765,6 +1769,7 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1765
1769
|
if (res.errorsWhileComputingFlags) {
|
|
1766
1770
|
// if not all flags were computed, we upsert flags instead of replacing them
|
|
1767
1771
|
const currentFlags = this.getPersistedProperty(PostHogPersistedProperty.FeatureFlags);
|
|
1772
|
+
this.logMsgIfDebug(() => console.log('PostHog Debug', 'Cached feature flags: ', JSON.stringify(currentFlags)));
|
|
1768
1773
|
const currentFlagPayloads = this.getPersistedProperty(PostHogPersistedProperty.FeatureFlagPayloads);
|
|
1769
1774
|
newFeatureFlags = { ...currentFlags, ...res.featureFlags };
|
|
1770
1775
|
newFeatureFlagPayloads = { ...currentFlagPayloads, ...res.featureFlagPayloads };
|
|
@@ -1926,8 +1931,8 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1926
1931
|
$exception_level: 'error',
|
|
1927
1932
|
$exception_list: [
|
|
1928
1933
|
{
|
|
1929
|
-
type: error.name,
|
|
1930
|
-
value: error.message,
|
|
1934
|
+
type: isError(error) ? error.name : 'Error',
|
|
1935
|
+
value: isError(error) ? error.message : error,
|
|
1931
1936
|
mechanism: {
|
|
1932
1937
|
handled: true,
|
|
1933
1938
|
synthetic: false,
|
|
@@ -1939,9 +1944,33 @@ class PostHogCore extends PostHogCoreStateless {
|
|
|
1939
1944
|
properties.$exception_personURL = new URL(`/project/${this.apiKey}/person/${this.getDistinctId()}`, this.host).toString();
|
|
1940
1945
|
this.capture('$exception', properties);
|
|
1941
1946
|
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Capture written user feedback for a LLM trace. Numeric values are converted to strings.
|
|
1949
|
+
* @param traceId The trace ID to capture feedback for.
|
|
1950
|
+
* @param userFeedback The feedback to capture.
|
|
1951
|
+
*/
|
|
1952
|
+
captureTraceFeedback(traceId, userFeedback) {
|
|
1953
|
+
this.capture('$ai_feedback', {
|
|
1954
|
+
$ai_feedback_text: userFeedback,
|
|
1955
|
+
$ai_trace_id: String(traceId),
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Capture a metric for a LLM trace. Numeric values are converted to strings.
|
|
1960
|
+
* @param traceId The trace ID to capture the metric for.
|
|
1961
|
+
* @param metricName The name of the metric to capture.
|
|
1962
|
+
* @param metricValue The value of the metric to capture.
|
|
1963
|
+
*/
|
|
1964
|
+
captureTraceMetric(traceId, metricName, metricValue) {
|
|
1965
|
+
this.capture('$ai_metric', {
|
|
1966
|
+
$ai_metric_name: metricName,
|
|
1967
|
+
$ai_metric_value: String(metricValue),
|
|
1968
|
+
$ai_trace_id: String(traceId),
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1942
1971
|
}
|
|
1943
1972
|
|
|
1944
|
-
var version = "3.
|
|
1973
|
+
var version = "3.4.1";
|
|
1945
1974
|
|
|
1946
1975
|
function getContext(window) {
|
|
1947
1976
|
let context = {};
|