flowgrid-sdk 1.0.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/LICENSE +21 -0
- package/dist/browser.d.ts +119 -0
- package/dist/flowgrid.min.js +2 -0
- package/dist/flowgrid.min.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client/enterprise-ftrpc.d.ts +51 -0
- package/dist/lib/client/ftrpc.d.ts +43 -0
- package/dist/lib/client/modules.d.ts +104 -0
- package/dist/lib/features/analytics/attribution.d.ts +257 -0
- package/dist/lib/features/analytics/events.d.ts +304 -0
- package/dist/lib/features/analytics/funnels.d.ts +291 -0
- package/dist/lib/features/analytics/heatmaps.d.ts +247 -0
- package/dist/lib/features/analytics/identify.d.ts +273 -0
- package/dist/lib/features/analytics/index.d.ts +22 -0
- package/dist/lib/features/analytics/page-views.d.ts +250 -0
- package/dist/lib/features/analytics/performance.d.ts +281 -0
- package/dist/lib/features/analytics/retention.d.ts +294 -0
- package/dist/lib/features/analytics/sessions.d.ts +277 -0
- package/dist/lib/features/core/activation.d.ts +239 -0
- package/dist/lib/features/core/experiment.d.ts +286 -0
- package/dist/lib/features/core/feature-flag.d.ts +264 -0
- package/dist/lib/features/core/index.d.ts +14 -0
- package/dist/lib/features/core/track-feature.d.ts +220 -0
- package/dist/lib/features/core/track-prompt.d.ts +247 -0
- package/dist/lib/features/ecommerce/cart.d.ts +298 -0
- package/dist/lib/features/ecommerce/checkout.d.ts +324 -0
- package/dist/lib/features/ecommerce/index.d.ts +26 -0
- package/dist/lib/features/ecommerce/inventory.d.ts +221 -0
- package/dist/lib/features/ecommerce/ltv.d.ts +258 -0
- package/dist/lib/features/ecommerce/products.d.ts +268 -0
- package/dist/lib/features/ecommerce/promotions.d.ts +266 -0
- package/dist/lib/features/ecommerce/purchases.d.ts +287 -0
- package/dist/lib/features/ecommerce/refunds.d.ts +232 -0
- package/dist/lib/features/ecommerce/search.d.ts +225 -0
- package/dist/lib/features/ecommerce/subscriptions.d.ts +281 -0
- package/dist/lib/features/ecommerce/wishlist.d.ts +236 -0
- package/dist/lib/features/enterprise/acquisition.d.ts +373 -0
- package/dist/lib/features/enterprise/alerts.d.ts +348 -0
- package/dist/lib/features/enterprise/churn.d.ts +288 -0
- package/dist/lib/features/enterprise/cohorts.d.ts +270 -0
- package/dist/lib/features/enterprise/engagement.d.ts +233 -0
- package/dist/lib/features/enterprise/forecasting.d.ts +351 -0
- package/dist/lib/features/enterprise/index.d.ts +20 -0
- package/dist/lib/features/enterprise/monetization.d.ts +356 -0
- package/dist/lib/features/enterprise/multi-path-funnels.d.ts +327 -0
- package/dist/lib/features/enterprise/paths.d.ts +332 -0
- package/dist/lib/features/enterprise/security.d.ts +387 -0
- package/dist/lib/features/enterprise/support.d.ts +329 -0
- package/dist/lib/frameworks/index.d.ts +9 -0
- package/dist/lib/frameworks/nextjs/client.d.ts +208 -0
- package/dist/lib/frameworks/nextjs/index.d.ts +29 -0
- package/dist/lib/frameworks/nextjs/server.d.ts +201 -0
- package/dist/lib/frameworks/node/index.d.ts +265 -0
- package/dist/lib/frameworks/nuxt/index.d.ts +190 -0
- package/dist/lib/frameworks/react/index.d.ts +245 -0
- package/dist/lib/frameworks/vue/index.d.ts +275 -0
- package/dist/lib/types/analytics.d.ts +365 -0
- package/dist/lib/types/common.d.ts +230 -0
- package/dist/lib/types/ecommerce.d.ts +309 -0
- package/dist/lib/types/index.d.ts +7 -0
- package/dist/lib/utils/functions.d.ts +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enterprise SDK Types
|
|
3
|
+
*/
|
|
4
|
+
type EnterpriseType = "engagement" | "cohorts" | "churn" | "monetization" | "multi_path_funnels" | "support" | "acquisition" | "paths" | "alerts" | "security" | "forecasting";
|
|
5
|
+
/**
|
|
6
|
+
* Enterprise SDK Base Class
|
|
7
|
+
* - Flowgrid TypeScript Remote Procedure Call for Enterprise Features
|
|
8
|
+
* - Routes to separate enterprise API endpoints
|
|
9
|
+
* - Requires enterprise-tier API key
|
|
10
|
+
*
|
|
11
|
+
* PRIVACY NOTICE:
|
|
12
|
+
* This SDK collects event data for analytics purposes. Ensure compliance with
|
|
13
|
+
* applicable privacy laws (GDPR, CCPA, etc.) when collecting user data.
|
|
14
|
+
* Do not send personally identifiable information without proper consent.
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* await this.init('eventName', { type: 'engagement', ... });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class EnterpriseFTRPC {
|
|
21
|
+
/**
|
|
22
|
+
* Web ID for the specific site or application.
|
|
23
|
+
* Used to identify the event source.
|
|
24
|
+
*/
|
|
25
|
+
protected webId: string;
|
|
26
|
+
/**
|
|
27
|
+
* API endpoint for sending events.
|
|
28
|
+
* Example: "https://api.flowgrid.com"
|
|
29
|
+
*/
|
|
30
|
+
protected endpoint: string;
|
|
31
|
+
/**
|
|
32
|
+
* Enterprise API Key for authenticating requests.
|
|
33
|
+
*/
|
|
34
|
+
private apiKey;
|
|
35
|
+
constructor(webId: string, endpoint: string, apiKey: string);
|
|
36
|
+
/**
|
|
37
|
+
* Sends an event to the Enterprise API.
|
|
38
|
+
* Used internally by subclasses to track enterprise events.
|
|
39
|
+
*
|
|
40
|
+
* @param eventName - Name of the event to track.
|
|
41
|
+
* @param properties - Additional properties to send with the event (must include type).
|
|
42
|
+
*/
|
|
43
|
+
protected init(eventName: string, properties: Record<string, any> & {
|
|
44
|
+
type: EnterpriseType;
|
|
45
|
+
}): Promise<any>;
|
|
46
|
+
/**
|
|
47
|
+
* Validates input parameters for security and correctness.
|
|
48
|
+
*/
|
|
49
|
+
private validateInput;
|
|
50
|
+
}
|
|
51
|
+
export type { EnterpriseType };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base SDK Class
|
|
3
|
+
* - Flowgrid TypeScript Remote Procedure Call
|
|
4
|
+
* - Handles common logic for sending events to the API.
|
|
5
|
+
*
|
|
6
|
+
* PRIVACY NOTICE:
|
|
7
|
+
* This SDK collects event data for analytics purposes. Ensure compliance with
|
|
8
|
+
* applicable privacy laws (GDPR, CCPA, etc.) when collecting user data.
|
|
9
|
+
* Do not send personally identifiable information without proper consent.
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* await this.init('eventName', { key: 'value' });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare class FTRPC {
|
|
16
|
+
/**
|
|
17
|
+
* Web ID for the specific site or application.
|
|
18
|
+
* Used to identify the event source.
|
|
19
|
+
*/
|
|
20
|
+
protected webId: string;
|
|
21
|
+
/**
|
|
22
|
+
* API endpoint for sending events.
|
|
23
|
+
* Example: "https://api.flowgrid.com"
|
|
24
|
+
*/
|
|
25
|
+
protected endpoint: string;
|
|
26
|
+
/**
|
|
27
|
+
* API Key for authenticating requests.
|
|
28
|
+
*/
|
|
29
|
+
private apiKey;
|
|
30
|
+
constructor(webId: string, endpoint: string, apiKey: string);
|
|
31
|
+
/**
|
|
32
|
+
* Sends an event to the API.
|
|
33
|
+
* Used internally by subclasses to track events.
|
|
34
|
+
*
|
|
35
|
+
* @param eventName - Name of the event to track.
|
|
36
|
+
* @param properties - Additional properties to send with the event.
|
|
37
|
+
*/
|
|
38
|
+
protected init<T>(eventName: string, properties?: Record<string, any>, request?: "GET" | "POST" | "PATCH"): Promise<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Validates input parameters for security and correctness.
|
|
41
|
+
*/
|
|
42
|
+
private validateInput;
|
|
43
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { FTRPC } from "./ftrpc";
|
|
2
|
+
type Config = {
|
|
3
|
+
eventName: string;
|
|
4
|
+
properties: Record<string, any>;
|
|
5
|
+
};
|
|
6
|
+
type ConfigResponse = {
|
|
7
|
+
eventName: string;
|
|
8
|
+
properties: Record<string, any>;
|
|
9
|
+
response: string | number | boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Flowgrid SDK
|
|
13
|
+
* For user activation events (onboarding, signup, etc.)
|
|
14
|
+
*/
|
|
15
|
+
export declare class Activation extends FTRPC {
|
|
16
|
+
/**
|
|
17
|
+
* Creates and tracks an activation event (onboarding, signup, etc.)
|
|
18
|
+
* Adds a "cool" tag to the event for extra flair.
|
|
19
|
+
*
|
|
20
|
+
* @param eventName - The name of the activation event to track.
|
|
21
|
+
* @param properties - Additional properties to send with the event.
|
|
22
|
+
* @returns A promise resolving to the API response.
|
|
23
|
+
*/
|
|
24
|
+
create(config: Config): Promise<ConfigResponse>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* TrackFeature
|
|
28
|
+
* Effortlessly track feature usage events (button clicks, feature access, etc.)
|
|
29
|
+
*/
|
|
30
|
+
export declare class TrackFeature extends FTRPC {
|
|
31
|
+
/**
|
|
32
|
+
* Records a feature usage event with optional custom properties.
|
|
33
|
+
*
|
|
34
|
+
* @param eventName - The name of the feature event to track.
|
|
35
|
+
* @param properties - Additional metadata to include with the event.
|
|
36
|
+
* @returns A promise resolving to the API response.
|
|
37
|
+
*/
|
|
38
|
+
create(config: Config): Promise<ConfigResponse>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Represents a specialized event tracker for prompt-related events.
|
|
42
|
+
*
|
|
43
|
+
* @extends FTRPC
|
|
44
|
+
*/
|
|
45
|
+
export declare class TrackPrompt extends FTRPC {
|
|
46
|
+
/**
|
|
47
|
+
* Creates and initializes a new prompt event with the specified name and properties.
|
|
48
|
+
*
|
|
49
|
+
* @param eventName - The name of the event to track.
|
|
50
|
+
* @param properties - Optional additional properties to associate with the event.
|
|
51
|
+
* These will be merged with default properties such as `type` and `timestamp`.
|
|
52
|
+
* @returns A promise that resolves with the result of the initialization.
|
|
53
|
+
*/
|
|
54
|
+
create(config: Config): Promise<ConfigResponse>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* AB TESTING
|
|
58
|
+
* For tracking A/B test experiment events.
|
|
59
|
+
*/
|
|
60
|
+
export declare class Experiment extends FTRPC {
|
|
61
|
+
/**
|
|
62
|
+
* Tracks an A/B test experiment event.
|
|
63
|
+
*
|
|
64
|
+
* @param experimentName - The name of the experiment.
|
|
65
|
+
* @param variant - The variant assigned to the user.
|
|
66
|
+
* @param properties - Additional properties to send with the event.
|
|
67
|
+
* @returns A promise resolving to the API response.
|
|
68
|
+
*/
|
|
69
|
+
track(config: Config & {
|
|
70
|
+
variant: string;
|
|
71
|
+
}): Promise<ConfigResponse>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Binded Experiment
|
|
75
|
+
* For binding users to specific experiment variants.
|
|
76
|
+
*/
|
|
77
|
+
export declare class BindedExperiment extends FTRPC {
|
|
78
|
+
/**
|
|
79
|
+
* Binds a user to a specific experiment variant.
|
|
80
|
+
*
|
|
81
|
+
* @param experimentName - The name of the experiment.
|
|
82
|
+
* @param variant - The variant to bind the user to.
|
|
83
|
+
* @param properties - Additional properties to send with the binding.
|
|
84
|
+
* @returns A promise resolving to the API response.
|
|
85
|
+
*/
|
|
86
|
+
create(config: Config & {
|
|
87
|
+
variant: string;
|
|
88
|
+
}): Promise<ConfigResponse>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Feature Flags
|
|
92
|
+
* For evaluating feature flags.
|
|
93
|
+
*/
|
|
94
|
+
export declare class FeatureFlag extends FTRPC {
|
|
95
|
+
/**
|
|
96
|
+
* Evaluates a feature flag for a given user.
|
|
97
|
+
*
|
|
98
|
+
* @param flagName - The name of the feature flag to evaluate.
|
|
99
|
+
* @param properties - Additional properties to send with the evaluation.
|
|
100
|
+
* @returns A promise resolving to the API response.
|
|
101
|
+
*/
|
|
102
|
+
evaluate(config: Config): Promise<ConfigResponse>;
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Product Analytics - Revenue Attribution
|
|
3
|
+
* @module features/analytics/attribution
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Multi-touch attribution modeling to understand which marketing
|
|
7
|
+
* channels and touchpoints drive conversions and revenue.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Track marketing touchpoints across customer journey
|
|
11
|
+
* - Calculate attribution for conversions
|
|
12
|
+
* - Compare attribution models (first-touch, last-touch, linear)
|
|
13
|
+
* - Optimize marketing spend allocation
|
|
14
|
+
* - Understand channel effectiveness
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Attributed revenue by channel
|
|
18
|
+
* - Conversion paths
|
|
19
|
+
* - Assisted conversions
|
|
20
|
+
* - Time to conversion
|
|
21
|
+
* - Channel influence score
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Sankey diagram: Customer journey paths
|
|
25
|
+
* - Bar chart: Revenue by channel
|
|
26
|
+
* - Table: Attribution comparison by model
|
|
27
|
+
* - Pie chart: Channel contribution
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const attribution = new Attribution(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Track touchpoint
|
|
34
|
+
* await attribution.trackTouchpoint({
|
|
35
|
+
* userId: 'user_123',
|
|
36
|
+
* channel: 'google_ads',
|
|
37
|
+
* campaign: 'brand_terms',
|
|
38
|
+
* medium: 'cpc'
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // Get attribution report
|
|
42
|
+
* const report = await attribution.getReport({ range: 'last30days' });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
import { FTRPC } from "../../client/ftrpc";
|
|
46
|
+
import { MoneyValue, DateRangeFilter } from "../../types";
|
|
47
|
+
/**
|
|
48
|
+
* Attribution model types.
|
|
49
|
+
*/
|
|
50
|
+
export type AttributionModel = 'first_touch' | 'last_touch' | 'linear' | 'time_decay' | 'position_based' | 'data_driven';
|
|
51
|
+
/**
|
|
52
|
+
* Marketing touchpoint configuration.
|
|
53
|
+
*/
|
|
54
|
+
export interface TouchpointConfig {
|
|
55
|
+
/** User ID */
|
|
56
|
+
userId: string;
|
|
57
|
+
/** Marketing channel */
|
|
58
|
+
channel: string;
|
|
59
|
+
/** Campaign name */
|
|
60
|
+
campaign?: string;
|
|
61
|
+
/** Traffic medium */
|
|
62
|
+
medium?: string;
|
|
63
|
+
/** Traffic source */
|
|
64
|
+
source?: string;
|
|
65
|
+
/** Content/creative */
|
|
66
|
+
content?: string;
|
|
67
|
+
/** Search term */
|
|
68
|
+
term?: string;
|
|
69
|
+
/** Referrer URL */
|
|
70
|
+
referrer?: string;
|
|
71
|
+
/** Landing page */
|
|
72
|
+
landingPage?: string;
|
|
73
|
+
/** Custom properties */
|
|
74
|
+
properties?: Record<string, unknown>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Conversion event for attribution.
|
|
78
|
+
*/
|
|
79
|
+
export interface ConversionEvent {
|
|
80
|
+
/** User ID */
|
|
81
|
+
userId: string;
|
|
82
|
+
/** Conversion type */
|
|
83
|
+
conversionType: 'purchase' | 'signup' | 'lead' | 'custom';
|
|
84
|
+
/** Conversion value */
|
|
85
|
+
value?: MoneyValue;
|
|
86
|
+
/** Conversion identifier (e.g., order ID) */
|
|
87
|
+
conversionId?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Touchpoint response from API.
|
|
91
|
+
*/
|
|
92
|
+
export interface TouchpointResponse {
|
|
93
|
+
eventName: string;
|
|
94
|
+
properties: Record<string, unknown>;
|
|
95
|
+
response: {
|
|
96
|
+
touchpointId: string;
|
|
97
|
+
userId: string;
|
|
98
|
+
position: number;
|
|
99
|
+
tracked: boolean;
|
|
100
|
+
};
|
|
101
|
+
timestamp: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Attribution report data.
|
|
105
|
+
*/
|
|
106
|
+
export interface AttributionReportData {
|
|
107
|
+
/** Selected attribution model */
|
|
108
|
+
model: AttributionModel;
|
|
109
|
+
/** Attribution by channel */
|
|
110
|
+
byChannel: Array<{
|
|
111
|
+
channel: string;
|
|
112
|
+
conversions: number;
|
|
113
|
+
attributedRevenue: MoneyValue;
|
|
114
|
+
assistedConversions: number;
|
|
115
|
+
avgTouchpoints: number;
|
|
116
|
+
firstTouchConversions: number;
|
|
117
|
+
lastTouchConversions: number;
|
|
118
|
+
}>;
|
|
119
|
+
/** Top conversion paths */
|
|
120
|
+
topPaths: Array<{
|
|
121
|
+
path: string[];
|
|
122
|
+
conversions: number;
|
|
123
|
+
revenue: MoneyValue;
|
|
124
|
+
avgTimeToConvert: number;
|
|
125
|
+
}>;
|
|
126
|
+
/** Summary metrics */
|
|
127
|
+
summary: {
|
|
128
|
+
totalConversions: number;
|
|
129
|
+
totalRevenue: MoneyValue;
|
|
130
|
+
avgTouchpointsPerConversion: number;
|
|
131
|
+
avgTimeToConversion: number;
|
|
132
|
+
topChannel: string;
|
|
133
|
+
topCampaign: string;
|
|
134
|
+
};
|
|
135
|
+
/** Model comparison */
|
|
136
|
+
modelComparison: Array<{
|
|
137
|
+
model: AttributionModel;
|
|
138
|
+
channelAttribution: Record<string, number>;
|
|
139
|
+
}>;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Attribution - Multi-touch attribution tracking.
|
|
143
|
+
*
|
|
144
|
+
* @extends FTRPC
|
|
145
|
+
*
|
|
146
|
+
* @description
|
|
147
|
+
* Provides attribution capabilities including:
|
|
148
|
+
* - Touchpoint tracking
|
|
149
|
+
* - Conversion attribution
|
|
150
|
+
* - Multiple attribution models
|
|
151
|
+
* - Path analysis
|
|
152
|
+
* - Channel effectiveness
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const attribution = new Attribution(webId, endpoint, apiKey);
|
|
157
|
+
*
|
|
158
|
+
* // Track touchpoints throughout customer journey
|
|
159
|
+
* await attribution.trackTouchpoint({
|
|
160
|
+
* userId: 'user_123',
|
|
161
|
+
* channel: 'email',
|
|
162
|
+
* campaign: 'welcome_series',
|
|
163
|
+
* medium: 'email'
|
|
164
|
+
* });
|
|
165
|
+
*
|
|
166
|
+
* // Record conversion
|
|
167
|
+
* await attribution.recordConversion({
|
|
168
|
+
* userId: 'user_123',
|
|
169
|
+
* conversionType: 'purchase',
|
|
170
|
+
* value: { amount: 9999, currency: 'USD' },
|
|
171
|
+
* conversionId: 'ORD-12345'
|
|
172
|
+
* });
|
|
173
|
+
*
|
|
174
|
+
* // Get attribution report
|
|
175
|
+
* const report = await attribution.getReport({
|
|
176
|
+
* model: 'linear'
|
|
177
|
+
* });
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
export declare class Attribution extends FTRPC {
|
|
181
|
+
/**
|
|
182
|
+
* Tracks a marketing touchpoint.
|
|
183
|
+
*
|
|
184
|
+
* @param config - Touchpoint configuration
|
|
185
|
+
* @returns Promise resolving to touchpoint response
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* await attribution.trackTouchpoint({
|
|
190
|
+
* userId: 'user_123',
|
|
191
|
+
* channel: 'facebook_ads',
|
|
192
|
+
* campaign: 'retargeting_cart',
|
|
193
|
+
* medium: 'paid_social',
|
|
194
|
+
* landingPage: '/products/special-offer'
|
|
195
|
+
* });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
trackTouchpoint(config: TouchpointConfig): Promise<TouchpointResponse>;
|
|
199
|
+
/**
|
|
200
|
+
* Records a conversion for attribution.
|
|
201
|
+
*
|
|
202
|
+
* @param event - Conversion event
|
|
203
|
+
* @returns Promise resolving to conversion response
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* await attribution.recordConversion({
|
|
208
|
+
* userId: 'user_123',
|
|
209
|
+
* conversionType: 'purchase',
|
|
210
|
+
* value: { amount: 14999, currency: 'USD' },
|
|
211
|
+
* conversionId: 'ORD-98765'
|
|
212
|
+
* });
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
recordConversion(event: ConversionEvent): Promise<TouchpointResponse>;
|
|
216
|
+
/**
|
|
217
|
+
* Gets attribution report with specified model.
|
|
218
|
+
*
|
|
219
|
+
* @param options - Report options
|
|
220
|
+
* @returns Promise resolving to attribution report
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```typescript
|
|
224
|
+
* const report = await attribution.getReport({
|
|
225
|
+
* model: 'position_based',
|
|
226
|
+
* filter: { range: 'last30days' }
|
|
227
|
+
* });
|
|
228
|
+
*
|
|
229
|
+
* // Bar chart - revenue by channel
|
|
230
|
+
* const channelChart = report.byChannel.map(c => ({
|
|
231
|
+
* name: c.channel,
|
|
232
|
+
* value: c.attributedRevenue.amount
|
|
233
|
+
* }));
|
|
234
|
+
*
|
|
235
|
+
* // Sankey - top conversion paths
|
|
236
|
+
* const pathData = report.topPaths;
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
getReport(options?: {
|
|
240
|
+
model?: AttributionModel;
|
|
241
|
+
filter?: DateRangeFilter;
|
|
242
|
+
}): Promise<AttributionReportData>;
|
|
243
|
+
/**
|
|
244
|
+
* Gets user journey/path for a specific user.
|
|
245
|
+
*
|
|
246
|
+
* @param userId - User identifier
|
|
247
|
+
* @returns Promise resolving to user journey data
|
|
248
|
+
*/
|
|
249
|
+
getUserJourney(userId: string): Promise<{
|
|
250
|
+
touchpoints: Array<TouchpointConfig & {
|
|
251
|
+
timestamp: string;
|
|
252
|
+
}>;
|
|
253
|
+
conversions: ConversionEvent[];
|
|
254
|
+
totalValue: MoneyValue;
|
|
255
|
+
}>;
|
|
256
|
+
}
|
|
257
|
+
export default Attribution;
|