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,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Enterprise - Customer Support & Experience Analytics
|
|
3
|
+
* @module features/enterprise/support
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Link support interactions to retention and conversion metrics.
|
|
7
|
+
* Track ticket volume, response times, and satisfaction scores.
|
|
8
|
+
*
|
|
9
|
+
* @useCases
|
|
10
|
+
* - Track support ticket volume
|
|
11
|
+
* - Monitor response and resolution times
|
|
12
|
+
* - Correlate CSAT/NPS with retention
|
|
13
|
+
* - Track feature complaints
|
|
14
|
+
* - Measure support impact on conversion
|
|
15
|
+
*
|
|
16
|
+
* @metrics
|
|
17
|
+
* - Ticket volume
|
|
18
|
+
* - Average response time
|
|
19
|
+
* - Average resolution time
|
|
20
|
+
* - CSAT score
|
|
21
|
+
* - First contact resolution rate
|
|
22
|
+
*
|
|
23
|
+
* @chartData
|
|
24
|
+
* - Line chart: Ticket volume over time
|
|
25
|
+
* - Bar chart: Tickets by category
|
|
26
|
+
* - Distribution: Resolution time
|
|
27
|
+
* - Correlation: Support vs retention
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const support = new SupportAnalytics(webId, endpoint, apiKey);
|
|
32
|
+
*
|
|
33
|
+
* // Track support ticket
|
|
34
|
+
* await support.trackTicket({
|
|
35
|
+
* ticketId: 'ticket_123',
|
|
36
|
+
* userId: 'user_456',
|
|
37
|
+
* category: 'billing',
|
|
38
|
+
* priority: 'high'
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import { EnterpriseFTRPC } from "../../client/enterprise-ftrpc";
|
|
43
|
+
import { DateRangeFilter, TimeSeriesData, TimeGranularity } from "../../types";
|
|
44
|
+
/**
|
|
45
|
+
* Ticket priority levels.
|
|
46
|
+
*/
|
|
47
|
+
export type TicketPriority = 'low' | 'medium' | 'high' | 'urgent';
|
|
48
|
+
/**
|
|
49
|
+
* Ticket status.
|
|
50
|
+
*/
|
|
51
|
+
export type TicketStatus = 'open' | 'pending' | 'in_progress' | 'resolved' | 'closed';
|
|
52
|
+
/**
|
|
53
|
+
* Support channel.
|
|
54
|
+
*/
|
|
55
|
+
export type SupportChannel = 'email' | 'chat' | 'phone' | 'social' | 'self_service' | 'other';
|
|
56
|
+
/**
|
|
57
|
+
* Ticket creation configuration.
|
|
58
|
+
*/
|
|
59
|
+
export interface TicketConfig {
|
|
60
|
+
/** Ticket ID */
|
|
61
|
+
ticketId: string;
|
|
62
|
+
/** User ID */
|
|
63
|
+
userId: string;
|
|
64
|
+
/** Account/company ID */
|
|
65
|
+
accountId?: string;
|
|
66
|
+
/** Ticket subject */
|
|
67
|
+
subject: string;
|
|
68
|
+
/** Ticket category */
|
|
69
|
+
category: string;
|
|
70
|
+
/** Sub-category */
|
|
71
|
+
subCategory?: string;
|
|
72
|
+
/** Priority level */
|
|
73
|
+
priority: TicketPriority;
|
|
74
|
+
/** Support channel */
|
|
75
|
+
channel: SupportChannel;
|
|
76
|
+
/** Related feature (if any) */
|
|
77
|
+
featureId?: string;
|
|
78
|
+
/** Custom properties */
|
|
79
|
+
properties?: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Ticket update configuration.
|
|
83
|
+
*/
|
|
84
|
+
export interface TicketUpdateConfig {
|
|
85
|
+
/** Ticket ID */
|
|
86
|
+
ticketId: string;
|
|
87
|
+
/** New status */
|
|
88
|
+
status: TicketStatus;
|
|
89
|
+
/** Assigned agent ID */
|
|
90
|
+
agentId?: string;
|
|
91
|
+
/** Response time (ms) - first response */
|
|
92
|
+
responseTimeMs?: number;
|
|
93
|
+
/** Resolution time (ms) - time to resolve */
|
|
94
|
+
resolutionTimeMs?: number;
|
|
95
|
+
/** Number of interactions */
|
|
96
|
+
interactionCount?: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* CSAT tracking configuration.
|
|
100
|
+
*/
|
|
101
|
+
export interface CSATConfig {
|
|
102
|
+
/** Ticket ID */
|
|
103
|
+
ticketId: string;
|
|
104
|
+
/** User ID */
|
|
105
|
+
userId: string;
|
|
106
|
+
/** CSAT score (1-5) */
|
|
107
|
+
score: number;
|
|
108
|
+
/** Feedback comment */
|
|
109
|
+
feedback?: string;
|
|
110
|
+
/** Agent ID */
|
|
111
|
+
agentId?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Feature complaint configuration.
|
|
115
|
+
*/
|
|
116
|
+
export interface FeatureComplaintConfig {
|
|
117
|
+
/** User ID */
|
|
118
|
+
userId: string;
|
|
119
|
+
/** Feature ID */
|
|
120
|
+
featureId: string;
|
|
121
|
+
/** Complaint type */
|
|
122
|
+
complaintType: 'bug' | 'usability' | 'missing_feature' | 'performance' | 'other';
|
|
123
|
+
/** Description */
|
|
124
|
+
description?: string;
|
|
125
|
+
/** Severity */
|
|
126
|
+
severity: 'minor' | 'moderate' | 'major' | 'critical';
|
|
127
|
+
/** Associated ticket ID */
|
|
128
|
+
ticketId?: string;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Support analytics filter.
|
|
132
|
+
*/
|
|
133
|
+
export interface SupportAnalyticsFilter extends DateRangeFilter {
|
|
134
|
+
/** Filter by category */
|
|
135
|
+
category?: string;
|
|
136
|
+
/** Filter by priority */
|
|
137
|
+
priority?: TicketPriority;
|
|
138
|
+
/** Filter by channel */
|
|
139
|
+
channel?: SupportChannel;
|
|
140
|
+
/** Filter by status */
|
|
141
|
+
status?: TicketStatus;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Ticket analytics result.
|
|
145
|
+
*/
|
|
146
|
+
export interface TicketAnalytics {
|
|
147
|
+
/** Total tickets */
|
|
148
|
+
totalTickets: number;
|
|
149
|
+
/** Open tickets */
|
|
150
|
+
openTickets: number;
|
|
151
|
+
/** Resolved tickets */
|
|
152
|
+
resolvedTickets: number;
|
|
153
|
+
/** Average response time (ms) */
|
|
154
|
+
avgResponseTimeMs: number;
|
|
155
|
+
/** Average resolution time (ms) */
|
|
156
|
+
avgResolutionTimeMs: number;
|
|
157
|
+
/** First contact resolution rate */
|
|
158
|
+
fcrRate: number;
|
|
159
|
+
/** Average CSAT score */
|
|
160
|
+
avgCSAT: number;
|
|
161
|
+
/** Tickets by category */
|
|
162
|
+
byCategory: Array<{
|
|
163
|
+
category: string;
|
|
164
|
+
count: number;
|
|
165
|
+
percentage: number;
|
|
166
|
+
}>;
|
|
167
|
+
/** Tickets by priority */
|
|
168
|
+
byPriority: Array<{
|
|
169
|
+
priority: TicketPriority;
|
|
170
|
+
count: number;
|
|
171
|
+
percentage: number;
|
|
172
|
+
}>;
|
|
173
|
+
/** Tickets by channel */
|
|
174
|
+
byChannel: Array<{
|
|
175
|
+
channel: SupportChannel;
|
|
176
|
+
count: number;
|
|
177
|
+
percentage: number;
|
|
178
|
+
}>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Support impact analysis.
|
|
182
|
+
*/
|
|
183
|
+
export interface SupportImpactAnalysis {
|
|
184
|
+
/** Correlation with retention */
|
|
185
|
+
retentionCorrelation: number;
|
|
186
|
+
/** Correlation with churn */
|
|
187
|
+
churnCorrelation: number;
|
|
188
|
+
/** Users with support tickets */
|
|
189
|
+
usersWithTickets: number;
|
|
190
|
+
/** Churn rate for users with tickets */
|
|
191
|
+
ticketUserChurnRate: number;
|
|
192
|
+
/** Churn rate for users without tickets */
|
|
193
|
+
noTicketUserChurnRate: number;
|
|
194
|
+
/** Impact of quick resolution on retention */
|
|
195
|
+
quickResolutionRetentionLift: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Feature complaint summary.
|
|
199
|
+
*/
|
|
200
|
+
export interface FeatureComplaintSummary {
|
|
201
|
+
/** Feature ID */
|
|
202
|
+
featureId: string;
|
|
203
|
+
/** Feature name */
|
|
204
|
+
featureName?: string;
|
|
205
|
+
/** Total complaints */
|
|
206
|
+
totalComplaints: number;
|
|
207
|
+
/** By complaint type */
|
|
208
|
+
byType: Array<{
|
|
209
|
+
type: string;
|
|
210
|
+
count: number;
|
|
211
|
+
}>;
|
|
212
|
+
/** By severity */
|
|
213
|
+
bySeverity: Array<{
|
|
214
|
+
severity: string;
|
|
215
|
+
count: number;
|
|
216
|
+
}>;
|
|
217
|
+
/** Trend direction */
|
|
218
|
+
trend: 'increasing' | 'stable' | 'decreasing';
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Agent performance.
|
|
222
|
+
*/
|
|
223
|
+
export interface AgentPerformance {
|
|
224
|
+
agentId: string;
|
|
225
|
+
agentName?: string;
|
|
226
|
+
ticketsHandled: number;
|
|
227
|
+
avgResponseTimeMs: number;
|
|
228
|
+
avgResolutionTimeMs: number;
|
|
229
|
+
avgCSAT: number;
|
|
230
|
+
fcrRate: number;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Calculate first contact resolution rate.
|
|
234
|
+
*/
|
|
235
|
+
export declare function calculateFCRRate(resolvedFirstContact: number, totalResolved: number): number;
|
|
236
|
+
/**
|
|
237
|
+
* Calculate average response time.
|
|
238
|
+
*/
|
|
239
|
+
export declare function calculateAvgResponseTime(responseTimes: number[]): number;
|
|
240
|
+
/**
|
|
241
|
+
* Classify CSAT score.
|
|
242
|
+
*/
|
|
243
|
+
export declare function classifyCSAT(score: number): 'poor' | 'fair' | 'good' | 'excellent';
|
|
244
|
+
/**
|
|
245
|
+
* Format duration in human-readable format.
|
|
246
|
+
*/
|
|
247
|
+
export declare function formatDuration(ms: number): string;
|
|
248
|
+
/**
|
|
249
|
+
* Customer support and experience analytics class.
|
|
250
|
+
*/
|
|
251
|
+
export declare class SupportAnalytics extends EnterpriseFTRPC {
|
|
252
|
+
/**
|
|
253
|
+
* Track new support ticket.
|
|
254
|
+
*/
|
|
255
|
+
trackTicket(config: TicketConfig): Promise<{
|
|
256
|
+
tracked: boolean;
|
|
257
|
+
}>;
|
|
258
|
+
/**
|
|
259
|
+
* Update ticket status.
|
|
260
|
+
*/
|
|
261
|
+
updateTicket(config: TicketUpdateConfig): Promise<{
|
|
262
|
+
updated: boolean;
|
|
263
|
+
}>;
|
|
264
|
+
/**
|
|
265
|
+
* Track ticket response.
|
|
266
|
+
*/
|
|
267
|
+
trackResponse(ticketId: string, agentId: string, responseTimeMs: number): Promise<{
|
|
268
|
+
tracked: boolean;
|
|
269
|
+
}>;
|
|
270
|
+
/**
|
|
271
|
+
* Track ticket resolution.
|
|
272
|
+
*/
|
|
273
|
+
trackResolution(ticketId: string, resolutionTimeMs: number, interactionCount: number): Promise<{
|
|
274
|
+
tracked: boolean;
|
|
275
|
+
}>;
|
|
276
|
+
/**
|
|
277
|
+
* Track CSAT score.
|
|
278
|
+
*/
|
|
279
|
+
trackCSAT(config: CSATConfig): Promise<{
|
|
280
|
+
tracked: boolean;
|
|
281
|
+
}>;
|
|
282
|
+
/**
|
|
283
|
+
* Track feature complaint.
|
|
284
|
+
*/
|
|
285
|
+
trackFeatureComplaint(config: FeatureComplaintConfig): Promise<{
|
|
286
|
+
tracked: boolean;
|
|
287
|
+
}>;
|
|
288
|
+
/**
|
|
289
|
+
* Get ticket analytics.
|
|
290
|
+
*/
|
|
291
|
+
getAnalytics(filter?: SupportAnalyticsFilter): Promise<TicketAnalytics>;
|
|
292
|
+
/**
|
|
293
|
+
* Get support impact analysis.
|
|
294
|
+
*/
|
|
295
|
+
getSupportImpact(filter?: DateRangeFilter): Promise<SupportImpactAnalysis>;
|
|
296
|
+
/**
|
|
297
|
+
* Get feature complaint summary.
|
|
298
|
+
*/
|
|
299
|
+
getFeatureComplaints(featureId?: string, filter?: DateRangeFilter): Promise<FeatureComplaintSummary[]>;
|
|
300
|
+
/**
|
|
301
|
+
* Get agent performance.
|
|
302
|
+
*/
|
|
303
|
+
getAgentPerformance(agentId?: string, filter?: DateRangeFilter): Promise<AgentPerformance[]>;
|
|
304
|
+
/**
|
|
305
|
+
* Get ticket trend.
|
|
306
|
+
*/
|
|
307
|
+
getTicketTrend(filter?: SupportAnalyticsFilter, granularity?: TimeGranularity): Promise<TimeSeriesData>;
|
|
308
|
+
/**
|
|
309
|
+
* Get CSAT trend.
|
|
310
|
+
*/
|
|
311
|
+
getCSATTrend(filter?: DateRangeFilter, granularity?: TimeGranularity): Promise<TimeSeriesData>;
|
|
312
|
+
/**
|
|
313
|
+
* Get response time distribution.
|
|
314
|
+
*/
|
|
315
|
+
getResponseTimeDistribution(filter?: DateRangeFilter): Promise<Array<{
|
|
316
|
+
bucket: string;
|
|
317
|
+
count: number;
|
|
318
|
+
percentage: number;
|
|
319
|
+
}>>;
|
|
320
|
+
/**
|
|
321
|
+
* Get user support history.
|
|
322
|
+
*/
|
|
323
|
+
getUserSupportHistory(userId: string): Promise<{
|
|
324
|
+
totalTickets: number;
|
|
325
|
+
avgCSAT: number;
|
|
326
|
+
categories: string[];
|
|
327
|
+
lastTicketDate: string;
|
|
328
|
+
}>;
|
|
329
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview FlowGrid SDK - Next.js Client Components
|
|
3
|
+
* @module frameworks/nextjs/client
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Client-side components and hooks for Next.js.
|
|
7
|
+
* All exports require 'use client' directive.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* // app/providers.tsx
|
|
12
|
+
* 'use client';
|
|
13
|
+
* import { FlowGridProvider } from 'flowgrid-sdk/nextjs/client';
|
|
14
|
+
*
|
|
15
|
+
* export function Providers({ children }) {
|
|
16
|
+
* return (
|
|
17
|
+
* <FlowGridProvider
|
|
18
|
+
* webId={process.env.NEXT_PUBLIC_FLOWGRID_WEB_ID!}
|
|
19
|
+
* endpoint={process.env.NEXT_PUBLIC_FLOWGRID_ENDPOINT!}
|
|
20
|
+
* apiKey={process.env.NEXT_PUBLIC_FLOWGRID_API_KEY!}
|
|
21
|
+
* >
|
|
22
|
+
* {children}
|
|
23
|
+
* </FlowGridProvider>
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
import { type ReactNode } from 'react';
|
|
29
|
+
import { Activation, TrackFeature, TrackPrompt, Experiment, FeatureFlag, PageViews, Sessions, Events, Identify, Funnels, Products, CartTracking, Checkout, Purchases } from '../../../index';
|
|
30
|
+
export interface FlowGridConfig {
|
|
31
|
+
webId: string;
|
|
32
|
+
endpoint: string;
|
|
33
|
+
apiKey: string;
|
|
34
|
+
autoTrackPageViews?: boolean;
|
|
35
|
+
autoTrackSessions?: boolean;
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface FlowGridContextValue {
|
|
39
|
+
activation: Activation;
|
|
40
|
+
trackFeature: TrackFeature;
|
|
41
|
+
trackPrompt: TrackPrompt;
|
|
42
|
+
experiment: Experiment;
|
|
43
|
+
featureFlag: FeatureFlag;
|
|
44
|
+
pageViews: PageViews;
|
|
45
|
+
sessions: Sessions;
|
|
46
|
+
events: Events;
|
|
47
|
+
identify: Identify;
|
|
48
|
+
funnels: Funnels;
|
|
49
|
+
products: Products;
|
|
50
|
+
cart: CartTracking;
|
|
51
|
+
checkout: Checkout;
|
|
52
|
+
purchases: Purchases;
|
|
53
|
+
trackEvent: (name: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
54
|
+
identifyUser: (userId: string, traits?: Record<string, unknown>) => Promise<void>;
|
|
55
|
+
isReady: boolean;
|
|
56
|
+
}
|
|
57
|
+
export interface FlowGridProviderProps extends FlowGridConfig {
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* FlowGrid Provider for Next.js App Router.
|
|
62
|
+
* Use in a Client Component wrapper.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* // app/providers.tsx
|
|
67
|
+
* 'use client';
|
|
68
|
+
*
|
|
69
|
+
* import { FlowGridProvider } from 'flowgrid-sdk/nextjs/client';
|
|
70
|
+
*
|
|
71
|
+
* export function Providers({ children }: { children: React.ReactNode }) {
|
|
72
|
+
* return (
|
|
73
|
+
* <FlowGridProvider
|
|
74
|
+
* webId={process.env.NEXT_PUBLIC_FLOWGRID_WEB_ID!}
|
|
75
|
+
* endpoint={process.env.NEXT_PUBLIC_FLOWGRID_ENDPOINT!}
|
|
76
|
+
* apiKey={process.env.NEXT_PUBLIC_FLOWGRID_API_KEY!}
|
|
77
|
+
* >
|
|
78
|
+
* {children}
|
|
79
|
+
* </FlowGridProvider>
|
|
80
|
+
* );
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* // app/layout.tsx
|
|
84
|
+
* import { Providers } from './providers';
|
|
85
|
+
*
|
|
86
|
+
* export default function RootLayout({ children }) {
|
|
87
|
+
* return (
|
|
88
|
+
* <html>
|
|
89
|
+
* <body>
|
|
90
|
+
* <Providers>{children}</Providers>
|
|
91
|
+
* </body>
|
|
92
|
+
* </html>
|
|
93
|
+
* );
|
|
94
|
+
* }
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function FlowGridProvider({ children, webId, endpoint, apiKey, autoTrackPageViews, autoTrackSessions, debug }: FlowGridProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
98
|
+
/**
|
|
99
|
+
* Access the FlowGrid SDK instance.
|
|
100
|
+
*/
|
|
101
|
+
export declare function useFlowGrid(): FlowGridContextValue;
|
|
102
|
+
/**
|
|
103
|
+
* Track an event.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* 'use client';
|
|
108
|
+
*
|
|
109
|
+
* import { useTrackEvent } from 'flowgrid-sdk/nextjs/client';
|
|
110
|
+
*
|
|
111
|
+
* export function FeatureButton() {
|
|
112
|
+
* const trackEvent = useTrackEvent();
|
|
113
|
+
*
|
|
114
|
+
* return (
|
|
115
|
+
* <button onClick={() => trackEvent('feature_clicked', { id: 'cta' })}>
|
|
116
|
+
* Click me
|
|
117
|
+
* </button>
|
|
118
|
+
* );
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export declare function useTrackEvent(): (name: string, properties?: Record<string, unknown>) => Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Get experiment variant.
|
|
125
|
+
*/
|
|
126
|
+
export declare function useExperiment(experimentId: string, userId: string): {
|
|
127
|
+
variant: string | null;
|
|
128
|
+
isLoading: boolean;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Evaluate a feature flag.
|
|
132
|
+
*/
|
|
133
|
+
export declare function useFeatureFlag(flagKey: string, context?: {
|
|
134
|
+
userId?: string;
|
|
135
|
+
}): {
|
|
136
|
+
isEnabled: boolean;
|
|
137
|
+
isLoading: boolean;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Identify user.
|
|
141
|
+
*/
|
|
142
|
+
export declare function useIdentify(userId: string | null, traits?: Record<string, unknown>): void;
|
|
143
|
+
/**
|
|
144
|
+
* Ecommerce hooks.
|
|
145
|
+
*/
|
|
146
|
+
export declare function useEcommerce(): {
|
|
147
|
+
trackProductView: (product: {
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
price: number;
|
|
151
|
+
currency?: string;
|
|
152
|
+
}) => Promise<void>;
|
|
153
|
+
trackAddToCart: (product: {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
price: number;
|
|
157
|
+
currency?: string;
|
|
158
|
+
}, quantity?: number) => Promise<void>;
|
|
159
|
+
trackPurchase: (orderData: {
|
|
160
|
+
orderId: string;
|
|
161
|
+
revenue: number;
|
|
162
|
+
items: Array<{
|
|
163
|
+
id: string;
|
|
164
|
+
name: string;
|
|
165
|
+
price: number;
|
|
166
|
+
quantity: number;
|
|
167
|
+
}>;
|
|
168
|
+
}) => Promise<void>;
|
|
169
|
+
products: Products;
|
|
170
|
+
cart: CartTracking;
|
|
171
|
+
checkout: Checkout;
|
|
172
|
+
purchases: Purchases;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Component to track page views in App Router.
|
|
176
|
+
* Add to your root layout.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```tsx
|
|
180
|
+
* // app/layout.tsx
|
|
181
|
+
* import { PageViewTracker } from 'flowgrid-sdk/nextjs/client';
|
|
182
|
+
*
|
|
183
|
+
* export default function RootLayout({ children }) {
|
|
184
|
+
* return (
|
|
185
|
+
* <html>
|
|
186
|
+
* <body>
|
|
187
|
+
* <Providers>
|
|
188
|
+
* <PageViewTracker />
|
|
189
|
+
* {children}
|
|
190
|
+
* </Providers>
|
|
191
|
+
* </body>
|
|
192
|
+
* </html>
|
|
193
|
+
* );
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
export declare function PageViewTracker(): null;
|
|
198
|
+
declare const _default: {
|
|
199
|
+
FlowGridProvider: typeof FlowGridProvider;
|
|
200
|
+
useFlowGrid: typeof useFlowGrid;
|
|
201
|
+
useTrackEvent: typeof useTrackEvent;
|
|
202
|
+
useExperiment: typeof useExperiment;
|
|
203
|
+
useFeatureFlag: typeof useFeatureFlag;
|
|
204
|
+
useIdentify: typeof useIdentify;
|
|
205
|
+
useEcommerce: typeof useEcommerce;
|
|
206
|
+
PageViewTracker: typeof PageViewTracker;
|
|
207
|
+
};
|
|
208
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview FlowGrid SDK - Next.js Integration
|
|
3
|
+
* @module frameworks/nextjs
|
|
4
|
+
*
|
|
5
|
+
* @description
|
|
6
|
+
* Next.js integration with proper App Router and Pages Router support.
|
|
7
|
+
* Includes Server Components, Client Components, and API Route helpers.
|
|
8
|
+
*
|
|
9
|
+
* ## File Organization
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* flowgrid-sdk/nextjs
|
|
13
|
+
* ├── client.tsx - Client components (use 'use client')
|
|
14
|
+
* ├── server.ts - Server-side utilities (API routes, Server Components)
|
|
15
|
+
* └── index.ts - Main exports
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* // Client Component
|
|
21
|
+
* 'use client';
|
|
22
|
+
* import { FlowGridProvider, useFlowGrid } from 'flowgrid-sdk/nextjs/client';
|
|
23
|
+
*
|
|
24
|
+
* // Server-side (API Route or Server Action)
|
|
25
|
+
* import { flowgrid } from 'flowgrid-sdk/nextjs/server';
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export * from './client';
|
|
29
|
+
export * from './server';
|