flowgrid-sdk 1.1.0 → 1.2.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 (65) hide show
  1. package/README.md +320 -8
  2. package/dist/browser.d.ts +6 -7
  3. package/dist/flowgrid.min.js +1 -1
  4. package/dist/flowgrid.min.js.map +1 -1
  5. package/dist/index.d.ts +11 -4
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/lib/client/transport.d.ts +175 -0
  9. package/dist/lib/consent/index.d.ts +37 -0
  10. package/dist/lib/consent/manager.d.ts +197 -0
  11. package/dist/lib/consent/types.d.ts +162 -0
  12. package/dist/lib/features/analytics/attribution.d.ts +3 -3
  13. package/dist/lib/features/analytics/events.d.ts +3 -3
  14. package/dist/lib/features/analytics/funnels.d.ts +3 -3
  15. package/dist/lib/features/analytics/heatmaps.d.ts +9 -3
  16. package/dist/lib/features/analytics/identify.d.ts +3 -3
  17. package/dist/lib/features/analytics/page-views.d.ts +3 -3
  18. package/dist/lib/features/analytics/performance.d.ts +3 -3
  19. package/dist/lib/features/analytics/retention.d.ts +3 -3
  20. package/dist/lib/features/analytics/sessions.d.ts +3 -3
  21. package/dist/lib/features/core/activation.d.ts +3 -3
  22. package/dist/lib/features/core/experiment.d.ts +86 -70
  23. package/dist/lib/features/core/index.d.ts +1 -3
  24. package/dist/lib/features/core/track-feature.d.ts +3 -3
  25. package/dist/lib/features/core/track-prompt.d.ts +3 -3
  26. package/dist/lib/features/ecommerce/cart.d.ts +3 -3
  27. package/dist/lib/features/ecommerce/checkout.d.ts +3 -3
  28. package/dist/lib/features/ecommerce/inventory.d.ts +3 -3
  29. package/dist/lib/features/ecommerce/ltv.d.ts +3 -3
  30. package/dist/lib/features/ecommerce/products.d.ts +3 -3
  31. package/dist/lib/features/ecommerce/promotions.d.ts +3 -3
  32. package/dist/lib/features/ecommerce/purchases.d.ts +3 -3
  33. package/dist/lib/features/ecommerce/refunds.d.ts +3 -3
  34. package/dist/lib/features/ecommerce/search.d.ts +3 -3
  35. package/dist/lib/features/ecommerce/subscriptions.d.ts +3 -3
  36. package/dist/lib/features/ecommerce/wishlist.d.ts +3 -3
  37. package/dist/lib/features/enterprise/acquisition.d.ts +2 -2
  38. package/dist/lib/features/enterprise/alerts.d.ts +2 -2
  39. package/dist/lib/features/enterprise/churn.d.ts +2 -2
  40. package/dist/lib/features/enterprise/cohorts.d.ts +2 -2
  41. package/dist/lib/features/enterprise/engagement.d.ts +24 -3
  42. package/dist/lib/features/enterprise/forecasting.d.ts +2 -2
  43. package/dist/lib/features/enterprise/monetization.d.ts +2 -2
  44. package/dist/lib/features/enterprise/multi-path-funnels.d.ts +2 -2
  45. package/dist/lib/features/enterprise/paths.d.ts +2 -2
  46. package/dist/lib/features/enterprise/security.d.ts +2 -2
  47. package/dist/lib/features/enterprise/support.d.ts +2 -2
  48. package/dist/lib/frameworks/nextjs/client.d.ts +7 -13
  49. package/dist/lib/frameworks/nextjs/server.d.ts +5 -15
  50. package/dist/lib/frameworks/node/index.d.ts +2 -6
  51. package/dist/lib/frameworks/nuxt/index.d.ts +7 -3
  52. package/dist/lib/frameworks/react/CookieBanner.d.ts +91 -0
  53. package/dist/lib/frameworks/react/index.d.ts +97 -135
  54. package/dist/lib/frameworks/vue/CookieBanner.d.ts +82 -0
  55. package/dist/lib/frameworks/vue/index.d.ts +28 -25
  56. package/dist/lib/types/analytics.d.ts +62 -0
  57. package/dist/lib/types/common.d.ts +2 -0
  58. package/dist/lib/utils/identity.d.ts +93 -0
  59. package/dist/lib/utils/storage.d.ts +69 -0
  60. package/package.json +13 -2
  61. package/dist/lib/client/enterprise-ftrpc.d.ts +0 -51
  62. package/dist/lib/client/ftrpc.d.ts +0 -132
  63. package/dist/lib/client/modules.d.ts +0 -104
  64. package/dist/lib/features/core/feature-flag.d.ts +0 -249
  65. package/dist/lib/utils/functions.d.ts +0 -1
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @fileoverview FlowGrid storage utilities.
3
+ * @module utils/storage
4
+ *
5
+ * @description
6
+ * Reads visitor identity and UTM attribution data from the same
7
+ * cookie / localStorage / sessionStorage keys used by the FlowGrid
8
+ * tracking scripts (track.js & flowgrid_oss_client_sdk.js).
9
+ *
10
+ * These functions are **read-only** — the tracking scripts remain the
11
+ * single writer. The SDK only consumes these values.
12
+ */
13
+ /**
14
+ * Read a cookie value by name.
15
+ * Returns `null` when the cookie is absent or document.cookie is unavailable.
16
+ */
17
+ export declare function getCookie(name: string): string | null;
18
+ /**
19
+ * Resolve the visitor ID written by track.js / flowgrid_oss_client_sdk.js.
20
+ *
21
+ * Storage locations (checked in order):
22
+ * 1. cookie `visitor_id`
23
+ * 2. localStorage `visitor_id`
24
+ *
25
+ * Returns `null` when neither source contains a value (e.g. tracking
26
+ * script hasn't run yet, or running server-side).
27
+ */
28
+ export declare function getVisitorId(): string | null;
29
+ /**
30
+ * Resolve the session ID written by track.js.
31
+ *
32
+ * Storage: `sessionStorage("session_id")`
33
+ */
34
+ export declare function getSessionId(): string | null;
35
+ /**
36
+ * Resolve the web_id written by track.js.
37
+ *
38
+ * Storage: `localStorage("web_id")`
39
+ */
40
+ export declare function getWebId(): string | null;
41
+ export interface FlowGridUTM {
42
+ utmSource?: string;
43
+ utmMedium?: string;
44
+ utmCampaign?: string;
45
+ utmTerm?: string;
46
+ utmContent?: string;
47
+ ref?: string;
48
+ source?: string;
49
+ via?: string;
50
+ }
51
+ /**
52
+ * Read UTM & attribution parameters persisted by
53
+ * flowgrid_oss_client_sdk.js as `__flowgrid_*` cookies.
54
+ */
55
+ export declare function getUTM(): FlowGridUTM;
56
+ export interface FlowGridUTMHistoryEntry {
57
+ timestamp: string;
58
+ utm_source?: string;
59
+ utm_medium?: string;
60
+ utm_campaign?: string;
61
+ utm_content?: string;
62
+ utm_term?: string;
63
+ }
64
+ /**
65
+ * Read the full UTM history array persisted by flowgrid_oss_client_sdk.js.
66
+ *
67
+ * Checks localStorage first, then the `utm_history` cookie.
68
+ */
69
+ export declare function getUTMHistory(): FlowGridUTMHistoryEntry[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowgrid-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A TypeScript SDK for tracking user events, feature usage, experiments, and feature flags with Flowgrid.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -65,6 +65,11 @@
65
65
  "types": "./dist/lib/types/index.d.ts",
66
66
  "import": "./dist/lib/types/index.mjs",
67
67
  "require": "./dist/lib/types/index.js"
68
+ },
69
+ "./consent": {
70
+ "types": "./dist/lib/consent/index.d.ts",
71
+ "import": "./dist/lib/consent/index.mjs",
72
+ "require": "./dist/lib/consent/index.js"
68
73
  }
69
74
  },
70
75
  "scripts": {
@@ -72,7 +77,12 @@
72
77
  "build:browser": "webpack --config webpack.browser.config.js",
73
78
  "build:all": "npm run build && npm run build:browser",
74
79
  "build:types": "tsc --emitDeclarationOnly",
75
- "test": "echo \"No tests specified\" && exit 0",
80
+ "test": "npx tsx tests/featureFlags.test.ts && npx tsx tests/core.test.ts && npx tsx tests/analytics.test.ts && npx tsx tests/ecommerce.test.ts && npx tsx tests/enterprise.test.ts",
81
+ "test:featureFlags": "npx tsx tests/featureFlags.test.ts",
82
+ "test:core": "npx tsx tests/core.test.ts",
83
+ "test:analytics": "npx tsx tests/analytics.test.ts",
84
+ "test:ecommerce": "npx tsx tests/ecommerce.test.ts",
85
+ "test:enterprise": "npx tsx tests/enterprise.test.ts",
76
86
  "lint": "echo \"No linting configured\" && exit 0",
77
87
  "prepublishOnly": "npm run build:all"
78
88
  },
@@ -128,6 +138,7 @@
128
138
  "@types/react": "^18.0.0",
129
139
  "react": "^18.3.1",
130
140
  "ts-loader": "^9.5.1",
141
+ "tsx": "^4.21.0",
131
142
  "typescript": "^5.9.2",
132
143
  "vue": "^3.5.27",
133
144
  "webpack": "^5.105.0",
@@ -1,51 +0,0 @@
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 };
@@ -1,132 +0,0 @@
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
- /**
16
- * FTRPC - Core transport layer for Flowgrid SDK.
17
- *
18
- * @description
19
- * Provides a secure, validated RPC-style transport layer used by all SDK modules.
20
- * Handles:
21
- * - Input validation
22
- * - Payload size enforcement
23
- * - Timeout handling
24
- * - Retry logic (network failures only)
25
- * - Authorization headers
26
- *
27
- * This class is designed to be extended by higher-level modules
28
- * (e.g., FeatureFlag, Analytics, Experiments).
29
- *
30
- * @example
31
- * ```ts
32
- * const client = new FTRPC("web_123", "api.flowgrid.com", "sk_live_xxx");
33
- * ```
34
- */
35
- export declare class FTRPC {
36
- /**
37
- * Unique Web ID identifying the site or application.
38
- * Used by the backend to associate incoming events.
39
- */
40
- protected webId: string;
41
- /**
42
- * Base API endpoint.
43
- * Example values:
44
- * - "api.flowgrid.com"
45
- * - "https://api.flowgrid.com"
46
- *
47
- * Protocol is normalized automatically.
48
- */
49
- protected endpoint: string;
50
- /**
51
- * Private API key used for authenticating requests.
52
- * Sent as a Bearer token in the Authorization header.
53
- */
54
- private apiKey;
55
- /**
56
- * Maximum allowed payload size (in bytes).
57
- * Prevents oversized event submissions.
58
- */
59
- private static readonly MAX_PAYLOAD_SIZE;
60
- /**
61
- * Maximum time (ms) before request is aborted.
62
- */
63
- private static readonly TIMEOUT_MS;
64
- /**
65
- * Maximum retry attempts for network-level failures.
66
- * Does NOT retry HTTP 4xx/5xx responses.
67
- */
68
- private static readonly MAX_RETRIES;
69
- /**
70
- * Creates a new FTRPC transport instance.
71
- *
72
- * @param webId - Unique identifier for the web property.
73
- * @param endpoint - API base endpoint.
74
- * @param apiKey - Private API key for authentication.
75
- *
76
- * @throws {Error} If required parameters are missing.
77
- */
78
- constructor(webId: string, endpoint: string, apiKey: string);
79
- /**
80
- * Core RPC transport method.
81
- *
82
- * @template T Expected JSON response type.
83
- *
84
- * @param eventName - Logical event or function name.
85
- * @param properties - Arbitrary event payload properties.
86
- * @param method - HTTP method ("GET", "POST", "PATCH").
87
- *
88
- * @returns Promise resolving to typed response.
89
- *
90
- * @remarks
91
- * - GET requests are treated as read-only operations.
92
- * - POST/PATCH requests may mutate backend state.
93
- * - Retries occur only for network failures or timeouts.
94
- */
95
- protected init<T>(eventName: string, properties?: Record<string, any>, method?: "GET" | "POST" | "PATCH"): Promise<T>;
96
- /**
97
- * Executes HTTP request with timeout and retry handling.
98
- *
99
- * @template T Expected response type.
100
- *
101
- * @param url - Fully constructed request URL.
102
- * @param method - HTTP method.
103
- * @param body - Optional JSON body (POST/PATCH only).
104
- *
105
- * @throws {Error} On timeout, network failure, or non-OK HTTP status.
106
- */
107
- private executeRequest;
108
- /**
109
- * Validates event name and payload.
110
- *
111
- * @param eventName - Event identifier.
112
- * @param properties - Associated event properties.
113
- *
114
- * @throws {Error} If validation fails.
115
- */
116
- private validateInput;
117
- /**
118
- * Normalizes endpoint input.
119
- * Ensures protocol is present and removes trailing slashes.
120
- *
121
- * @param endpoint - Raw endpoint string.
122
- * @returns Normalized endpoint URL.
123
- */
124
- private normalizeEndpoint;
125
- /**
126
- * Safely reads response text without throwing.
127
- *
128
- * @param res - Fetch Response object.
129
- * @returns Response text or empty string.
130
- */
131
- private safeRead;
132
- }
@@ -1,104 +0,0 @@
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 {};
@@ -1,249 +0,0 @@
1
- /**
2
- * @fileoverview Core - Feature Flags
3
- * @module features/core/feature-flag
4
- *
5
- * @description
6
- * Track feature flag evaluations and usage to understand
7
- * rollout progress and flag performance.
8
- *
9
- * @useCases
10
- * - Track flag evaluations
11
- * - Monitor rollout progress
12
- * - Analyze flag impact
13
- * - Debug flag configurations
14
- * - Measure gradual rollouts
15
- *
16
- * @metrics
17
- * - Evaluations per flag
18
- * - Unique users per variant
19
- * - Rollout percentage
20
- * - Error rate
21
- * - Flag age
22
- *
23
- * @chartData
24
- * - Pie chart: Users by variant
25
- * - Line chart: Evaluations over time
26
- * - Table: Active flags summary
27
- * - Bar chart: Top evaluated flags
28
- *
29
- * @example
30
- * ```typescript
31
- * const featureFlag = new FeatureFlag(webId, endpoint, apiKey);
32
- *
33
- * await featureFlag.evaluate({
34
- * eventName: 'new_dashboard',
35
- * properties: { userId: 'user_123', result: true }
36
- * });
37
- * ```
38
- */
39
- import { FTRPC } from "../../client/ftrpc";
40
- import { TimeSeriesData } from "../../types";
41
- /**
42
- * Base feature flag configuration.
43
- */
44
- export interface FlagConfig {
45
- /** Flag name/event */
46
- eventName: string;
47
- /** Evaluation properties */
48
- properties: Record<string, unknown>;
49
- }
50
- /**
51
- * Feature flag definition.
52
- */
53
- export interface FlagDefinition {
54
- /** Flag key */
55
- flagKey: string;
56
- /** Flag name */
57
- name: string;
58
- /** Description */
59
- description?: string;
60
- /** Flag type */
61
- type: 'boolean' | 'string' | 'number' | 'json';
62
- /** Default value */
63
- defaultValue: boolean | string | number | Record<string, unknown>;
64
- /** Variants (for multivariate flags) */
65
- variants?: Array<{
66
- key: string;
67
- value: boolean | string | number | Record<string, unknown>;
68
- weight?: number;
69
- }>;
70
- /** Targeting rules */
71
- targeting?: {
72
- rules: Array<{
73
- attribute: string;
74
- operator: 'equals' | 'contains' | 'in' | 'gt' | 'lt';
75
- value: unknown;
76
- variant: string;
77
- }>;
78
- };
79
- /** Rollout percentage (0-100) */
80
- rolloutPercentage?: number;
81
- }
82
- /**
83
- * Flag evaluation configuration.
84
- */
85
- export interface FlagEvaluationConfig {
86
- /** Flag key */
87
- flagKey: string;
88
- /** User ID */
89
- userId?: string;
90
- /** Evaluation context */
91
- context?: Record<string, unknown>;
92
- /** Evaluated variant/value */
93
- result: boolean | string | number | Record<string, unknown>;
94
- /** Reason for evaluation result */
95
- reason?: 'default' | 'targeting' | 'rollout' | 'override' | 'error';
96
- /** Evaluation duration (ms) */
97
- duration?: number;
98
- }
99
- /**
100
- * Feature flag response.
101
- */
102
- export interface FlagResponse {
103
- eventName: string;
104
- properties: Record<string, unknown>;
105
- response: {
106
- tracked: boolean;
107
- flagKey?: string;
108
- };
109
- timestamp: string;
110
- }
111
- /**
112
- * Single flag analytics.
113
- */
114
- export interface FlagAnalyticsData {
115
- /** Flag info */
116
- flag: {
117
- flagKey: string;
118
- name: string;
119
- type: string;
120
- status: 'active' | 'inactive' | 'archived';
121
- createdAt: string;
122
- lastModified: string;
123
- };
124
- /** Evaluation stats */
125
- evaluations: {
126
- total: number;
127
- uniqueUsers: number;
128
- avgDuration: number;
129
- errorRate: number;
130
- };
131
- /** Results by variant */
132
- byVariant: Array<{
133
- variant: string;
134
- evaluations: number;
135
- uniqueUsers: number;
136
- percentage: number;
137
- }>;
138
- /** Results by reason */
139
- byReason: Record<string, number>;
140
- /** Trends */
141
- trends: TimeSeriesData;
142
- }
143
- /**
144
- * All flags analytics.
145
- */
146
- export interface AllFlagsAnalyticsData {
147
- /** Summary */
148
- summary: {
149
- totalFlags: number;
150
- activeFlags: number;
151
- totalEvaluations: number;
152
- uniqueUsers: number;
153
- avgEvaluationsPerUser: number;
154
- };
155
- /** Top flags by evaluations */
156
- topFlags: Array<{
157
- flagKey: string;
158
- name: string;
159
- evaluations: number;
160
- uniqueUsers: number;
161
- rolloutPercentage: number;
162
- }>;
163
- /** Stale flags (not evaluated recently) */
164
- staleFlags: Array<{
165
- flagKey: string;
166
- name: string;
167
- lastEvaluated: string;
168
- daysSinceEvaluation: number;
169
- }>;
170
- /** Flags by status */
171
- byStatus: {
172
- active: number;
173
- inactive: number;
174
- archived: number;
175
- };
176
- }
177
- /**
178
- * FeatureFlag - Track feature flag evaluations.
179
- *
180
- * @extends FTRPC
181
- *
182
- * @description
183
- * Provides feature flag tracking including:
184
- * - Flag evaluations
185
- * - Rollout monitoring
186
- * - Flag definitions
187
- * - Usage analytics
188
- * - Stale flag detection
189
- *
190
- * @example
191
- * ```typescript
192
- * const featureFlag = new FeatureFlag(webId, endpoint, apiKey);
193
- *
194
- * // Track evaluation
195
- * await featureFlag.trackEvaluation({
196
- * flagKey: 'new_checkout',
197
- * userId: 'user_123',
198
- * result: true,
199
- * reason: 'rollout'
200
- * });
201
- *
202
- * // Get flag analytics
203
- * const analytics = await featureFlag.getFlagAnalytics('new_checkout');
204
- * console.log(`${analytics.evaluations.total} evaluations`);
205
- * ```
206
- */
207
- export declare class FeatureFlag extends FTRPC {
208
- /**
209
- * Evaluates and tracks a feature flag.
210
- *
211
- * @param config - Flag configuration
212
- * @returns Promise resolving to flag response
213
- */
214
- evaluate(config: FlagConfig): Promise<FlagResponse>;
215
- /**
216
- * Tracks a flag evaluation with details.
217
- *
218
- * @param config - Flag evaluation configuration
219
- * @returns Promise resolving to flag response
220
- */
221
- trackEvaluation(config: FlagEvaluationConfig): Promise<FlagResponse>;
222
- /**
223
- * Defines/updates a feature flag.
224
- *
225
- * @param definition - Flag definition
226
- * @returns Promise resolving to flag response
227
- */
228
- define(definition: FlagDefinition): Promise<FlagResponse>;
229
- /**
230
- * Tracks flag status change (enable/disable).
231
- *
232
- * @param flagKey - Flag key
233
- * @param enabled - Whether flag is enabled
234
- * @param changedBy - User who made the change
235
- * @returns Promise resolving to flag response
236
- */
237
- trackStatusChange(flagKey: string, enabled: boolean, changedBy?: string): Promise<FlagResponse>;
238
- /**
239
- * Tracks rollout percentage change.
240
- *
241
- * @param flagKey - Flag key
242
- * @param previousPercentage - Previous rollout %
243
- * @param newPercentage - New rollout %
244
- * @param changedBy - User who made the change
245
- * @returns Promise resolving to flag response
246
- */
247
- trackRolloutChange(flagKey: string, previousPercentage: number, newPercentage: number, changedBy?: string): Promise<FlagResponse>;
248
- }
249
- export default FeatureFlag;
@@ -1 +0,0 @@
1
- export declare function _0x7777(): string;