
typescriptconst fetchGarminActivities = async (event: any) => {const oauthToken = event.oauthToken;const oauthTokenSecret = event.oauthTokenSecret;const currentDate = new Date();const summaryStartTimeInSeconds = Math.floor(Date.UTC(currentDate.getUTCFullYear(), currentDate.getUTCMonth(), currentDate.getUTCDate(), 0, 0, 0, 0) / 1000);const summaryEndTimeInSeconds = summaryStartTimeInSeconds + 86400;try {const response = await axios({method: "GET",url: "https://apis.garmin.com/wellness-api/rest/backfill/activityDetails",headers: generateOauthSignatureHeaders({method: "GET",url: "https://apis.garmin.com/wellness-api/rest/backfill/activityDetails",oauthToken,oauthTokenSecret,summaryStartTimeInSeconds,summaryEndTimeInSeconds,}),params: {summaryStartTimeInSeconds,summaryEndTimeInSeconds,},});// Process and store the activity data} catch (error) {console.error(error?.response?.data ?? error);}};

typescriptconst fetchPolarActivityList = async (event: any) => {const accessToken = event.accessToken;const userId = event.userId;try {const response = await axios({method: "GET",url: `https://www.polaraccesslink.com/v3/users/${userId}/activity-transactions`,headers: {Authorization: `Bearer ${accessToken}`,},});// Process and store the activity data} catch (error) {console.error(error?.response?.data ?? error);}};
typescriptconst fetchFitbitActivities = async (event: any) => {const accessToken = event.accessToken;const userId = event.userId;try {const response = await axios({method: "GET",url: `https://api.fitbit.com/1/user/${userId}/activities/list.json`,headers: {Authorization: `Bearer ${accessToken}`,},params: {sort: 'desc',offset: 0,limit: 100,},});// Process and store the activity data} catch (error) {console.error(error?.response?.data ?? error);}};
typescriptinitHealthKit = () => {let options = {permissions: {read: ['Height', 'Weight', PERMS.StepCount, PERMS.BodyFatPercentage,PERMS.Step, PERMS.DistanceWalkingRunning, PERMS.HeartRate,PERMS.BodyTemperature, PERMS.BloodPressureDiastolic,],write: ['Height', 'Weight'],},}AppleHealthKit.isAvailable((error, available) => {if (available) {AppleHealthKit.initHealthKit(options, (err, results) => {if (err) {console.error('Error initializing HealthKit', err);} else {console.log('HealthKit initialized successfully');}});} else {console.error('HealthKit is not available on this device');}});}
To create a unified experience, implement a robust backend system:
Example of storing activity data in DynamoDB:
typescriptconst createActivityEvent = async (eventInfo: {userId: string;title: string;latitude?: number;longitude?: number;fitbitLogId?: string;garminSummaryId?: string;polarExerciseId?: string;appleActivityId?: string;startDate?: string | null;endDate?: string | null;activityType: string;},healthMetrics: {avgHr: number | null;avgPace: number | null;calories: number | null;distanceInMeters: number | null;steps: number | null;vo2Max: number | null;},user: User) => {const date = new Date();const eventPayload = {TableName: process.env.EVENTS_TABLE_NAME as string,Item: {id: uuidv4(),userId: eventInfo.userId,title: eventInfo.title,startDate: eventInfo.startDate,endDate: eventInfo.endDate,activityType: eventInfo.activityType,healthMetrics: healthMetrics,createdAt: date.toISOString(),updatedAt: date.toISOString(),},};await dbClient.put(eventPayload).promise();};
By meticulously integrating various health tracking platforms into a single system, you can provide users with a comprehensive and seamless health monitoring experience. This unified approach not only simplifies data management for users but also enables more accurate insights and personalized recommendations. As you develop your integrated health tracking app, prioritize data accuracy, user privacy, and a smooth user experience across all connected devices and platforms.

The tutorial outlines how to integrate Jenkins and Slack for monitoring CI/CD pipelines. It involves setting up a custom Slack app to receive messages from Jenkins, configuring Jenkins with the Slack Notification plugin, and adding the OAuth token from Slack as a secret text credential in Jenkins. Both traditional Jenkins jobs and Jenkins pipelines can be configured to send Slack notifications, with pipeline scripts used to send messages in the latter case.
Beiryu
Contributor

Xin chào các bạn, hôm nay mình sẽ chia sẻ với các bạn về hành trình xây dựng tính năng đọc truyện "Let's Story" trong ứng dụng Applaydu và những câu chuyện thú vị xoay quanh quá trình phát triển tính năng này.
Beiryu
Contributor