Email Us

Health Data Service

Use the Health Data Service to get user data and generated metrics from the Point database.

User Data

Use getUserData() to retrieve basic information about your User.

import PointSdkRn, { User } from "react-native-point-sdk";

try {
  const userData: User = await PointSdkRn.getUserData();
  console.log(userData);
} catch (error) {
  console.log(error);
}

The User object also contains some information related to their health journey, like their Goal or SpecificGoal, the current GoalProgress, and their last Workout.

💡 Currently, personal information such as name and email are not stored in any of our databases for privacy reasons.

Goals

Goals are used by the Health Data Service to know what is the main objective of your user while working out. This is used to generate recommendations and insights that help the user reach their objectives.

⚠️ We highly recommend setting a goal. Not setting a goal will greatly decrease the number of insights generated.

Setting a User Goal

Call syncUserGoal(goal:) to set the user Goal.

import PointSdkRn, { User, Goal } from "react-native-point-sdk";

try {
  const goal: Goal = "weightLoss";
  const user: User = await PointSdkRn.setUserGoal(goal);
  console.log(user);
} catch (error) {
  console.log(error);
}

Currently, the two options are Goal/athleticPerformance and Goal/weightLoss. You are free to use them as you wish, as long one of them is set for each user. You can hardcode the same goal for all users, present them as two options to choose from, or present a larger set of more specific goals that map to one of these two options. Your choice depends on your app's audience.

The SDK also provides a set of SpecificGoals (all values are only aliases to a Goal). Call syncUserSpecificGoal(specificGoal:) to set the user SpecificGoal. If you use the specific goals you don't need to call syncUserGoal.

import PointSdkRn, { User, SpecificGoal } from "react-native-point-sdk";

try {
  const specificGoal: SpecificGoal = "prepareForEvent";
  const user: User = await PointSdkRn.setUserSpecificGoal(specificGoal);
  console.log(user);
} catch (error) {
  console.log(error);
}

Checking the Goal Progress

You can also check their current GoalProgress, which are scores ranging from 0 to 1, generated by the Point Health Data Service. The goal progress is divided into four different scores: GoalProgress/overall, GoalProgress/endurance, GoalProgress/recovery and GoalProgress/strength.

import PointSdkRn, { User } from "react-native-point-sdk";

try {
 const userData: User = await PointSdkRn.getUserData();
 console.log(userData.goalProgress.overall.value);
 console.log(userData.goalProgress.strength.value);
} catch (error) {
 console.log(error);
}

For more information about the goal scoring system, check Point Data Science Overview. Note that you can have your own ways of interpreting the scores and creating an overall score.

User Workouts

Use getUserWorkouts(offset:) to retrieve a list of the User's last 16 Workouts, in descending order. The offset is meant to be used as a pagination, and if no value is passed, it is defaulted to 0.

import PointSdkRn, { Workout } from "react-native-point-sdk";

try {
  const offset: number = 0;
  const workouts: Workout[] = await PointSdkRn.getUserWorkouts(offset);
  console.log(workouts);
} catch (error) {
  console.log(error);
}

Retrieves a single Workout for the given id.

import PointSdkRn, { Workout } from "react-native-point-sdk";

try {
  const workoutId = 1;
  const workout: Workout = await PointSdkRn.getUserWorkoutById(workoutId);
  console.log(workout);
} catch (error) {
  console.log(error);
}

Workout Rating

You can allow users to rate their past workouts. A workout rating is divided in "Difficulty", "Energy" and "Instructor" ratings. Each field can be rated from 1 to 5, defaulting to 0 if a value is not set.

import PointSdkRn, { Workout, WorkoutRatings } from "react-native-point-sdk";

try {
  const workoutId = 1;
  const workoutRatings: WorkoutRatings = {
    difficulty: 1,
    energy: 2,
    instructor: 3,
  };
  const workout: Workout = await PointSdkRn.rateWorkout(
    workoutId,
    workoutRatings
  );
  console.log(workout);
} catch (error) {
  console.log(error);
}

⚠️ We recommend you to rate a workout only once.

Daily History

Use getDailyHistory(offset) to retrieve a list of the User's last 16 days worth of DailyHistory, in descending order. The DailyHistory is composed of daily total calories, exertion rate and total workout duration.

import PointSdkRn from "react-native-point-sdk";

try {
  const offset: number = 0;
  const dailyHistory = await PointSdkRn.getDailyHistory(offset);
  console.log(dailyHistory);
} catch (error) {
  console.log(error);
}

💡 The offset is meant to be used as a pagination, and if no value is passed, it is defaulted to 0.

User Health Metrics

You can get a set of user health metrics, which are a summary of the collected samples. Check HealthMetric to know all kinds of health metrics available.

import PointSdkRn, { HealthMetricType } from "react-native-point-sdk";

try {
  const workoutId = 1;
  const date = new Date().toIsoString();
  const filter: HealthMetricType[] = [
    "RestingHR",
    "OneMinuteHRR",
    "ThreeMinuteHRR",
  ];
  const healthMetrics = await PointSdkRn.getHealthMetrics({
    workoutId,
    filter,
    date,
  });
  console.log(healthMetrics);
} catch (error) {
  console.log(error);
}

✨ You can filter by type, workout or date.

Insights

As your user goes through their health journey, Point automatically generates actionable health insights that will help your users achieve maximal health and wellness. These insights can be wrapped in custom copy text, so you can recommend helpful actions for them to take in your product or platform, using Point's real-time health intelligence system.

You can get the list of generated Insights using getInsights(types:from:to:offset:). You must provide a list of InsightType. You can also filter the results based on a date interval using the from and to parameters.

⚠️ The result is limited to 16 insights. You can use the offset parameter for pagination. If not provided, it defaults to 0.

  async function getInsights() {
    try {
      console.log(await PointSdkRn.getInsights({ types: [InsightType.UsualWorkoutTime]}));
    } catch (error) {
      console.log(error);
    }
  }

To check the insight's content, you will need to parse Insight/additionalFields as a JSON. The JSON keys changes for each insight type. For example, the insight type InsightType/exertionOptimalPm has the keys change and pct_change, while type InsightType/mostEfficientWorkoutType has the keys workout_type and avg_value.

💡 You can find detailed information about Insights here, including all JSON keys for each type (refer to the 'Metadata' column in each table).

Workout Recommendations

Retrieves a list of WorkoutRecommendation. Workout recommendations are generated weekly on the Point database, based in the user goal. The date parameter defines which week you will get recommendations from.

import PointSdkRn, { WorkoutRecommendation } from "react-native-point-sdk";

try {
  const date = new Date("2021-10-2").toIsoString();
  const workoutRecommendations: WorkoutRecommendation[] =
    await PointSdkRn.getWorkoutRecommendations(date);
  console.log(workoutRecommendations);
} catch (error) {
  console.log(error);
}

💡 Use the current date to get recommendations from the current week.

Saving a Workout Recommendation

You can use saveWorkoutRecommendation(id:) to let your user choose which workout recommendations they wish to accomplish. By saving it, Point is able to check if the user accomplished this recommendation and use this information to improve the next recommendations given to this user.

import PointSdkRn, { WorkoutRecommendation } from "react-native-point-sdk";

async function saveWorkoutRecommendation(recommendation: WorkoutRecommendation) {
  try {
    console.log(await PointSdkRn.saveWorkoutRecommendation(recommendation.id));
  } catch (error) {
    console.log(error);
  }
}

Connect with Us

Terms & Conditions | Privacy Policy © 2023 Point® (Key Point Technologies, Inc.)