Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Map Where a Hiker's Message Goes

In this lesson, you followed one hiker’s message through the assistant, found every copy it leaves, and gave each copy its lifetime.

Key Points

  • Hikers type more than the answer needs. Marta’s message holds her name, a booking reference, her friend’s asthma and her phone number, but the answer needs only the place and the day.
  • The request to your provider carries the question with all of Marta’s details. It lives as long as the call.
  • The provider keeps a copy. Not training on API data is a separate promise from not keeping it. Providers keep requests for about 30 days by default, longer for flagged content or a legal hold. Some also keep a stored copy you can fetch by its ID, for at least 30 days unless you switch it off.
  • Your trace holds two copies, in the retrieve span’s query and the model span’s request. Your trace writer keeps them for 30 days. The daily sweep deletes each day’s file once that day is 30 days old. The sweep runs at startup and once a day, so only while your app runs. The request log holds no copy, because it writes only the fields you chose, like the safe log line in Configuration, CORS and Logging for Node APIs.
  • An eval case built from a hiker’s report is another copy, kept as long as your repository. Take the names, numbers and health details out by hand first, and drop any detail the failure doesn’t need. A cache in your app would be one more.
  • The numbers: one question left four copies of Marta’s details on this map, counting the provider’s copy once, though a provider can hold more than one (its logs and, if switched on, a stored response). Your app keeps its own for 30 days. The provider keeps its copies by its own terms.
  • Map every copy, give each its lifetime, and send and keep only what the answer needs.

Final Code

In model/index.js, name the fields a request may carry, so nothing else reaches the provider:

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

00:00 In Replay a Call From Its Trace, you turned a hiker’s question into an eval case. That question named no one. Many of the simulated season’s questions do.

00:11 Here’s one message from Marta. It has her name, a booking reference, her friend’s asthma, and her phone number. The question itself is about snow on the Col de Fenêtre on Thursday.

00:23 To answer it, the assistant needs only the place and the day. Everything else rides along. In this video, you’ll follow this one message and find every copy the assistant makes of it.

00:36 The message goes to your server, and then to the model. The request your model module sends holds the instructions, any reports that matched (none did here) and the question, with all of Marta’s details inside.

00:48 That copy lives only as long as the call. Next, the provider keeps a copy. Your provider doesn’t train on API data by default. But not training on it is a separate promise from not keeping it.

01:02 Providers keep requests for about 30 days by default, longer for flagged content or a legal hold. The text below the video has each provider’s terms, and a setting that keeps less.

01:15 Then your server writes the trace. Search today’s trace file for Marta’s phone number, and grep counts 2 lines. They’re the retrieve span’s query and the model span’s request.

01:26 This demo writes every trace. Your trace writer keeps flagged answers and a sample of the rest, for 30 days. While your app runs, a daily sweep deletes each day’s file once that day is 30 days old.

01:41 Search the request log for the same number: 0. The log writes only the fields you chose, so it holds no copy.

01:51 Two more places can hold the message. If a hiker reports this answer, it can become an eval case, as the Forcella answer did. Take the names, numbers and health details out by hand first, because the case stays as long as your repository.

02:06 And your app has no cache yet. A cache would be another box on this map. Now count the copies on this map. One question leaves four copies of Marta’s details.

02:17 They’re the request, the provider’s copy, and two trace lines.

02:23 Your app keeps its own for 30 days, until the daily sweep. The provider keeps its copy by its own terms.

02:31 Now cut what you can. Start with what leaves your server. In your model module, name the four fields the request may carry. Today the request carries only these four, so nothing changes yet.

02:45 But a field someone adds later is left behind.

02:49 That keeps new fields out, but not what Marta typed. Her question still goes to the provider with her details. The next lesson cleans them out of your traces, but the request keeps them.

03:01 For now, ask hikers for less. A notice by the question box says what’s sent and kept, and asks them to leave out names, numbers and health details.

03:12 So map every copy of a message, give each one its lifetime, and send and keep only what the answer needs.

03:20 Here, one question made four copies on this map, and your app keeps its own for 30 days. Two of those copies are your traces. In the next lesson, Redact Before You Record, you’ll clean what Marta typed out of the trace before it’s written.

Become a Member to join the conversation.