Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/utils/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changes that have landed but are not yet released.

### New Features
- Added `objectEntries`
- Added `NOTIFICATION_TYPES` and `NotificationCenter`

## [0.1.0] - March 1, 2019

Expand Down
53 changes: 53 additions & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,56 @@ export function sprintf(format: string, ...args: any[]): string {
}
})
}
/*
* Notification types for use with NotificationCenter
* Format is EVENT: <list of parameters to callback>
*
* SDK consumers can use these to register callbacks with the notification center.
*
* @deprecated since 3.1.0
* ACTIVATE: An impression event will be sent to Optimizely
* Callbacks will receive an object argument with the following properties:
* - experiment {Object}
* - userId {string}
* - attributes {Object|undefined}
* - variation {Object}
* - logEvent {Object}
*
* DECISION: A decision is made in the system. i.e. user activation,
* feature access or feature-variable value retrieval
* Callbacks will receive an object argument with the following properties:
* - type {string}
* - userId {string}
* - attributes {Object|undefined}
* - decisionInfo {Object|undefined}
*
* LOG_EVENT: A batch of events, which could contain impressions and/or conversions,
* will be sent to Optimizely
* Callbacks will receive an object argument with the following properties:
* - url {string}
* - httpVerb {string}
* - params {Object}
*
* OPTIMIZELY_CONFIG_UPDATE: This Optimizely instance has been updated with a new
* config
*
* TRACK: A conversion event will be sent to Optimizely
* Callbacks will receive the an object argument with the following properties:
* - eventKey {string}
* - userId {string}
* - attributes {Object|undefined}
* - eventTags {Object|undefined}
* - logEvent {Object}
*
*/
export enum NOTIFICATION_TYPES {
ACTIVATE = 'ACTIVATE:experiment, user_id,attributes, variation, event',
DECISION = 'DECISION:type, userId, attributes, decisionInfo',
LOG_EVENT = 'LOG_EVENT:logEvent',
OPTIMIZELY_CONFIG_UPDATE = 'OPTIMIZELY_CONFIG_UPDATE',
TRACK = 'TRACK:event_key, user_id, attributes, event_tags, event',
}

export interface NotificationCenter {
sendNotifications(notificationType: NOTIFICATION_TYPES, notificationData?: any): void
}