Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Status
colourGreen
titleAccurate

Code Block
languagejs
linenumberstrue
{
  "config": { // All clients listen here permanently
    "articleBaseUrl": "http://cloud-storage.com/articles/"
,
 },   "userslegalsUrl": {"http://impossible.am/legalstuff/",
    "user_id_01for7MW": {
//    Clients listen here permanently"facebookPage": "",
      "usernamefacebookGroup": "user",
// [default:null]
      "emailinstagramUser": "user@somewhere.com", // [default:null]
      "fitnessLevelfaqsUrl": 10,""
// [default:10]   },
    "fitnessBiasforAfterburner": 1, // [default:1]{
      "createdfacebookPage": 987654345"",
// Unix timestamp (seconds) [default:0]
      "maxImpactCreditfacebookGroup": 3"",
// [default:0]
      "impactCreditinstagramUser": 0.9"",
// [default:0]       "updatedICfaqsUrl": 987654345,""
// Unix timestamp (seconds) [default:0] }
  },
   "triggersFiredusers": {
"triggerId_01": true, "triggerId_02    "user_id_01": true },{ // [default:null]Clients listen here     "sessions": {permanently
          "for7MWusername": 2"user", // [default:0null]
 
      "forAfterburneremail": 0"user@somewhere.com", // [default:0]
      },null]
      "totalActivitiesfitnessLevel": 210, // [default:010]
      "totalActivities7MWfitnessBias": 1, // [default:01]
      "totalActivitiesAFcreated": 1987654345, // Unix timestamp (seconds) [default:0]
      "firstActivity7MWmaxImpactCredit": 9876543453, // Unix timestamp (seconds) [default:0]
      "impactCredit": 0.9, // [default:0]
      "firstActivityAFupdatedIC": 987654345, // Unix timestamp (seconds) [default:0]
    }   },
  "visibleWorkoutDefs": { // Workout defs that are visible to the user"triggersFired": { "triggerId_01": true, "triggerId_02": true }, // [default:null]
      "user_id_01sessions": {
        "for7MW": {2, // 7MW[default:0]
clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved"forAfterburner": 0 // [default:0]
     "wktdef1": {
   },
       "recommendedtotalActivities": ""2, // Not recommended, just visible // [default:null0]
	      "lockedtotalActivities7MW": true1, // Not[default:0]
available to user (unlocked via IAP and/or journey trigger) "totalActivitiesAF": 1, // [default:false0]
 		     "lockStringfirstActivity7MW": "Finish 6 more workouts before Thurs 9th June"987654345, // DisplayedUnix totimestamp user(seconds) [default:null0]
  
       "MWIfirstActivityAF": 0.54987654345, // Unix timestamp (seconds) [default:0.5]
  
       "breakdowntimedNotifSeqVersion": {0, // Version of timed notif sequence user is on    "epoc": 0.1, // (server use) [default:0.25]
      "testMode": false, // Puts the app in 'test  "cardio": 0.1, //mode' for this user [default:0.25false]
      "notifTokens": { // APN tokens for "metabolic": 0.1, //the user's devices [default:0.25null]
        "for7MW": {   "strengthapn_token": 0.1 true }, // [default:0.25]
     Where 'api_token' is the actual token string
    }    "forAfterburner": {   "apn_token": true },
      }
 "wktdef2": {  }
    },
   "recommendedvisibles": "You{
need to work on your abs","workoutDefs": { // RecommendedWorkout anddefs reasonthat forare thisvisible to bethe shown to user
		  "locked": false,
// Available to user 		  "lockStringuser_id_01": "",{ 
         "MWIfor7MW": 0.54,
          "breakdown": {
  { // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
          "epocwktdef1": 0.1,{
            "cardiorecommended": 0.1"", // Not recommended, just visible        "metabolic": 0.1,// [default:null]
             "strengthlocked": 0.1
          }
   true, // Not available to user (unlocked via IAP and/or journey trigger) [default:false]
  	     }   "lockString": "Finish 6 more },workouts before Thurs 9th    "forAfterburner": {June", // Displayed Afterburnerto clients listen here permanently for ChildAdded, ChildChanged and ChildRemoveduser [default:null]
            "MWI": 0.54,  "wktdef1": {// [default:0.5]
            "recommendedbreakdown": "", // Not recommended, just visible
	 {
              "lockedepoc": false0.1, // Available to user
		  "lockString": "",[default:0.25]
              "MWIcardio": 0.541, // [default:0.25]
        "breakdown": {             "epoc"metabolic": 0.1, // [default:0.25]
              "cardiostrength": 0.1, // [default:0.25]
            "metabolic": 0.1,}
          },
  "strength": 0.1
          }
        },         "wktdef2": {
            "recommended": "You need to work on your abs", // Recommended and reason for this to be shown to user
		
            "locked": false, // Available to user
		            "lockString": "",
            "MWI": 0.54,
            "breakdown": {
              "epoc": 0.1,
              "cardio": 0.1,
              "metabolic": 0.1,
              "strength": 0.1
          }  }
      }     }
 }     }   },
  "workouts": {     "activitiesforAfterburner": { // Afterburner clients listen here  "user_id_01": { // Clients listen here permanently for ChildAddedpermanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01  "wktdef1": {
// Clients post new activity to here with auto id, server listens           "workoutDefId"recommended": "wktdef1", // [no default]Not recommended, just visible
  	        "finishlocked": 987654345false, // UnixAvailable timestampto (seconds) [default:0]user
  	         "iterationslockString": 1.5, // Number of times it was performed [default:1]"",
            "exertionMWI": 0.554,
// [default:0.5]           "finalHeartRateBPMbreakdown": {
 160, // [default:140]           "finalHeartRateDelayepoc": 0.1,
 // Length of delay (in secs) after the workout before the HR was measured"cardio": (0.1,
 if they didn't press the 'start again' button) [default:0]
		      "appmetabolic": "7MW" // Short code of the app the activity was performed in: 7MW, AF, etc [default:null] 0.1,
              "strength": 0.1
            }
      }     },

   "results": {       "user_id_01wktdef2": {
//  Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved  "recommended": "You need to work on your "workout_id_01": {abs", // ServerRecommended postsand workoutreason resultsfor herethis to be shown to user
     "workoutDefId": "wktdef1", // [no default]
          "finishlocked": 987654345false, // UnixAvailable timestampto (seconds)user
// [no default]           "AWIlockString": 0.1"",
// [default:0.5]           "responseDurationMWI": 34560.54,
// [default: 0]           "intensitybreakdown": 0.9, // [default:0.5]
		  "app": "7MW", // Short code of the app the activity was performed in: 7MW, AF, etc [no default]{
              "epoc": 0.1,
              "responsescardio": { // [no default]0.1,
               "cardiometabolic": {0.1,
              "stressstrength": 43,0.1
            }
 "magnitudeProduct": 0.6,        }
      "halflifeProduct": 0.3,  }
      }
    },
    "durationroutines": 5678,{
      "user_id_01": { 
        "volumefor7MW": 3456{ // 7MW clients listen here permanently for ChildAdded, ChildChanged and   },
ChildRemoved
           "strengthroutine_id_01": {
 
            "stresslocked": 43true, // Not available to user (unlocked via IAP and/or journey trigger) [default:false]
   "magnitudeProduct": 0.6,         "lockString": "Finish 6 more workouts before Thurs 9th "halflifeProductJune": 0.3,
    // Displayed to user [default:null]
          "duration": 5678},
              "volume"routine_id_02": {
3456            "locked": }true,
            "epoclockString": {"" // No lock string, so only unlocked via IAP [default:null]
     "stress": 43,    },
          "magnitudeProductroutine_id_03": 0.6,
{
             "halflifeProductlocked": 0.3false, // Available
            "durationlockString": 5678,""
          }
   "volume": 3456    },
        },
            "metabolic": {"forAfterburner": { // 7MW clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
                "stress"routine_id_03": 43,
 {
            "magnitudeProductlocked": 0.6false, // Available
            "halflifeProductlockString": 0.3,""
          }
        }
 "duration": 5678,    }
    }
  },
  "volumeworkouts": 3456{
    "activities": {
      }
          },
 "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "muscleGroupsworkout_id_01": { // Clients post new activity to here with     "upper": 0.3, // [default: 0.3]auto id, server listens
             "lowerworkoutDefId": 0.3"wktdef1", // [no default: 0.3]

           "corefinish": 0.4987654345, // Unix timestamp (seconds) [default: 0.3]
          }
        }"iterations": 1.5, // Number of times it was performed [default:1]
       }   "exertion":  }
  },0.5, // [default:0.5]
    "afterburn": {     "user_id_01": {finalHeartRateBPM": 160, // [default:140]
Clients listen here permanently       "startfinalHeartRateDelay": 3456789870, // UnixLength of timestampdelay (secondsin secs) //after [nothe default]workout before the HR was measured  "response": { // [default:null]
        "resolution": 600,(0 if they didn't press the 'start again' button) [default:0]
		  "app": "7MW" // SecsShort code of the app the activity was performed "epoc"in: [0.6,0.5,0.3,0.2,0.1,0.0],7MW, AF, etc [default:null]
        }
      }
    },
    "results": {
      "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
        "workout_id_01": { // Server posts workout results here
          "workoutDefId": "wktdef1", // [no default]
          "finish": 987654345, // Unix timestamp (seconds) // [no default]
          "AWI": 0.1, // [default:0.5]
          "responseDuration": 3456, // [default: 0]
          "intensity": 0.9, // [default:0.5]
		  "app": "7MW", // Short code of the app the activity was performed in: 7MW, AF, etc [no default]
          "responses": { // [no default]
            "cardio": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "strength": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "epoc": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            },
            "metabolic": {
              "stress": 43,
              "magnitudeProduct": 0.6,
              "halflifeProduct": 0.3,
              "duration": 5678,
              "volume": 3456
            }
          },
          "muscleGroups": {
            "upper": 0.3, // [default: 0.3]
            "lower": 0.3, // [default: 0.3]
            "core": 0.4 // [default: 0.3]
          }
        }
      }
    }
  },
  "afterburn": {
    "user_id_01": { // Clients listen here permanently
      "start": 345678987, // Unix timestamp (seconds) // [no default]
      "response": { // [default:null]
        "resolution": 600, // Secs
        "epoc": [0.6,0.5,0.3,0.2,0.1,0.0],
        "cardio": [0.6,0.5,0.3,0.2,0.1,0.0],
        "strength": [0.6,0.5,0.3,0.2,0.1,0.0],
        "metabolic": [0.6,0.5,0.3,0.2,0.1,0.0]
      },
      "impactCredit": { // [default:null]
        "resolution": 600, // Secs
        "futureCredit": 0.9,
        "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
      },
      "messages": [ // Messages displayed below the radar chart [default:null]
        {"t":0,"body":"Restoring body temperature", "detail": ""},
        {"t":120,"body":"Replenishing glycogen stores", "detail": "detail/glycogen"}
      ],
      "notifications": [ // [default:null]
        {"t":6000,"body":"Great workout! You're still burning calories and building strength."},
        {"t":14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ]
    }
  },
  "timelineArticles": {
    "user_id_01": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved
      "article_id_01": {
        "cardiodate": [0.6,0.5,0.3,0.2,0.1,0.0], 4567890987, // Unix timestamp (seconds) // [no default]
        "strengthtitle": [0.6,0.5,0.3,0.2,0.1,0.0], "Post title", // [no default]
        "metabolic": [0.6,0.5,0.3,0.2,0.1,0.0read": false, // [default:true]
      },  "location": "post/location.html", // [no default]
		"impactCrediticon": {"default", // [default:null"default"]
        "resolutionappMask": 600"7MW,AF", // Secs [default: all apps]
        "futureCreditpromptRating": 0.9,true // [default:false]
      }
 "pending": [0.0,0.1,0.2,0.3,0.4,0.5]
     }
  },
  "definitions": {
    "messagesroutines": [{ // MessagesClients displayedlisten belowhere thepermanently radarfor chart [default:null]
 ChildAdded, ChildChanged and ChildRemoved
      {"t":0,"body":"Restoring body temperature", "detailroutine_id_01": {
        "title": "The Wonder Routine"}, // [no default]
     {"t":120,"body":"Replenishing glycogen stores", "detailimage": "detail/glycogen"}
 wonder-routine", // [default:"default-routine"]
    ],    "desc": "Big long description"notifications":, [ // [default:null]
        {"tappStoreId7MW":6000, "bodyroutine01":"Great workout! You're still burning calories and building strength."},, // StoreKit product id [default:null]
        {"tin7MW":14400,"body":"Fitness test unlocked! You're ready to take another fitness test."}
      ] true, // For server use [default:false]
        "inAfterburner": false, // For server use [default:false]
      }  "lockedIn7MW": },false, // For server use [default:false]
  "timelineArticles": {     "user_id_01lockedInAfterburner": {false, // ClientsFor listenserver here permanently for ChildAdded, ChildChanged and ChildRemoveduse [default:false]
        "video": "",  "article_id_01": {// [default:null]
        "dateminFitnessLevel": 45678909874, // Unix timestamp (seconds) [default:1]
        "workoutDefs": { // [no default]
          "titlewktdef1": "Post{
title", // [no default]         "readtype": false1, // [default:true1]
            "locationtitle": "post/location.htmlAerobic", // [no default]
		"icon            "image": "defaultabs", // [default:"default"]
            "appMaskdesc": "7MW,AF"Aerobic Basic Movement", // [default: all apps]
 null]
    }     }   },
  "definitionsbreakDuration": {
    "exerciseDefs": { // Clients listen here permanently for ChildAdded, ChildChanged and ChildRemoved5, // // [default:10]
            "appStoreId7MW": "exdef1": {workout01", // StoreKit product id [default:null]
            "behaviourlocked": 1false, // For server use [default:1false]
        "title			"MWI": "Cruches"0.54, // [no default:0.5]
            "videoexercises": "01-Crunches.mp4",[ // [no default]
        "image": "abs", // [default:"default"]
       {
      "desc": "A crunch begins with lying face up on the floor with knees bent. The movement begins by curling the shoulders towards the pelvis. The hands can be behind or beside the neck or crossed over the chest. Injury can be caused by pushing against the head or neck with hands.", // [default:null]"id": "exdef1", // [no default]
                "duration": 20 // [no default]
              },
          "subtitle": "Target your abs for{
a balanced set of stomach muscles.", // [default:null]         "calPerSecid": 5"exdef2",
// [default:0]                "skillduration": 0.2, // [default:0.5]15
           "strength": 0.7, // [default:0.5] },
        "cardio": 0.1, // [default:0.5]   {
     "epoc": 0.4, // [default:0.5]         "metabolicid": 0.4"exdef3",
// [default:0.5]
        "upper": 0.5, // [default:0.5]         "coreduration": 0.5, // [default:0.5]10
         "lower": 0.5 // [default:0.5]  },
    },       "exdef2": {  {
      "behaviour": 1,         "titleid": "Squatsexdef4",
        "video": "02-Squats.mp4",
        "imageduration": "abs", 5
              "desc": "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",},
              {
                "subtitleid": "Train your lower body and core.","exdef5",
                "calPerSecduration": 10
4,          "skill": 0.2,   }
     "strength": 0.6,      ],
  "cardio": 0.3,         "epocadaptiveStress": 0.4,{
        "metabolic": 0.6,         "upperstrength": 0.52, // [default:1]
      "core": 0.5,           "lowercardio": 0.59, // [default:1]
    }     },     "workoutDefsmetabolic": {0.6, // Clients[default:1]
listen here permanently for ChildAdded, ChildChanged and ChildRemoved       "wktdef1epoc": {0.6 // [default:1]
           "type": 1},
  // [default:1]         "titlemuscleStress": "Aerobic", // [no default] {
              "imageupper": "abs"10, // [default:"default"1]
        "desc": "Aerobic Basic Movement", // [default:null]
        "breakDurationlower": 510, // // [default:101]
		"appStoreId: "workout01", // StoreKit product id [default:null]         "in7MWcore": true,10 // For server use [default:false1]
        "inAfterburner": false, // For server use [default:false]  }
        "exercises": [ //}
[no default]       }
   {   }
    },
    "idexerciseDefs": "exdef1",{ // Clients [nolisten default]here permanently for ChildAdded, ChildChanged and ChildRemoved
      "durationexdef1": 20{
// [no default]           }"behaviour": 1, // [default:1]
        {
   "title": "Cruches", // [no default]
        "idvideo": "exdef201-Crunches.mp4", // [no default]
         "durationimage": 15
 "abs", // [default:"default"]
        },
          {
            "id": "exdef3",
            "duration": 10
          },
          {
            "id": "exdef4",
   "desc": "A crunch begins with lying face up on the floor with knees bent. The movement begins by curling the shoulders towards the pelvis. The hands can be behind or beside the neck or crossed over the chest. Injury can be caused by pushing against the head or neck with hands.", // [default:null]
        "subtitle": "Target your abs for a balanced set of stomach muscles.", // [default:null]
        "durationcalPerSec": 5, // [default:0]
        }"skill": 0.2, // [default:0.5]
        {
   "strength": 0.7, // [default:0.5]
        "idcardio": "exdef5"0.1, // [default:0.5]
          "durationepoc": 10
 0.4, // [default:0.5]
        }
        ],"metabolic": 0.4, // [default:0.5]
        "adaptiveStressupper": {
 0.5, // [default:0.5]
        "strengthcore": 0.25, // [default:10.5]
          "cardiolower": 0.95, // [default:10.5]
 
        "metabolicneedsHalfwaySwap": 0.6,false // [default:1false]
      },
      "epocexdef2": 0.6 // [default:1] {
        "behaviour": 1,
        }"title": "Squats",
        "muscleStressvideo": {"02-Squats.mp4",
          "upperimage": 10, // [default:1]
          "lower": 10, // [default:1]
          "core": 10 // [default:1]"abs",
        "desc": "Squats are an excellent exercise for training the lower body and core muscles, if done regularly they help to define thighs and buttocks.",
        "subtitle": "Train your }lower body and core.",
   },       "wktdef2calPerSec": {4,
        "typeskill": 10.2,
        "titlestrength": "Thai Boxing"0.6,
        "imagecardio": "abs"0.3,
        "descepoc": "Boxing With Kicking"0.4,
        "breakDurationmetabolic": 40.6,
		"appStoreId: "", // StoreKit product id         "in7MWupper": false0.5,
// For server use         "inAfterburnercore": true, // For server use0.5,
        "exerciseslower": [0.5,
        "needsHalfwaySwap": true
{        }
    "id": "exdef5"},
    "journeyTriggers": {
      "durationforAfterburner": 15{
        "trigger01": {
},           {
"category": "achievement",
           "idtriggerType": "exdef3activeDaysInWeeks",

           "durationcondition1": 104, // 4 active days
      },    "condition2": 8, // every week for 8 {
 weeks
          "idactions": "exdef1",[
              "duration": 5
{"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
         }         ],
        "stress": {{"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          "strength": 0.2,]
          "cardio": 0.9,
 },
        "metabolictrigger02": 0.6,{
          "epoccategory": 0.6 "education",
           },"triggerType": "totalActivities",
          "muscleStresscondition1": { 10, // 10 activities
          "uppercondition2": 100, // Not used
          "loweractions": [
10,            "core": 10{"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}
        }  ]
    }    }
},     "journeyTriggers: {},
      "forAfterburnerfor7MW": {
        "trigger01": {
          "category": "achievement",
          "triggerType": "activeDaysInWeeks",
          "condition1": 4, // 4 active days
          "condition2": 8, // every week for 8 weeks
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
            {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
          ]
        },
        "trigger02": {
          "category": "education",
          "triggerType": "totalActivities",
          "condition1": 10, // 10 activities
          "condition2": 0, // Not used
          "actions": [
            {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}}
          ]
        }
      }
    }
    "timedNotifs": {
      "forAfterburner": {
        "notif01": {
          "deltaHours": 24, ]// Delta after APN token reg that the notif }is delivered [no default]
   },       "for7MWseqVersion": {
        "trigger01": { 0, // Sequence version to allow future updates without flooding existing users [default:0]
          "categorytitle": "achievementTitle of notification", // [default:""]
          "triggerTypebody": "activeDaysInWeeksBody of notification", // [no default]
       "condition1": 4}, //
4 active days    },
      "condition2for7MW": 8, // every week for 8 weeks {
        "notif01": {
          "actionsdeltaHours": [24, 
           {"actionTypeseqVersion":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"},
  0, 
         {"actionType":"unlockWorkout","workoutDefId":"workoutDef_id_01","articleId":"article_id_02","data":""}
  "title": "Title of notification",
          "body": "Body of notification"
        ]},
      }
 },   }
  },
  "trigger02receipts": {
    "user_id_01": {
      "categoryreceipt_auto_id_01": "education",
{
         "triggerTypereceipt": "totalActivitiesreceipt_data", //          "condition1": 10, // 10 activities
 Written by the client after an IAP purchase
        "condition2validation": 0,{ // NotWritten usedby the server after the receipt has been processed
  "actions": [       "validationDate": 3456789, //    {"actionType":"postArticle","articleId":"article_id_01","data":"e.g. url parameters"}Timestamp [default:0]
          "isValid": true [default:false]
        }
      }
    }
  },
}

Client-Side Data Validation & Error Handling

We apply the following process to validate data on the client and to handle the errors appropriately:

SituationActions
  • Property is missing or is wrong type
  • Property has a default defined in the model schema.
  • Log error to crashlytics.
  • Handle silently and apply default value.
  • Property is missing or is wrong type
  • Property doesn't have a default defined.
  • Log error to crashlytics.
  • Throw exception (catch the exception according to object-specific rules, see below).
  • Entire object is missing
  • Log error to crashlytics.
  • Throw exception (catch the exception according to object-specific rules, see below).

Data Validation Exception Handling

EntityChecksAction
visibleWorkoutDef
  • Missing properties without defaults.
  • Missing or invalid workout definition.
Hide from user.
exerciseDefinition
  • Missing properties without defaults.
Tell user via alert view.
timelineArticle
  • Missing properties without defaults.
Hide from user.
activity
  • Missing properties without defaults.
Tell user via alert view.
result
  • Missing properties without defaults.
Tell user via alert view.
afterburn
  • Missing properties without defaults.
Tell user via alert view.
userN/A (all properties have defaults)None