posthog-node 3.5.0 → 3.6.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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## 3.6.1 - 2024-01-26
2
+
3
+ 1. Remove new relative date operators, combine into regular date operators
4
+
5
+ # 3.6.0 - 2024-01-18
6
+
7
+ 1. Adds support for overriding the event `uuid`
8
+
1
9
  # 3.5.0 - 2024-01-09
2
10
 
3
11
  1. When local evaluation is enabled, we automatically add flag information to all events sent to PostHog, whenever possible. This makes it easier to use these events in experiments.
package/lib/index.cjs.js CHANGED
@@ -158,7 +158,7 @@ function __spreadArray(to, from, pack) {
158
158
  return to.concat(ar || Array.prototype.slice.call(from));
159
159
  }
160
160
 
161
- var version = "3.5.0";
161
+ var version = "3.6.1";
162
162
 
163
163
  var PostHogPersistedProperty;
164
164
  (function (PostHogPersistedProperty) {
@@ -1016,7 +1016,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1016
1016
  this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
1017
1017
  return;
1018
1018
  }
1019
- var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime() });
1019
+ var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime(), uuid: (options === null || options === void 0 ? void 0 : options.uuid) ? options.uuid : generateUUID(globalThis) });
1020
1020
  var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
1021
1021
  if (addGeoipDisableProperty) {
1022
1022
  if (!message.properties) {
@@ -2450,14 +2450,10 @@ function matchProperty(property, propertyValues) {
2450
2450
 
2451
2451
  case 'is_date_after':
2452
2452
  case 'is_date_before':
2453
- case 'is_relative_date_before':
2454
- case 'is_relative_date_after':
2455
2453
  {
2456
- var parsedDate = null;
2454
+ var parsedDate = relativeDateParseForFeatureFlagMatching(String(value));
2457
2455
 
2458
- if (['is_relative_date_before', 'is_relative_date_after'].includes(operator)) {
2459
- parsedDate = relativeDateParseForFeatureFlagMatching(String(value));
2460
- } else {
2456
+ if (parsedDate == null) {
2461
2457
  parsedDate = convertToDateTime(value);
2462
2458
  }
2463
2459
 
@@ -2467,7 +2463,7 @@ function matchProperty(property, propertyValues) {
2467
2463
 
2468
2464
  var overrideDate = convertToDateTime(overrideValue);
2469
2465
 
2470
- if (['is_date_before', 'is_relative_date_before'].includes(operator)) {
2466
+ if (['is_date_before'].includes(operator)) {
2471
2467
  return overrideDate < parsedDate;
2472
2468
  }
2473
2469
 
@@ -2618,7 +2614,7 @@ function convertToDateTime(value) {
2618
2614
  }
2619
2615
 
2620
2616
  function relativeDateParseForFeatureFlagMatching(value) {
2621
- var regex = /^(?<number>[0-9]+)(?<interval>[a-z])$/;
2617
+ var regex = /^-?(?<number>[0-9]+)(?<interval>[a-z])$/;
2622
2618
  var match = value.match(regex);
2623
2619
  var parsedDt = new Date(new Date().toISOString());
2624
2620
 
@@ -2750,12 +2746,14 @@ function (_super) {
2750
2746
  groups = _a.groups,
2751
2747
  sendFeatureFlags = _a.sendFeatureFlags,
2752
2748
  timestamp = _a.timestamp,
2753
- disableGeoip = _a.disableGeoip;
2749
+ disableGeoip = _a.disableGeoip,
2750
+ uuid = _a.uuid;
2754
2751
 
2755
2752
  var _capture = function (props) {
2756
2753
  _super.prototype.captureStateless.call(_this, distinctId, event, props, {
2757
2754
  timestamp: timestamp,
2758
- disableGeoip: disableGeoip
2755
+ disableGeoip: disableGeoip,
2756
+ uuid: uuid
2759
2757
  });
2760
2758
  }; // :TRICKY: If we flush, or need to shut down, to not lose events we want this promise to resolve before we flush
2761
2759
 
@@ -3187,7 +3185,7 @@ function (_super) {
3187
3185
 
3188
3186
  PostHog.prototype.addLocalPersonAndGroupProperties = function (distinctId, groups, personProperties, groupProperties) {
3189
3187
  var allPersonProperties = __assign({
3190
- $current_distinct_id: distinctId
3188
+ distinct_id: distinctId
3191
3189
  }, personProperties || {});
3192
3190
 
3193
3191
  var allGroupProperties = {};