@contractspec/lib.analytics 1.57.0 → 1.58.0
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/browser/churn/index.js +77 -0
- package/dist/browser/churn/predictor.js +77 -0
- package/dist/browser/cohort/index.js +117 -0
- package/dist/browser/cohort/tracker.js +117 -0
- package/dist/browser/funnel/analyzer.js +68 -0
- package/dist/browser/funnel/index.js +68 -0
- package/dist/browser/growth/hypothesis-generator.js +46 -0
- package/dist/browser/growth/index.js +46 -0
- package/dist/browser/index.js +723 -0
- package/dist/browser/lifecycle/index.js +287 -0
- package/dist/browser/lifecycle/metric-collectors.js +58 -0
- package/dist/browser/lifecycle/posthog-bridge.js +79 -0
- package/dist/browser/lifecycle/posthog-metric-source.js +205 -0
- package/dist/browser/posthog/event-source.js +138 -0
- package/dist/browser/posthog/index.js +138 -0
- package/dist/browser/types.js +0 -0
- package/dist/churn/index.d.ts +2 -2
- package/dist/churn/index.d.ts.map +1 -0
- package/dist/churn/index.js +77 -2
- package/dist/churn/predictor.d.ts +15 -19
- package/dist/churn/predictor.d.ts.map +1 -1
- package/dist/churn/predictor.js +72 -68
- package/dist/cohort/index.d.ts +2 -2
- package/dist/cohort/index.d.ts.map +1 -0
- package/dist/cohort/index.js +117 -2
- package/dist/cohort/tracker.d.ts +3 -7
- package/dist/cohort/tracker.d.ts.map +1 -1
- package/dist/cohort/tracker.js +106 -87
- package/dist/funnel/analyzer.d.ts +4 -8
- package/dist/funnel/analyzer.d.ts.map +1 -1
- package/dist/funnel/analyzer.js +67 -62
- package/dist/funnel/index.d.ts +2 -2
- package/dist/funnel/index.d.ts.map +1 -0
- package/dist/funnel/index.js +69 -3
- package/dist/growth/hypothesis-generator.d.ts +11 -15
- package/dist/growth/hypothesis-generator.d.ts.map +1 -1
- package/dist/growth/hypothesis-generator.js +46 -39
- package/dist/growth/index.d.ts +2 -2
- package/dist/growth/index.d.ts.map +1 -0
- package/dist/growth/index.js +47 -3
- package/dist/index.d.ts +8 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +724 -12
- package/dist/lifecycle/index.d.ts +4 -4
- package/dist/lifecycle/index.d.ts.map +1 -0
- package/dist/lifecycle/index.js +287 -4
- package/dist/lifecycle/metric-collectors.d.ts +22 -26
- package/dist/lifecycle/metric-collectors.d.ts.map +1 -1
- package/dist/lifecycle/metric-collectors.js +55 -44
- package/dist/lifecycle/posthog-bridge.d.ts +9 -13
- package/dist/lifecycle/posthog-bridge.d.ts.map +1 -1
- package/dist/lifecycle/posthog-bridge.js +77 -25
- package/dist/lifecycle/posthog-metric-source.d.ts +40 -44
- package/dist/lifecycle/posthog-metric-source.d.ts.map +1 -1
- package/dist/lifecycle/posthog-metric-source.js +200 -180
- package/dist/node/churn/index.js +77 -0
- package/dist/node/churn/predictor.js +77 -0
- package/dist/node/cohort/index.js +117 -0
- package/dist/node/cohort/tracker.js +117 -0
- package/dist/node/funnel/analyzer.js +68 -0
- package/dist/node/funnel/index.js +68 -0
- package/dist/node/growth/hypothesis-generator.js +46 -0
- package/dist/node/growth/index.js +46 -0
- package/dist/node/index.js +723 -0
- package/dist/node/lifecycle/index.js +287 -0
- package/dist/node/lifecycle/metric-collectors.js +58 -0
- package/dist/node/lifecycle/posthog-bridge.js +79 -0
- package/dist/node/lifecycle/posthog-metric-source.js +205 -0
- package/dist/node/posthog/event-source.js +138 -0
- package/dist/node/posthog/index.js +138 -0
- package/dist/node/types.js +0 -0
- package/dist/posthog/event-source.d.ts +18 -22
- package/dist/posthog/event-source.d.ts.map +1 -1
- package/dist/posthog/event-source.js +131 -111
- package/dist/posthog/index.d.ts +2 -2
- package/dist/posthog/index.d.ts.map +1 -0
- package/dist/posthog/index.js +139 -3
- package/dist/types.d.ts +52 -55
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/package.json +189 -46
- package/dist/churn/predictor.js.map +0 -1
- package/dist/cohort/tracker.js.map +0 -1
- package/dist/funnel/analyzer.js.map +0 -1
- package/dist/growth/hypothesis-generator.js.map +0 -1
- package/dist/lifecycle/metric-collectors.js.map +0 -1
- package/dist/lifecycle/posthog-bridge.js.map +0 -1
- package/dist/lifecycle/posthog-metric-source.js.map +0 -1
- package/dist/posthog/event-source.js.map +0 -1
|
@@ -1,40 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/growth/hypothesis-generator.ts
|
|
3
|
+
class GrowthHypothesisGenerator {
|
|
4
|
+
minDelta;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.minDelta = options?.minDelta ?? 0.05;
|
|
7
|
+
}
|
|
8
|
+
generate(metrics) {
|
|
9
|
+
return metrics.map((metric) => this.fromMetric(metric)).filter((hypothesis) => Boolean(hypothesis));
|
|
10
|
+
}
|
|
11
|
+
fromMetric(metric) {
|
|
12
|
+
const change = this.delta(metric);
|
|
13
|
+
if (Math.abs(change) < this.minDelta)
|
|
14
|
+
return null;
|
|
15
|
+
const direction = change > 0 ? "rising" : "declining";
|
|
16
|
+
const statement = this.statement(metric, change, direction);
|
|
17
|
+
return {
|
|
18
|
+
statement,
|
|
19
|
+
metric: metric.name,
|
|
20
|
+
confidence: Math.abs(change) > 0.2 ? "high" : "medium",
|
|
21
|
+
impact: this.impact(metric)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
delta(metric) {
|
|
25
|
+
if (metric.previous == null)
|
|
26
|
+
return 0;
|
|
27
|
+
const prev = metric.previous || 1;
|
|
28
|
+
return (metric.current - prev) / Math.abs(prev);
|
|
29
|
+
}
|
|
30
|
+
impact(metric) {
|
|
31
|
+
if (metric.target && metric.current < metric.target * 0.8)
|
|
32
|
+
return "high";
|
|
33
|
+
if (metric.target && metric.current < metric.target)
|
|
34
|
+
return "medium";
|
|
35
|
+
return "low";
|
|
36
|
+
}
|
|
37
|
+
statement(metric, change, direction) {
|
|
38
|
+
const percent = Math.abs(parseFloat((change * 100).toFixed(1)));
|
|
39
|
+
if (direction === "declining") {
|
|
40
|
+
return `${metric.name} is down ${percent}% vs last period; test new onboarding prompts to recover activation.`;
|
|
41
|
+
}
|
|
42
|
+
return `${metric.name} grew ${percent}% period-over-period; double down with expanded experiment or pricing test.`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
GrowthHypothesisGenerator
|
|
36
47
|
};
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { GrowthHypothesisGenerator };
|
|
40
|
-
//# sourceMappingURL=hypothesis-generator.js.map
|
package/dist/growth/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export * from './hypothesis-generator';
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/growth/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
|
package/dist/growth/index.js
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/growth/hypothesis-generator.ts
|
|
3
|
+
class GrowthHypothesisGenerator {
|
|
4
|
+
minDelta;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.minDelta = options?.minDelta ?? 0.05;
|
|
7
|
+
}
|
|
8
|
+
generate(metrics) {
|
|
9
|
+
return metrics.map((metric) => this.fromMetric(metric)).filter((hypothesis) => Boolean(hypothesis));
|
|
10
|
+
}
|
|
11
|
+
fromMetric(metric) {
|
|
12
|
+
const change = this.delta(metric);
|
|
13
|
+
if (Math.abs(change) < this.minDelta)
|
|
14
|
+
return null;
|
|
15
|
+
const direction = change > 0 ? "rising" : "declining";
|
|
16
|
+
const statement = this.statement(metric, change, direction);
|
|
17
|
+
return {
|
|
18
|
+
statement,
|
|
19
|
+
metric: metric.name,
|
|
20
|
+
confidence: Math.abs(change) > 0.2 ? "high" : "medium",
|
|
21
|
+
impact: this.impact(metric)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
delta(metric) {
|
|
25
|
+
if (metric.previous == null)
|
|
26
|
+
return 0;
|
|
27
|
+
const prev = metric.previous || 1;
|
|
28
|
+
return (metric.current - prev) / Math.abs(prev);
|
|
29
|
+
}
|
|
30
|
+
impact(metric) {
|
|
31
|
+
if (metric.target && metric.current < metric.target * 0.8)
|
|
32
|
+
return "high";
|
|
33
|
+
if (metric.target && metric.current < metric.target)
|
|
34
|
+
return "medium";
|
|
35
|
+
return "low";
|
|
36
|
+
}
|
|
37
|
+
statement(metric, change, direction) {
|
|
38
|
+
const percent = Math.abs(parseFloat((change * 100).toFixed(1)));
|
|
39
|
+
if (direction === "declining") {
|
|
40
|
+
return `${metric.name} is down ${percent}% vs last period; test new onboarding prompts to recover activation.`;
|
|
41
|
+
}
|
|
42
|
+
return `${metric.name} grew ${percent}% period-over-period; double down with expanded experiment or pricing test.`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
GrowthHypothesisGenerator
|
|
47
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { PosthogAnalyticsEventSource, PosthogAnalyticsEventSourceOptions } from "./posthog/event-source.js";
|
|
10
|
-
export { AnalyticsEvent, ChurnPredictor, ChurnPredictorOptions, ChurnSignal, CohortAnalysis, CohortDefinition, CohortEvent, CohortStats, CohortTracker, FunnelAnalysis, FunnelAnalyzer, FunnelDefinition, FunnelStep, FunnelStepResult, GrowthHypothesis, GrowthHypothesisGenerator, GrowthMetric, HypothesisGeneratorOptions, LifecycleMetricSource, LifecycleStageChangePayload, PostHogLikeClient, PosthogAnalyticsEventSource, PosthogAnalyticsEventSourceOptions, PosthogLifecycleMetricSource, PosthogLifecycleMetricSourceOptions, collectLifecycleMetrics, createStageChangeEvent, lifecycleEventNames, metricsToSignals, trackLifecycleAssessment, trackLifecycleStageChange };
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './funnel';
|
|
3
|
+
export * from './cohort';
|
|
4
|
+
export * from './churn';
|
|
5
|
+
export * from './growth';
|
|
6
|
+
export * from './lifecycle';
|
|
7
|
+
export * from './posthog';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|