@shiva004/surveys 0.7.0 → 0.9.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/dist/App.d.ts +1 -0
- package/dist/errortracking/ErrorTrackingApp.d.ts +7 -0
- package/dist/errortracking/data.d.ts +112 -0
- package/dist/events/data.d.ts +6 -0
- package/dist/flags/FlagsApp.d.ts +9 -0
- package/dist/flags/controls.d.ts +13 -0
- package/dist/flags/data.d.ts +172 -0
- package/dist/flags/icons.d.ts +40 -0
- package/dist/flags/targeting-ui.d.ts +16 -0
- package/dist/flags/targeting.d.ts +93 -0
- package/dist/index.d.ts +46 -3
- package/dist/index.js +9957 -4939
- package/dist/livelogs/LiveLogsApp.d.ts +7 -0
- package/dist/livelogs/data.d.ts +47 -0
- package/dist/logs/EnvPanel.d.ts +2 -1
- package/dist/logs/data.d.ts +8 -0
- package/dist/mockapi/MockApiApp.d.ts +7 -0
- package/dist/mockapi/data.d.ts +116 -0
- package/dist/notifications/NotificationsApp.d.ts +10 -0
- package/dist/notifications/data.d.ts +112 -0
- package/dist/queues/QueuesApp.d.ts +9 -0
- package/dist/queues/charts.d.ts +12 -0
- package/dist/queues/data.d.ts +136 -0
- package/dist/ratelimit/RateLimitApp.d.ts +8 -0
- package/dist/ratelimit/data.d.ts +147 -0
- package/dist/ratelimit/limiter.d.ts +29 -0
- package/dist/recorder/capture.d.ts +30 -0
- package/dist/recorder/db.d.ts +6 -0
- package/dist/recorder/recorder.d.ts +45 -0
- package/dist/releases/ReleasesApp.d.ts +10 -0
- package/dist/releases/data.d.ts +107 -0
- package/dist/sessions/SessionsApp.d.ts +10 -0
- package/dist/sessions/data.d.ts +64 -0
- package/dist/store.d.ts +43 -0
- package/dist/style.css +1 -1
- package/dist/ui.d.ts +60 -0
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { type LinkStatus } from '../store';
|
|
2
|
+
export type IssueStatus = 'unresolved' | 'resolved' | 'ignored';
|
|
3
|
+
export declare const ISSUE_STATUSES: IssueStatus[];
|
|
4
|
+
/** runtime = uncaught error / unhandled rejection, console = console.error, network = failed fetch, remote = your backend, anything else = a logger name or the `source` you pass to captureError(). */
|
|
5
|
+
export type IssueSource = string;
|
|
6
|
+
export interface Occurrence {
|
|
7
|
+
ts: number;
|
|
8
|
+
page: string;
|
|
9
|
+
http?: number;
|
|
10
|
+
traceId?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Issue {
|
|
13
|
+
id: string;
|
|
14
|
+
/** Error message without the type prefix. */
|
|
15
|
+
title: string;
|
|
16
|
+
/** TypeError, RangeError, UnhandledRejection, HTTP 500, ConsoleError ... */
|
|
17
|
+
type: string;
|
|
18
|
+
source: IssueSource;
|
|
19
|
+
status: IssueStatus;
|
|
20
|
+
count: number;
|
|
21
|
+
firstSeen: number;
|
|
22
|
+
lastSeen: number;
|
|
23
|
+
/** Page (path) of the latest occurrence. */
|
|
24
|
+
page: string;
|
|
25
|
+
stack?: string;
|
|
26
|
+
/** Latest occurrences, newest first. */
|
|
27
|
+
occurrences: Occurrence[];
|
|
28
|
+
/** Came back after being resolved. */
|
|
29
|
+
regressed: boolean;
|
|
30
|
+
resolvedAt?: number;
|
|
31
|
+
release?: string;
|
|
32
|
+
/** True for issues loaded from your backend. */
|
|
33
|
+
remote?: boolean;
|
|
34
|
+
tags?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
export interface ErrorInput {
|
|
37
|
+
title: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
source?: IssueSource;
|
|
40
|
+
ts?: number;
|
|
41
|
+
page?: string;
|
|
42
|
+
stack?: string;
|
|
43
|
+
http?: number;
|
|
44
|
+
traceId?: string;
|
|
45
|
+
release?: string;
|
|
46
|
+
tags?: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
export interface ErrorTrackingConfig {
|
|
49
|
+
environment?: string;
|
|
50
|
+
/** Issues kept in memory. Default 300. */
|
|
51
|
+
max?: number;
|
|
52
|
+
/** Occurrences kept per issue. Default 100. */
|
|
53
|
+
maxOccurrences?: number;
|
|
54
|
+
/** localStorage key. Default "et_issues_v1". */
|
|
55
|
+
storageKey?: string;
|
|
56
|
+
/** Release / app version stamped on new issues. */
|
|
57
|
+
release?: string;
|
|
58
|
+
/** Errors whose message matches are not tracked (e.g. /ResizeObserver loop/). */
|
|
59
|
+
ignore?: (string | RegExp)[];
|
|
60
|
+
/** Called after every status change (resolve / ignore / reopen), also for issues from your backend. */
|
|
61
|
+
onStatusChange?: (issue: Issue, status: IssueStatus) => void;
|
|
62
|
+
/** Called for every new issue (first occurrence of an error), e.g. to send an alert. */
|
|
63
|
+
onNewIssue?: (issue: Issue) => void;
|
|
64
|
+
}
|
|
65
|
+
export declare const useErrorTracking: () => {
|
|
66
|
+
issues: Issue[];
|
|
67
|
+
link: LinkStatus;
|
|
68
|
+
};
|
|
69
|
+
export declare const getIssues: () => Issue[];
|
|
70
|
+
export declare const getIssue: (id: string) => Issue | undefined;
|
|
71
|
+
export declare const getErrorEnvironment: (override?: string) => string;
|
|
72
|
+
/** Set once at app start. Every field is optional. */
|
|
73
|
+
export declare const configureErrorTracking: (c?: ErrorTrackingConfig) => void;
|
|
74
|
+
export declare const fingerprint: (e: {
|
|
75
|
+
type: string;
|
|
76
|
+
title: string;
|
|
77
|
+
source: string;
|
|
78
|
+
stack?: string;
|
|
79
|
+
}) => string;
|
|
80
|
+
/** Record one error. Same error again = count + 1 on the same issue. A resolved issue that happens again is reopened and flagged as regressed. */
|
|
81
|
+
export declare const recordError: (e: ErrorInput) => Issue | null;
|
|
82
|
+
/** Report an error you caught yourself: `try { ... } catch (e) { captureError(e, { source: 'checkout' }) }`. */
|
|
83
|
+
export declare const captureError: (err: unknown, ctx?: {
|
|
84
|
+
source?: string;
|
|
85
|
+
tags?: Record<string, string>;
|
|
86
|
+
http?: number;
|
|
87
|
+
traceId?: string;
|
|
88
|
+
}) => Issue | null;
|
|
89
|
+
export declare const setIssueStatus: (id: string, status: IssueStatus) => void;
|
|
90
|
+
export declare const resolveIssue: (id: string) => void;
|
|
91
|
+
export declare const ignoreIssue: (id: string) => void;
|
|
92
|
+
export declare const reopenIssue: (id: string) => void;
|
|
93
|
+
export declare const deleteIssue: (id: string) => void;
|
|
94
|
+
export declare const clearIssues: () => void;
|
|
95
|
+
/** Track this app's errors. Logger lines include uncaught errors and unhandled rejections, so each error is seen once. Safe to call twice. */
|
|
96
|
+
export declare const startLocalErrorTracking: () => (() => void);
|
|
97
|
+
/** Turn one issue from a backend into an Issue. Accepts the usual names (title/message, first_seen/firstSeen, events/count ...). */
|
|
98
|
+
export declare const toRemoteIssue: (raw: unknown) => Issue | null;
|
|
99
|
+
export interface ErrorTrackingConnection {
|
|
100
|
+
/** JSON endpoint: an array of issues, or `{ "issues": [] }`. */
|
|
101
|
+
url: string;
|
|
102
|
+
pollMs?: number;
|
|
103
|
+
headers?: Record<string, string>;
|
|
104
|
+
/** How resolve / ignore / reopen reach your backend. PATCH sends `{ status }` to `url/<id>`; PUT and POST send `{ id, status }` to `url`. Default "none": the backend stays read-only. */
|
|
105
|
+
statusMethod?: 'PATCH' | 'PUT' | 'POST' | 'none';
|
|
106
|
+
}
|
|
107
|
+
/** Load issues from your backend every few seconds. Returns a function that disconnects. */
|
|
108
|
+
export declare const connectErrorTracking: (o: ErrorTrackingConnection) => (() => void);
|
|
109
|
+
/** Pull the backend now (the Refresh button). */
|
|
110
|
+
export declare const refreshErrorTracking: () => void | undefined;
|
|
111
|
+
/** Occurrences per bucket, oldest first, for the trend bars. */
|
|
112
|
+
export declare const trend: (i: Issue, buckets?: number, bucketMs?: number, now?: number) => number[];
|
package/dist/events/data.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export interface CaptureOptions {
|
|
|
64
64
|
errors?: boolean;
|
|
65
65
|
network?: boolean;
|
|
66
66
|
visibility?: boolean;
|
|
67
|
+
/** Fetch calls whose URL matches are not reported as api_request (string = substring, RegExp = test). The ingestion endpoint itself is always skipped. */
|
|
68
|
+
ignoreUrls?: Array<string | RegExp>;
|
|
67
69
|
/** Forward logger lines (console.* and logger.*) as events. Default: ERROR + WARN only. */
|
|
68
70
|
logs?: boolean | {
|
|
69
71
|
levels?: Level[];
|
|
@@ -77,7 +79,11 @@ export interface RemoteEvent {
|
|
|
77
79
|
userId?: string;
|
|
78
80
|
properties?: Record<string, unknown>;
|
|
79
81
|
}
|
|
82
|
+
/** Be told about every event as it is recorded (Live Logs and Sessions use this). Returns an unsubscribe function. */
|
|
83
|
+
export declare const onIngestEvent: (fn: (e: IngestEvent) => void) => () => void;
|
|
80
84
|
export declare const configureIngestion: (c: IngestionConfig) => void;
|
|
85
|
+
/** Current user id (anonymous id until identify() is called). */
|
|
86
|
+
export declare const getUserId: () => string;
|
|
81
87
|
export declare const identify: (id: string) => void;
|
|
82
88
|
/** Send one event into the pipeline. Returns the event id. */
|
|
83
89
|
export declare const trackEvent: (name: string, properties?: Record<string, unknown>, opts?: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './flags.css';
|
|
3
|
+
export interface FlagsAppProps {
|
|
4
|
+
/** Called when the user clicks "Open Live Events". */
|
|
5
|
+
onOpenEvents?: () => void;
|
|
6
|
+
/** Overrides the project name (otherwise the one passed to configureFlags, default "checkout"). */
|
|
7
|
+
project?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const FlagsApp: React.FC<FlagsAppProps>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const Switch: React.FC<{
|
|
3
|
+
on: boolean;
|
|
4
|
+
label: string;
|
|
5
|
+
onChange: () => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
/** Range input that only commits when the user releases it (one event per change, not one per pixel). */
|
|
9
|
+
export declare const RolloutSlider: React.FC<{
|
|
10
|
+
value: number;
|
|
11
|
+
onCommit: (n: number) => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { type Condition, type Context, type Match, type Rule, type RuleServe, type Segment } from './targeting';
|
|
2
|
+
export type Env = 'production' | 'staging' | 'development';
|
|
3
|
+
export declare const ENVS: Env[];
|
|
4
|
+
export type FlagKind = 'release' | 'experiment' | 'ops' | 'permission';
|
|
5
|
+
export declare const KINDS: FlagKind[];
|
|
6
|
+
export declare const FLAG_SOURCE = "flags";
|
|
7
|
+
export interface EnvState {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
rollout: number;
|
|
10
|
+
}
|
|
11
|
+
export interface HistoryItem {
|
|
12
|
+
ts: number;
|
|
13
|
+
actor: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
export type ScheduleAction = 'enable' | 'disable' | 'rollout';
|
|
17
|
+
export type ExpiryAction = 'archive' | 'disable';
|
|
18
|
+
/** A change that is applied automatically at a future time. */
|
|
19
|
+
export interface Schedule {
|
|
20
|
+
id: string;
|
|
21
|
+
env: Env;
|
|
22
|
+
action: ScheduleAction;
|
|
23
|
+
rollout?: number;
|
|
24
|
+
at: number;
|
|
25
|
+
}
|
|
26
|
+
export interface Flag {
|
|
27
|
+
key: string;
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
kind: FlagKind;
|
|
31
|
+
owner: string;
|
|
32
|
+
archived: boolean;
|
|
33
|
+
createdAt: number;
|
|
34
|
+
updatedAt: number;
|
|
35
|
+
envs: Record<Env, EnvState>;
|
|
36
|
+
history: HistoryItem[];
|
|
37
|
+
/** Draft: saved but not live. Evaluates as off until published. */
|
|
38
|
+
draft?: boolean;
|
|
39
|
+
/** Temporary flag: when this time passes, `expiryAction` is applied automatically. */
|
|
40
|
+
expiresAt?: number;
|
|
41
|
+
expiryAction?: ExpiryAction;
|
|
42
|
+
schedules?: Schedule[];
|
|
43
|
+
/** Targeting rules, checked top to bottom after the environment switch. First match wins. */
|
|
44
|
+
rules?: Rule[];
|
|
45
|
+
}
|
|
46
|
+
/** Host-app configuration (set once via configureFlags before rendering FlagsApp). */
|
|
47
|
+
export interface FlagsConfig {
|
|
48
|
+
/** Project name shown in the page and attached to every event. Default "checkout". */
|
|
49
|
+
project?: string;
|
|
50
|
+
/** Flags to start with when nothing is stored yet. Default: none (use demoFlags() for the built-in demo set). */
|
|
51
|
+
initialFlags?: Flag[];
|
|
52
|
+
/** Environment used by isFeatureEnabled() when none is passed. Default "production". */
|
|
53
|
+
environment?: Env;
|
|
54
|
+
/** localStorage key used for persistence. Default "ff_<project>_v1". */
|
|
55
|
+
storageKey?: string;
|
|
56
|
+
/** A flag with no change for this many days counts as stale. Default 30. */
|
|
57
|
+
staleAfterDays?: number;
|
|
58
|
+
/** Name recorded in the history of changes. Default "you". */
|
|
59
|
+
actor?: string;
|
|
60
|
+
/** Called after every change, e.g. to sync flags to your backend. */
|
|
61
|
+
onChange?: (flags: Flag[]) => void;
|
|
62
|
+
/** Segments to start with when nothing is stored yet. Default: none. */
|
|
63
|
+
initialSegments?: Segment[];
|
|
64
|
+
}
|
|
65
|
+
export declare const getProject: () => string;
|
|
66
|
+
interface Snapshot {
|
|
67
|
+
flags: Flag[];
|
|
68
|
+
version: number;
|
|
69
|
+
}
|
|
70
|
+
/** The built-in checkout demo flags. Pass to configureFlags({ initialFlags: demoFlags() }) for a demo. */
|
|
71
|
+
export declare const demoFlags: () => Flag[];
|
|
72
|
+
/**
|
|
73
|
+
* Configure the flag store for your project. Call once at app start, before rendering FlagsApp.
|
|
74
|
+
* Stored flags (localStorage) win over `initialFlags`.
|
|
75
|
+
*/
|
|
76
|
+
export declare const configureFlags: (c: FlagsConfig) => void;
|
|
77
|
+
export declare const useFlags: () => Snapshot;
|
|
78
|
+
export declare const getFlags: () => Flag[];
|
|
79
|
+
export declare const getFlag: (key: string) => Flag | undefined;
|
|
80
|
+
export declare const toggleFlag: (key: string, env: Env) => void;
|
|
81
|
+
export declare const setRollout: (key: string, env: Env, rollout: number) => void;
|
|
82
|
+
export declare const KEY_RE: RegExp;
|
|
83
|
+
export declare const createFlag: (input: {
|
|
84
|
+
key: string;
|
|
85
|
+
name: string;
|
|
86
|
+
kind: FlagKind;
|
|
87
|
+
description: string;
|
|
88
|
+
draft?: boolean;
|
|
89
|
+
}) => string | null;
|
|
90
|
+
export declare const setArchived: (key: string, archived: boolean) => void;
|
|
91
|
+
/** Turn a flag off in every environment at once. */
|
|
92
|
+
export declare const killFlag: (key: string) => void;
|
|
93
|
+
export declare const resetFlags: () => void;
|
|
94
|
+
export declare const getStaleAfterDays: () => number;
|
|
95
|
+
/** Live flag with no change for `staleAfterDays` days: a candidate for cleanup. */
|
|
96
|
+
export declare const isStale: (f: Flag, now?: number) => boolean;
|
|
97
|
+
/** Make a draft live (still off in every environment until you switch it on). */
|
|
98
|
+
export declare const publishFlag: (key: string) => void;
|
|
99
|
+
/** Delete a draft for good. Live flags cannot be deleted, only archived. */
|
|
100
|
+
export declare const deleteFlag: (key: string) => void;
|
|
101
|
+
export declare const scheduleChange: (key: string, input: {
|
|
102
|
+
env: Env;
|
|
103
|
+
action: ScheduleAction;
|
|
104
|
+
rollout?: number;
|
|
105
|
+
at: number;
|
|
106
|
+
}) => string | null;
|
|
107
|
+
export declare const cancelSchedule: (key: string, id: string) => void;
|
|
108
|
+
export declare const describeSchedule: (s: Schedule) => string;
|
|
109
|
+
/** Make a flag temporary (expires at `at`), or pass null to make it permanent again. */
|
|
110
|
+
export declare const setExpiration: (key: string, at: number | null, action?: ExpiryAction) => string | null;
|
|
111
|
+
/** Apply scheduled changes and expirations that are due. Returns how many were applied. FlagsApp calls this every 15 s. */
|
|
112
|
+
export declare const runDue: () => number;
|
|
113
|
+
/** Add a rule (rule.id empty) or replace an existing one. Returns an error message, or null on success. */
|
|
114
|
+
export declare const saveRule: (key: string, input: {
|
|
115
|
+
id?: string;
|
|
116
|
+
name: string;
|
|
117
|
+
match: Match;
|
|
118
|
+
conditions: Condition[];
|
|
119
|
+
serve: RuleServe;
|
|
120
|
+
rollout: number;
|
|
121
|
+
}) => string | null;
|
|
122
|
+
export declare const deleteRule: (key: string, id: string) => void;
|
|
123
|
+
/** Rules run top to bottom, so order matters. */
|
|
124
|
+
export declare const moveRule: (key: string, id: string, dir: -1 | 1) => void;
|
|
125
|
+
/** Flags (by key) whose rules point at this segment. */
|
|
126
|
+
export declare const segmentUsage: (segKey: string) => Flag[];
|
|
127
|
+
/** How many rules and segments use this attribute. */
|
|
128
|
+
export declare const attributeUsage: (attr: string) => {
|
|
129
|
+
rules: number;
|
|
130
|
+
segments: number;
|
|
131
|
+
};
|
|
132
|
+
/** Delete a segment unless a flag rule still uses it. Returns an error message, or null. */
|
|
133
|
+
export declare const deleteSegment: (key: string) => string | null;
|
|
134
|
+
/** Delete a custom attribute unless a rule or segment still uses it. Returns an error message, or null. */
|
|
135
|
+
export declare const deleteAttribute: (key: string) => string | null;
|
|
136
|
+
/** Stable 0–99 bucket for a user within a flag. */
|
|
137
|
+
export declare const bucketOf: (key: string, userId: string) => number;
|
|
138
|
+
export interface Evaluation {
|
|
139
|
+
enabled: boolean;
|
|
140
|
+
reason: string;
|
|
141
|
+
bucket: number; /** Name of the targeting rule that decided, if any. */
|
|
142
|
+
rule?: string;
|
|
143
|
+
}
|
|
144
|
+
export declare const evaluate: (key: string, userId: string, env?: Env, ctx?: Context) => Evaluation;
|
|
145
|
+
/**
|
|
146
|
+
* Read a flag from your app code. Emits a deduplicated "flag_evaluated" event
|
|
147
|
+
* (once per flag + user + result per session) into the live ingestion pipeline.
|
|
148
|
+
*/
|
|
149
|
+
export declare const isFeatureEnabled: (key: string, userId?: string, env?: Env, ctx?: Context) => boolean;
|
|
150
|
+
/** Evaluation from the admin page: always emits, so every test shows up live. */
|
|
151
|
+
export declare const testEvaluate: (key: string, userId: string, env: Env, ctx?: Context) => Evaluation;
|
|
152
|
+
export interface FlagsConnection {
|
|
153
|
+
/** GET returns the flags (an array, or { flags: [...] }). Local changes are sent back to the same URL. */
|
|
154
|
+
url: string;
|
|
155
|
+
headers?: Record<string, string>;
|
|
156
|
+
/** How often to pull the latest flags. Default 10 000 ms. Use 0 to pull once. */
|
|
157
|
+
pollMs?: number;
|
|
158
|
+
/** HTTP method used to save local changes. Default "PUT". Use "none" for read-only. */
|
|
159
|
+
saveMethod?: 'PUT' | 'POST' | 'none';
|
|
160
|
+
}
|
|
161
|
+
export interface LiveStatus {
|
|
162
|
+
state: 'off' | 'connecting' | 'live' | 'error';
|
|
163
|
+
at: number;
|
|
164
|
+
error: string;
|
|
165
|
+
}
|
|
166
|
+
export declare const useFlagsLive: () => LiveStatus;
|
|
167
|
+
/**
|
|
168
|
+
* Use real flags from your backend: pulls on start and every `pollMs`, and saves each local change.
|
|
169
|
+
* Returns a function that stops syncing.
|
|
170
|
+
*/
|
|
171
|
+
export declare const connectFlags: (o: FlagsConnection) => (() => void);
|
|
172
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const P: {
|
|
3
|
+
readonly flag: "M5 21V4 M5 4h11l-2 4 2 4H5";
|
|
4
|
+
readonly plus: "M12 5v14 M5 12h14";
|
|
5
|
+
readonly user: "M12 12a4 4 0 100-8 4 4 0 000 8z M4 21c0-4 3.5-6 8-6s8 2 8 6";
|
|
6
|
+
readonly draft: "M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z M14 3v5h5 M9 14h6";
|
|
7
|
+
readonly schedule: "M4 6h16v14H4z M4 10h16 M8 3v4 M16 3v4 M12 13v3l2 1";
|
|
8
|
+
readonly folder: "M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2z";
|
|
9
|
+
readonly folderPlus: "M3 7a2 2 0 012-2h4l2 2h8a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2z M12 11v6 M9 14h6";
|
|
10
|
+
readonly timer: "M10 2h4 M12 14l3-3 M12 22a8 8 0 100-16 8 8 0 000 16z";
|
|
11
|
+
readonly hourglass: "M6 2h12 M6 22h12 M7 2v4l5 6-5 6v4 M17 2v4l-5 6 5 6v4";
|
|
12
|
+
readonly owner: "M12 12a4 4 0 100-8 4 4 0 000 8z M4 21c0-4 3.5-6 8-6 M16 19l2 2 4-4";
|
|
13
|
+
readonly assign: "M12 12a4 4 0 100-8 4 4 0 000 8z M4 21c0-4 3.5-6 8-6 M19 8v6 M16 11h6";
|
|
14
|
+
readonly clock: "M12 22a10 10 0 100-20 10 10 0 000 20z M12 6v6l4 2";
|
|
15
|
+
readonly alert: "M12 3l10 18H2z M12 10v5 M12 18h.01";
|
|
16
|
+
readonly layers: "M12 3l9 5-9 5-9-5z M3 13l9 5 9-5 M3 17l9 5 9-5";
|
|
17
|
+
readonly trending: "M3 17l6-6 4 4 8-8 M15 7h6v6";
|
|
18
|
+
readonly archive: "M3 4h18v4H3z M5 8v12h14V8 M10 12h4";
|
|
19
|
+
readonly audit: "M14 3H7a2 2 0 00-2 2v14a2 2 0 002 2h10a2 2 0 002-2V8z M14 3v5h5 M9 13h6 M9 17h4";
|
|
20
|
+
readonly bookmark: "M6 3h12v18l-6-4-6 4z";
|
|
21
|
+
readonly users: "M9 11a3.5 3.5 0 100-7 3.5 3.5 0 000 7z M2 20c0-3.5 3-5.5 7-5.5s7 2 7 5.5 M17 4.5a3.5 3.5 0 010 7 M18 14.8c2.4.6 4 2.3 4 5.2";
|
|
22
|
+
readonly x: "M6 6l12 12 M18 6L6 18";
|
|
23
|
+
readonly search: "M11 19a8 8 0 100-16 8 8 0 000 16z M21 21l-4.3-4.3";
|
|
24
|
+
readonly menu: "M4 6h16 M4 12h16 M4 18h16";
|
|
25
|
+
readonly rule: "M6 3v12 M6 15a3 3 0 100 6 3 3 0 000-6z M18 3a3 3 0 100 6 3 3 0 000-6z M18 9c0 6-12 3-12 6";
|
|
26
|
+
readonly percent: "M19 5L5 19 M7 9a2 2 0 100-4 2 2 0 000 4z M17 19a2 2 0 100-4 2 2 0 000 4z";
|
|
27
|
+
readonly attrs: "M12 12a4 4 0 100-8 4 4 0 000 8z M4 21c0-4 3.5-6 8-6 M18 14v4 M16 16h4";
|
|
28
|
+
readonly segments: "M12 3l9 5-9 5-9-5z M3 13l9 5 9-5 M3 17l9 5 9-5";
|
|
29
|
+
readonly segmentPlus: "M12 5v14 M5 12h14";
|
|
30
|
+
readonly target: "M12 21a9 9 0 100-18 9 9 0 000 18z M12 16a4 4 0 100-8 4 4 0 000 8z M12 12h.01";
|
|
31
|
+
readonly trash: "M4 7h16 M9 7V4h6v3 M6 7l1 13h10l1-13";
|
|
32
|
+
readonly up: "M12 19V5 M6 11l6-6 6 6";
|
|
33
|
+
readonly down: "M12 5v14 M6 13l6 6 6-6";
|
|
34
|
+
};
|
|
35
|
+
export type IconName = keyof typeof P;
|
|
36
|
+
export declare const Icon: React.FC<{
|
|
37
|
+
name: IconName;
|
|
38
|
+
size?: number;
|
|
39
|
+
}>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconName } from './icons';
|
|
3
|
+
export type TPage = 'rules' | 'rollouts' | 'attributes' | 'add-attribute' | 'segments' | 'create-segment';
|
|
4
|
+
export type PageKey = 'flags' | TPage;
|
|
5
|
+
export declare const SIDEBAR: {
|
|
6
|
+
title: string;
|
|
7
|
+
items: {
|
|
8
|
+
id: PageKey;
|
|
9
|
+
label: string;
|
|
10
|
+
icon: IconName;
|
|
11
|
+
}[];
|
|
12
|
+
}[];
|
|
13
|
+
export declare const TargetingPages: React.FC<{
|
|
14
|
+
page: TPage;
|
|
15
|
+
go: (p: PageKey) => void;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type AttrType = 'string' | 'number' | 'boolean';
|
|
2
|
+
export interface Attribute {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: AttrType;
|
|
6
|
+
description: string;
|
|
7
|
+
builtin?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** `attr` of a condition that asks "is the user in this segment?" (value = segment key). */
|
|
10
|
+
export declare const SEGMENT_ATTR = "$segment";
|
|
11
|
+
export type Op = 'is' | 'is_not' | 'contains' | 'starts_with' | 'one_of' | 'gt' | 'gte' | 'lt' | 'lte' | 'in_segment' | 'not_in_segment';
|
|
12
|
+
export interface Condition {
|
|
13
|
+
attr: string;
|
|
14
|
+
op: Op;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export type Match = 'all' | 'any';
|
|
18
|
+
export declare const OP_LABEL: Record<Op, string>;
|
|
19
|
+
export declare const OPS_FOR: Record<AttrType | 'segment', Op[]>;
|
|
20
|
+
export interface Segment {
|
|
21
|
+
key: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
match: Match;
|
|
25
|
+
conditions: Condition[];
|
|
26
|
+
/** User ids that are always in the segment. */
|
|
27
|
+
included: string[];
|
|
28
|
+
/** User ids that are never in the segment (wins over everything else). */
|
|
29
|
+
excluded: string[];
|
|
30
|
+
createdAt: number;
|
|
31
|
+
updatedAt: number;
|
|
32
|
+
createdBy: string;
|
|
33
|
+
}
|
|
34
|
+
export type RuleServe = 'on' | 'off';
|
|
35
|
+
export interface Rule {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
match: Match;
|
|
39
|
+
conditions: Condition[];
|
|
40
|
+
serve: RuleServe; /** % of matching users served `on` (0-100). */
|
|
41
|
+
rollout: number;
|
|
42
|
+
}
|
|
43
|
+
/** What your app knows about the current user, e.g. { country: 'IN', plan: 'pro' }. `id` is added for you. */
|
|
44
|
+
export type Context = Record<string, string | number | boolean | null | undefined>;
|
|
45
|
+
export declare const ATTR_RE: RegExp;
|
|
46
|
+
export declare const SEGMENT_RE: RegExp;
|
|
47
|
+
export declare const BUILTIN_ATTRIBUTES: Attribute[];
|
|
48
|
+
interface Snapshot {
|
|
49
|
+
custom: Attribute[];
|
|
50
|
+
segments: Segment[];
|
|
51
|
+
attributes: Attribute[];
|
|
52
|
+
version: number;
|
|
53
|
+
}
|
|
54
|
+
export declare const parseList: (text: string) => string[];
|
|
55
|
+
/** Called by configureFlags(). Stored data (localStorage) wins over `segments`. */
|
|
56
|
+
export declare const configureTargeting: (c: {
|
|
57
|
+
storageKey?: string;
|
|
58
|
+
actor?: string;
|
|
59
|
+
segments?: Segment[];
|
|
60
|
+
}) => void;
|
|
61
|
+
export declare const useTargeting: () => Snapshot;
|
|
62
|
+
export declare const getSegments: () => Segment[];
|
|
63
|
+
export declare const getSegment: (key: string) => Segment | undefined;
|
|
64
|
+
export declare const getAttributes: () => Attribute[];
|
|
65
|
+
/** Returns an error message, or null when the conditions can be saved. */
|
|
66
|
+
export declare const validateConditions: (conds: Condition[], allowSegments: boolean) => string | null;
|
|
67
|
+
export declare const segmentMatches: (seg: Segment, ctx: Context) => boolean;
|
|
68
|
+
export declare const conditionMatches: (c: Condition, ctx: Context) => boolean;
|
|
69
|
+
export declare const ruleMatches: (r: Pick<Rule, "match" | "conditions">, ctx: Context) => boolean;
|
|
70
|
+
/** "country=IN, plan=pro" (commas or new lines) -> { country: 'IN', plan: 'pro' }. */
|
|
71
|
+
export declare const parseContext: (text: string) => Context;
|
|
72
|
+
export declare const describeCondition: (c: Condition) => string;
|
|
73
|
+
export declare const addAttribute: (input: {
|
|
74
|
+
key: string;
|
|
75
|
+
label: string;
|
|
76
|
+
type: AttrType;
|
|
77
|
+
description: string;
|
|
78
|
+
}) => string | null;
|
|
79
|
+
export declare const removeAttribute: (key: string) => void;
|
|
80
|
+
/** Create (editing = null) or update a segment. Returns an error message, or null on success. */
|
|
81
|
+
export declare const saveSegment: (input: {
|
|
82
|
+
key: string;
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
match: Match;
|
|
86
|
+
conditions: Condition[];
|
|
87
|
+
included: string[];
|
|
88
|
+
excluded: string[];
|
|
89
|
+
}, editing: string | null) => string | null;
|
|
90
|
+
export declare const removeSegment: (key: string) => void;
|
|
91
|
+
/** Example segments for the demo flags. Pass to configureFlags({ initialSegments: demoSegments() }). */
|
|
92
|
+
export declare const demoSegments: () => Segment[];
|
|
93
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,60 @@
|
|
|
1
1
|
import './styles.css';
|
|
2
2
|
export { App as LogsFeedbackApp } from './App';
|
|
3
3
|
export { LogsApp } from './logs/LogsApp';
|
|
4
|
-
export { createLogger, logger } from './logs/data';
|
|
5
|
-
export type { Logger, WrapOptions } from './logs/data';
|
|
4
|
+
export { createLogger, logger, configureLogs } from './logs/data';
|
|
5
|
+
export type { Logger, WrapOptions, LogsConfig } from './logs/data';
|
|
6
6
|
export { FeedbackApp } from './feedback/FeedbackApp';
|
|
7
7
|
export type { FeedbackAppProps, FeedbackResponse } from './feedback/FeedbackApp';
|
|
8
8
|
export * from './walkthrough';
|
|
9
9
|
export { getNetworkInfo, setNetworkName, refreshNetwork, setPublicLookup, isPublicLookupEnabled, formatLocalTime, } from './logs/environment';
|
|
10
10
|
export { HeatmapApp } from './heatmap/HeatmapApp';
|
|
11
11
|
export { IngestionApp } from './events/IngestionApp';
|
|
12
|
-
export { startEventCapture, trackEvent, ingestRemote, identify, configureIngestion, useIngestion, getIngestionSnapshot, } from './events/data';
|
|
12
|
+
export { startEventCapture, trackEvent, ingestRemote, identify, getUserId, configureIngestion, useIngestion, getIngestionSnapshot, setPaused as setIngestionPaused, resetIngestion, } from './events/data';
|
|
13
13
|
export type { IngestionConfig, CaptureOptions, RemoteEvent, WireEvent, IngestEvent, IngestStatus } from './events/data';
|
|
14
|
+
export { FlagsApp } from './flags/FlagsApp';
|
|
15
|
+
export type { FlagsAppProps } from './flags/FlagsApp';
|
|
16
|
+
export { configureFlags, isFeatureEnabled, evaluate as evaluateFlag, useFlags, getFlags, getFlag, toggleFlag, setRollout, saveRule as saveFlagRule, deleteRule as deleteFlagRule, createFlag, setArchived, killFlag, resetFlags, demoFlags, bucketOf, connectFlags, useFlagsLive, ENVS as FLAG_ENVS, KINDS as FLAG_KINDS, } from './flags/data';
|
|
17
|
+
export type { Flag, FlagKind, FlagsConfig, FlagsConnection, LiveStatus as FlagsLiveStatus, EnvState as FlagEnvState, Evaluation as FlagEvaluation, Env as FlagEnv } from './flags/data';
|
|
18
|
+
export { useTargeting, getSegments, getSegment, saveSegment, addAttribute as addUserAttribute, BUILTIN_ATTRIBUTES as USER_ATTRIBUTES, demoSegments, } from './flags/targeting';
|
|
19
|
+
export { deleteSegment, deleteAttribute } from './flags/data';
|
|
20
|
+
export type { Segment, Rule as FlagRule, Condition as FlagCondition, Attribute as UserAttribute, Context as FlagContext } from './flags/targeting';
|
|
21
|
+
export { QueuesApp } from './queues/QueuesApp';
|
|
22
|
+
export type { QueuesAppProps } from './queues/QueuesApp';
|
|
23
|
+
export { configureQueues, setQueues, connectQueues, useQueues, createQueue, pauseQueue, resumeQueue, deleteQueue, purgeQueue, redriveDead, deleteDead, quarantineToPoison, releasePoison, dropPoison, restartConsumer, statusOf as queueStatus, } from './queues/data';
|
|
24
|
+
export type { Queue, QueuesConfig, QueuesConnection, QueuesState, QueueAction, QStatus, QKind, Msg as QueueMessage, Consumer as QueueConsumer, Exchange as QueueExchange } from './queues/data';
|
|
25
|
+
export { SessionsApp } from './sessions/SessionsApp';
|
|
26
|
+
export type { SessionsAppProps } from './sessions/SessionsApp';
|
|
27
|
+
export { configureSessions, setSessions, connectSessions, startLocalSession, useSessions, refreshSessions, toggleSaved as toggleSavedSession, deleteSession } from './sessions/data';
|
|
28
|
+
export type { Session, SessionEvent, SessionsConfig, SessionsConnection, Device as SessionDevice } from './sessions/data';
|
|
29
|
+
export { LiveLogsApp } from './livelogs/LiveLogsApp';
|
|
30
|
+
export type { LiveLogsAppProps } from './livelogs/LiveLogsApp';
|
|
31
|
+
export { configureLiveLogs, pushLiveLog, setLivePaused, clearLiveLogs, connectLiveLogs, startLocalLiveLogs, useLiveLogs as useLiveLogStream } from './livelogs/data';
|
|
32
|
+
export type { LiveLog, LiveLevel, LiveLogsConfig, LiveLogsConnection } from './livelogs/data';
|
|
33
|
+
export { RateLimitApp } from './ratelimit/RateLimitApp';
|
|
34
|
+
export type { RateLimitAppProps } from './ratelimit/RateLimitApp';
|
|
35
|
+
export { configureRateLimit, connectRateLimit, refreshRateLimit, startRateLimit, useRateLimit, checkRateLimit, withRateLimit, reportBackendLimit, RateLimitError, createRule as createRateLimitRule, toggleRule as toggleRateLimitRule, deleteRule as deleteRateLimitRule, clearViolations as clearRateLimitViolations, getRules as getRateLimitRules, getViolations as getRateLimitViolations, } from './ratelimit/data';
|
|
36
|
+
export type { Rule as RateLimitRule, Violation as RateLimitViolation, RuleInput as RateLimitRuleInput, RateLimitConfig, RateLimitConnection, CheckInput as RateLimitCheckInput, CheckResult as RateLimitCheckResult, RuleAction as RateLimitAction, RuleScope as RateLimitScope, RuleEnv as RateLimitEnv } from './ratelimit/data';
|
|
37
|
+
export { createLimiter } from './ratelimit/limiter';
|
|
38
|
+
export type { Limiter, LimiterOptions, Decision as LimiterDecision, Strategy as RateLimitStrategy } from './ratelimit/limiter';
|
|
39
|
+
export { ErrorTrackingApp } from './errortracking/ErrorTrackingApp';
|
|
40
|
+
export type { ErrorTrackingAppProps } from './errortracking/ErrorTrackingApp';
|
|
41
|
+
export { configureErrorTracking, connectErrorTracking, refreshErrorTracking, startLocalErrorTracking, useErrorTracking, captureError, recordError, setIssueStatus, resolveIssue, ignoreIssue, reopenIssue, deleteIssue, clearIssues, getIssues, getIssue, } from './errortracking/data';
|
|
42
|
+
export type { Issue, IssueStatus, IssueSource, Occurrence, ErrorInput, ErrorTrackingConfig, ErrorTrackingConnection } from './errortracking/data';
|
|
43
|
+
export { ReleasesApp } from './releases/ReleasesApp';
|
|
44
|
+
export type { ReleasesAppProps } from './releases/ReleasesApp';
|
|
45
|
+
export { configureReleases, connectReleases, refreshReleases, startLocalReleases, useReleases, trackRelease, setReleaseStatus, rollBackRelease, redeployRelease, deleteRelease, clearReleases, getReleases, getRelease, currentOf as currentRelease, previousOf as previousRelease, errorRate as releaseErrorRate, healthOf as releaseHealth, } from './releases/data';
|
|
46
|
+
export type { Release, ReleaseStatus, ReleaseStats, ReleaseError, ReleaseInput, ReleasesConfig, ReleasesConnection, Health as ReleaseHealth } from './releases/data';
|
|
47
|
+
export { NotificationsApp } from './notifications/NotificationsApp';
|
|
48
|
+
export type { NotificationsAppProps } from './notifications/NotificationsApp';
|
|
49
|
+
export { configureNotifications, connectNotifications, refreshNotifications, startLocalNotifications, useNotifications, notify, markNotificationRead, markAllRead, deleteNotification, clearNotifications, getNotifications, unreadCount, setDesktopNotifications, DEFAULT_RULES as DEFAULT_NOTIFICATION_RULES, createRule as createNotificationRule, updateRule as updateNotificationRule, toggleRule as toggleNotificationRule, deleteRule as deleteNotificationRule, resetRules as resetNotificationRules, getRules as getNotificationRules, } from './notifications/data';
|
|
50
|
+
export type { Notification as AppNotification, NotifyInput, Severity as NotificationSeverity, Sample as NotificationSample, Rule as NotificationRule, RuleInput as NotificationRuleInput, RuleKind as NotificationRuleKind, NotificationsConfig, NotificationsConnection } from './notifications/data';
|
|
51
|
+
export { MockApiApp } from './mockapi/MockApiApp';
|
|
52
|
+
export type { MockApiAppProps } from './mockapi/MockApiApp';
|
|
53
|
+
export { configureMockApi, connectMockApi, refreshMockApi, startMockApi, useMockApi, createMock, updateMock, toggleMock, deleteMock, duplicateMock, clearMocks, clearMockHits, setMockApiEnabled, exportMocks, importMocks, getMocks, getMock, getMockHits, matchMock, respondWithMock, fillTemplate, } from './mockapi/data';
|
|
54
|
+
export type { Mock, MockInput, MockHit, MockApiConfig, MockApiConnection, Method as MockMethod } from './mockapi/data';
|
|
14
55
|
export { startHeatmapCapture, clearHeatmap, getHeatmapData } from './heatmap/capture';
|
|
56
|
+
export { start as startSessionReplay, stop as stopSessionReplay, useRecorder } from './recorder/recorder';
|
|
57
|
+
export type { RecMeta, RecNet, RecStore, RecForm, RecLog } from './recorder/recorder';
|
|
15
58
|
export { RouteRecorderWatcher } from './recorder/RouteRecorderWatcher';
|
|
16
59
|
export type { RouteRecorderWatcherProps } from './recorder/RouteRecorderWatcher';
|
|
17
60
|
export type { AppProps } from './App';
|