posthog-js 1.232.6 → 1.232.7
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/all-external-dependencies.js.map +1 -1
- package/dist/array.full.es5.js +1 -1
- package/dist/array.full.es5.js.map +1 -1
- package/dist/array.full.js +1 -1
- package/dist/array.full.js.map +1 -1
- package/dist/array.full.no-external.js +1 -1
- package/dist/array.full.no-external.js.map +1 -1
- package/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/customizations.full.js +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.d.ts +29 -1
- package/dist/module.full.d.ts +29 -1
- package/dist/module.full.js +1 -1
- package/dist/module.full.js.map +1 -1
- package/dist/module.full.no-external.d.ts +29 -1
- package/dist/module.full.no-external.js +1 -1
- package/dist/module.full.no-external.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.d.ts +29 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/dist/src/posthog-core.d.ts +1 -0
- package/dist/src/posthog-surveys-types.d.ts +4 -1
- package/dist/src/posthog-surveys.d.ts +24 -0
- package/dist/surveys-preview.d.ts +29 -1
- package/dist/surveys-preview.js.map +1 -1
- package/dist/surveys.js.map +1 -1
- package/lib/package.json +1 -1
- package/lib/src/posthog-core.d.ts +1 -0
- package/lib/src/posthog-core.js +17 -0
- package/lib/src/posthog-core.js.map +1 -1
- package/lib/src/posthog-surveys-types.d.ts +4 -1
- package/lib/src/posthog-surveys-types.js.map +1 -1
- package/lib/src/posthog-surveys.d.ts +24 -0
- package/lib/src/posthog-surveys.js +104 -6
- package/lib/src/posthog-surveys.js.map +1 -1
- package/package.json +1 -1
package/dist/module.d.ts
CHANGED
|
@@ -2118,7 +2118,10 @@ interface SpecificQuestionBranching {
|
|
|
2118
2118
|
interface SurveyResponse {
|
|
2119
2119
|
surveys: Survey[];
|
|
2120
2120
|
}
|
|
2121
|
-
type SurveyCallback = (surveys: Survey[]
|
|
2121
|
+
type SurveyCallback = (surveys: Survey[], context?: {
|
|
2122
|
+
isLoaded: boolean;
|
|
2123
|
+
error?: string;
|
|
2124
|
+
}) => void;
|
|
2122
2125
|
type SurveyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains';
|
|
2123
2126
|
interface SurveyElement {
|
|
2124
2127
|
text?: string;
|
|
@@ -2249,11 +2252,35 @@ declare class PostHogSurveys {
|
|
|
2249
2252
|
private _surveyManager;
|
|
2250
2253
|
private _isFetchingSurveys;
|
|
2251
2254
|
private _isInitializingSurveys;
|
|
2255
|
+
private _surveyCallbacks;
|
|
2252
2256
|
constructor(instance: PostHog);
|
|
2253
2257
|
onRemoteConfig(response: RemoteConfig): void;
|
|
2254
2258
|
reset(): void;
|
|
2255
2259
|
loadIfEnabled(): void;
|
|
2260
|
+
/**
|
|
2261
|
+
* Register a callback that runs when surveys are initialized.
|
|
2262
|
+
* ### Usage:
|
|
2263
|
+
*
|
|
2264
|
+
* posthog.onSurveysLoaded((surveys) => {
|
|
2265
|
+
* // You can work with all surveys
|
|
2266
|
+
* console.log('All available surveys:', surveys)
|
|
2267
|
+
*
|
|
2268
|
+
* // Or get active matching surveys
|
|
2269
|
+
* posthog.getActiveMatchingSurveys((activeMatchingSurveys) => {
|
|
2270
|
+
* if (activeMatchingSurveys.length > 0) {
|
|
2271
|
+
* posthog.renderSurvey(activeMatchingSurveys[0].id, '#survey-container')
|
|
2272
|
+
* }
|
|
2273
|
+
* })
|
|
2274
|
+
* })
|
|
2275
|
+
*
|
|
2276
|
+
* @param {Function} callback The callback function will be called when surveys are loaded or updated.
|
|
2277
|
+
* It receives the array of all surveys and a context object with error status.
|
|
2278
|
+
* @returns {Function} A function that can be called to unsubscribe the listener.
|
|
2279
|
+
*/
|
|
2280
|
+
onSurveysLoaded(callback: SurveyCallback): () => void;
|
|
2256
2281
|
getSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|
|
2282
|
+
/** Helper method to notify all registered callbacks */
|
|
2283
|
+
private _notifySurveyCallbacks;
|
|
2257
2284
|
private isSurveyFeatureFlagEnabled;
|
|
2258
2285
|
getActiveMatchingSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|
|
2259
2286
|
checkFlags(survey: Survey): boolean;
|
|
@@ -2690,6 +2717,7 @@ declare class PostHog {
|
|
|
2690
2717
|
*/
|
|
2691
2718
|
on(event: 'eventCaptured', cb: (...args: any[]) => void): () => void;
|
|
2692
2719
|
onFeatureFlags(callback: FeatureFlagsCallback): () => void;
|
|
2720
|
+
onSurveysLoaded(callback: SurveyCallback): () => void;
|
|
2693
2721
|
onSessionId(callback: SessionIdChangedCallback): () => void;
|
|
2694
2722
|
/** Get list of all surveys. */
|
|
2695
2723
|
getSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|
package/dist/module.full.d.ts
CHANGED
|
@@ -2118,7 +2118,10 @@ interface SpecificQuestionBranching {
|
|
|
2118
2118
|
interface SurveyResponse {
|
|
2119
2119
|
surveys: Survey[];
|
|
2120
2120
|
}
|
|
2121
|
-
type SurveyCallback = (surveys: Survey[]
|
|
2121
|
+
type SurveyCallback = (surveys: Survey[], context?: {
|
|
2122
|
+
isLoaded: boolean;
|
|
2123
|
+
error?: string;
|
|
2124
|
+
}) => void;
|
|
2122
2125
|
type SurveyMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains';
|
|
2123
2126
|
interface SurveyElement {
|
|
2124
2127
|
text?: string;
|
|
@@ -2249,11 +2252,35 @@ declare class PostHogSurveys {
|
|
|
2249
2252
|
private _surveyManager;
|
|
2250
2253
|
private _isFetchingSurveys;
|
|
2251
2254
|
private _isInitializingSurveys;
|
|
2255
|
+
private _surveyCallbacks;
|
|
2252
2256
|
constructor(instance: PostHog);
|
|
2253
2257
|
onRemoteConfig(response: RemoteConfig): void;
|
|
2254
2258
|
reset(): void;
|
|
2255
2259
|
loadIfEnabled(): void;
|
|
2260
|
+
/**
|
|
2261
|
+
* Register a callback that runs when surveys are initialized.
|
|
2262
|
+
* ### Usage:
|
|
2263
|
+
*
|
|
2264
|
+
* posthog.onSurveysLoaded((surveys) => {
|
|
2265
|
+
* // You can work with all surveys
|
|
2266
|
+
* console.log('All available surveys:', surveys)
|
|
2267
|
+
*
|
|
2268
|
+
* // Or get active matching surveys
|
|
2269
|
+
* posthog.getActiveMatchingSurveys((activeMatchingSurveys) => {
|
|
2270
|
+
* if (activeMatchingSurveys.length > 0) {
|
|
2271
|
+
* posthog.renderSurvey(activeMatchingSurveys[0].id, '#survey-container')
|
|
2272
|
+
* }
|
|
2273
|
+
* })
|
|
2274
|
+
* })
|
|
2275
|
+
*
|
|
2276
|
+
* @param {Function} callback The callback function will be called when surveys are loaded or updated.
|
|
2277
|
+
* It receives the array of all surveys and a context object with error status.
|
|
2278
|
+
* @returns {Function} A function that can be called to unsubscribe the listener.
|
|
2279
|
+
*/
|
|
2280
|
+
onSurveysLoaded(callback: SurveyCallback): () => void;
|
|
2256
2281
|
getSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|
|
2282
|
+
/** Helper method to notify all registered callbacks */
|
|
2283
|
+
private _notifySurveyCallbacks;
|
|
2257
2284
|
private isSurveyFeatureFlagEnabled;
|
|
2258
2285
|
getActiveMatchingSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|
|
2259
2286
|
checkFlags(survey: Survey): boolean;
|
|
@@ -2690,6 +2717,7 @@ declare class PostHog {
|
|
|
2690
2717
|
*/
|
|
2691
2718
|
on(event: 'eventCaptured', cb: (...args: any[]) => void): () => void;
|
|
2692
2719
|
onFeatureFlags(callback: FeatureFlagsCallback): () => void;
|
|
2720
|
+
onSurveysLoaded(callback: SurveyCallback): () => void;
|
|
2693
2721
|
onSessionId(callback: SessionIdChangedCallback): () => void;
|
|
2694
2722
|
/** Get list of all surveys. */
|
|
2695
2723
|
getSurveys(callback: SurveyCallback, forceReload?: boolean): void;
|