@posthog/browser-common 0.10.3 → 0.10.5
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 +1 -1
- package/dist/config.mjs +1 -1
- package/dist/feature-flags.d.ts +4 -0
- package/dist/feature-flags.js +25 -5
- package/dist/feature-flags.mjs +25 -5
- package/dist/surveys/surveys-extension-utils.d.ts +8 -0
- package/dist/surveys/surveys-extension-utils.js +10 -0
- package/dist/surveys/surveys-extension-utils.mjs +8 -1
- package/dist/surveys-renderer.js +2 -4
- package/dist/surveys-renderer.mjs +3 -5
- package/package.json +2 -2
package/dist/config.js
CHANGED
package/dist/config.mjs
CHANGED
package/dist/feature-flags.d.ts
CHANGED
|
@@ -76,6 +76,8 @@ export declare class PostHogFeatureFlags implements Extension {
|
|
|
76
76
|
private _additionalReloadRequested;
|
|
77
77
|
private _reloadDebouncer;
|
|
78
78
|
private _firingFeatureFlagsCallbacks;
|
|
79
|
+
private _flagCallsPendingCapture;
|
|
80
|
+
private _sendingFlagCallsPendingCapture;
|
|
79
81
|
private _flagsLoadedFromRemote;
|
|
80
82
|
private _staleCacheRefreshTriggered;
|
|
81
83
|
private _consecutiveStatusZeroFailures;
|
|
@@ -153,6 +155,8 @@ export declare class PostHogFeatureFlags implements Extension {
|
|
|
153
155
|
setAnonymousDistinctId(anon_distinct_id: string | undefined): void;
|
|
154
156
|
setReloadingPaused(isPaused: boolean): void;
|
|
155
157
|
resetFlagCallReported(): void;
|
|
158
|
+
/** Sends `$feature_flag_called` for the flags read while capture was off, once the client can capture. */
|
|
159
|
+
sendFlagCallsPendingCapture(): void;
|
|
156
160
|
_callFlagsEndpoint(options?: {
|
|
157
161
|
disableFlags?: boolean;
|
|
158
162
|
}): void;
|
package/dist/feature-flags.js
CHANGED
|
@@ -207,6 +207,8 @@ class PostHogFeatureFlags {
|
|
|
207
207
|
this._reloadingDisabled = false;
|
|
208
208
|
this._additionalReloadRequested = false;
|
|
209
209
|
this._firingFeatureFlagsCallbacks = false;
|
|
210
|
+
this._flagCallsPendingCapture = new Map();
|
|
211
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
210
212
|
this._flagsLoadedFromRemote = false;
|
|
211
213
|
this._staleCacheRefreshTriggered = false;
|
|
212
214
|
this._consecutiveStatusZeroFailures = 0;
|
|
@@ -650,6 +652,19 @@ class PostHogFeatureFlags {
|
|
|
650
652
|
}
|
|
651
653
|
resetFlagCallReported() {
|
|
652
654
|
this._remove(external_constants_js_namespaceObject.FLAG_CALL_REPORTED);
|
|
655
|
+
this._flagCallsPendingCapture = new Map();
|
|
656
|
+
}
|
|
657
|
+
sendFlagCallsPendingCapture() {
|
|
658
|
+
if (0 === this._flagCallsPendingCapture.size || this._sendingFlagCallsPendingCapture || !this._client?.canCapture) return;
|
|
659
|
+
this._sendingFlagCallsPendingCapture = true;
|
|
660
|
+
try {
|
|
661
|
+
this._flagCallsPendingCapture.forEach((readBy, key)=>{
|
|
662
|
+
if (readBy === this._client?.distinctId) this.getFeatureFlagResult(key);
|
|
663
|
+
else this._flagCallsPendingCapture.delete(key);
|
|
664
|
+
});
|
|
665
|
+
} finally{
|
|
666
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
667
|
+
}
|
|
653
668
|
}
|
|
654
669
|
_callFlagsEndpoint(options) {
|
|
655
670
|
this._clearDebouncer();
|
|
@@ -813,11 +828,15 @@ class PostHogFeatureFlags {
|
|
|
813
828
|
});
|
|
814
829
|
} else {
|
|
815
830
|
const canCapture = this._client?.canCapture;
|
|
816
|
-
if (
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
831
|
+
if (canCapture) this._flagCallsPendingCapture.delete(key);
|
|
832
|
+
else {
|
|
833
|
+
if (Object.keys(flagCallReported).length > 0) {
|
|
834
|
+
flagCallReported = {};
|
|
835
|
+
this._set({
|
|
836
|
+
[external_constants_js_namespaceObject.FLAG_CALL_REPORTED]: flagCallReported
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
this._flagCallsPendingCapture.set(key, this._client?.distinctId);
|
|
821
840
|
}
|
|
822
841
|
if (canCapture && !flagCallReported[key]?.includes(flagReportValue)) {
|
|
823
842
|
if ((0, core_namespaceObject.isArray)(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
|
|
@@ -1215,6 +1234,7 @@ class PostHogFeatureFlags {
|
|
|
1215
1234
|
this._clearDebouncer();
|
|
1216
1235
|
this._override_warning = false;
|
|
1217
1236
|
this._consecutiveStatusZeroFailures = 0;
|
|
1237
|
+
this._flagCallsPendingCapture = new Map();
|
|
1218
1238
|
}
|
|
1219
1239
|
}
|
|
1220
1240
|
exports.FeatureFlagError = __webpack_exports__.FeatureFlagError;
|
package/dist/feature-flags.mjs
CHANGED
|
@@ -171,6 +171,8 @@ class PostHogFeatureFlags {
|
|
|
171
171
|
this._reloadingDisabled = false;
|
|
172
172
|
this._additionalReloadRequested = false;
|
|
173
173
|
this._firingFeatureFlagsCallbacks = false;
|
|
174
|
+
this._flagCallsPendingCapture = new Map();
|
|
175
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
174
176
|
this._flagsLoadedFromRemote = false;
|
|
175
177
|
this._staleCacheRefreshTriggered = false;
|
|
176
178
|
this._consecutiveStatusZeroFailures = 0;
|
|
@@ -614,6 +616,19 @@ class PostHogFeatureFlags {
|
|
|
614
616
|
}
|
|
615
617
|
resetFlagCallReported() {
|
|
616
618
|
this._remove(FLAG_CALL_REPORTED);
|
|
619
|
+
this._flagCallsPendingCapture = new Map();
|
|
620
|
+
}
|
|
621
|
+
sendFlagCallsPendingCapture() {
|
|
622
|
+
if (0 === this._flagCallsPendingCapture.size || this._sendingFlagCallsPendingCapture || !this._client?.canCapture) return;
|
|
623
|
+
this._sendingFlagCallsPendingCapture = true;
|
|
624
|
+
try {
|
|
625
|
+
this._flagCallsPendingCapture.forEach((readBy, key)=>{
|
|
626
|
+
if (readBy === this._client?.distinctId) this.getFeatureFlagResult(key);
|
|
627
|
+
else this._flagCallsPendingCapture.delete(key);
|
|
628
|
+
});
|
|
629
|
+
} finally{
|
|
630
|
+
this._sendingFlagCallsPendingCapture = false;
|
|
631
|
+
}
|
|
617
632
|
}
|
|
618
633
|
_callFlagsEndpoint(options) {
|
|
619
634
|
this._clearDebouncer();
|
|
@@ -777,11 +792,15 @@ class PostHogFeatureFlags {
|
|
|
777
792
|
});
|
|
778
793
|
} else {
|
|
779
794
|
const canCapture = this._client?.canCapture;
|
|
780
|
-
if (
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
795
|
+
if (canCapture) this._flagCallsPendingCapture.delete(key);
|
|
796
|
+
else {
|
|
797
|
+
if (Object.keys(flagCallReported).length > 0) {
|
|
798
|
+
flagCallReported = {};
|
|
799
|
+
this._set({
|
|
800
|
+
[FLAG_CALL_REPORTED]: flagCallReported
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
this._flagCallsPendingCapture.set(key, this._client?.distinctId);
|
|
785
804
|
}
|
|
786
805
|
if (canCapture && !flagCallReported[key]?.includes(flagReportValue)) {
|
|
787
806
|
if (isArray(flagCallReported[key])) flagCallReported[key].push(flagReportValue);
|
|
@@ -1179,6 +1198,7 @@ class PostHogFeatureFlags {
|
|
|
1179
1198
|
this._clearDebouncer();
|
|
1180
1199
|
this._override_warning = false;
|
|
1181
1200
|
this._consecutiveStatusZeroFailures = 0;
|
|
1201
|
+
this._flagCallsPendingCapture = new Map();
|
|
1182
1202
|
}
|
|
1183
1203
|
}
|
|
1184
1204
|
export { FeatureFlagError, PostHogFeatureFlags, QuotaLimitedResource, filterActiveFeatureFlags, parseFlagsResponse };
|
|
@@ -131,3 +131,11 @@ export declare function getSurveyContainerClass(survey: Pick<Survey, 'id'>, asSe
|
|
|
131
131
|
* Used by both surveys and product tours for consistent positioning
|
|
132
132
|
*/
|
|
133
133
|
export declare function getPopoverPosition(type?: SurveyType, position?: SurveyPosition, surveyWidgetType?: SurveyWidgetType): Record<string, string>;
|
|
134
|
+
/**
|
|
135
|
+
* Style overrides for a tab widget's popup. The popup is centred next to the
|
|
136
|
+
* tab only while the survey uses the default right position or explicitly
|
|
137
|
+
* asks to sit next to its trigger. Any other selected position is a
|
|
138
|
+
* deliberate placement, so no override applies and getPopoverPosition alone
|
|
139
|
+
* decides where the popup goes.
|
|
140
|
+
*/
|
|
141
|
+
export declare function getTabWidgetPopupOverrides(position?: SurveyPosition): Record<string, string>;
|
|
@@ -49,6 +49,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
49
49
|
getSurveyResponseKey: ()=>surveys_namespaceObject.getSurveyResponseKey,
|
|
50
50
|
getSurveySeen: ()=>getSurveySeen,
|
|
51
51
|
getSurveyStylesheet: ()=>getSurveyStylesheet,
|
|
52
|
+
getTabWidgetPopupOverrides: ()=>getTabWidgetPopupOverrides,
|
|
52
53
|
hasWaitPeriodPassed: ()=>hasWaitPeriodPassed,
|
|
53
54
|
hex2rgb: ()=>hex2rgb,
|
|
54
55
|
hexToRgba: ()=>hexToRgba,
|
|
@@ -669,6 +670,13 @@ function getPopoverPosition(type, position = external_survey_constants_js_namesp
|
|
|
669
670
|
};
|
|
670
671
|
}
|
|
671
672
|
}
|
|
673
|
+
function getTabWidgetPopupOverrides(position) {
|
|
674
|
+
if (!position || position === external_survey_constants_js_namespaceObject.SurveyPosition.Right || position === external_survey_constants_js_namespaceObject.SurveyPosition.NextToTrigger) return {
|
|
675
|
+
top: '50%',
|
|
676
|
+
bottom: 'auto'
|
|
677
|
+
};
|
|
678
|
+
return {};
|
|
679
|
+
}
|
|
672
680
|
exports.SurveyContext = __webpack_exports__.SurveyContext;
|
|
673
681
|
exports.addSurveyCSSVariablesToElement = __webpack_exports__.addSurveyCSSVariablesToElement;
|
|
674
682
|
exports.canActivateRepeatedly = __webpack_exports__.canActivateRepeatedly;
|
|
@@ -690,6 +698,7 @@ exports.getSurveyContainerClass = __webpack_exports__.getSurveyContainerClass;
|
|
|
690
698
|
exports.getSurveyResponseKey = __webpack_exports__.getSurveyResponseKey;
|
|
691
699
|
exports.getSurveySeen = __webpack_exports__.getSurveySeen;
|
|
692
700
|
exports.getSurveyStylesheet = __webpack_exports__.getSurveyStylesheet;
|
|
701
|
+
exports.getTabWidgetPopupOverrides = __webpack_exports__.getTabWidgetPopupOverrides;
|
|
693
702
|
exports.hasWaitPeriodPassed = __webpack_exports__.hasWaitPeriodPassed;
|
|
694
703
|
exports.hex2rgb = __webpack_exports__.hex2rgb;
|
|
695
704
|
exports.hexToRgba = __webpack_exports__.hexToRgba;
|
|
@@ -723,6 +732,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
723
732
|
"getSurveyResponseKey",
|
|
724
733
|
"getSurveySeen",
|
|
725
734
|
"getSurveyStylesheet",
|
|
735
|
+
"getTabWidgetPopupOverrides",
|
|
726
736
|
"hasWaitPeriodPassed",
|
|
727
737
|
"hex2rgb",
|
|
728
738
|
"hexToRgba",
|
|
@@ -606,4 +606,11 @@ function getPopoverPosition(type, position = SurveyPosition.Right, surveyWidgetT
|
|
|
606
606
|
};
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
|
|
609
|
+
function getTabWidgetPopupOverrides(position) {
|
|
610
|
+
if (!position || position === SurveyPosition.Right || position === SurveyPosition.NextToTrigger) return {
|
|
611
|
+
top: '50%',
|
|
612
|
+
bottom: 'auto'
|
|
613
|
+
};
|
|
614
|
+
return {};
|
|
615
|
+
}
|
|
616
|
+
export { SurveyContext, addSurveyCSSVariablesToElement, canActivateRepeatedly, clearAllInMemoryInProgressSurveyState, clearInProgressSurveyState, defaultSurveyAppearance, dismissedSurveyEvent, doesSurveyDeviceTypesMatch, doesSurveyMatchSelector, doesSurveyUrlMatch, getContrastingTextColor, getDisplayOrderChoices, getDisplayOrderQuestions, getFontFamily, getInProgressSurveyState, getPopoverPosition, getQuestionOrder, getSurveyContainerClass, getSurveyResponseKey, getSurveySeen, getSurveyStylesheet, getTabWidgetPopupOverrides, hasWaitPeriodPassed, hex2rgb, hexToRgba, isSurveyInProgress, renderChildrenAsTextOrHtml, retrieveSurveyShadow, sendSurveyAbandonedEvent, sendSurveyEvent, setInProgressSurveyState, shuffle, useSurveyContext };
|
package/dist/surveys-renderer.js
CHANGED
|
@@ -1164,10 +1164,7 @@ function FeedbackWidget({ survey, forceDisableHtml, posthog, readOnly, surveyLan
|
|
|
1164
1164
|
(0, hooks_namespaceObject.useEffect)(()=>{
|
|
1165
1165
|
if (!posthog) return void survey_utils_js_namespaceObject.SURVEY_LOGGER.error('FeedbackWidget called without a PostHog instance.');
|
|
1166
1166
|
if (readOnly) return;
|
|
1167
|
-
if (survey.appearance?.widgetType === 'tab') setStyleOverrides(
|
|
1168
|
-
top: '50%',
|
|
1169
|
-
bottom: 'auto'
|
|
1170
|
-
});
|
|
1167
|
+
if (survey.appearance?.widgetType === 'tab') setStyleOverrides((0, surveys_extension_utils_js_namespaceObject.getTabWidgetPopupOverrides)(survey.appearance?.position));
|
|
1171
1168
|
const handleShowSurvey = (event)=>{
|
|
1172
1169
|
const customEvent = event;
|
|
1173
1170
|
if (customEvent.detail?.surveyId === survey.id) {
|
|
@@ -1189,6 +1186,7 @@ function FeedbackWidget({ survey, forceDisableHtml, posthog, readOnly, surveyLan
|
|
|
1189
1186
|
readOnly,
|
|
1190
1187
|
survey.id,
|
|
1191
1188
|
survey.appearance?.widgetType,
|
|
1189
|
+
survey.appearance?.position,
|
|
1192
1190
|
survey.appearance?.widgetSelector,
|
|
1193
1191
|
survey.appearance?.borderColor
|
|
1194
1192
|
]);
|
|
@@ -14,7 +14,7 @@ import { ConfirmationMessage } from "./surveys/components/ConfirmationMessage.mj
|
|
|
14
14
|
import { IntroScreen } from "./surveys/components/IntroScreen.mjs";
|
|
15
15
|
import { Cancel } from "./surveys/components/QuestionHeader.mjs";
|
|
16
16
|
import { LinkQuestion, MultipleChoiceQuestion, OpenTextQuestion, RatingQuestion } from "./surveys/components/QuestionTypes.mjs";
|
|
17
|
-
import { SurveyContext, addSurveyCSSVariablesToElement, canActivateRepeatedly, clearAllInMemoryInProgressSurveyState, clearInProgressSurveyState, defaultSurveyAppearance, dismissedSurveyEvent, doesSurveyDeviceTypesMatch, doesSurveyMatchSelector, doesSurveyUrlMatch, getDisplayOrderQuestions, getInProgressSurveyState, getPopoverPosition, getQuestionOrder, getSurveyContainerClass, getSurveyResponseKey, getSurveySeen, getSurveyStylesheet, hasWaitPeriodPassed, isSurveyInProgress, retrieveSurveyShadow, sendSurveyAbandonedEvent, sendSurveyEvent, setInProgressSurveyState } from "./surveys/surveys-extension-utils.mjs";
|
|
17
|
+
import { SurveyContext, addSurveyCSSVariablesToElement, canActivateRepeatedly, clearAllInMemoryInProgressSurveyState, clearInProgressSurveyState, defaultSurveyAppearance, dismissedSurveyEvent, doesSurveyDeviceTypesMatch, doesSurveyMatchSelector, doesSurveyUrlMatch, getDisplayOrderQuestions, getInProgressSurveyState, getPopoverPosition, getQuestionOrder, getSurveyContainerClass, getSurveyResponseKey, getSurveySeen, getSurveyStylesheet, getTabWidgetPopupOverrides, hasWaitPeriodPassed, isSurveyInProgress, retrieveSurveyShadow, sendSurveyAbandonedEvent, sendSurveyEvent, setInProgressSurveyState } from "./surveys/surveys-extension-utils.mjs";
|
|
18
18
|
import { calculatePrefillStartIndex, convertPrefillToResponses, extractPrefillParamsFromUrl } from "./surveys/survey-url-prefill.mjs";
|
|
19
19
|
import { getNextSurveyStep } from "./surveys/survey-branching.mjs";
|
|
20
20
|
import { applySurveyTranslationForUser } from "./surveys/survey-translations.mjs";
|
|
@@ -1121,10 +1121,7 @@ function FeedbackWidget({ survey, forceDisableHtml, posthog, readOnly, surveyLan
|
|
|
1121
1121
|
useEffect(()=>{
|
|
1122
1122
|
if (!posthog) return void SURVEY_LOGGER.error('FeedbackWidget called without a PostHog instance.');
|
|
1123
1123
|
if (readOnly) return;
|
|
1124
|
-
if (survey.appearance?.widgetType === 'tab') setStyleOverrides(
|
|
1125
|
-
top: '50%',
|
|
1126
|
-
bottom: 'auto'
|
|
1127
|
-
});
|
|
1124
|
+
if (survey.appearance?.widgetType === 'tab') setStyleOverrides(getTabWidgetPopupOverrides(survey.appearance?.position));
|
|
1128
1125
|
const handleShowSurvey = (event)=>{
|
|
1129
1126
|
const customEvent = event;
|
|
1130
1127
|
if (customEvent.detail?.surveyId === survey.id) {
|
|
@@ -1146,6 +1143,7 @@ function FeedbackWidget({ survey, forceDisableHtml, posthog, readOnly, surveyLan
|
|
|
1146
1143
|
readOnly,
|
|
1147
1144
|
survey.id,
|
|
1148
1145
|
survey.appearance?.widgetType,
|
|
1146
|
+
survey.appearance?.position,
|
|
1149
1147
|
survey.appearance?.widgetSelector,
|
|
1150
1148
|
survey.appearance?.borderColor
|
|
1151
1149
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/browser-common",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.5",
|
|
4
4
|
"description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
"dependencies": {
|
|
242
242
|
"dompurify": "^3.4.13",
|
|
243
243
|
"preact": "^10.29.3",
|
|
244
|
-
"@posthog/core": "^1.
|
|
244
|
+
"@posthog/core": "^1.63.1",
|
|
245
245
|
"@posthog/types": "^1.419.0"
|
|
246
246
|
},
|
|
247
247
|
"devDependencies": {
|