You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LivePlugins allows you to write JavaScript-based transformation plugins that process analytics events in your app. These plugins run in a secure, sandboxed JavaScript environment with no network access.
110
+
LivePlugins allows you to write JavaScript-based transformation plugins that process analytics events in your app. These plugins run in a secure, sandboxed JavaScript environment with no network access. Also see the [LivePlugins Javascript API Reference](#liveplugins-javascript-api-reference) for more information.
111
111
112
112
### Plugin Types
113
113
@@ -180,7 +180,7 @@ LivePlugins can implement several lifecycle methods:
180
180
181
181
## Signals
182
182
183
-
Signals are lightweight data points that capture user interactions and system events in your app. While individual signals provide small pieces of information, they become powerful when combined to generate rich analytics events.
183
+
Signals are lightweight data points that capture user interactions and system events in your app. While individual signals provide small pieces of information, they become powerful when combined to generate rich analytics events. Also see the [Signals Javascript API Reference](#signals-javascript-api-reference) for more information.
184
184
185
185
### Core Concepts
186
186
@@ -475,6 +475,8 @@ public protocol SignalJSONBroadcaster: SignalBroadcaster {
475
475
476
476
The JSON broadcaster is useful when you need to work with the raw dictionary representation of signals before they're converted to JSON.
477
477
478
+
> Note: Signals is a paid feature that may need to be enabled on your workspace by your Segment representative.
479
+
478
480
## Destination Filters
479
481
480
482
Destination Filters allows you to run your Segment workspace's destination filters directly on-device. This feature requires:
@@ -495,9 +497,9 @@ Once configured, your device-mode destinations will automatically respect the sa
495
497
496
498
> Note: Destination Filters is a paid feature that may need to be enabled on your workspace by your Segment representative.
497
499
498
-
---
500
+
___
499
501
500
-
## LivePlugins API Reference
502
+
## LivePlugins Javascript API Reference
501
503
502
504
### Utility Functions
503
505
@@ -589,3 +591,233 @@ const UpdateType = {
589
591
}
590
592
```
591
593
594
+
## Signals JavaScript Runtime API
595
+
596
+
### Signal Type Constants
597
+
598
+
```javascript
599
+
constSignalType= {
600
+
Interaction:"interaction",
601
+
Navigation:"navigation",
602
+
Network:"network",
603
+
LocalData:"localData",
604
+
Instrumentation:"instrumentation",
605
+
UserDefined:"userDefined"
606
+
}
607
+
```
608
+
609
+
### Base Signal Classes
610
+
611
+
#### RawSignal
612
+
Base class for all signals:
613
+
614
+
```javascript
615
+
classRawSignal {
616
+
constructor(type, data) {} // Create new signal with type and data
617
+
618
+
// Properties
619
+
anonymousId: string // Anonymous ID from analytics instance
620
+
type: SignalType // Type of signal
621
+
data: object // Signal-specific data
622
+
timestamp:Date// Creation timestamp
623
+
index: number // Sequential index (set by signals.add())
624
+
}
625
+
```
626
+
627
+
### Navigation Signals
628
+
629
+
Navigation action constants:
630
+
631
+
```javascript
632
+
constNavigationAction= {
633
+
Forward:"forward", // Forward navigation
634
+
Backward:"backward", // Backward navigation
635
+
Modal:"modal", // Modal presentation
636
+
Entering:"entering", // Screen entry
637
+
Leaving:"leaving", // Screen exit
638
+
Page:"page", // Page change
639
+
Popup:"popup"// Popup display
640
+
}
641
+
```
642
+
643
+
Navigation signal class:
644
+
645
+
```javascript
646
+
classNavigationSignalextendsRawSignal {
647
+
constructor(action, screen) {} // Create navigation signal
648
+
649
+
// Data Properties
650
+
data.action: string // NavigationAction value
651
+
data.screen: string // Screen identifier
652
+
}
653
+
```
654
+
655
+
### Interaction Signals
656
+
657
+
```javascript
658
+
classInteractionSignalextendsRawSignal {
659
+
constructor(component, info, object) {} // Create interaction signal
660
+
661
+
// Data Properties
662
+
data.component: string // UI component type
663
+
data.info: string // Additional information
664
+
data.data: object // Custom interaction data
665
+
}
666
+
```
667
+
668
+
### Network Signals
669
+
670
+
Network action constants:
671
+
672
+
```javascript
673
+
constNetworkAction= {
674
+
Request:"request", // Outgoing request
675
+
Response:"response"// Incoming response
676
+
}
677
+
```
678
+
679
+
Network signal class:
680
+
681
+
```javascript
682
+
classNetworkSignalextendsRawSignal {
683
+
constructor(action, url, object) {} // Create network signal
684
+
685
+
// Data Properties
686
+
data.action: string // NetworkAction value
687
+
data.url: string // Request/response URL
688
+
data.data: object // Network payload data
689
+
}
690
+
```
691
+
692
+
### Local Data Signals
693
+
694
+
Local data action constants:
695
+
696
+
```javascript
697
+
constLocalDataAction= {
698
+
Loaded:"loaded", // Data loaded
699
+
Updated:"updated", // Data updated
700
+
Saved:"saved", // Data saved
701
+
Deleted:"deleted", // Data deleted
702
+
Undefined:"undefined"// Other operations
703
+
}
704
+
```
705
+
706
+
Local data signal class:
707
+
708
+
```javascript
709
+
classLocalDataSignalextendsRawSignal {
710
+
constructor(action, identifier, object) {} // Create local data signal
711
+
712
+
// Data Properties
713
+
data.action: string // LocalDataAction value
714
+
data.identifier: string // Data identifier
715
+
data.data: object // Associated data
716
+
}
717
+
```
718
+
719
+
### Instrumentation Signals
720
+
721
+
Event type constants:
722
+
723
+
```javascript
724
+
constEventType= {
725
+
Track:"track", // Track events
726
+
Screen:"screen", // Screen events
727
+
Identify:"identify", // Identify events
728
+
Group:"group", // Group events
729
+
Alias:"alias"// Alias events
730
+
}
731
+
```
732
+
733
+
Instrumentation signal class:
734
+
735
+
```javascript
736
+
classInstrumentationSignalextendsRawSignal {
737
+
constructor(rawEvent) {} // Create instrumentation signal
738
+
739
+
// Data Properties
740
+
data.type: string // EventType value
741
+
data.rawEvent: object // Original analytics event
742
+
}
743
+
```
744
+
745
+
### Signals Buffer Management
746
+
747
+
The Signals class manages a buffer of recently collected signals:
748
+
749
+
```javascript
750
+
classSignals {
751
+
constructor() {} // Create new signals buffer
752
+
753
+
// Properties
754
+
signalBuffer: RawSignal[] // Array of signals
755
+
signalCounter: number // Current signal count
756
+
maxBufferSize: number // Maximum buffer size (default: 1000)
757
+
758
+
// Methods
759
+
add(signal) {} // Add signal to buffer
760
+
getNextIndex() {} // Get next signal index
761
+
762
+
// Signal Search Methods
763
+
find(fromSignal, // Starting signal (optional)
764
+
signalType, // Signal type to find (optional)
765
+
predicate) {} // Search predicate function
766
+
767
+
findAndApply(fromSignal, // Starting signal (optional)
768
+
signalType, // Signal type to find (optional)
769
+
searchPredicate, // Search criteria
770
+
applyPredicate) {} // Function to apply to found signal
771
+
}
772
+
```
773
+
774
+
A global instance is automatically created and available:
775
+
776
+
```javascript
777
+
let signals =newSignals() // Global signals buffer instance
0 commit comments