@shiva004/surveys 0.7.0 → 0.8.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/events/data.d.ts +4 -0
- package/dist/flags/FlagsApp.d.ts +9 -0
- package/dist/flags/data.d.ts +143 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +4598 -3885
- package/dist/logs/EnvPanel.d.ts +2 -1
- package/dist/logs/data.d.ts +8 -0
- package/dist/style.css +1 -1
- package/dist/ui.d.ts +19 -0
- package/package.json +1 -1
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[];
|
|
@@ -78,6 +80,8 @@ export interface RemoteEvent {
|
|
|
78
80
|
properties?: Record<string, unknown>;
|
|
79
81
|
}
|
|
80
82
|
export declare const configureIngestion: (c: IngestionConfig) => void;
|
|
83
|
+
/** Current user id (anonymous id until identify() is called). */
|
|
84
|
+
export declare const getUserId: () => string;
|
|
81
85
|
export declare const identify: (id: string) => void;
|
|
82
86
|
/** Send one event into the pipeline. Returns the event id. */
|
|
83
87
|
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,143 @@
|
|
|
1
|
+
export type Env = 'production' | 'staging' | 'development';
|
|
2
|
+
export declare const ENVS: Env[];
|
|
3
|
+
export type FlagKind = 'release' | 'experiment' | 'ops' | 'permission';
|
|
4
|
+
export declare const KINDS: FlagKind[];
|
|
5
|
+
export declare const FLAG_SOURCE = "flags";
|
|
6
|
+
export interface EnvState {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
rollout: number;
|
|
9
|
+
}
|
|
10
|
+
export interface HistoryItem {
|
|
11
|
+
ts: number;
|
|
12
|
+
actor: string;
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
export type ScheduleAction = 'enable' | 'disable' | 'rollout';
|
|
16
|
+
export type ExpiryAction = 'archive' | 'disable';
|
|
17
|
+
/** A change that is applied automatically at a future time. */
|
|
18
|
+
export interface Schedule {
|
|
19
|
+
id: string;
|
|
20
|
+
env: Env;
|
|
21
|
+
action: ScheduleAction;
|
|
22
|
+
rollout?: number;
|
|
23
|
+
at: number;
|
|
24
|
+
}
|
|
25
|
+
export interface Flag {
|
|
26
|
+
key: string;
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
kind: FlagKind;
|
|
30
|
+
owner: string;
|
|
31
|
+
archived: boolean;
|
|
32
|
+
createdAt: number;
|
|
33
|
+
updatedAt: number;
|
|
34
|
+
envs: Record<Env, EnvState>;
|
|
35
|
+
history: HistoryItem[];
|
|
36
|
+
/** Draft: saved but not live. Evaluates as off until published. */
|
|
37
|
+
draft?: boolean;
|
|
38
|
+
/** Temporary flag: when this time passes, `expiryAction` is applied automatically. */
|
|
39
|
+
expiresAt?: number;
|
|
40
|
+
expiryAction?: ExpiryAction;
|
|
41
|
+
schedules?: Schedule[];
|
|
42
|
+
}
|
|
43
|
+
/** Host-app configuration (set once via configureFlags before rendering FlagsApp). */
|
|
44
|
+
export interface FlagsConfig {
|
|
45
|
+
/** Project name shown in the page and attached to every event. Default "checkout". */
|
|
46
|
+
project?: string;
|
|
47
|
+
/** Flags to start with when nothing is stored yet. Default: none (use demoFlags() for the built-in demo set). */
|
|
48
|
+
initialFlags?: Flag[];
|
|
49
|
+
/** Environment used by isFeatureEnabled() when none is passed. Default "production". */
|
|
50
|
+
environment?: Env;
|
|
51
|
+
/** localStorage key used for persistence. Default "ff_<project>_v1". */
|
|
52
|
+
storageKey?: string;
|
|
53
|
+
/** A flag with no change for this many days counts as stale. Default 30. */
|
|
54
|
+
staleAfterDays?: number;
|
|
55
|
+
/** Name recorded in the history of changes. Default "you". */
|
|
56
|
+
actor?: string;
|
|
57
|
+
/** Called after every change, e.g. to sync flags to your backend. */
|
|
58
|
+
onChange?: (flags: Flag[]) => void;
|
|
59
|
+
}
|
|
60
|
+
export declare const getProject: () => string;
|
|
61
|
+
interface Snapshot {
|
|
62
|
+
flags: Flag[];
|
|
63
|
+
version: number;
|
|
64
|
+
}
|
|
65
|
+
/** The built-in checkout demo flags. Pass to configureFlags({ initialFlags: demoFlags() }) for a demo. */
|
|
66
|
+
export declare const demoFlags: () => Flag[];
|
|
67
|
+
/**
|
|
68
|
+
* Configure the flag store for your project. Call once at app start, before rendering FlagsApp.
|
|
69
|
+
* Stored flags (localStorage) win over `initialFlags`.
|
|
70
|
+
*/
|
|
71
|
+
export declare const configureFlags: (c: FlagsConfig) => void;
|
|
72
|
+
export declare const useFlags: () => Snapshot;
|
|
73
|
+
export declare const getFlags: () => Flag[];
|
|
74
|
+
export declare const getFlag: (key: string) => Flag | undefined;
|
|
75
|
+
export declare const toggleFlag: (key: string, env: Env) => void;
|
|
76
|
+
export declare const setRollout: (key: string, env: Env, rollout: number) => void;
|
|
77
|
+
export declare const KEY_RE: RegExp;
|
|
78
|
+
export declare const createFlag: (input: {
|
|
79
|
+
key: string;
|
|
80
|
+
name: string;
|
|
81
|
+
kind: FlagKind;
|
|
82
|
+
description: string;
|
|
83
|
+
draft?: boolean;
|
|
84
|
+
}) => string | null;
|
|
85
|
+
export declare const setArchived: (key: string, archived: boolean) => void;
|
|
86
|
+
/** Turn a flag off in every environment at once. */
|
|
87
|
+
export declare const killFlag: (key: string) => void;
|
|
88
|
+
export declare const resetFlags: () => void;
|
|
89
|
+
export declare const getStaleAfterDays: () => number;
|
|
90
|
+
/** Live flag with no change for `staleAfterDays` days: a candidate for cleanup. */
|
|
91
|
+
export declare const isStale: (f: Flag, now?: number) => boolean;
|
|
92
|
+
/** Make a draft live (still off in every environment until you switch it on). */
|
|
93
|
+
export declare const publishFlag: (key: string) => void;
|
|
94
|
+
/** Delete a draft for good. Live flags cannot be deleted, only archived. */
|
|
95
|
+
export declare const deleteFlag: (key: string) => void;
|
|
96
|
+
export declare const scheduleChange: (key: string, input: {
|
|
97
|
+
env: Env;
|
|
98
|
+
action: ScheduleAction;
|
|
99
|
+
rollout?: number;
|
|
100
|
+
at: number;
|
|
101
|
+
}) => string | null;
|
|
102
|
+
export declare const cancelSchedule: (key: string, id: string) => void;
|
|
103
|
+
export declare const describeSchedule: (s: Schedule) => string;
|
|
104
|
+
/** Make a flag temporary (expires at `at`), or pass null to make it permanent again. */
|
|
105
|
+
export declare const setExpiration: (key: string, at: number | null, action?: ExpiryAction) => string | null;
|
|
106
|
+
/** Apply scheduled changes and expirations that are due. Returns how many were applied. FlagsApp calls this every 15 s. */
|
|
107
|
+
export declare const runDue: () => number;
|
|
108
|
+
/** Stable 0–99 bucket for a user within a flag. */
|
|
109
|
+
export declare const bucketOf: (key: string, userId: string) => number;
|
|
110
|
+
export interface Evaluation {
|
|
111
|
+
enabled: boolean;
|
|
112
|
+
reason: string;
|
|
113
|
+
bucket: number;
|
|
114
|
+
}
|
|
115
|
+
export declare const evaluate: (key: string, userId: string, env?: Env) => Evaluation;
|
|
116
|
+
/**
|
|
117
|
+
* Read a flag from your app code. Emits a deduplicated "flag_evaluated" event
|
|
118
|
+
* (once per flag + user + result per session) into the live ingestion pipeline.
|
|
119
|
+
*/
|
|
120
|
+
export declare const isFeatureEnabled: (key: string, userId?: string, env?: Env) => boolean;
|
|
121
|
+
/** Evaluation from the admin page: always emits, so every test shows up live. */
|
|
122
|
+
export declare const testEvaluate: (key: string, userId: string, env: Env) => Evaluation;
|
|
123
|
+
export interface FlagsConnection {
|
|
124
|
+
/** GET returns the flags (an array, or { flags: [...] }). Local changes are sent back to the same URL. */
|
|
125
|
+
url: string;
|
|
126
|
+
headers?: Record<string, string>;
|
|
127
|
+
/** How often to pull the latest flags. Default 10 000 ms. Use 0 to pull once. */
|
|
128
|
+
pollMs?: number;
|
|
129
|
+
/** HTTP method used to save local changes. Default "PUT". Use "none" for read-only. */
|
|
130
|
+
saveMethod?: 'PUT' | 'POST' | 'none';
|
|
131
|
+
}
|
|
132
|
+
export interface LiveStatus {
|
|
133
|
+
state: 'off' | 'connecting' | 'live' | 'error';
|
|
134
|
+
at: number;
|
|
135
|
+
error: string;
|
|
136
|
+
}
|
|
137
|
+
export declare const useFlagsLive: () => LiveStatus;
|
|
138
|
+
/**
|
|
139
|
+
* Use real flags from your backend: pulls on start and every `pollMs`, and saves each local change.
|
|
140
|
+
* Returns a function that stops syncing.
|
|
141
|
+
*/
|
|
142
|
+
export declare const connectFlags: (o: FlagsConnection) => (() => void);
|
|
143
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
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, 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';
|
|
14
18
|
export { startHeatmapCapture, clearHeatmap, getHeatmapData } from './heatmap/capture';
|
|
15
19
|
export { RouteRecorderWatcher } from './recorder/RouteRecorderWatcher';
|
|
16
20
|
export type { RouteRecorderWatcherProps } from './recorder/RouteRecorderWatcher';
|