PERS SDK - v2.3.26 / Exports / TriggerSourceManager
TriggerSource Manager - Clean, high-level interface for trigger source operations
Manages trigger sources which are physical or digital activation points for campaigns:
- QR_CODE: Scannable QR codes
- NFC_TAG: NFC tap points
- GPS_GEOFENCE: Location-based triggers
- API_WEBHOOK: External system integration
- TRANSACTION: Purchase/payment based triggers
Trigger sources are independent entities that can be created, managed, and then assigned to campaigns. This separation allows reuse and flexible campaign configuration.
Example
// Get all QR code trigger sources
const qrSources = await sdk.triggerSources.getAll({ type: 'QR_CODE' });
// Create a new QR code trigger source
const source = await sdk.triggerSources.create({
type: 'QR_CODE',
name: 'Store Entrance QR',
businessId: 'business-123'
});
// Assign to campaign (via CampaignManager)
await sdk.campaigns.assignTriggerSource('campaign-456', source.id);• new TriggerSourceManager(apiClient, events?): TriggerSourceManager
| Name | Type |
|---|---|
apiClient | PersApiClient |
events? | PersEventEmitter |
managers/trigger-source-manager.ts:47
▸ getAll(options?): Promise<PaginatedResponseDTO<TriggerSourceDTO>>
Get trigger sources with optional filters and pagination
Retrieves trigger sources (QR codes, NFC tags, GPS geofences, webhooks, etc.) that can be used to activate campaigns. Supports filtering by type, business, campaign association, and active status.
| Name | Type | Description |
|---|---|---|
options? | TriggerSourceQueryOptions | Filter and pagination options |
Promise<PaginatedResponseDTO<TriggerSourceDTO>>
Promise resolving to paginated trigger sources
Example
// Get all QR code trigger sources
const qrSources = await sdk.triggerSources.getAll({ type: 'QR_CODE' });
// Get trigger sources for a specific business
const businessSources = await sdk.triggerSources.getAll({
businessId: 'business-123',
active: true,
page: 1,
limit: 20
});
// Get trigger sources assigned to a campaign
const campaignSources = await sdk.triggerSources.getAll({
campaignId: 'campaign-456'
});managers/trigger-source-manager.ts:84
▸ getById(triggerSourceId): Promise<TriggerSourceDTO>
Get trigger source by ID
Retrieves detailed information for a specific trigger source including its type, location, metadata, and usage analytics.
| Name | Type | Description |
|---|---|---|
triggerSourceId | string | UUID of the trigger source |
Promise<TriggerSourceDTO>
Promise resolving to trigger source details
Throws
When trigger source with specified ID is not found
Example
const source = await sdk.triggerSources.getById('source-123');
console.log('Trigger Source:', source.name);
console.log('Type:', source.type);
console.log('Active:', source.isActive);
if (source.coordsLatitude && source.coordsLongitude) {
console.log('Location:', source.coordsLatitude, source.coordsLongitude);
}managers/trigger-source-manager.ts:111
▸ create(triggerSource): Promise<TriggerSourceDTO>
Admin: Create a new trigger source
Creates a new trigger source (QR code, NFC tag, GPS geofence, webhook, or transaction-based trigger) that can be assigned to campaigns. Requires administrator privileges.
| Name | Type | Description |
|---|---|---|
triggerSource | TriggerSourceCreateRequestDTO | Trigger source creation data |
Promise<TriggerSourceDTO>
Promise resolving to created trigger source
Throws
When not authenticated as admin or validation fails
Example
// Create a QR code trigger source
const qrSource = await sdk.triggerSources.create({
type: 'QR_CODE',
name: 'Store Entrance QR',
description: 'QR code at main entrance',
businessId: 'business-123',
coordsLatitude: 47.6062,
coordsLongitude: -122.3321
});
// Create an NFC tag trigger source
const nfcSource = await sdk.triggerSources.create({
type: 'NFC_TAG',
name: 'Product Display NFC',
metadata: { productId: 'SKU-12345' }
});
// Create a GPS geofence trigger source
const geoSource = await sdk.triggerSources.create({
type: 'GPS_GEOFENCE',
name: 'Store Area',
coordsLatitude: 47.6062,
coordsLongitude: -122.3321,
metadata: { radiusMeters: 100 }
});managers/trigger-source-manager.ts:155
▸ update(triggerSourceId, triggerSource): Promise<TriggerSourceDTO>
Admin: Update a trigger source
Updates an existing trigger source's configuration. All fields are optional; only provided fields will be updated. Requires administrator privileges.
| Name | Type | Description |
|---|---|---|
triggerSourceId | string | UUID of the trigger source to update |
triggerSource | Partial<TriggerSourceCreateRequestDTO> | Updated trigger source data (partial) |
Promise<TriggerSourceDTO>
Promise resolving to updated trigger source
Throws
When not authenticated as admin or trigger source not found
Example
// Update trigger source name and location
const updated = await sdk.triggerSources.update('source-123', {
name: 'Updated Store Entrance QR',
description: 'New description',
coordsLatitude: 47.6063,
coordsLongitude: -122.3322
});managers/trigger-source-manager.ts:190
▸ delete(triggerSourceId): Promise<boolean>
Admin: Delete a trigger source
Soft deletes a trigger source, making it inactive. The trigger source will be removed from any campaigns it was assigned to. Requires administrator privileges.
| Name | Type | Description |
|---|---|---|
triggerSourceId | string | UUID of the trigger source to delete |
Promise<boolean>
Promise resolving to success status
Throws
When not authenticated as admin or trigger source not found
Example
const success = await sdk.triggerSources.delete('source-123');
console.log('Trigger source deleted:', success);managers/trigger-source-manager.ts:223
▸ getTriggerSourceService(): TriggerSourceService
Get the full trigger source service for advanced operations
TriggerSourceService instance with full API access