Skip to content
Last updated

PERS SDK - v2.3.26 / Exports / TriggerSourceManager

Class: 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);

Table of contents

Constructors

Methods

Constructors

constructor

• new TriggerSourceManager(apiClient, events?): TriggerSourceManager

Parameters

NameType
apiClientPersApiClient
events?PersEventEmitter

Returns

TriggerSourceManager

Defined in

managers/trigger-source-manager.ts:47

Methods

getAll

▸ 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.

Parameters

NameTypeDescription
options?TriggerSourceQueryOptionsFilter and pagination options

Returns

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'
});

Defined in

managers/trigger-source-manager.ts:84


getById

▸ 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.

Parameters

NameTypeDescription
triggerSourceIdstringUUID of the trigger source

Returns

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);
}

Defined in

managers/trigger-source-manager.ts:111


create

▸ 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.

Parameters

NameTypeDescription
triggerSourceTriggerSourceCreateRequestDTOTrigger source creation data

Returns

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 }
});

Defined in

managers/trigger-source-manager.ts:155


update

▸ 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.

Parameters

NameTypeDescription
triggerSourceIdstringUUID of the trigger source to update
triggerSourcePartial<TriggerSourceCreateRequestDTO>Updated trigger source data (partial)

Returns

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
});

Defined in

managers/trigger-source-manager.ts:190


delete

▸ 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.

Parameters

NameTypeDescription
triggerSourceIdstringUUID of the trigger source to delete

Returns

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);

Defined in

managers/trigger-source-manager.ts:223


getTriggerSourceService

▸ getTriggerSourceService(): TriggerSourceService

Get the full trigger source service for advanced operations

Returns

TriggerSourceService

TriggerSourceService instance with full API access

Defined in

managers/trigger-source-manager.ts:241