posthog-js 1.161.3 → 1.161.4

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/module.d.ts CHANGED
@@ -267,6 +267,7 @@ interface PostHogConfig {
267
267
  /** @deprecated - use `disable_persistence` instead */
268
268
  disable_cookie?: boolean;
269
269
  disable_surveys: boolean;
270
+ disable_web_experiments: boolean;
270
271
  /** If set, posthog-js will never load external scripts such as those needed for Session Replay or Surveys. */
271
272
  disable_external_dependency_loading?: boolean;
272
273
  enable_recording_console_log?: boolean;
@@ -500,9 +501,10 @@ interface ToolbarParams {
500
501
  featureFlags?: Record<string, string | boolean>;
501
502
  }
502
503
  type SnippetArrayItem = [method: string, ...args: any[]];
503
- type JsonType = string | number | boolean | null | {
504
+ type JsonRecord = {
504
505
  [key: string]: JsonType;
505
- } | Array<JsonType>;
506
+ };
507
+ type JsonType = string | number | boolean | null | JsonRecord | Array<JsonType>;
506
508
  /** A feature that isn't publicly available yet.*/
507
509
  interface EarlyAccessFeature {
508
510
  name: string;
@@ -1705,6 +1707,58 @@ declare class WebVitalsAutocapture {
1705
1707
  private _startCapturing;
1706
1708
  }
1707
1709
 
1710
+ interface WebExperimentTransform {
1711
+ attributes?: {
1712
+ name: string;
1713
+ value: string;
1714
+ }[];
1715
+ selector?: string;
1716
+ text?: string;
1717
+ html?: string;
1718
+ imgUrl?: string;
1719
+ className?: string;
1720
+ }
1721
+ type WebExperimentUrlMatchType = 'regex' | 'not_regex' | 'exact' | 'is_not' | 'icontains' | 'not_icontains';
1722
+ interface WebExperimentVariant {
1723
+ conditions?: {
1724
+ url?: string;
1725
+ urlMatchType?: WebExperimentUrlMatchType;
1726
+ utm?: {
1727
+ utm_source?: string;
1728
+ utm_medium?: string;
1729
+ utm_campaign?: string;
1730
+ utm_term?: string;
1731
+ };
1732
+ };
1733
+ variant_name: string;
1734
+ transforms: WebExperimentTransform[];
1735
+ }
1736
+ interface WebExperiment {
1737
+ id: number;
1738
+ name: string;
1739
+ feature_flag_key?: string;
1740
+ variants: Record<string, WebExperimentVariant>;
1741
+ }
1742
+ type WebExperimentsCallback = (webExperiments: WebExperiment[]) => void;
1743
+
1744
+ declare class WebExperiments {
1745
+ instance: PostHog;
1746
+ private _featureFlags?;
1747
+ private _flagToExperiments?;
1748
+ constructor(instance: PostHog);
1749
+ applyFeatureFlagChanges(flags: string[]): void;
1750
+ afterDecideResponse(response: DecideResponse): void;
1751
+ loadIfEnabled(): void;
1752
+ getWebExperimentsAndEvaluateDisplayLogic: (forceReload?: boolean) => void;
1753
+ getWebExperiments(callback: WebExperimentsCallback, forceReload: boolean): void;
1754
+ private static matchesTestVariant;
1755
+ private static matchUrlConditions;
1756
+ static getWindowLocation(): Location | undefined;
1757
+ private static matchUTMConditions;
1758
+ private static logInfo;
1759
+ private static applyTransforms;
1760
+ }
1761
+
1708
1762
  declare class PostHogExceptions {
1709
1763
  private readonly instance;
1710
1764
  private _endpointSuffix;
@@ -1735,6 +1789,7 @@ declare class PostHog {
1735
1789
  pageViewManager: PageViewManager;
1736
1790
  featureFlags: PostHogFeatureFlags;
1737
1791
  surveys: PostHogSurveys;
1792
+ experiments: WebExperiments;
1738
1793
  toolbar: Toolbar;
1739
1794
  exceptions: PostHogExceptions;
1740
1795
  consent: ConsentManager;
@@ -2408,4 +2463,4 @@ declare class PostHog {
2408
2463
 
2409
2464
  declare const posthog: PostHog;
2410
2465
 
2411
- export { type ActionStepStringMatching, type ActionStepType, type ActionType, type AutocaptureCompatibleElement, type AutocaptureConfig, type BasicSurveyQuestion, type BootstrapConfig, type Breaker, type CaptureOptions, type CaptureResult, type CapturedNetworkRequest, Compression, type DecideResponse, type DomAutocaptureEvents, type EarlyAccessFeature, type EarlyAccessFeatureCallback, type EarlyAccessFeatureResponse, type ErrorConversions, type ErrorEventArgs, type ErrorProperties, type EventHandler, type FeatureFlagsCallback, type FlagVariant, type Headers, type HeatmapConfig, type InitiatorType, type IsFeatureEnabledOptions, type JsonType, type LinkSurveyQuestion, type MultipleSurveyQuestion, type NetworkRecordOptions, type NetworkRequest, type OptInOutCapturingOptions, type PerformanceCaptureConfig, type PersistentStore, PostHog, type PostHogConfig, type Properties, type Property, type QueuedRequestOptions, type RatingSurveyQuestion, type RequestCallback, type RequestOptions, type RequestResponse, type RetriableRequestOptions, type SessionIdChangedCallback, type SessionRecordingOptions, type SeverityLevel, type SnippetArrayItem, type SupportedWebVitalsMetrics, type Survey, type SurveyAppearance, type SurveyCallback, type SurveyElement, type SurveyQuestion, SurveyQuestionBranchingType, type SurveyQuestionDescriptionContentType, SurveyQuestionType, type SurveyRenderReason, type SurveyResponse, SurveyType, type SurveyUrlMatchType, type ToolbarParams, type ToolbarSource, type ToolbarUserIntent, type ToolbarVersion, posthog as default, posthog, severityLevels };
2466
+ export { type ActionStepStringMatching, type ActionStepType, type ActionType, type AutocaptureCompatibleElement, type AutocaptureConfig, type BasicSurveyQuestion, type BootstrapConfig, type Breaker, type CaptureOptions, type CaptureResult, type CapturedNetworkRequest, Compression, type DecideResponse, type DomAutocaptureEvents, type EarlyAccessFeature, type EarlyAccessFeatureCallback, type EarlyAccessFeatureResponse, type ErrorConversions, type ErrorEventArgs, type ErrorProperties, type EventHandler, type FeatureFlagsCallback, type FlagVariant, type Headers, type HeatmapConfig, type InitiatorType, type IsFeatureEnabledOptions, type JsonRecord, type JsonType, type LinkSurveyQuestion, type MultipleSurveyQuestion, type NetworkRecordOptions, type NetworkRequest, type OptInOutCapturingOptions, type PerformanceCaptureConfig, type PersistentStore, PostHog, type PostHogConfig, type Properties, type Property, type QueuedRequestOptions, type RatingSurveyQuestion, type RequestCallback, type RequestOptions, type RequestResponse, type RetriableRequestOptions, type SessionIdChangedCallback, type SessionRecordingOptions, type SeverityLevel, type SnippetArrayItem, type SupportedWebVitalsMetrics, type Survey, type SurveyAppearance, type SurveyCallback, type SurveyElement, type SurveyQuestion, SurveyQuestionBranchingType, type SurveyQuestionDescriptionContentType, SurveyQuestionType, type SurveyRenderReason, type SurveyResponse, SurveyType, type SurveyUrlMatchType, type ToolbarParams, type ToolbarSource, type ToolbarUserIntent, type ToolbarVersion, posthog as default, posthog, severityLevels };