@funnelsgrove/runtime 0.1.32 → 0.1.34

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.
@@ -1,23 +1,48 @@
1
1
  import type { FunnelManifestExperiment } from './funnel.manifest.types.js';
2
- export type FunnelExperimentDefinition = {
2
+ export type FunnelExperimentStatus = 'draft' | 'running' | 'paused' | 'stopped';
3
+ export type FunnelRouteExperimentType = 'paywall' | 'step';
4
+ type FunnelExperimentBase = {
3
5
  id: string;
4
6
  name: string;
5
- type: 'paywall' | 'step';
6
- status?: 'running' | 'paused' | 'stopped';
7
+ status?: FunnelExperimentStatus;
7
8
  launchDate: string;
9
+ };
10
+ export type FunnelRouteExperimentDefinition = FunnelExperimentBase & {
11
+ type: FunnelRouteExperimentType;
12
+ stepId?: string;
8
13
  control: {
14
+ variantKey?: string;
9
15
  stepId: string;
10
16
  label?: string;
11
17
  trafficPercent: number;
12
18
  };
13
19
  variant: {
20
+ variantKey?: string;
14
21
  stepId: string;
15
22
  label?: string;
16
23
  trafficPercent: number;
17
24
  };
18
25
  };
19
- export type PaywallExperimentDefinition = FunnelExperimentDefinition & {
26
+ export type FunnelPricingExperimentDefinition = FunnelExperimentBase & {
27
+ type: 'pricing';
28
+ paywallStepId: string;
29
+ control: {
30
+ variantKey?: string;
31
+ offerSetKey: string;
32
+ label?: string;
33
+ trafficPercent: number;
34
+ };
35
+ variant: {
36
+ variantKey?: string;
37
+ offerSetKey: string;
38
+ label?: string;
39
+ trafficPercent: number;
40
+ };
41
+ };
42
+ export type FunnelExperimentDefinition = FunnelRouteExperimentDefinition | FunnelPricingExperimentDefinition;
43
+ export type PaywallExperimentDefinition = FunnelRouteExperimentDefinition & {
20
44
  type: 'paywall';
21
45
  };
22
46
  export declare const defineFunnelExperiments: <const T extends readonly FunnelExperimentDefinition[]>(experiments: T) => T;
23
47
  export declare const toManifestExperiments: (experiments: readonly FunnelExperimentDefinition[]) => FunnelManifestExperiment[];
48
+ export {};
@@ -11,9 +11,15 @@ export const toManifestExperiments = (experiments) => experiments
11
11
  .filter((experiment) => { var _a; return ((_a = experiment.status) !== null && _a !== void 0 ? _a : 'running') === 'running'; })
12
12
  .map((experiment) => ({
13
13
  experimentId: experiment.id,
14
- stepId: experiment.control.stepId,
14
+ stepId: experiment.type === 'pricing'
15
+ ? experiment.paywallStepId
16
+ : experiment.stepId || experiment.control.stepId,
15
17
  variants: [
16
- Object.assign(Object.assign({ variantKey: 'control' }, (experiment.control.label ? { label: experiment.control.label } : {})), { trafficPercent: experiment.control.trafficPercent, routeToStepId: experiment.control.stepId }),
17
- Object.assign(Object.assign({ variantKey: 'variant_b' }, (experiment.variant.label ? { label: experiment.variant.label } : {})), { trafficPercent: experiment.variant.trafficPercent, routeToStepId: experiment.variant.stepId }),
18
+ Object.assign(Object.assign({ variantKey: experiment.control.variantKey || 'control' }, (experiment.control.label ? { label: experiment.control.label } : {})), { trafficPercent: experiment.control.trafficPercent, routeToStepId: experiment.type === 'pricing'
19
+ ? experiment.paywallStepId
20
+ : experiment.control.stepId }),
21
+ Object.assign(Object.assign({ variantKey: experiment.variant.variantKey || 'variant_b' }, (experiment.variant.label ? { label: experiment.variant.label } : {})), { trafficPercent: experiment.variant.trafficPercent, routeToStepId: experiment.type === 'pricing'
22
+ ? experiment.paywallStepId
23
+ : experiment.variant.stepId }),
18
24
  ],
19
25
  }));
@@ -1,5 +1,29 @@
1
1
  import type { FunnelStepKind, FunnelStepType } from '../steps/types.js';
2
2
  export type TemplateArchitectureVersion = number;
3
+ export type FunnelBreakpointName = 'small' | 'medium' | 'large' | 'desktop-small';
4
+ export type FunnelManifestBreakpoint = {
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export type FunnelManifestBreakpoints = Record<FunnelBreakpointName, FunnelManifestBreakpoint>;
9
+ export declare const DEFAULT_FUNNEL_BREAKPOINTS: {
10
+ readonly small: {
11
+ readonly width: 375;
12
+ readonly height: 667;
13
+ };
14
+ readonly medium: {
15
+ readonly width: 393;
16
+ readonly height: 852;
17
+ };
18
+ readonly large: {
19
+ readonly width: 402;
20
+ readonly height: 874;
21
+ };
22
+ readonly 'desktop-small': {
23
+ readonly width: 1280;
24
+ readonly height: 800;
25
+ };
26
+ };
3
27
  export type FunnelManifestStep = {
4
28
  id: string;
5
29
  path: string;
@@ -59,6 +83,7 @@ export type FunnelManifest = {
59
83
  width: number;
60
84
  height: number;
61
85
  };
86
+ breakpoints?: FunnelManifestBreakpoints;
62
87
  assets: Record<string, FunnelManifestAsset>;
63
88
  steps: readonly FunnelManifestStep[];
64
89
  entryPoints?: readonly FunnelManifestEntryPoint[];
@@ -1 +1,6 @@
1
- export {};
1
+ export const DEFAULT_FUNNEL_BREAKPOINTS = {
2
+ small: { width: 375, height: 667 },
3
+ medium: { width: 393, height: 852 },
4
+ large: { width: 402, height: 874 },
5
+ 'desktop-small': { width: 1280, height: 800 },
6
+ };
@@ -44,14 +44,15 @@ export const bootstrapPostHog = (config) => {
44
44
  bootstrap: { distinctID: config.distinctId },
45
45
  loaded: () => {
46
46
  const scopeProperties = buildFlagScopeProperties(config);
47
- if (Object.keys(scopeProperties).length > 0) {
48
- posthog.setPersonPropertiesForFlags(scopeProperties, false);
49
- }
50
47
  let unsubscribe = null;
51
48
  unsubscribe = posthog.onFeatureFlags(() => {
52
49
  unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
53
50
  markReady();
54
51
  });
52
+ if (Object.keys(scopeProperties).length > 0) {
53
+ posthog.setPersonPropertiesForFlags(scopeProperties, true);
54
+ return;
55
+ }
55
56
  posthog.reloadFeatureFlags();
56
57
  },
57
58
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",