|
| 1 | +/* eslint-disable no-shadow */ |
| 2 | +/** |
| 3 | + * Copyright 2020, Optimizely |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +declare module '@optimizely/optimizely-sdk/lib/core/notification_center' { |
| 19 | + import { LogHandler, ErrorHandler } from '@optimizely/js-sdk-logging'; |
| 20 | + |
| 21 | + export enum NOTIFICATION_TYPES { |
| 22 | + ACTIVATE = 'ACTIVATE:experiment, user_id,attributes, variation, event', |
| 23 | + DECISION = 'DECISION:type, userId, attributes, decisionInfo', |
| 24 | + LOG_EVENT = 'LOG_EVENT:logEvent', |
| 25 | + OPTIMIZELY_CONFIG_UPDATE = 'OPTIMIZELY_CONFIG_UPDATE', |
| 26 | + TRACK = 'TRACK:event_key, user_id, attributes, event_tags, event', |
| 27 | + } |
| 28 | + |
| 29 | + export enum DECISION_NOTIFICATION_TYPES { |
| 30 | + AB_TEST = 'ab-test', |
| 31 | + FEATURE = 'feature', |
| 32 | + FEATURE_TEST = 'feature-test', |
| 33 | + FEATURE_VARIABLE = 'feature-variable', |
| 34 | + ALL_FEATURE_VARIABLES = 'all-feature-variables', |
| 35 | + } |
| 36 | + |
| 37 | + export type Options = { |
| 38 | + logger: LogHandler; |
| 39 | + errorHandler: ErrorHandler; |
| 40 | + }; |
| 41 | + |
| 42 | + export type SourceInfo = { |
| 43 | + experimentKey?: string; |
| 44 | + variationKey?: string; |
| 45 | + }; |
| 46 | + |
| 47 | + export type VariableValues = { |
| 48 | + [name: string]: unknown; |
| 49 | + }; |
| 50 | + |
| 51 | + export type DecisionInfo = { |
| 52 | + experimentKey?: string; |
| 53 | + variationKey?: string; |
| 54 | + featureKey?: string; |
| 55 | + featureEnabled?: boolean; |
| 56 | + source?: string; |
| 57 | + sourceInfo?: SourceInfo; |
| 58 | + variableKey?: string; |
| 59 | + variableValue?: unknown; |
| 60 | + variableValues?: VariableValues; |
| 61 | + variableType?: string; |
| 62 | + }; |
| 63 | + |
| 64 | + export interface NotificationData { |
| 65 | + type?: string; |
| 66 | + userId?: string; |
| 67 | + attributes?: import('../../shared_types').UserAttributes; |
| 68 | + decisionInfo?: DecisionInfo; |
| 69 | + experiment?: import('../../shared_types').Experiment; |
| 70 | + variation?: import('../../shared_types').Variation; |
| 71 | + logEvent?: import('../../shared_types').Event; |
| 72 | + eventKey?: string; |
| 73 | + eventTags?: import('../../shared_types').EventTags; |
| 74 | + } |
| 75 | + |
| 76 | + export interface NotificationCenter { |
| 77 | + /** |
| 78 | + * Fires notifications for the argument type. All registered callbacks for this type will be |
| 79 | + * called. The notificationData object will be passed on to callbacks called. |
| 80 | + * @param {NOTIFICATION_TYPES} notificationType One of NOTIFICATION_TYPES |
| 81 | + * @param {NotificationData} notificationData Will be passed to callbacks called |
| 82 | + */ |
| 83 | + sendNotifications(notificationType: NOTIFICATION_TYPES, notificationData: NotificationData): void; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Create an instance of NotificationCenter |
| 88 | + * @param {Options} options |
| 89 | + * @returns {NotificationCenter} An instance of NotificationCenter |
| 90 | + */ |
| 91 | + export function createNotificationCenter(options: Options): NotificationCenter; |
| 92 | +} |
0 commit comments