File tree Expand file tree Collapse file tree 7 files changed +35
-25
lines changed
signals-integration-tests/src/tests/signals-vanilla Expand file tree Collapse file tree 7 files changed +35
-25
lines changed Original file line number Diff line number Diff line change @@ -54,20 +54,23 @@ test.describe('network signals - fetch', () => {
5454 ( el ) => el . properties ! . data . action === 'request'
5555 )
5656 expect ( requests ) . toHaveLength ( 1 )
57- expect ( requests [ 0 ] . properties ! . data ) . toMatchObject ( {
57+ expect ( requests [ 0 ] . properties ! . data ) . toEqual ( {
5858 action : 'request' ,
5959 url : 'http://localhost/test' ,
60+ method : 'POST' ,
6061 data : { key : 'value' } ,
6162 } )
6263
6364 const responses = networkEvents . filter (
6465 ( el ) => el . properties ! . data . action === 'response'
6566 )
6667 expect ( responses ) . toHaveLength ( 1 )
67- expect ( responses [ 0 ] . properties ! . data ) . toMatchObject ( {
68+ expect ( responses [ 0 ] . properties ! . data ) . toEqual ( {
6869 action : 'response' ,
6970 url : 'http://localhost/test' ,
7071 data : { foo : 'test' } ,
72+ statusCode : 200 ,
73+ ok : true ,
7174 } )
7275 } )
7376
@@ -176,6 +179,8 @@ test.describe('network signals - fetch', () => {
176179 action : 'response' ,
177180 url : 'http://localhost/test' ,
178181 data : { errorMsg : 'foo' } ,
182+ statusCode : 400 ,
183+ ok : false ,
179184 } )
180185 expect ( responses ) . toHaveLength ( 1 )
181186 } )
@@ -213,6 +218,8 @@ test.describe('network signals - fetch', () => {
213218 action : 'response' ,
214219 url : 'http://localhost/test' ,
215220 data : 'foo' ,
221+ statusCode : 400 ,
222+ ok : false ,
216223 } )
217224 expect ( responses ) . toHaveLength ( 1 )
218225 } )
Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ type JSONObject = {
1818} ;
1919type JSONArray = JSONValue [ ] ;
2020interface SegmentEvent {
21- type : EventType ;
22- [ key : string ] : any ;
21+ /**
22+ * @example 'track' | 'page' | 'screen' | 'identify' | 'group' | 'alias'
23+ */
24+ type : string ;
25+ [ key : string ] : unknown ;
2326}
24- type EventType = "track" | "page" | "screen" | "identify" | "group" | "alias" ;
2527type SignalTypes = Signal [ "type" ] ;
2628type NavigationAction = "forward" | "backward" | "modal" | "entering" | "leaving" | "page" | "popup" ;
2729type NetworkAction = "request" | "response" ;
@@ -57,7 +59,6 @@ interface NetworkData {
5759}
5860interface NetworkSignal extends RawSignal < "network" > {
5961 data : NetworkData ;
60- [ key : string ] : unknown ;
6162}
6263interface LocalData {
6364 action : LocalDataAction ;
@@ -77,6 +78,8 @@ interface InstrumentationData {
7778interface InstrumentationSignal extends RawSignal < "instrumentation" > {
7879 data : InstrumentationData ;
7980}
81+ interface MobileSignalsRuntime extends ISignalsRuntime < Signal > {
82+ }
8083
8184
8285
Original file line number Diff line number Diff line change @@ -18,10 +18,12 @@ type JSONObject = {
1818} ;
1919type JSONArray = JSONValue [ ] ;
2020interface SegmentEvent {
21- type : EventType ;
22- [ key : string ] : any ;
21+ /**
22+ * @example 'track' | 'page' | 'screen' | 'identify' | 'group' | 'alias'
23+ */
24+ type : string ;
25+ [ key : string ] : unknown ;
2326}
24- type EventType = "track" | "page" | "screen" | "identify" | "group" | "alias" ;
2527type SignalTypes = Signal [ "type" ] ;
2628interface RawSignal < T extends SignalTypes , Data > extends BaseSignal {
2729 type : T ;
@@ -80,6 +82,8 @@ interface NetworkRequestData extends BaseNetworkData {
8082interface NetworkResponseData extends BaseNetworkData {
8183 action : "response" ;
8284 url : string ;
85+ statusCode : number ;
86+ ok : boolean ;
8387}
8488type NetworkData = NetworkRequestData | NetworkResponseData ;
8589type NetworkSignal = RawSignal < "network" , NetworkData > ;
@@ -88,10 +92,12 @@ interface UserDefinedSignalData {
8892}
8993type UserDefinedSignal = RawSignal < "userDefined" , UserDefinedSignalData > ;
9094type Signal = InteractionSignal | NavigationSignal | InstrumentationSignal | NetworkSignal | UserDefinedSignal ;
95+ interface WebSignalsRuntime extends ISignalsRuntime < Signal > {
96+ }
9197
9298
9399
94- declare const signals : ISignalsRuntime < Signal >
100+ declare const signals : WebSignalsRuntime
95101declare const SignalType : {
96102 Interaction : 'interaction'
97103 Navigation : 'navigation'
Original file line number Diff line number Diff line change @@ -21,14 +21,9 @@ export type JSONObject = { [member: string]: JSONValue }
2121export type JSONArray = JSONValue [ ]
2222
2323export interface SegmentEvent {
24- type : EventType // e.g 'track'
25- [ key : string ] : any
24+ /**
25+ * @example 'track' | 'page' | 'screen' | 'identify' | 'group' | 'alias'
26+ */
27+ type : string
28+ [ key : string ] : unknown
2629}
27-
28- export type EventType =
29- | 'track'
30- | 'page'
31- | 'screen'
32- | 'identify'
33- | 'group'
34- | 'alias'
Original file line number Diff line number Diff line change 11import { Emitter } from '@segment/analytics-generic-utils'
22import { logger } from '../../lib/logger'
3- import { Signal } from '../../types '
3+ import { Signal } from '@segment/analytics-signals-runtime '
44
55export interface EmitSignal {
66 emit : ( signal : Signal ) => void
Original file line number Diff line number Diff line change 11import { logger } from '../../lib/logger'
22import { createWorkerBox , WorkerBoxAPI } from '../../lib/workerbox'
33import { resolvers } from './arg-resolvers'
4- import { AnalyticsRuntimePublicApi , Signal , AnalyticsEnums } from '../../types'
4+ import { AnalyticsRuntimePublicApi , AnalyticsEnums } from '../../types'
55import { replaceBaseUrl } from '../../lib/replace-base-url'
6- import { SignalsRuntime } from '@segment/analytics-signals-runtime'
6+ import { SignalsRuntime , Signal } from '@segment/analytics-signals-runtime'
77
88export type MethodName =
99 | 'page'
Original file line number Diff line number Diff line change 44 */
55export { SignalsPlugin } from './plugin/signals-plugin'
66export { Signals } from './core/signals'
7-
7+ export type { Signal } from '@segment/analytics-signals-runtime'
88export type {
99 ProcessSignal ,
1010 AnalyticsRuntimePublicApi ,
1111 SignalsPluginSettingsConfig ,
12- Signal ,
1312} from './types'
You can’t perform that action at this time.
0 commit comments