@lssm/lib.analytics 0.4.1 → 1.41.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lssm/lib.analytics",
3
- "version": "0.4.1",
3
+ "version": "1.41.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -11,6 +11,7 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
14
+ "publish:pkg:canary": "bun publish:pkg --tag canary",
14
15
  "build": "bun build:bundle && bun build:types",
15
16
  "build:bundle": "tsdown",
16
17
  "build:types": "tsc --noEmit",
@@ -22,32 +23,48 @@
22
23
  "test": "bun run"
23
24
  },
24
25
  "dependencies": {
25
- "@lssm/lib.lifecycle": "0.3.1",
26
+ "@lssm/lib.lifecycle": "1.41.1",
26
27
  "dayjs": "^1.11.13"
27
28
  },
28
29
  "devDependencies": {
29
- "@lssm/tool.tsdown": "0.12.1",
30
- "@lssm/tool.typescript": "0.11.1",
31
- "tsdown": "^0.16.6",
30
+ "@lssm/tool.tsdown": "1.41.1",
31
+ "@lssm/tool.typescript": "1.41.1",
32
+ "tsdown": "^0.17.4",
32
33
  "typescript": "^5.9.3"
33
34
  },
34
35
  "exports": {
35
- ".": "./dist/index.js",
36
- "./churn": "./dist/churn/index.js",
37
- "./churn/predictor": "./dist/churn/predictor.js",
38
- "./cohort": "./dist/cohort/index.js",
39
- "./cohort/tracker": "./dist/cohort/tracker.js",
40
- "./funnel": "./dist/funnel/index.js",
41
- "./funnel/analyzer": "./dist/funnel/analyzer.js",
42
- "./growth": "./dist/growth/index.js",
43
- "./growth/hypothesis-generator": "./dist/growth/hypothesis-generator.js",
44
- "./lifecycle": "./dist/lifecycle/index.js",
45
- "./lifecycle/metric-collectors": "./dist/lifecycle/metric-collectors.js",
46
- "./lifecycle/posthog-bridge": "./dist/lifecycle/posthog-bridge.js",
47
- "./types": "./dist/types.js",
36
+ ".": "./src/index.ts",
37
+ "./churn": "./src/churn/index.ts",
38
+ "./churn/predictor": "./src/churn/predictor.ts",
39
+ "./cohort": "./src/cohort/index.ts",
40
+ "./cohort/tracker": "./src/cohort/tracker.ts",
41
+ "./funnel": "./src/funnel/index.ts",
42
+ "./funnel/analyzer": "./src/funnel/analyzer.ts",
43
+ "./growth": "./src/growth/index.ts",
44
+ "./growth/hypothesis-generator": "./src/growth/hypothesis-generator.ts",
45
+ "./lifecycle": "./src/lifecycle/index.ts",
46
+ "./lifecycle/metric-collectors": "./src/lifecycle/metric-collectors.ts",
47
+ "./lifecycle/posthog-bridge": "./src/lifecycle/posthog-bridge.ts",
48
+ "./types": "./src/types.ts",
48
49
  "./*": "./*"
49
50
  },
50
51
  "publishConfig": {
51
- "access": "public"
52
+ "access": "public",
53
+ "exports": {
54
+ ".": "./dist/index.js",
55
+ "./churn": "./dist/churn/index.js",
56
+ "./churn/predictor": "./dist/churn/predictor.js",
57
+ "./cohort": "./dist/cohort/index.js",
58
+ "./cohort/tracker": "./dist/cohort/tracker.js",
59
+ "./funnel": "./dist/funnel/index.js",
60
+ "./funnel/analyzer": "./dist/funnel/analyzer.js",
61
+ "./growth": "./dist/growth/index.js",
62
+ "./growth/hypothesis-generator": "./dist/growth/hypothesis-generator.js",
63
+ "./lifecycle": "./dist/lifecycle/index.js",
64
+ "./lifecycle/metric-collectors": "./dist/lifecycle/metric-collectors.js",
65
+ "./lifecycle/posthog-bridge": "./dist/lifecycle/posthog-bridge.js",
66
+ "./types": "./dist/types.js",
67
+ "./*": "./*"
68
+ }
52
69
  }
53
70
  }
@@ -1,2 +0,0 @@
1
- import { ChurnPredictor, ChurnPredictorOptions } from "./predictor.js";
2
- export { ChurnPredictor, ChurnPredictorOptions };
@@ -1,21 +0,0 @@
1
- import { AnalyticsEvent, ChurnSignal } from "../types.js";
2
-
3
- //#region src/churn/predictor.d.ts
4
- interface ChurnPredictorOptions {
5
- recencyWeight?: number;
6
- frequencyWeight?: number;
7
- errorWeight?: number;
8
- decayDays?: number;
9
- }
10
- declare class ChurnPredictor {
11
- private readonly recencyWeight;
12
- private readonly frequencyWeight;
13
- private readonly errorWeight;
14
- private readonly decayDays;
15
- constructor(options?: ChurnPredictorOptions);
16
- score(events: AnalyticsEvent[]): ChurnSignal[];
17
- private computeScore;
18
- private drivers;
19
- }
20
- //#endregion
21
- export { ChurnPredictor, ChurnPredictorOptions };
@@ -1,2 +0,0 @@
1
- import { CohortTracker } from "./tracker.js";
2
- export { CohortTracker };
@@ -1,8 +0,0 @@
1
- import { AnalyticsEvent, CohortAnalysis, CohortDefinition } from "../types.js";
2
-
3
- //#region src/cohort/tracker.d.ts
4
- declare class CohortTracker {
5
- analyze(events: AnalyticsEvent[], definition: CohortDefinition): CohortAnalysis;
6
- }
7
- //#endregion
8
- export { CohortTracker };
@@ -1,9 +0,0 @@
1
- import { AnalyticsEvent, FunnelAnalysis, FunnelDefinition } from "../types.js";
2
-
3
- //#region src/funnel/analyzer.d.ts
4
- declare class FunnelAnalyzer {
5
- analyze(events: AnalyticsEvent[], definition: FunnelDefinition): FunnelAnalysis;
6
- private evaluateUser;
7
- }
8
- //#endregion
9
- export { FunnelAnalyzer };
@@ -1,2 +0,0 @@
1
- import { FunnelAnalyzer } from "./analyzer.js";
2
- export { FunnelAnalyzer };
@@ -1,17 +0,0 @@
1
- import { GrowthHypothesis, GrowthMetric } from "../types.js";
2
-
3
- //#region src/growth/hypothesis-generator.d.ts
4
- interface HypothesisGeneratorOptions {
5
- minDelta?: number;
6
- }
7
- declare class GrowthHypothesisGenerator {
8
- private readonly minDelta;
9
- constructor(options?: HypothesisGeneratorOptions);
10
- generate(metrics: GrowthMetric[]): GrowthHypothesis[];
11
- private fromMetric;
12
- private delta;
13
- private impact;
14
- private statement;
15
- }
16
- //#endregion
17
- export { GrowthHypothesisGenerator, HypothesisGeneratorOptions };
@@ -1,2 +0,0 @@
1
- import { GrowthHypothesisGenerator, HypothesisGeneratorOptions } from "./hypothesis-generator.js";
2
- export { GrowthHypothesisGenerator, HypothesisGeneratorOptions };
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { AnalyticsEvent, ChurnSignal, CohortAnalysis, CohortDefinition, CohortEvent, CohortStats, FunnelAnalysis, FunnelDefinition, FunnelStep, FunnelStepResult, GrowthHypothesis, GrowthMetric } from "./types.js";
2
- import { ChurnPredictor, ChurnPredictorOptions } from "./churn/predictor.js";
3
- import { CohortTracker } from "./cohort/tracker.js";
4
- import { FunnelAnalyzer } from "./funnel/analyzer.js";
5
- import { GrowthHypothesisGenerator, HypothesisGeneratorOptions } from "./growth/hypothesis-generator.js";
6
- import { LifecycleMetricSource, LifecycleStageChangePayload, collectLifecycleMetrics, createStageChangeEvent, lifecycleEventNames, metricsToSignals } from "./lifecycle/metric-collectors.js";
7
- import { PostHogLikeClient, trackLifecycleAssessment, trackLifecycleStageChange } from "./lifecycle/posthog-bridge.js";
8
- export { AnalyticsEvent, ChurnPredictor, ChurnPredictorOptions, ChurnSignal, CohortAnalysis, CohortDefinition, CohortEvent, CohortStats, CohortTracker, FunnelAnalysis, FunnelAnalyzer, FunnelDefinition, FunnelStep, FunnelStepResult, GrowthHypothesis, GrowthHypothesisGenerator, GrowthMetric, HypothesisGeneratorOptions, LifecycleMetricSource, LifecycleStageChangePayload, PostHogLikeClient, collectLifecycleMetrics, createStageChangeEvent, lifecycleEventNames, metricsToSignals, trackLifecycleAssessment, trackLifecycleStageChange };
@@ -1,3 +0,0 @@
1
- import { LifecycleMetricSource, LifecycleStageChangePayload, collectLifecycleMetrics, createStageChangeEvent, lifecycleEventNames, metricsToSignals } from "./metric-collectors.js";
2
- import { PostHogLikeClient, trackLifecycleAssessment, trackLifecycleStageChange } from "./posthog-bridge.js";
3
- export { LifecycleMetricSource, LifecycleStageChangePayload, PostHogLikeClient, collectLifecycleMetrics, createStageChangeEvent, lifecycleEventNames, metricsToSignals, trackLifecycleAssessment, trackLifecycleStageChange };
@@ -1,29 +0,0 @@
1
- import { AnalyticsEvent } from "../types.js";
2
- import { LifecycleMetricSnapshot, LifecycleSignal, LifecycleStage } from "@lssm/lib.lifecycle";
3
-
4
- //#region src/lifecycle/metric-collectors.d.ts
5
- interface LifecycleMetricSource {
6
- getActiveUsers(): Promise<number | undefined>;
7
- getWeeklyActiveUsers?(): Promise<number | undefined>;
8
- getRetentionRate?(): Promise<number | undefined>;
9
- getMonthlyRecurringRevenue?(): Promise<number | undefined>;
10
- getCustomerCount?(): Promise<number | undefined>;
11
- getTeamSize?(): Promise<number | undefined>;
12
- getBurnMultiple?(): Promise<number | undefined>;
13
- }
14
- declare const collectLifecycleMetrics: (source: LifecycleMetricSource) => Promise<LifecycleMetricSnapshot>;
15
- declare const metricsToSignals: (metrics: LifecycleMetricSnapshot, tenantId?: string) => LifecycleSignal[];
16
- declare const lifecycleEventNames: {
17
- readonly assessmentRun: "lifecycle_assessment_run";
18
- readonly stageChanged: "lifecycle_stage_changed";
19
- readonly guidanceConsumed: "lifecycle_guidance_consumed";
20
- };
21
- interface LifecycleStageChangePayload {
22
- tenantId?: string;
23
- previousStage?: LifecycleStage;
24
- nextStage: LifecycleStage;
25
- confidence: number;
26
- }
27
- declare const createStageChangeEvent: (payload: LifecycleStageChangePayload) => AnalyticsEvent;
28
- //#endregion
29
- export { LifecycleMetricSource, LifecycleStageChangePayload, collectLifecycleMetrics, createStageChangeEvent, lifecycleEventNames, metricsToSignals };
@@ -1,14 +0,0 @@
1
- import { LifecycleAssessment } from "@lssm/lib.lifecycle";
2
-
3
- //#region src/lifecycle/posthog-bridge.d.ts
4
- interface PostHogLikeClient {
5
- capture: (event: {
6
- distinctId: string;
7
- event: string;
8
- properties?: Record<string, unknown>;
9
- }) => Promise<void> | void;
10
- }
11
- declare const trackLifecycleAssessment: (client: PostHogLikeClient, tenantId: string, assessment: LifecycleAssessment) => Promise<void>;
12
- declare const trackLifecycleStageChange: (client: PostHogLikeClient, tenantId: string, previousStage: number | undefined, nextStage: number) => Promise<void>;
13
- //#endregion
14
- export { PostHogLikeClient, trackLifecycleAssessment, trackLifecycleStageChange };
package/dist/types.d.ts DELETED
@@ -1,67 +0,0 @@
1
- //#region src/types.d.ts
2
- interface AnalyticsEvent {
3
- name: string;
4
- userId: string;
5
- tenantId?: string;
6
- timestamp: string | Date;
7
- properties?: Record<string, unknown>;
8
- }
9
- interface FunnelStep {
10
- id: string;
11
- eventName: string;
12
- match?: (event: AnalyticsEvent) => boolean;
13
- }
14
- interface FunnelDefinition {
15
- name: string;
16
- steps: FunnelStep[];
17
- windowHours?: number;
18
- }
19
- interface FunnelStepResult {
20
- step: FunnelStep;
21
- count: number;
22
- conversionRate: number;
23
- dropOffRate: number;
24
- }
25
- interface FunnelAnalysis {
26
- definition: FunnelDefinition;
27
- totalUsers: number;
28
- steps: FunnelStepResult[];
29
- }
30
- interface CohortEvent extends AnalyticsEvent {
31
- amount?: number;
32
- }
33
- interface CohortDefinition {
34
- bucket: 'day' | 'week' | 'month';
35
- periods: number;
36
- startDate?: Date;
37
- }
38
- interface CohortStats {
39
- cohortKey: string;
40
- users: number;
41
- retention: number[];
42
- ltv: number;
43
- }
44
- interface CohortAnalysis {
45
- definition: CohortDefinition;
46
- cohorts: CohortStats[];
47
- }
48
- interface ChurnSignal {
49
- userId: string;
50
- score: number;
51
- bucket: 'low' | 'medium' | 'high';
52
- drivers: string[];
53
- }
54
- interface GrowthMetric {
55
- name: string;
56
- current: number;
57
- previous?: number;
58
- target?: number;
59
- }
60
- interface GrowthHypothesis {
61
- statement: string;
62
- metric: string;
63
- confidence: 'low' | 'medium' | 'high';
64
- impact: 'low' | 'medium' | 'high';
65
- }
66
- //#endregion
67
- export { AnalyticsEvent, ChurnSignal, CohortAnalysis, CohortDefinition, CohortEvent, CohortStats, FunnelAnalysis, FunnelDefinition, FunnelStep, FunnelStepResult, GrowthHypothesis, GrowthMetric };