File tree 1 file changed +41
-0
lines changed
src/connections/sources/catalog/libraries/mobile/react-native
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -481,6 +481,47 @@ segmentClient.add({ plugin: new Logger() });
481
481
482
482
As the plugin overrides the ` execute ()` method, this ` Logger ` calls ` console .log ` for every event going through the Timeline.
483
483
484
+ ### Add a custom Destination Plugin
485
+
486
+ You can add custom plugins to Destination Plugins. For example, you could implement the following logic to send events to Braze on weekends only:
487
+
488
+ ` ` ` js
489
+
490
+ import { createClient } from ' @segment/analytics-react-native' ;
491
+
492
+ import {BrazePlugin } from ' @segment/analytics-react-native-plugin-braze' ;
493
+ import {BrazeEventPlugin } from ' ./BrazeEventPlugin' ;
494
+
495
+ const segmentClient = createClient ({
496
+ writeKey: ' SEGMENT_KEY'
497
+ });
498
+
499
+ const brazeplugin = new BrazePlugin ();
500
+ const myBrazeEventPlugin = new BrazeEventPlugin ();
501
+ brazeplugin .add (myBrazeEventPlugin);
502
+ segmentClient .add ({plugin: brazeplugin});
503
+
504
+ // Plugin code for BrazeEventPlugin.ts
505
+ import {
506
+ Plugin ,
507
+ PluginType ,
508
+ SegmentEvent ,
509
+ } from ' @segment/analytics-react-native' ;
510
+
511
+ export class BrazeEventPlugin extends Plugin {
512
+ type = PluginType .before ;
513
+
514
+ execute (event : SegmentEvent ) {
515
+ var today = new Date ();
516
+ if (today .getDay () === 6 || today .getDay () === 0 ) {
517
+ return event ;
518
+ }
519
+ }
520
+ }
521
+ ` ` `
522
+
523
+ Segment would then send events to the Braze Destination Plugin on Saturdays and Sundays, based on device time.
524
+
484
525
### Example Plugins
485
526
These are the example plugins you can use and alter to meet your tracking needs:
486
527
You can’t perform that action at this time.
0 commit comments