@optimizely/js-sdk-utils
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -10,4 +10,10 @@ # Changelog | ||
## [0.2.0] - August 7, 2019 | ||
### New Features | ||
- Added `objectEntries` | ||
- Added `NOTIFICATION_TYPES` and `NotificationCenter` | ||
## [0.1.0] - March 1, 2019 | ||
Initial release | ||
Initial release |
@@ -19,2 +19,5 @@ export declare type Omit<T, K> = Pick<T, Exclude<keyof T, K>>; | ||
}): K[]; | ||
export declare function objectEntries<K>(obj: { | ||
[key: string]: K; | ||
}): [string, K][]; | ||
export declare function find<K>(arr: K[], cond: (arg: K) => boolean): K | undefined; | ||
@@ -25,1 +28,11 @@ export declare function keyBy<K>(arr: K[], keyByFn: (item: K) => string): { | ||
export declare function sprintf(format: string, ...args: any[]): string; | ||
export declare 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; | ||
} |
@@ -61,2 +61,6 @@ "use strict"; | ||
exports.objectValues = objectValues; | ||
function objectEntries(obj) { | ||
return Object.keys(obj).map(function (key) { return [key, obj[key]]; }); | ||
} | ||
exports.objectEntries = objectEntries; | ||
function find(arr, cond) { | ||
@@ -104,1 +108,51 @@ var found; | ||
exports.sprintf = sprintf; | ||
/* | ||
* 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} | ||
* | ||
*/ | ||
var NOTIFICATION_TYPES; | ||
(function (NOTIFICATION_TYPES) { | ||
NOTIFICATION_TYPES["ACTIVATE"] = "ACTIVATE:experiment, user_id,attributes, variation, event"; | ||
NOTIFICATION_TYPES["DECISION"] = "DECISION:type, userId, attributes, decisionInfo"; | ||
NOTIFICATION_TYPES["LOG_EVENT"] = "LOG_EVENT:logEvent"; | ||
NOTIFICATION_TYPES["OPTIMIZELY_CONFIG_UPDATE"] = "OPTIMIZELY_CONFIG_UPDATE"; | ||
NOTIFICATION_TYPES["TRACK"] = "TRACK:event_key, user_id, attributes, event_tags, event"; | ||
})(NOTIFICATION_TYPES = exports.NOTIFICATION_TYPES || (exports.NOTIFICATION_TYPES = {})); |
{ | ||
"name": "@optimizely/js-sdk-utils", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Optimizely Full Stack Utils", | ||
@@ -5,0 +5,0 @@ "author": "jordangarcia <jordan@optimizely.com>", |
19398
192