Skip to content

Commit 530223e

Browse files
msohailhussainuzair-folio3
and
uzair-folio3
authored
feat: added declaration file for event builder index.d.ts (#573)
Summary: Added declaration file under optimizely-sdk/lib/core/event_builder/index.d.ts Test plan: All unit tests must work fine. Co-authored-by: uzair-folio3 <[email protected]>
1 parent 90c5fdb commit 530223e

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright 2020, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
declare module '@optimizely/optimizely-sdk/lib/core/event_builder' {
18+
import { ProjectConfig } from '@optimizely/optimizely-sdk/lib/core/project_config';
19+
20+
interface ImpressionConfig {
21+
experimentKey: string;
22+
variationKey: string;
23+
userId: string;
24+
userAttributes: import('../../shared_types').UserAttributes;
25+
clientEngine: string;
26+
clientVersion: string;
27+
configObj: ProjectConfig;
28+
}
29+
30+
interface ConversionConfig {
31+
eventKey: string;
32+
eventTags: import('../../shared_types').EventTags;
33+
userId: string;
34+
userAttributes: import('../../shared_types').UserAttributes;
35+
clientEngine: string;
36+
clientVersion: string;
37+
configObj: ProjectConfig;
38+
}
39+
40+
/**
41+
* Creates an ImpressionEvent object from decision data
42+
* @param {ImpressionConfig} config
43+
* @return {ImpressionEvent} an ImpressionEvent object
44+
*/
45+
export function buildImpressionEvent(config: ImpressionConfig): import('@optimizely/js-sdk-event-processor').ImpressionEvent;
46+
47+
/**
48+
* Creates a ConversionEvent object from track
49+
* @param {ConversionConfig} config
50+
* @return {ConversionEvent} a ConversionEvent object
51+
*/
52+
export function buildConversionEvent(config: ConversionConfig): import('@optimizely/js-sdk-event-processor').ConversionEvent;
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright 2020, Optimizely
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
declare module '@optimizely/optimizely-sdk/lib/core/event_builder' {
18+
import { ProjectConfig } from '@optimizely/optimizely-sdk/lib/core/project_config';
19+
import { LogHandler } from '@optimizely/js-sdk-logging';
20+
import { Event as EventLoggingEndpoint } from '@optimizely/optimizely-sdk';
21+
22+
interface ImpressionOptions {
23+
attributes?: import('../../shared_types').UserAttributes;
24+
clientEngine: string;
25+
clientVersion: string;
26+
configObj: ProjectConfig;
27+
experimentId: string;
28+
eventKey?: string;
29+
variationId: string;
30+
logger?: LogHandler;
31+
userId: string;
32+
}
33+
34+
interface ConversionEventOptions {
35+
attributes?: import('../../shared_types').UserAttributes;
36+
clientEngine: string;
37+
clientVersion: string;
38+
configObj: ProjectConfig;
39+
eventKey: string;
40+
logger: LogHandler;
41+
userId: string;
42+
eventTags?: import('../../shared_types').EventTags;
43+
}
44+
45+
/**
46+
* Create impression event params to be sent to the logging endpoint
47+
* @param {ImpressionOptions} options Object containing values needed to build impression event
48+
* @return {EventLoggingEndpoint} Params to be used in impression event logging endpoint call
49+
*/
50+
export function getImpressionEvent(options: ImpressionOptions): EventLoggingEndpoint;
51+
52+
/**
53+
* Create conversion event params to be sent to the logging endpoint
54+
* @param {ConversionEventOptions} options Object containing values needed to build conversion event
55+
* @return {EventLoggingEndpoint} Params to be used in conversion event logging endpoint call
56+
*/
57+
export function getConversionEvent(options: ConversionEventOptions): EventLoggingEndpoint;
58+
}

packages/optimizely-sdk/lib/shared_types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,7 @@ export interface OptimizelyConfig {
8888
revision: string;
8989
getDatafile(): string;
9090
}
91+
92+
export type EventTags = {
93+
[key: string]: string | number | boolean;
94+
};

0 commit comments

Comments
 (0)