@@ -13,38 +13,53 @@ pnpm install @segment/analytics-signals-runtime
1313
1414### Usage
1515
16- ### As a regular library
16+ ### Importing the signals runtime as a module (e.g. ` signals.find() ` )
1717
1818``` ts
19- import {
20- WebSignalsRuntime ,
21- // WebRuntimeConstants,
22- // MobileSignalsRuntime
23- // MobileRuntimeConstants
24- } from ' @segment/analytics-signals-runtime'
19+ import { WebSignalsRuntime , Signal } from ' @segment/analytics-signals-runtime'
20+ // MobileSignalsRuntime
21+ // WebRuntimeConstants,
22+ // MobileRuntimeConstants,
2523
26- const signals = new WebSignalsRuntime ([... .])
24+ const mockSignalBuffer: Signal [] = [{
25+ type: " network" ,
26+ data: {
27+ action: " response" ,
28+ url: " https://segment-integrations.github.io/segment-shop-auto/cart" ,
29+ data: { foo: " bar" },
30+ ok: true ,
31+ status: 201 ,
32+ contentType: " application/json" ,
33+ page: {
34+ path: " /segment-shop-auto/" ,
35+ referrer: " " ,
36+ title: " Segment Shop - Home Collection - Timecraft" ,
37+ search: " " ,
38+ url: " https://segment-integrations.github.io/segment-shop-auto/#/home-collection/Timecraft" ,
39+ hostname: " segment-integrations.github.io" ,
40+ hash: " #/home-collection/Timecraft"
41+ }
42+ }
43+ }]
2744
28- // get the more recent network signal in the buffer
29- const networkSignal = signals .find (null , ' network' )
30-
31- // all signals
32- const allInstrumentationSignals = signals .find (null , ' network' )
45+ const signals = new WebSignalsRuntime (mockSignalBuffer )
3346
47+ const networkSignal = signals .find (null , ' network' )
3448
3549```
36- ### As a string
37- Exposes the SignalsObject
38-
50+ ### Importing the signals runtime a JS string
3951``` ts
40- import { getRuntimeCode } from ' @segment/analytics-signals-runtime` `
52+ import { getRuntimeCode , getMobileRuntimeCode } from ' @segment/analytics-signals-runtime'
4153
4254eval (`
43- ${getRuntimeCode ()}
55+ ${getMobileRuntimeCode ()}
4456 signals.signalBuffer = [....]
4557 ` )
46-
4758```
59+
60+ ### API documentation
61+ For all exports, explore [ the index.ts] ( src/index.ts ) .
62+
4863### Development
4964` yarn build ` generate the following artifacts:
5065| Generated File(s) | Description |
0 commit comments