File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
packages/browser/architecture Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments