Skip to content

Commit

Permalink
fix: update the shape of goalData for tracking revenue
Browse files Browse the repository at this point in the history
  • Loading branch information
abbaseya committed Jun 3, 2024
1 parent da8a2c9 commit f54356f
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 12 deletions.
6 changes: 3 additions & 3 deletions packages/data/src/data-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
VisitorTrackingEvents,
ConversionEvent,
ConfigGoal,
GoalData,
VisitorSegments,
ConfigSegment,
BucketingAttributes,
Expand All @@ -49,7 +50,6 @@ import {
ERROR_MESSAGES,
MESSAGES,
RuleError,
GoalDataKey,
SegmentsKeys,
SystemEvents,
ConversionSettingKey
Expand Down Expand Up @@ -913,15 +913,15 @@ export class DataManager implements DataManagerInterface {
* @param {string} visitorId
* @param {string} goalId
* @param {Record<string, any>=} goalRule An object of key-value pairs that are used for goal matching
* @param {Array<Record<GoalDataKey, number>>} goalData An array of object of key-value pairs
* @param {Array<GoalData>} goalData An array of object of key-value pairs
* @param {VisitorSegments} segments
* @param {Record<ConversionSettingKey, number | string | boolean>} conversionSetting An object of key-value pairs that are used for tracking settings
*/
convert(
visitorId: string,
goalId: string,
goalRule?: Record<string, any>,
goalData?: Array<Record<GoalDataKey, number>>,
goalData?: Array<GoalData>,
segments?: VisitorSegments,
conversionSetting?: Record<ConversionSettingKey, number | string | boolean>
): RuleError | boolean {
Expand Down
6 changes: 3 additions & 3 deletions packages/data/src/interfaces/data-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {
VisitorSegments,
ConfigExperience,
BucketingAttributes,
LocationAttributes
LocationAttributes,
GoalData
} from '@convertcom/js-sdk-types';
import {DataStoreManagerInterface} from './data-store-manager';
import {
BucketingError,
ConversionSettingKey,
GoalDataKey,
RuleError
} from '@convertcom/js-sdk-enums';

Expand Down Expand Up @@ -56,7 +56,7 @@ export interface DataManagerInterface {
visitorId: string,
goalId: string,
goalRule?: Record<string, any>,
goalData?: Array<Record<GoalDataKey, number>>,
goalData?: Array<GoalData>,
segments?: VisitorSegments,
conversionSetting?: Record<ConversionSettingKey, number | string | boolean>
): RuleError | boolean;
Expand Down
13 changes: 10 additions & 3 deletions packages/js-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,16 @@ convertSDK.onReady().then(() => {
},
conversionData: [
{
amount: 10.3,
productsCount: 2,
transactionId: 'transaction-unique-id'
key: 'amount',
value: 10.3
},
{
key: 'productsCount',
value: 2
},
{
key: 'transactionId',
value: 'transaction-unique-id'
}
],
conversionSetting: {
Expand Down
2 changes: 2 additions & 0 deletions packages/js-sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export {
BucketedVariation,
BucketingAttributes,
ConversionAttributes,
LocationAttributes,
Entity,
IdentityField,
SegmentsAttributes,
Expand All @@ -161,6 +162,7 @@ export {
ConfigGoal,
ConfigAudience,
ConfigLocation,
GoalData,
RequireAtLeastOne,
VisitorTrackingEvents,
Path
Expand Down
2 changes: 1 addition & 1 deletion packages/js-sdk/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export class Context implements ContextInterface {
* @param {string} goalKey A goal key
* @param {ConversionAttributes=} attributes An object that specifies attributes for the visitor
* @param {Record<string, any>=} attributes.ruleData An object of key-value pairs that are used for goal matching
* @param {Array<Record<GoalDataKey, number>>=} attributes.conversionData An array of key-value pairs that are used for transaction data
* @param {Array<GoalData>=} attributes.conversionData An array of key-value pairs that are used for transaction data
* @param {Record<ConversionSettingKey, number | string | boolean>} attributes.conversionSetting An object of key-value pairs that are used for tracking settings
* @return {RuleError}
*/
Expand Down
1 change: 1 addition & 0 deletions packages/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './src/BucketingHash';
export * from './src/Config';
export * from './src/ConversionAttributes';
export * from './src/Entity';
export * from './src/GoalData';
export * from './src/IndentityField';
export * from './src/Integration';
export * from './src/LocationAttributes';
Expand Down
5 changes: 3 additions & 2 deletions packages/types/src/ConversionAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
* License Apache-2.0
*/

import {ConversionSettingKey, GoalDataKey} from '@convertcom/js-sdk-enums';
import {ConversionSettingKey} from '@convertcom/js-sdk-enums';
import {GoalData} from './GoalData';

export type ConversionAttributes = {
ruleData?: Record<string, any>;
conversionData?: Array<Record<GoalDataKey, number>>;
conversionData?: Array<GoalData>;
conversionSetting?: Record<ConversionSettingKey, number | string | boolean>;
};
13 changes: 13 additions & 0 deletions packages/types/src/GoalData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*!
* Convert JS SDK
* Version 1.0.0
* Copyright(c) 2020 Convert Insights, Inc
* License Apache-2.0
*/

import {GoalDataKey} from '@convertcom/js-sdk-enums';

export type GoalData = {
key: GoalDataKey;
value: number | string;
};

0 comments on commit f54356f

Please sign in to comment.