From c98a5bfb2ef7a01da4cfdfa6e06f6d98b48b295a Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Tue, 6 Aug 2019 19:49:40 -0700 Subject: [PATCH 1/7] Add notification types as an enum in utils --- packages/utils/src/index.ts | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index b8012872e..3a91638cc 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -102,3 +102,44 @@ export function sprintf(format: string, ...args: any[]): string { } }) } +/* + * Notification types for use with NotificationCenter + * Format is EVENT: + * + * 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} + * + * 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", + OPTIMIZELY_CONFIG_UPDATE = "OPTIMIZELY_CONFIG_UPDATE", + TRACK = "TRACK:event_key, user_id, attributes, event_tags, event" +} From 7080436f9612c020b47ce6ca649978c458b5344c Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Tue, 6 Aug 2019 20:02:15 -0700 Subject: [PATCH 2/7] Add log event notification type --- packages/utils/src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 3a91638cc..a2de59505 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -138,8 +138,9 @@ export function sprintf(format: string, ...args: any[]): string { * */ export enum NOTIFICATION_TYPES { - ACTIVATE = "ACTIVATE:experiment, user_id,attributes, variation, event", - DECISION = "DECISION:type, userId, attributes, decisionInfo", - OPTIMIZELY_CONFIG_UPDATE = "OPTIMIZELY_CONFIG_UPDATE", - TRACK = "TRACK:event_key, user_id, attributes, event_tags, event" + 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', } From 2f01faf9962fc08057d4ae67bd69ecb06106f7c1 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Tue, 6 Aug 2019 20:08:17 -0700 Subject: [PATCH 3/7] Add comment for new notification type --- packages/utils/src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index a2de59505..5a395c944 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -125,6 +125,13 @@ export function sprintf(format: string, ...args: any[]): string { * - attributes {Object|undefined} * - decisionInfo {Object|undefined} * + * LOG_EVENT: A batch of events, which could contain impressions and/or conversions, + * was 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 * From a97dea664dbb54139df92bfd8c8bfa473ee54c73 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Tue, 6 Aug 2019 20:08:57 -0700 Subject: [PATCH 4/7] Capitalize Object --- packages/utils/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 5a395c944..b706c79ad 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -130,7 +130,7 @@ export function sprintf(format: string, ...args: any[]): string { * Callbacks will receive an object argument with the following properties: * - url {string} * - httpVerb {string} - * - params {object} + * - params {Object} * * OPTIMIZELY_CONFIG_UPDATE: This Optimizely instance has been updated with a new * config From f2d6fa4503fd7feefd4cf3565b4034834810b763 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Tue, 6 Aug 2019 20:38:05 -0700 Subject: [PATCH 5/7] Add NotificationCenter interface --- packages/utils/src/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index b706c79ad..c8458df7f 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -151,3 +151,7 @@ export enum NOTIFICATION_TYPES { 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 +} From eec268cb8c16cf54997716b371a5fe24d7ef6d2d Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Wed, 7 Aug 2019 08:10:35 -0700 Subject: [PATCH 6/7] Fix language - will be sent, not was sent --- packages/utils/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index c8458df7f..41b62621e 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -126,7 +126,7 @@ export function sprintf(format: string, ...args: any[]): string { * - decisionInfo {Object|undefined} * * LOG_EVENT: A batch of events, which could contain impressions and/or conversions, - * was sent to Optimizely + * will be sent to Optimizely * Callbacks will receive an object argument with the following properties: * - url {string} * - httpVerb {string} From 8354f158144a4ffac1d5eedc8425e6c1d47bc9d9 Mon Sep 17 00:00:00 2001 From: Matt Carroll Date: Wed, 7 Aug 2019 13:21:15 -0700 Subject: [PATCH 7/7] Update changelog --- packages/utils/CHANGELOG.MD | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/utils/CHANGELOG.MD b/packages/utils/CHANGELOG.MD index 36ad0c811..16b2f1f8a 100644 --- a/packages/utils/CHANGELOG.MD +++ b/packages/utils/CHANGELOG.MD @@ -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