HydraNPS

Add the rating card to a Unity experience

One prefab, in front of your ending screen. No account, no server of your own, and no secret in your build. The visitor answers one question and the fleet keeps the answer.

Download the package Full guide Card spec

What the visitor sees

How was it?
★★★★★

Point at the stars above. This is the card, in the colors and the geometry of the spec: a dark card over your last frame, five stars, and a skip. One tap closes it. No tap for 10 seconds also closes it. The same card is on the screens, the tablets, the headsets and the browser, because every renderer reads one spec file.

Install

Unity 2021.3 or later. The one dependency is com.unity.ugui, which every Unity project has. The package draws no asset and imports nothing: the star is a mesh and the text uses a built in font.

The normal route. Download com.experiencenet.hydranps-0.1.0.tgz, then in Unity open Window > Package Manager > + > Add package from tarball.

https://releases.experiencenet.com/hydranps/production/v0.3.5/com.experiencenet.hydranps-0.1.0.tgz

That link is the package in this service version, v0.3.5. The newest published version is always at https://releases.experiencenet.com/api/v1/releases/hydranps/production, and /unity/package.tgz on this site sends you to it.

Other routes. Copy the folder unity/com.experiencenet.hydranps into your project Packages folder, which always works. With access to the hydranps repository, Add package from git URL takes https://github.com/cederikdotcom/hydranps.git?path=/unity/com.experiencenet.hydranps.

Use it, with no code

  1. Drag HydraNPSCard from the package Runtime/Prefabs folder into the scene that ends your experience.
  2. Disable the object.
  3. On the object, wire On Finished to the thing that shows your ending screen.
  4. Where your experience ends, enable the object instead of showing that screen.

The card opens, the visitor taps a star or skips, the card closes, and your ending screen comes up.

Or with one line

using ExperienceNet.HydraNPS;

HydraNPS.Ask(ShowEndingScreen);

On Rated, and the Action<int> overload, give the stars from 1 to 5, or 0 when nobody answered. Almost no experience needs that number: the server keeps it. Call HydraNPS.StartSession() when the visit starts if you want the reported duration to cover the whole visit.

Settings on the prefab

FieldDefaultWhat it does
Experience Name empty The catalog name of your experience. Empty means the Unity product name folded to a slug. A configuration file on the machine wins over this field, and the body wins over both.
Show On Enable on Open the card when the object is enabled. This is what makes the no code pattern work.
Auto Dismiss Seconds 10 Seconds with no input before the card closes itself. The spec says 10. A different number breaks the comparison with the other platforms.
Render Mode Screen Space Overlay Correct for every streamed experience. Use world space only for an experience the visitor sees in a headset, where a screen space overlay does not appear.
World Space Distance 2 Metres in front of the camera, in world space mode only.

What the card promises

Where the score goes

On the fleet: through the body

Your experience posts the score to hydrabody on the loopback interface of the body it runs on. The body already knows which experience session this is, which venue it is in and which credential to use, so your build holds nothing secret and nothing to configure per venue.

POST http://127.0.0.1:47991/api/v1/nps/rating

{
  "source": "experience",
  "experience": "your-experience-name",
  "score": 8,
  "score_scale": "5-star",
  "experience_version": "1.4.2",
  "session_hint": "exp-3f91ab02-1761590400123"
}

This endpoint is not built yet. hydrabody needs the route, and hydracluster needs to deliver the service address and the write token to the bodies. Until that ships, use the direct transport below. Nothing in your scene changes when it lands.

On your own machine: direct

Put a hydranps.json beside your built executable, or in C:\experiences\hydranps.json on a body, or at /etc/hydranps/experience.json on Linux:

{
  "transport": "direct",
  "hydranps_url": "https://hydranps.experiencenet.com",
  "submit_token": "ask the ExperienceNet team",
  "experience": "your-experience-name"
}

Never compile that token into the build and never commit it. A built experience is readable, and a token in it is a token everybody has. That is the whole reason the fleet path goes through the body instead. To show the card and report nothing, for a trade show demo, set "transport": "disabled".

A post that fails on the network is not lost. It goes to a queue file in Application.persistentDataPath and is sent at the next start of the experience. A record older than 24 hours is dropped, and a record the server refuses is not retried.

The score on the wire

Five stars travel as 1 to 10, stars * 2, with score_scale: "5-star" on the record. That keeps an experience record, a head record and a browser record comparable in one average. A skip, and a card nobody answered, both report no score, which is the record that makes the rated share countable.

More