Skip to content

Commit 16b8380

Browse files
committed
wip
1 parent cca1079 commit 16b8380

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/browser/architecture/ARCHITECTURE.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,23 @@ graph TD
7474

7575
### Example: Plugin Implementation
7676
```ts
77-
export const myPlugin = {
78-
name: 'Do stuff'
77+
analytics.register({
78+
name: 'My Plugin',
7979
type: 'before',
8080
isLoaded: () => true,
8181
load: () => Promise.resolve(),
82+
// lowercase all track event names
83+
track: (ctx) => {
84+
ctx.event.event = ctx.event.event.toLowerCase()
85+
return ctx
86+
},
8287
// drop page events with a specific title
8388
page: (ctx) => {
8489
if (ctx.properties.title === 'some title') {
8590
return null
8691
}
8792
}
88-
// lowercase all track event names
89-
track: (ctx) => {
90-
ctx.event.event = ctx.event.event.toLowerCase()
91-
return ctx
92-
}
93-
}
94-
analytics.register(myPlugin)
93+
})
9594
```
9695
### Example: Source Middleware Implementation
9796
```ts
@@ -101,7 +100,7 @@ analytics.addSourceMiddleware(({ payload, next }) => {
101100
// change the event name to lowercase
102101
event.event = event.event.toLowerCase()
103102
} else if (event.type === 'page') {
104-
// drop any page events with no title
103+
// drop any page events with a specific title
105104
if (event.properties.title === 'some title') {
106105
return null
107106
}

0 commit comments

Comments
 (0)