@posthog/browser-common 0.9.7 → 0.9.8

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/config.js CHANGED
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const packageVersion = "0.9.7";
30
+ const packageVersion = "0.9.8";
31
31
  const Config = {
32
32
  DEBUG: false,
33
33
  LIB_VERSION: packageVersion,
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const packageVersion = "0.9.7";
1
+ const packageVersion = "0.9.8";
2
2
  const Config = {
3
3
  DEBUG: false,
4
4
  LIB_VERSION: packageVersion,
@@ -811,46 +811,53 @@ class PostHogFeatureFlags {
811
811
  [external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported,
812
812
  [external_constants_js_namespaceObject.FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
813
813
  });
814
- } else if (key in flagCallReported && flagCallReported[key].includes(flagReportValue)) {
815
- if (sessionIdToPersist) this._set({
816
- [external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported,
817
- [external_constants_js_namespaceObject.FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
818
- });
819
814
  } else {
820
- if ((0, core_namespaceObject.isArray)(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
821
- else flagCallReported[key] = [
822
- flagReportValue
823
- ];
824
- this._set({
815
+ const canCapture = this._client?.canCapture;
816
+ if (!canCapture && Object.keys(flagCallReported).length > 0) {
817
+ flagCallReported = {};
818
+ this._set({
819
+ [external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported
820
+ });
821
+ }
822
+ if (canCapture && !flagCallReported[key]?.includes(flagReportValue)) {
823
+ if ((0, core_namespaceObject.isArray)(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
824
+ else flagCallReported[key] = [
825
+ flagReportValue
826
+ ];
827
+ this._set({
828
+ [external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported,
829
+ ...sessionIdToPersist ? {
830
+ [external_constants_js_namespaceObject.FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
831
+ } : {}
832
+ });
833
+ const flagDetails = this.getFeatureFlagDetails(key);
834
+ const errors = [
835
+ ...this._prop(external_constants_js_namespaceObject.PERSISTENCE_FEATURE_FLAG_ERRORS) ?? []
836
+ ];
837
+ if ((0, core_namespaceObject.isUndefined)(flagValue)) errors.push(FeatureFlagError.FLAG_MISSING);
838
+ const properties = {
839
+ $feature_flag: key,
840
+ $feature_flag_response: flagValue,
841
+ $feature_flag_payload: payload ?? null,
842
+ $feature_flag_request_id: requestId,
843
+ $feature_flag_evaluated_at: evaluatedAt,
844
+ $feature_flag_bootstrapped_response: this._config.bootstrap?.featureFlags?.[key] ?? null,
845
+ $feature_flag_bootstrapped_payload: this._config.bootstrap?.featureFlagPayloads?.[key] ?? null,
846
+ $used_bootstrap_value: !this._flagsLoadedFromRemote
847
+ };
848
+ if (!(0, core_namespaceObject.isUndefined)(flagDetails?.metadata?.has_experiment)) properties.$feature_flag_has_experiment = flagDetails.metadata.has_experiment;
849
+ if (!(0, core_namespaceObject.isUndefined)(flagDetails?.metadata?.version)) properties.$feature_flag_version = flagDetails.metadata.version;
850
+ const reason = flagDetails?.reason?.description ?? flagDetails?.reason?.code;
851
+ if (reason) properties.$feature_flag_reason = reason;
852
+ if (flagDetails?.metadata?.id) properties.$feature_flag_id = flagDetails.metadata.id;
853
+ if (!(0, core_namespaceObject.isUndefined)(flagDetails?.original_variant) || !(0, core_namespaceObject.isUndefined)(flagDetails?.original_enabled)) properties.$feature_flag_original_response = (0, core_namespaceObject.isUndefined)(flagDetails.original_variant) ? flagDetails.original_enabled : flagDetails.original_variant;
854
+ if (flagDetails?.metadata?.original_payload) properties.$feature_flag_original_payload = flagDetails?.metadata?.original_payload;
855
+ if (errors.length) properties.$feature_flag_error = errors.join(',');
856
+ this._captureFeatureFlagCalled(properties);
857
+ } else if (sessionIdToPersist) this._set({
825
858
  [external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported,
826
- ...sessionIdToPersist ? {
827
- [external_constants_js_namespaceObject.FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
828
- } : {}
859
+ [external_constants_js_namespaceObject.FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
829
860
  });
830
- const flagDetails = this.getFeatureFlagDetails(key);
831
- const errors = [
832
- ...this._prop(external_constants_js_namespaceObject.PERSISTENCE_FEATURE_FLAG_ERRORS) ?? []
833
- ];
834
- if ((0, core_namespaceObject.isUndefined)(flagValue)) errors.push(FeatureFlagError.FLAG_MISSING);
835
- const properties = {
836
- $feature_flag: key,
837
- $feature_flag_response: flagValue,
838
- $feature_flag_payload: payload ?? null,
839
- $feature_flag_request_id: requestId,
840
- $feature_flag_evaluated_at: evaluatedAt,
841
- $feature_flag_bootstrapped_response: this._config.bootstrap?.featureFlags?.[key] ?? null,
842
- $feature_flag_bootstrapped_payload: this._config.bootstrap?.featureFlagPayloads?.[key] ?? null,
843
- $used_bootstrap_value: !this._flagsLoadedFromRemote
844
- };
845
- if (!(0, core_namespaceObject.isUndefined)(flagDetails?.metadata?.has_experiment)) properties.$feature_flag_has_experiment = flagDetails.metadata.has_experiment;
846
- if (!(0, core_namespaceObject.isUndefined)(flagDetails?.metadata?.version)) properties.$feature_flag_version = flagDetails.metadata.version;
847
- const reason = flagDetails?.reason?.description ?? flagDetails?.reason?.code;
848
- if (reason) properties.$feature_flag_reason = reason;
849
- if (flagDetails?.metadata?.id) properties.$feature_flag_id = flagDetails.metadata.id;
850
- if (!(0, core_namespaceObject.isUndefined)(flagDetails?.original_variant) || !(0, core_namespaceObject.isUndefined)(flagDetails?.original_enabled)) properties.$feature_flag_original_response = (0, core_namespaceObject.isUndefined)(flagDetails.original_variant) ? flagDetails.original_enabled : flagDetails.original_variant;
851
- if (flagDetails?.metadata?.original_payload) properties.$feature_flag_original_payload = flagDetails?.metadata?.original_payload;
852
- if (errors.length) properties.$feature_flag_error = errors.join(',');
853
- this._captureFeatureFlagCalled(properties);
854
861
  }
855
862
  if (!flagExists) return;
856
863
  return {
@@ -775,46 +775,53 @@ class PostHogFeatureFlags {
775
775
  [FLAG_CALL_REPORTED]: flagCallReported,
776
776
  [FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
777
777
  });
778
- } else if (key in flagCallReported && flagCallReported[key].includes(flagReportValue)) {
779
- if (sessionIdToPersist) this._set({
780
- [FLAG_CALL_REPORTED]: flagCallReported,
781
- [FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
782
- });
783
778
  } else {
784
- if (isArray(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
785
- else flagCallReported[key] = [
786
- flagReportValue
787
- ];
788
- this._set({
779
+ const canCapture = this._client?.canCapture;
780
+ if (!canCapture && Object.keys(flagCallReported).length > 0) {
781
+ flagCallReported = {};
782
+ this._set({
783
+ [FLAG_CALL_REPORTED]: flagCallReported
784
+ });
785
+ }
786
+ if (canCapture && !flagCallReported[key]?.includes(flagReportValue)) {
787
+ if (isArray(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
788
+ else flagCallReported[key] = [
789
+ flagReportValue
790
+ ];
791
+ this._set({
792
+ [FLAG_CALL_REPORTED]: flagCallReported,
793
+ ...sessionIdToPersist ? {
794
+ [FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
795
+ } : {}
796
+ });
797
+ const flagDetails = this.getFeatureFlagDetails(key);
798
+ const errors = [
799
+ ...this._prop(PERSISTENCE_FEATURE_FLAG_ERRORS) ?? []
800
+ ];
801
+ if (isUndefined(flagValue)) errors.push(FeatureFlagError.FLAG_MISSING);
802
+ const properties = {
803
+ $feature_flag: key,
804
+ $feature_flag_response: flagValue,
805
+ $feature_flag_payload: payload ?? null,
806
+ $feature_flag_request_id: requestId,
807
+ $feature_flag_evaluated_at: evaluatedAt,
808
+ $feature_flag_bootstrapped_response: this._config.bootstrap?.featureFlags?.[key] ?? null,
809
+ $feature_flag_bootstrapped_payload: this._config.bootstrap?.featureFlagPayloads?.[key] ?? null,
810
+ $used_bootstrap_value: !this._flagsLoadedFromRemote
811
+ };
812
+ if (!isUndefined(flagDetails?.metadata?.has_experiment)) properties.$feature_flag_has_experiment = flagDetails.metadata.has_experiment;
813
+ if (!isUndefined(flagDetails?.metadata?.version)) properties.$feature_flag_version = flagDetails.metadata.version;
814
+ const reason = flagDetails?.reason?.description ?? flagDetails?.reason?.code;
815
+ if (reason) properties.$feature_flag_reason = reason;
816
+ if (flagDetails?.metadata?.id) properties.$feature_flag_id = flagDetails.metadata.id;
817
+ if (!isUndefined(flagDetails?.original_variant) || !isUndefined(flagDetails?.original_enabled)) properties.$feature_flag_original_response = isUndefined(flagDetails.original_variant) ? flagDetails.original_enabled : flagDetails.original_variant;
818
+ if (flagDetails?.metadata?.original_payload) properties.$feature_flag_original_payload = flagDetails?.metadata?.original_payload;
819
+ if (errors.length) properties.$feature_flag_error = errors.join(',');
820
+ this._captureFeatureFlagCalled(properties);
821
+ } else if (sessionIdToPersist) this._set({
789
822
  [FLAG_CALL_REPORTED]: flagCallReported,
790
- ...sessionIdToPersist ? {
791
- [FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
792
- } : {}
823
+ [FLAG_CALL_REPORTED_SESSION_ID]: sessionIdToPersist
793
824
  });
794
- const flagDetails = this.getFeatureFlagDetails(key);
795
- const errors = [
796
- ...this._prop(PERSISTENCE_FEATURE_FLAG_ERRORS) ?? []
797
- ];
798
- if (isUndefined(flagValue)) errors.push(FeatureFlagError.FLAG_MISSING);
799
- const properties = {
800
- $feature_flag: key,
801
- $feature_flag_response: flagValue,
802
- $feature_flag_payload: payload ?? null,
803
- $feature_flag_request_id: requestId,
804
- $feature_flag_evaluated_at: evaluatedAt,
805
- $feature_flag_bootstrapped_response: this._config.bootstrap?.featureFlags?.[key] ?? null,
806
- $feature_flag_bootstrapped_payload: this._config.bootstrap?.featureFlagPayloads?.[key] ?? null,
807
- $used_bootstrap_value: !this._flagsLoadedFromRemote
808
- };
809
- if (!isUndefined(flagDetails?.metadata?.has_experiment)) properties.$feature_flag_has_experiment = flagDetails.metadata.has_experiment;
810
- if (!isUndefined(flagDetails?.metadata?.version)) properties.$feature_flag_version = flagDetails.metadata.version;
811
- const reason = flagDetails?.reason?.description ?? flagDetails?.reason?.code;
812
- if (reason) properties.$feature_flag_reason = reason;
813
- if (flagDetails?.metadata?.id) properties.$feature_flag_id = flagDetails.metadata.id;
814
- if (!isUndefined(flagDetails?.original_variant) || !isUndefined(flagDetails?.original_enabled)) properties.$feature_flag_original_response = isUndefined(flagDetails.original_variant) ? flagDetails.original_enabled : flagDetails.original_variant;
815
- if (flagDetails?.metadata?.original_payload) properties.$feature_flag_original_payload = flagDetails?.metadata?.original_payload;
816
- if (errors.length) properties.$feature_flag_error = errors.join(',');
817
- this._captureFeatureFlagCalled(properties);
818
825
  }
819
826
  if (!flagExists) return;
820
827
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/browser-common",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -218,8 +218,8 @@
218
218
  },
219
219
  "dependencies": {
220
220
  "preact": "^10.29.3",
221
- "@posthog/core": "^1.59.3",
222
- "@posthog/types": "^1.416.0"
221
+ "@posthog/types": "^1.416.0",
222
+ "@posthog/core": "^1.59.4"
223
223
  },
224
224
  "devDependencies": {
225
225
  "@rsbuild/plugin-react": "^2.1.0",