diff --git a/packages/signals/signals/README.md b/packages/signals/signals/README.md index 1c60e36ae..25f19c69e 100644 --- a/packages/signals/signals/README.md +++ b/packages/signals/signals/README.md @@ -6,6 +6,32 @@ See: [settings.ts](src/types/settings.ts) ## Quick start + +## Snippet Users +```html + + My Website + + + + + + + + + + +``` + +## `npm` Users ### Installation ```bash # npm @@ -21,8 +47,9 @@ pnpm install @segment/analytics-signals import { AnalyticsBrowser } from '@segment/analytics-next' import { SignalsPlugin } from '@segment/analytics-signals' -const analytics = new AnalyticsBrowser() -const signalsPlugin = new SignalsPlugin() +export const analytics = new AnalyticsBrowser() +export const signalsPlugin = new SignalsPlugin() + analytics.register(signalsPlugin) analytics.load({ @@ -30,7 +57,15 @@ analytics.load({ }) ``` +### Extending / Emitting Custom Signals +```ts +import { signalsPlugin } from './analytics' // assuming you exported your plugin instance. +signalsPlugin.addSignal({ + type: 'userDefined', + data: { foo: 'bar' } +}) +``` ### Debugging #### Enable debug mode @@ -49,17 +84,10 @@ https://my-website.com?segment_signals_debug=false #### Listening to signals ```ts const signalsPlugin = new SignalsPlugin() + signalsPlugin.onSignal((signal) => console.log(signal)) ``` -### Emitting Signals -```ts -const signalsPlugin = new SignalsPlugin() -signalsPlugin.addSignal({ - type: 'userDefined', - data: { foo: 'bar' } -}) -``` ### Playground / Development / Testing See the [signals example repo](../signals-example).