|
| 1 | +/* These types will be used in the segment app UI for autocomplete */ |
| 2 | +/* eslint-disable */ |
| 3 | + |
| 4 | + |
| 5 | +interface BaseSignal { |
| 6 | + type: string; |
| 7 | +} |
| 8 | +type SignalOfType<AllSignals extends BaseSignal, SignalType extends AllSignals["type"]> = AllSignals & { |
| 9 | + type: SignalType; |
| 10 | +}; |
| 11 | +interface ISignalsRuntime<Signal extends BaseSignal> { |
| 12 | + find: <SignalType extends Signal["type"]>(fromSignal: Signal, signalType: SignalType, predicate?: (signal: SignalOfType<Signal, SignalType>) => boolean) => SignalOfType<Signal, SignalType> | undefined; |
| 13 | +} |
| 14 | +type JSONPrimitive = string | number | boolean | null; |
| 15 | +type JSONValue = JSONPrimitive | JSONObject | JSONArray; |
| 16 | +type JSONObject = { |
| 17 | + [member: string]: JSONValue; |
| 18 | +}; |
| 19 | +type JSONArray = JSONValue[]; |
| 20 | +interface SegmentEvent { |
| 21 | + type: string; |
| 22 | + [key: string]: any; |
| 23 | +} |
| 24 | +type WebSignalTypes = WebSignal["type"]; |
| 25 | +interface WebAppSignal<T extends WebSignalTypes, Data> extends BaseSignal { |
| 26 | + type: T; |
| 27 | + data: Data; |
| 28 | + metadata?: Record<string, any>; |
| 29 | +} |
| 30 | +type WebInteractionData = WebClickData | WebSubmitData | WebChangeData; |
| 31 | +interface WebSerializedTarget { |
| 32 | + [key: string]: any; |
| 33 | +} |
| 34 | +type WebClickData = { |
| 35 | + eventType: "click"; |
| 36 | + target: WebSerializedTarget; |
| 37 | +}; |
| 38 | +type WebSubmitData = { |
| 39 | + eventType: "submit"; |
| 40 | + submitter: WebSerializedTarget; |
| 41 | +}; |
| 42 | +type WebChangeData = { |
| 43 | + eventType: "change"; |
| 44 | + [key: string]: unknown; |
| 45 | +}; |
| 46 | +type WebInteractionSignal = WebAppSignal<"interaction", WebInteractionData>; |
| 47 | +interface WebBaseNavigationData<ActionType extends string> { |
| 48 | + action: ActionType; |
| 49 | + url: string; |
| 50 | + hash: string; |
| 51 | +} |
| 52 | +interface WebURLChangeNavigationData extends WebBaseNavigationData<"urlChange"> { |
| 53 | + prevUrl: string; |
| 54 | +} |
| 55 | +interface WebPageChangeNavigationData extends WebBaseNavigationData<"pageLoad"> { |
| 56 | +} |
| 57 | +type WebNavigationData = WebURLChangeNavigationData | WebPageChangeNavigationData; |
| 58 | +type WebNavigationSignal = WebAppSignal<"navigation", WebNavigationData>; |
| 59 | +interface WebInstrumentationData { |
| 60 | + rawEvent: unknown; |
| 61 | +} |
| 62 | +type WebInstrumentationSignal = WebAppSignal<"instrumentation", WebInstrumentationData>; |
| 63 | +interface WebNetworkSignalMetadata { |
| 64 | + filters: { |
| 65 | + allowed: string[]; |
| 66 | + disallowed: string[]; |
| 67 | + }; |
| 68 | +} |
| 69 | +interface WebBaseNetworkData { |
| 70 | + action: string; |
| 71 | + url: string; |
| 72 | + data: JSONValue; |
| 73 | +} |
| 74 | +interface WebNetworkRequestData extends WebBaseNetworkData { |
| 75 | + action: "request"; |
| 76 | + url: string; |
| 77 | + method: string; |
| 78 | +} |
| 79 | +interface WebNetworkResponseData extends WebBaseNetworkData { |
| 80 | + action: "response"; |
| 81 | + url: string; |
| 82 | +} |
| 83 | +type WebNetworkData = WebNetworkRequestData | WebNetworkResponseData; |
| 84 | +type WebNetworkSignal = WebAppSignal<"network", WebNetworkData>; |
| 85 | +interface WebUserDefinedSignalData { |
| 86 | + [key: string]: any; |
| 87 | +} |
| 88 | +type WebUserDefinedSignal = WebAppSignal<"userDefined", WebUserDefinedSignalData>; |
| 89 | +type WebSignal = WebInteractionSignal | WebNavigationSignal | WebInstrumentationSignal | WebNetworkSignal | WebUserDefinedSignal; |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | +declare const signals: ISignalsRuntime<WebSignal> |
| 94 | +declare const SignalType: { |
| 95 | + Interaction: 'interaction' |
| 96 | + Navigation: 'navigation' |
| 97 | + Network: 'network' |
| 98 | + LocalData: 'localData' |
| 99 | + Instrumentation: 'instrumentation' |
| 100 | + UserDefined: 'userDefined' |
| 101 | +} |
| 102 | +declare const EventType: { |
| 103 | + Track: 'track' |
| 104 | + Page: 'page' |
| 105 | + Screen: 'screen' |
| 106 | + Identify: 'identify' |
| 107 | + Group: 'group' |
| 108 | + Alias: 'alias' |
| 109 | +} |
| 110 | +declare const NavigationAction: { |
| 111 | + URLChange: 'urlChange' |
| 112 | + PageLoad: 'pageLoad' |
| 113 | +} |
0 commit comments