@prosdevlab/experience-sdk-plugins 0.1.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/package.json +34 -0
- package/src/banner/banner.test.ts +728 -0
- package/src/banner/banner.ts +369 -0
- package/src/banner/index.ts +6 -0
- package/src/debug/debug.test.ts +230 -0
- package/src/debug/debug.ts +106 -0
- package/src/debug/index.ts +6 -0
- package/src/frequency/frequency.test.ts +361 -0
- package/src/frequency/frequency.ts +247 -0
- package/src/frequency/index.ts +6 -0
- package/src/index.ts +22 -0
- package/src/types.ts +92 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +14 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for Experience SDK plugins
|
|
3
|
+
* These types are re-exported by core for user convenience
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Experience content - varies by type
|
|
8
|
+
*/
|
|
9
|
+
export type ExperienceContent = BannerContent | ModalContent | TooltipContent;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Banner content configuration
|
|
13
|
+
*/
|
|
14
|
+
export interface BannerContent {
|
|
15
|
+
title?: string;
|
|
16
|
+
message: string;
|
|
17
|
+
buttons?: Array<{
|
|
18
|
+
text: string;
|
|
19
|
+
action?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
variant?: 'primary' | 'secondary' | 'link';
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}>;
|
|
24
|
+
dismissable?: boolean;
|
|
25
|
+
position?: 'top' | 'bottom';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Modal content configuration
|
|
30
|
+
*/
|
|
31
|
+
export interface ModalContent {
|
|
32
|
+
title: string;
|
|
33
|
+
message: string;
|
|
34
|
+
confirmText?: string;
|
|
35
|
+
cancelText?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Tooltip content configuration
|
|
40
|
+
*/
|
|
41
|
+
export interface TooltipContent {
|
|
42
|
+
message: string;
|
|
43
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Experience definition
|
|
48
|
+
*/
|
|
49
|
+
export interface Experience {
|
|
50
|
+
id: string;
|
|
51
|
+
type: 'banner' | 'modal' | 'tooltip';
|
|
52
|
+
targeting: Record<string, any>;
|
|
53
|
+
content: ExperienceContent;
|
|
54
|
+
frequency?: {
|
|
55
|
+
max: number;
|
|
56
|
+
per: 'session' | 'day' | 'week';
|
|
57
|
+
};
|
|
58
|
+
priority?: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Decision output from evaluation
|
|
63
|
+
*/
|
|
64
|
+
export interface Decision {
|
|
65
|
+
show: boolean;
|
|
66
|
+
experienceId?: string;
|
|
67
|
+
reasons: string[];
|
|
68
|
+
trace: TraceStep[];
|
|
69
|
+
context: Record<string, any>;
|
|
70
|
+
metadata: DecisionMetadata;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Trace step for decision path
|
|
75
|
+
*/
|
|
76
|
+
export interface TraceStep {
|
|
77
|
+
step: string;
|
|
78
|
+
timestamp: number;
|
|
79
|
+
duration: number;
|
|
80
|
+
input?: any;
|
|
81
|
+
output?: any;
|
|
82
|
+
passed: boolean;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Decision metadata
|
|
87
|
+
*/
|
|
88
|
+
export interface DecisionMetadata {
|
|
89
|
+
evaluatedAt: number;
|
|
90
|
+
experienceCount: number;
|
|
91
|
+
evaluationTimeMs: number;
|
|
92
|
+
}
|
package/tsconfig.json
ADDED
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
format: ['esm'],
|
|
6
|
+
dts: true,
|
|
7
|
+
splitting: false,
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
clean: true,
|
|
10
|
+
treeshake: true,
|
|
11
|
+
minify: false,
|
|
12
|
+
outDir: 'dist',
|
|
13
|
+
skipNodeModulesBundle: true,
|
|
14
|
+
});
|