Skip to content

Commit 31a5391

Browse files
committed
wip
1 parent c346eda commit 31a5391

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

packages/signals/signals-runtime/src/test-helpers/mocks/mock-signal-types-web.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ export const mockNavigationSignal: NavigationSignal = {
2121
url: 'https://example.com',
2222
hash: '#section1',
2323
prevUrl: 'https://example.com/home',
24+
path: '/home',
25+
title: 'Home Page',
26+
search: '?utm_source=google',
2427
},
2528
}
2629

2730
export const mockInstrumentationSignal: InstrumentationSignal = {
2831
type: 'instrumentation',
2932
data: {
30-
rawEvent: { type: 'customEvent', detail: 'example' },
33+
rawEvent: { type: 'track', properties: { key: 'value' }, context: {} },
3134
},
3235
}
3336

packages/signals/signals-runtime/src/web/web-signals-types.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,25 @@ export type InteractionSignal = RawSignal<'interaction', InteractionData>
3535
interface BaseNavigationData<ActionType extends string> {
3636
action: ActionType
3737
url: string
38+
/**
39+
* The hash part of the URL, including the leading `#`
40+
* @example '#section1'
41+
*/
3842
hash: string
43+
/**
44+
* The path part of the URL, including the leading `/`
45+
* @example '/home'
46+
*/
47+
path: string
48+
/**
49+
* The search part of the URL, including the leading `?`
50+
* @example '?utm_source=google'
51+
*/
52+
/**
53+
* The title of the page
54+
* @example 'Home Page'
55+
*/
56+
title: string
3957
}
4058

4159
export interface URLChangeNavigationData
@@ -66,22 +84,42 @@ export interface NetworkSignalMetadata {
6684
}
6785

6886
interface BaseNetworkData {
69-
action: string
87+
action: 'request' | 'response'
7088
url: string
89+
/**
90+
* The content of the request or response
91+
* @example { key: 'value' }
92+
*/
7193
data: JSONValue
94+
/**
95+
* The content type of the request or response
96+
* @example 'application/json'
97+
*/
7298
contentType: string
7399
}
74100

75101
interface NetworkRequestData extends BaseNetworkData {
76102
action: 'request'
77103
url: string
104+
/**
105+
* The HTTP method used for the request
106+
* @example 'GET' | 'POST' | 'PUT' | 'DELETE'
107+
*/
78108
method: string
79109
}
80110

81111
interface NetworkResponseData extends BaseNetworkData {
82112
action: 'response'
83113
url: string
114+
/**
115+
* The status code of the response
116+
* @example 200
117+
*/
84118
status: number
119+
/**
120+
* Whether the request was successful
121+
* For example, a status code of 200-299 is considered successful
122+
*/
85123
ok: boolean
86124
}
87125

0 commit comments

Comments
 (0)