Skip to content

Commit

Permalink
update messenger service with trace ID
Browse files Browse the repository at this point in the history
  • Loading branch information
mahasak committed Dec 29, 2023
1 parent db39f88 commit cd95bc0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion femto-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"typescript": "^5.1.6"
},
"name": "@femto-sh/femto-shared",
"version": "0.0.1",
"version": "0.0.2",
"scripts": {
"db:introspect": "dotenv -- prisma introspect",
"db:generate": "dotenv -- prisma generate",
Expand Down
26 changes: 13 additions & 13 deletions femto-shared/src/messenger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {genChannelData} from "./data";

export const callSendAPI = async (page_id: string, message_data: any) => {
export const callSendAPI = async (traceId: string, page_id: string, message_data: any) => {
try {
const pageConfig = await genChannelData("FACEBOOK_PAGE", page_id);
if (pageConfig && pageConfig.token && pageConfig.token !== "") {
Expand All @@ -26,18 +26,18 @@ export const callSendAPI = async (page_id: string, message_data: any) => {
}
}

export const markSeen = async (page_id: string, psid: string) => {
export const markSeen = async (traceId: string, page_id: string, psid: string) => {
const messageData = {
recipient: {
id: psid
},
"sender_action": "mark_seen"
};

await callSendAPI(page_id, messageData);
await callSendAPI(traceId, page_id, messageData);
}

export const sendButtonTemplate = async (page_id: string, recipientId: string, message: string, buttons: any) => {
export const sendButtonTemplate = async (traceId: string, page_id: string, recipientId: string, message: string, buttons: any) => {
const payload = {
recipient: {
id: recipientId
Expand All @@ -54,10 +54,10 @@ export const sendButtonTemplate = async (page_id: string, recipientId: string, m
}
};

await callSendAPI(page_id, payload);
await callSendAPI(traceId, page_id, payload);
}

export const sendGenericTemplate = async (page_id: string, recipientId: string, elements: any) => {
export const sendGenericTemplate = async (traceId: string, page_id: string, recipientId: string, elements: any) => {
const payload = {
recipient: {
id: recipientId
Expand All @@ -73,21 +73,21 @@ export const sendGenericTemplate = async (page_id: string, recipientId: string,
}
};

await callSendAPI(page_id, payload);
await callSendAPI(traceId, page_id, payload);
}

export const sendMessageTemplate = async (page_id: string, recipientId: string, template: any) => {
export const sendMessageTemplate = async (traceId: string, page_id: string, recipientId: string, template: any) => {
const payload = {
recipient: {
id: recipientId
},
message: template
};

await callSendAPI(page_id, payload);
await callSendAPI(traceId, page_id, payload);
}

export const sendQuickReplies = async (page_id: string, recipientId: string, messageText: string, choices: any) => {
export const sendQuickReplies = async (traceId: string, page_id: string, recipientId: string, messageText: string, choices: any) => {
const payload = {
recipient: {
id: recipientId
Expand All @@ -99,10 +99,10 @@ export const sendQuickReplies = async (page_id: string, recipientId: string, mes
}
};

await callSendAPI(page_id, payload);
await callSendAPI(traceId, page_id, payload);
}

export const sendTextMessage = async (page_id: string, recipientId: string, messageText: string) => {
export const sendTextMessage = async (traceId: string, page_id: string, recipientId: string, messageText: string) => {
const messageData = {
recipient: {
id: recipientId
Expand All @@ -112,5 +112,5 @@ export const sendTextMessage = async (page_id: string, recipientId: string, mess
}
};

await callSendAPI(page_id, messageData);
await callSendAPI(traceId, page_id, messageData);
}

0 comments on commit cd95bc0

Please sign in to comment.