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.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/dist/browser.d.ts +119 -0
  3. package/dist/flowgrid.min.js +2 -0
  4. package/dist/flowgrid.min.js.map +1 -0
  5. package/dist/index.d.ts +44 -0
  6. package/dist/index.js +2 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/client/enterprise-ftrpc.d.ts +51 -0
  9. package/dist/lib/client/ftrpc.d.ts +43 -0
  10. package/dist/lib/client/modules.d.ts +104 -0
  11. package/dist/lib/features/analytics/attribution.d.ts +257 -0
  12. package/dist/lib/features/analytics/events.d.ts +304 -0
  13. package/dist/lib/features/analytics/funnels.d.ts +291 -0
  14. package/dist/lib/features/analytics/heatmaps.d.ts +247 -0
  15. package/dist/lib/features/analytics/identify.d.ts +273 -0
  16. package/dist/lib/features/analytics/index.d.ts +22 -0
  17. package/dist/lib/features/analytics/page-views.d.ts +250 -0
  18. package/dist/lib/features/analytics/performance.d.ts +281 -0
  19. package/dist/lib/features/analytics/retention.d.ts +294 -0
  20. package/dist/lib/features/analytics/sessions.d.ts +277 -0
  21. package/dist/lib/features/core/activation.d.ts +239 -0
  22. package/dist/lib/features/core/experiment.d.ts +286 -0
  23. package/dist/lib/features/core/feature-flag.d.ts +264 -0
  24. package/dist/lib/features/core/index.d.ts +14 -0
  25. package/dist/lib/features/core/track-feature.d.ts +220 -0
  26. package/dist/lib/features/core/track-prompt.d.ts +247 -0
  27. package/dist/lib/features/ecommerce/cart.d.ts +298 -0
  28. package/dist/lib/features/ecommerce/checkout.d.ts +324 -0
  29. package/dist/lib/features/ecommerce/index.d.ts +26 -0
  30. package/dist/lib/features/ecommerce/inventory.d.ts +221 -0
  31. package/dist/lib/features/ecommerce/ltv.d.ts +258 -0
  32. package/dist/lib/features/ecommerce/products.d.ts +268 -0
  33. package/dist/lib/features/ecommerce/promotions.d.ts +266 -0
  34. package/dist/lib/features/ecommerce/purchases.d.ts +287 -0
  35. package/dist/lib/features/ecommerce/refunds.d.ts +232 -0
  36. package/dist/lib/features/ecommerce/search.d.ts +225 -0
  37. package/dist/lib/features/ecommerce/subscriptions.d.ts +281 -0
  38. package/dist/lib/features/ecommerce/wishlist.d.ts +236 -0
  39. package/dist/lib/features/enterprise/acquisition.d.ts +373 -0
  40. package/dist/lib/features/enterprise/alerts.d.ts +348 -0
  41. package/dist/lib/features/enterprise/churn.d.ts +288 -0
  42. package/dist/lib/features/enterprise/cohorts.d.ts +270 -0
  43. package/dist/lib/features/enterprise/engagement.d.ts +233 -0
  44. package/dist/lib/features/enterprise/forecasting.d.ts +351 -0
  45. package/dist/lib/features/enterprise/index.d.ts +20 -0
  46. package/dist/lib/features/enterprise/monetization.d.ts +356 -0
  47. package/dist/lib/features/enterprise/multi-path-funnels.d.ts +327 -0
  48. package/dist/lib/features/enterprise/paths.d.ts +332 -0
  49. package/dist/lib/features/enterprise/security.d.ts +387 -0
  50. package/dist/lib/features/enterprise/support.d.ts +329 -0
  51. package/dist/lib/frameworks/index.d.ts +9 -0
  52. package/dist/lib/frameworks/nextjs/client.d.ts +208 -0
  53. package/dist/lib/frameworks/nextjs/index.d.ts +29 -0
  54. package/dist/lib/frameworks/nextjs/server.d.ts +201 -0
  55. package/dist/lib/frameworks/node/index.d.ts +265 -0
  56. package/dist/lib/frameworks/nuxt/index.d.ts +190 -0
  57. package/dist/lib/frameworks/react/index.d.ts +245 -0
  58. package/dist/lib/frameworks/vue/index.d.ts +275 -0
  59. package/dist/lib/types/analytics.d.ts +365 -0
  60. package/dist/lib/types/common.d.ts +230 -0
  61. package/dist/lib/types/ecommerce.d.ts +309 -0
  62. package/dist/lib/types/index.d.ts +7 -0
  63. package/dist/lib/utils/functions.d.ts +1 -0
  64. package/package.json +139 -0
@@ -0,0 +1,245 @@
1
+ /**
2
+ * @fileoverview FlowGrid SDK - React Integration
3
+ * @module frameworks/react
4
+ *
5
+ * @description
6
+ * React hooks and context provider for FlowGrid SDK.
7
+ * All hooks are client-side only (use 'use client' in Next.js App Router).
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * // App.tsx - Wrap your app
12
+ * import { FlowGridProvider } from 'flowgrid-sdk/react';
13
+ *
14
+ * function App() {
15
+ * return (
16
+ * <FlowGridProvider
17
+ * webId="your-web-id"
18
+ * endpoint="https://api.flowgrid.io"
19
+ * apiKey="your-api-key"
20
+ * >
21
+ * <YourApp />
22
+ * </FlowGridProvider>
23
+ * );
24
+ * }
25
+ * ```
26
+ */
27
+ import React, { type ReactNode } from 'react';
28
+ import { Activation, TrackFeature, TrackPrompt, Experiment, FeatureFlag, PageViews, Sessions, Events, Identify, Funnels, Products, CartTracking, Checkout, Purchases } from '../../../index';
29
+ export interface FlowGridConfig {
30
+ webId: string;
31
+ endpoint: string;
32
+ apiKey: string;
33
+ /** Auto-track page views (default: true) */
34
+ autoTrackPageViews?: boolean;
35
+ /** Auto-track sessions (default: true) */
36
+ autoTrackSessions?: boolean;
37
+ /** Enable debug mode (default: false) */
38
+ debug?: boolean;
39
+ }
40
+ export interface FlowGridContextValue {
41
+ activation: Activation;
42
+ trackFeature: TrackFeature;
43
+ trackPrompt: TrackPrompt;
44
+ experiment: Experiment;
45
+ featureFlag: FeatureFlag;
46
+ pageViews: PageViews;
47
+ sessions: Sessions;
48
+ events: Events;
49
+ identify: Identify;
50
+ funnels: Funnels;
51
+ products: Products;
52
+ cart: CartTracking;
53
+ checkout: Checkout;
54
+ purchases: Purchases;
55
+ trackEvent: (name: string, properties?: Record<string, unknown>) => Promise<void>;
56
+ identifyUser: (userId: string, traits?: Record<string, unknown>) => Promise<void>;
57
+ isReady: boolean;
58
+ }
59
+ export interface FlowGridProviderProps extends FlowGridConfig {
60
+ children: ReactNode;
61
+ }
62
+ /**
63
+ * FlowGrid Provider - Wrap your app to enable analytics.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * <FlowGridProvider
68
+ * webId="web_123"
69
+ * endpoint="https://api.flowgrid.io"
70
+ * apiKey="key_abc"
71
+ * autoTrackPageViews={true}
72
+ * >
73
+ * <App />
74
+ * </FlowGridProvider>
75
+ * ```
76
+ */
77
+ export declare function FlowGridProvider({ children, webId, endpoint, apiKey, autoTrackPageViews, autoTrackSessions, debug }: FlowGridProviderProps): import("react/jsx-runtime").JSX.Element;
78
+ /**
79
+ * Access the FlowGrid SDK instance.
80
+ * Must be used within FlowGridProvider.
81
+ *
82
+ * @example
83
+ * ```tsx
84
+ * function MyComponent() {
85
+ * const { trackEvent, events } = useFlowGrid();
86
+ *
87
+ * const handleClick = () => {
88
+ * trackEvent('button_clicked', { buttonId: 'cta' });
89
+ * };
90
+ *
91
+ * return <button onClick={handleClick}>Click me</button>;
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function useFlowGrid(): FlowGridContextValue;
96
+ /**
97
+ * Track page views automatically on route changes.
98
+ * Use in your root layout or App component.
99
+ *
100
+ * @example
101
+ * ```tsx
102
+ * function App() {
103
+ * usePageView(); // Tracks on every route change
104
+ * return <Routes />;
105
+ * }
106
+ * ```
107
+ */
108
+ export declare function usePageView(pageName?: string): void;
109
+ /**
110
+ * Track an event when component mounts.
111
+ *
112
+ * @example
113
+ * ```tsx
114
+ * function PricingPage() {
115
+ * useTrackEvent('pricing_page_viewed', { source: 'navbar' });
116
+ * return <PricingContent />;
117
+ * }
118
+ * ```
119
+ */
120
+ export declare function useTrackEvent(eventName: string, properties?: Record<string, unknown>, deps?: React.DependencyList): void;
121
+ /**
122
+ * Get experiment variant for a user.
123
+ *
124
+ * @example
125
+ * ```tsx
126
+ * function CheckoutPage() {
127
+ * const { variant, isLoading } = useExperiment('checkout_v2', 'user_123');
128
+ *
129
+ * if (isLoading) return <Loading />;
130
+ *
131
+ * return variant === 'treatment'
132
+ * ? <NewCheckout />
133
+ * : <OldCheckout />;
134
+ * }
135
+ * ```
136
+ */
137
+ export declare function useExperiment(experimentId: string, userId: string): {
138
+ variant: string | null;
139
+ isLoading: boolean;
140
+ };
141
+ /**
142
+ * Evaluate a feature flag.
143
+ *
144
+ * @example
145
+ * ```tsx
146
+ * function Dashboard() {
147
+ * const { isEnabled, isLoading } = useFeatureFlag('new_dashboard', {
148
+ * userId: 'user_123'
149
+ * });
150
+ *
151
+ * if (isLoading) return <Loading />;
152
+ *
153
+ * return isEnabled ? <NewDashboard /> : <OldDashboard />;
154
+ * }
155
+ * ```
156
+ */
157
+ export declare function useFeatureFlag(flagKey: string, context?: {
158
+ userId?: string;
159
+ [key: string]: unknown;
160
+ }): {
161
+ isEnabled: boolean;
162
+ isLoading: boolean;
163
+ };
164
+ /**
165
+ * Track user identity.
166
+ *
167
+ * @example
168
+ * ```tsx
169
+ * function ProfilePage({ user }) {
170
+ * useIdentify(user.id, {
171
+ * email: user.email,
172
+ * plan: user.plan
173
+ * });
174
+ *
175
+ * return <Profile />;
176
+ * }
177
+ * ```
178
+ */
179
+ export declare function useIdentify(userId: string, traits?: Record<string, unknown>): void;
180
+ /**
181
+ * Ecommerce tracking hooks.
182
+ *
183
+ * @example
184
+ * ```tsx
185
+ * function ProductPage({ product }) {
186
+ * const { trackProductView, trackAddToCart } = useEcommerce();
187
+ *
188
+ * useEffect(() => {
189
+ * trackProductView(product);
190
+ * }, [product]);
191
+ *
192
+ * const handleAddToCart = () => {
193
+ * trackAddToCart(product, 1);
194
+ * };
195
+ *
196
+ * return <button onClick={handleAddToCart}>Add to Cart</button>;
197
+ * }
198
+ * ```
199
+ */
200
+ export declare function useEcommerce(): {
201
+ trackProductView: (product: {
202
+ id: string;
203
+ name: string;
204
+ price: number;
205
+ currency?: string;
206
+ category?: string;
207
+ }) => Promise<void>;
208
+ trackAddToCart: (product: {
209
+ id: string;
210
+ name: string;
211
+ price: number;
212
+ currency?: string;
213
+ }, quantity?: number) => Promise<void>;
214
+ trackCheckoutStart: (cartItems: Array<{
215
+ productId: string;
216
+ name: string;
217
+ price: number;
218
+ quantity: number;
219
+ }>) => Promise<void>;
220
+ trackPurchase: (orderData: {
221
+ orderId: string;
222
+ revenue: number;
223
+ items: Array<{
224
+ id: string;
225
+ name: string;
226
+ price: number;
227
+ quantity: number;
228
+ }>;
229
+ }) => Promise<void>;
230
+ products: Products;
231
+ cart: CartTracking;
232
+ checkout: Checkout;
233
+ purchases: Purchases;
234
+ };
235
+ declare const _default: {
236
+ FlowGridProvider: typeof FlowGridProvider;
237
+ useFlowGrid: typeof useFlowGrid;
238
+ usePageView: typeof usePageView;
239
+ useTrackEvent: typeof useTrackEvent;
240
+ useExperiment: typeof useExperiment;
241
+ useFeatureFlag: typeof useFeatureFlag;
242
+ useIdentify: typeof useIdentify;
243
+ useEcommerce: typeof useEcommerce;
244
+ };
245
+ export default _default;
@@ -0,0 +1,275 @@
1
+ /**
2
+ * @fileoverview FlowGrid SDK - Vue 3 Integration
3
+ * @module frameworks/vue
4
+ *
5
+ * @description
6
+ * Vue 3 composables and plugin for FlowGrid SDK.
7
+ * Uses Composition API for reactive state management.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * // main.ts
12
+ * import { createApp } from 'vue';
13
+ * import { FlowGridPlugin } from 'flowgrid-sdk/vue';
14
+ *
15
+ * const app = createApp(App);
16
+ * app.use(FlowGridPlugin, {
17
+ * webId: 'your-web-id',
18
+ * endpoint: 'https://api.flowgrid.io',
19
+ * apiKey: 'your-api-key'
20
+ * });
21
+ * app.mount('#app');
22
+ * ```
23
+ */
24
+ import { type App, type Ref } from 'vue';
25
+ import { Activation, TrackFeature, TrackPrompt, Experiment, FeatureFlag, PageViews, Sessions, Events, Identify, Funnels, Products, CartTracking, Checkout, Purchases } from '../../../index';
26
+ export interface FlowGridConfig {
27
+ webId: string;
28
+ endpoint: string;
29
+ apiKey: string;
30
+ autoTrackPageViews?: boolean;
31
+ autoTrackSessions?: boolean;
32
+ debug?: boolean;
33
+ }
34
+ export interface FlowGridInstance {
35
+ activation: Activation;
36
+ trackFeature: TrackFeature;
37
+ trackPrompt: TrackPrompt;
38
+ experiment: Experiment;
39
+ featureFlag: FeatureFlag;
40
+ pageViews: PageViews;
41
+ sessions: Sessions;
42
+ events: Events;
43
+ identify: Identify;
44
+ funnels: Funnels;
45
+ products: Products;
46
+ cart: CartTracking;
47
+ checkout: Checkout;
48
+ purchases: Purchases;
49
+ isReady: Ref<boolean>;
50
+ sessionId: Ref<string | null>;
51
+ }
52
+ /**
53
+ * Vue plugin for FlowGrid SDK.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { createApp } from 'vue';
58
+ * import { FlowGridPlugin } from 'flowgrid-sdk/vue';
59
+ *
60
+ * createApp(App)
61
+ * .use(FlowGridPlugin, {
62
+ * webId: 'web_123',
63
+ * endpoint: 'https://api.flowgrid.io',
64
+ * apiKey: 'key_abc',
65
+ * autoTrackPageViews: true
66
+ * })
67
+ * .mount('#app');
68
+ * ```
69
+ */
70
+ export declare const FlowGridPlugin: {
71
+ install(app: App, options: FlowGridConfig): void;
72
+ };
73
+ /**
74
+ * Access the FlowGrid SDK instance.
75
+ *
76
+ * @example
77
+ * ```vue
78
+ * <script setup>
79
+ * import { useFlowGrid } from 'flowgrid-sdk/vue';
80
+ *
81
+ * const { events, trackEvent } = useFlowGrid();
82
+ *
83
+ * const handleClick = () => {
84
+ * trackEvent('button_clicked', { id: 'cta' });
85
+ * };
86
+ * </script>
87
+ * ```
88
+ */
89
+ export declare function useFlowGrid(): {
90
+ trackEvent: (name: string, properties?: Record<string, unknown>) => Promise<void>;
91
+ identifyUser: (userId: string, traits?: Record<string, unknown>) => Promise<void>;
92
+ activation: Activation;
93
+ trackFeature: TrackFeature;
94
+ trackPrompt: TrackPrompt;
95
+ experiment: Experiment;
96
+ featureFlag: FeatureFlag;
97
+ pageViews: PageViews;
98
+ sessions: Sessions;
99
+ events: Events;
100
+ identify: Identify;
101
+ funnels: Funnels;
102
+ products: Products;
103
+ cart: CartTracking;
104
+ checkout: Checkout;
105
+ purchases: Purchases;
106
+ isReady: Ref<boolean>;
107
+ sessionId: Ref<string | null>;
108
+ };
109
+ /**
110
+ * Track page views with Vue Router integration.
111
+ *
112
+ * @example
113
+ * ```vue
114
+ * <script setup>
115
+ * import { usePageView } from 'flowgrid-sdk/vue';
116
+ * import { useRoute } from 'vue-router';
117
+ *
118
+ * const route = useRoute();
119
+ * usePageView(() => route.path);
120
+ * </script>
121
+ * ```
122
+ */
123
+ export declare function usePageView(pathGetter?: () => string): void;
124
+ /**
125
+ * Track an event on component mount.
126
+ *
127
+ * @example
128
+ * ```vue
129
+ * <script setup>
130
+ * import { useTrackEvent } from 'flowgrid-sdk/vue';
131
+ *
132
+ * useTrackEvent('pricing_page_viewed', { source: 'navbar' });
133
+ * </script>
134
+ * ```
135
+ */
136
+ export declare function useTrackEvent(eventName: string, properties?: Record<string, unknown>): void;
137
+ /**
138
+ * Use an experiment variant.
139
+ *
140
+ * @example
141
+ * ```vue
142
+ * <script setup>
143
+ * import { useExperiment } from 'flowgrid-sdk/vue';
144
+ *
145
+ * const { variant, isLoading } = useExperiment('checkout_v2', 'user_123');
146
+ * </script>
147
+ *
148
+ * <template>
149
+ * <NewCheckout v-if="variant === 'treatment'" />
150
+ * <OldCheckout v-else />
151
+ * </template>
152
+ * ```
153
+ */
154
+ export declare function useExperiment(experimentId: string, userId: string): {
155
+ variant: Ref<string | null, string | null>;
156
+ isLoading: Ref<boolean, boolean>;
157
+ };
158
+ /**
159
+ * Evaluate a feature flag.
160
+ *
161
+ * @example
162
+ * ```vue
163
+ * <script setup>
164
+ * import { useFeatureFlag } from 'flowgrid-sdk/vue';
165
+ *
166
+ * const { isEnabled, isLoading } = useFeatureFlag('new_dashboard');
167
+ * </script>
168
+ *
169
+ * <template>
170
+ * <NewDashboard v-if="isEnabled" />
171
+ * <OldDashboard v-else />
172
+ * </template>
173
+ * ```
174
+ */
175
+ export declare function useFeatureFlag(flagKey: string, userId?: string): {
176
+ isEnabled: Ref<boolean, boolean>;
177
+ isLoading: Ref<boolean, boolean>;
178
+ };
179
+ /**
180
+ * Identify a user.
181
+ *
182
+ * @example
183
+ * ```vue
184
+ * <script setup>
185
+ * import { useIdentify } from 'flowgrid-sdk/vue';
186
+ *
187
+ * const props = defineProps<{ userId: string; email: string }>();
188
+ *
189
+ * useIdentify(() => props.userId, () => ({ email: props.email }));
190
+ * </script>
191
+ * ```
192
+ */
193
+ export declare function useIdentify(userIdGetter: () => string | null, traitsGetter?: () => Record<string, unknown>): void;
194
+ /**
195
+ * Ecommerce composable.
196
+ *
197
+ * @example
198
+ * ```vue
199
+ * <script setup>
200
+ * import { useEcommerce } from 'flowgrid-sdk/vue';
201
+ *
202
+ * const { trackProductView, trackAddToCart } = useEcommerce();
203
+ *
204
+ * onMounted(() => {
205
+ * trackProductView(product);
206
+ * });
207
+ * </script>
208
+ * ```
209
+ */
210
+ export declare function useEcommerce(): {
211
+ trackProductView: (product: {
212
+ id: string;
213
+ name: string;
214
+ price: number;
215
+ currency?: string;
216
+ }) => Promise<void>;
217
+ trackAddToCart: (product: {
218
+ id: string;
219
+ name: string;
220
+ price: number;
221
+ currency?: string;
222
+ }, quantity?: number) => Promise<void>;
223
+ trackCheckoutStart: (cartItems: Array<{
224
+ productId: string;
225
+ name: string;
226
+ price: number;
227
+ quantity: number;
228
+ }>) => Promise<void>;
229
+ trackPurchase: (orderData: {
230
+ orderId: string;
231
+ revenue: number;
232
+ items: Array<{
233
+ id: string;
234
+ name: string;
235
+ price: number;
236
+ quantity: number;
237
+ }>;
238
+ }) => Promise<void>;
239
+ products: Products;
240
+ cart: CartTracking;
241
+ checkout: Checkout;
242
+ purchases: Purchases;
243
+ };
244
+ /**
245
+ * Vue Router plugin for automatic page view tracking.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * import { createRouter } from 'vue-router';
250
+ * import { createRouterPlugin } from 'flowgrid-sdk/vue';
251
+ *
252
+ * const router = createRouter({ ... });
253
+ * router.afterEach(createRouterPlugin());
254
+ * ```
255
+ */
256
+ export declare function createRouterPlugin(): (to: {
257
+ path: string;
258
+ name?: string;
259
+ }, from: {
260
+ path: string;
261
+ }) => void;
262
+ declare const _default: {
263
+ FlowGridPlugin: {
264
+ install(app: App, options: FlowGridConfig): void;
265
+ };
266
+ useFlowGrid: typeof useFlowGrid;
267
+ usePageView: typeof usePageView;
268
+ useTrackEvent: typeof useTrackEvent;
269
+ useExperiment: typeof useExperiment;
270
+ useFeatureFlag: typeof useFeatureFlag;
271
+ useIdentify: typeof useIdentify;
272
+ useEcommerce: typeof useEcommerce;
273
+ createRouterPlugin: typeof createRouterPlugin;
274
+ };
275
+ export default _default;