Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FC-129678 : Remove status field dependency on conversation property update #117

Merged
merged 7 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/freshchat-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshworks-jaya/freshchat-api",
"version": "0.7.36",
"version": "0.7.36-beta-2",
"description": "Provides simple interface for accessing Freshchat's public APIs",
"repository": "[email protected]:freshdesk/jaya-lib.git",
"main": "lib/index.js",
Expand Down
10 changes: 4 additions & 6 deletions packages/freshchat-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,13 @@ export default class Freshchat {
*/
conversationPropertiesUpdate(
conversationId: string,
status: string,
properties: unknown,
assigned_agent_id: string,
status?: string | null,
): AxiosPromise<Conversation> {
const conversationPropsUpdateApiUrl = `${this.apiUrl}/conversations/${conversationId}`;
let requiredProperties = JSON.stringify({
properties,
status,
});

const payload = status === null ? { properties } : { properties, status };
const requiredProperties = JSON.stringify(payload);

return axios.put(conversationPropsUpdateApiUrl, requiredProperties, { headers: this.headers });
}
Expand Down
4 changes: 2 additions & 2 deletions packages/rule-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freshworks-jaya/rule-engine",
"version": "0.18.6-beta-1",
"version": "0.18.6-beta-24",
"description": "Provides methods to process rules in product events in marketplace app",
"repository": "[email protected]:freshdesk/jaya-lib.git",
"main": "lib/index.js",
Expand Down Expand Up @@ -44,7 +44,7 @@
"typescript": "^4.3.2"
},
"dependencies": {
"@freshworks-jaya/freshchat-api": "0.7.36",
"@freshworks-jaya/freshchat-api": "0.7.36-beta-2",
"@freshworks-jaya/kairos-api": "^0.1.5",
"@freshworks-jaya/marketplace-models": "0.1.36",
"@freshworks-jaya/utilities": "^1.0.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/rule-engine/src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ export class Utils {
}
});
}

public static setConversationFields(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
conversationFieldsResponse: any,
Expand All @@ -346,4 +347,15 @@ export class Utils {
convFieldsMap.set(field.column_name, field.name);
});
}

/*
* Check if feature flag is available and enabled.
*/
public static isFeatureFlagEnabled = (
integrations: Integrations,
featureFlag: string,
): Boolean => {
return integrations?.featureFlags?.[featureFlag] || false;
};

}
5 changes: 1 addition & 4 deletions packages/rule-engine/src/models/rule-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export interface Integrations {
requestProxy: RequestProxy;
};
timezoneOffset: number;
features: {
betaFeaturesEnabled: string[];
featuresEnabled: string[];
};
featureFlags: Record<string, boolean>;
}

export interface ProductCredentials {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default async (
const freshchat = new Freshchat(freshchatApiUrl, freshchatApiToken, ruleAlias);
const modelProperties = productEventPayload.data.conversation || productEventPayload.data.message;
const conversationId = modelProperties.conversation_id;
const assigned_agent_id = modelProperties.assigned_agent_id ? modelProperties.assigned_agent_id : '';
const status = modelProperties.status;

const convPropertiesActionValue = actionValue as PropertiesConditionValue;
Expand Down Expand Up @@ -50,7 +49,13 @@ export default async (
),
};
}
await freshchat.conversationPropertiesUpdate(conversationId, status, properties, assigned_agent_id);

if (Utils.isFeatureFlagEnabled(integrations, 'EXCLUSIVE_UPDATE_FOR_CONV_PROP')) {
await freshchat.conversationPropertiesUpdate(conversationId, properties, null);
} else {
await freshchat.conversationPropertiesUpdate(conversationId, properties, status);
}

} catch (err) {
Utils.log(
productEventPayload,
Expand Down
Loading