@keyframerdev/vitals 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -27,12 +27,15 @@ At the app's entry, with the project's field key (`kfp_live_…`, public and wri
27
27
  ```ts
28
28
  import { startVitals } from '@keyframerdev/vitals'
29
29
  import AsyncStorage from '@react-native-async-storage/async-storage'
30
- import * as Application from 'expo-application'
30
+ import Constants from 'expo-constants'
31
+ import { Platform } from 'react-native'
32
+
33
+ const build = Platform.OS === 'ios' ? Constants.platform?.ios?.buildNumber : Constants.expoConfig?.android?.versionCode
31
34
 
32
35
  startVitals({
33
36
  key: 'kfp_live_…',
34
- appVersion: Application.nativeApplicationVersion!,
35
- build: Application.nativeBuildVersion ?? undefined,
37
+ appVersion: Constants.expoConfig?.version ?? '0',
38
+ build: build == null ? undefined : String(build),
36
39
  navigationRef, // React Navigation's createNavigationContainerRef() or expo-router's useNavigationContainerRef()
37
40
  storage: AsyncStorage, // optional: checkpoints, retries and the daily cap survive restarts
38
41
  })
@@ -40,6 +43,10 @@ startVitals({
40
43
 
41
44
  Nothing is measured or sent before `startVitals`. If your app asks for consent, call it after.
42
45
 
46
+ `expo-constants` rather than `expo-application`: the latter is a native module, and an EAS Update that adds it crashes every installed binary built without it. Without Expo, use `react-native-device-info` or your own constants.
47
+
48
+ Before your store release, declare it in the stores' privacy forms (App Store: Diagnostics > Performance Data; Google Play: Diagnostics) and add a sentence to your privacy policy: [what to declare](https://keyframer.dev/inspector/docs/vitals/store-privacy).
49
+
43
50
  | Option | Default | What it does |
44
51
  | --- | --- | --- |
45
52
  | `key` | required | The project's field key |
@@ -53,6 +60,7 @@ Nothing is measured or sent before `startVitals`. If your app asks for consent,
53
60
  | `device` | none | `{ model, memoryBytes, memoryGb, tier, displayHz }`, read by the app (for example from `expo-device`) |
54
61
  | `appId` | none | The bundle id or package name |
55
62
  | `endpoint` | `https://vitals.keyframer.dev` | The ingest server |
63
+ | `debug` | `false` | Logs what the SDK decides, measures and sends: the session and its sampling, frames a second per thread, each report against the server's limits. Lines are tagged `[Keyframer.dev]` and go through `console.debug`, so Metro shows them as `DEBUG` (a note for you, such as development builds being off, is `INFO`; a refused report is `WARN`). For development builds |
56
64
 
57
65
  ## Call sites with file and line
58
66
 
package/dist/index.js CHANGED
@@ -624,7 +624,7 @@ var MAX_FRAME_MS = 10 * 60 * 1000;
624
624
 
625
625
  // src/version.ts
626
626
  var SDK_NAME = "@keyframerdev/vitals";
627
- var SDK_VERSION = "0.1.3";
627
+ var SDK_VERSION = "0.1.5";
628
628
 
629
629
  // src/controller.ts
630
630
  var STORAGE_KEYS = {
@@ -684,6 +684,7 @@ async function write(storage, key, value) {
684
684
  await storage.setItem(key, JSON.stringify(value));
685
685
  } catch {}
686
686
  }
687
+ var TAG = "[Keyframer.dev]";
687
688
 
688
689
  class VitalsController {
689
690
  env;
@@ -813,7 +814,7 @@ class VitalsController {
813
814
  }
814
815
  }
815
816
  this.sampled = sampled;
816
- this.debug(`session ${this.nonce.slice(0, 6)}: ${sampled ? "sampled" : "not sampled"} (rate ${this.sampleRate}, environment ${env}` + `${devOk ? "" : ", the project does not collect development builds"})`);
817
+ this.debug(`Motion Vitals ${SDK_VERSION}, session ${this.nonce.slice(0, 6)}: ${sampled ? "sampled" : "not sampled"} (rate ${this.sampleRate}, environment ${env}` + `${devOk ? "" : ", the project does not collect development builds"})`);
817
818
  if (!sampled)
818
819
  return;
819
820
  this.collector.clear();
@@ -1221,7 +1222,11 @@ class VitalsController {
1221
1222
  if (run !== this.run || !this.opts)
1222
1223
  return;
1223
1224
  try {
1224
- const res = await this.env.fetch(`${this.endpoint()}/v1/config/${encodeURIComponent(this.opts.key)}`, { method: "GET", headers: {} });
1225
+ const fresh = Math.round(this.env.wall()).toString(36);
1226
+ const res = await this.env.fetch(`${this.endpoint()}/v1/config/${encodeURIComponent(this.opts.key)}?t=${fresh}`, {
1227
+ method: "GET",
1228
+ headers: { "Cache-Control": "no-cache" }
1229
+ });
1225
1230
  if (run !== this.run)
1226
1231
  return;
1227
1232
  if (res.status === 200) {
@@ -1254,7 +1259,7 @@ class VitalsController {
1254
1259
  if (kept)
1255
1260
  this.debug("this project keeps development builds: this build's reports show in the dashboard's Development view");
1256
1261
  else
1257
- this.env.log?.("[keyframer vitals] This project does not keep reports from development builds, so this build sends nothing. " + `To test here, turn on "Development builds" in the project's setup on keyframer.dev, then reload. Release builds are not affected.`, "info");
1262
+ this.env.log?.(`${TAG} This project does not keep reports from development builds, so this build sends nothing. ` + `To test here, turn on "Development builds" in the project's setup on keyframer.dev, then reload. Release builds are not affected.`, "info");
1258
1263
  }
1259
1264
  if (!kept && this.sampled)
1260
1265
  this.endSampling();
@@ -1291,11 +1296,11 @@ class VitalsController {
1291
1296
  }
1292
1297
  }
1293
1298
  log(message) {
1294
- this.env.log?.(`[keyframer vitals] ${message}`);
1299
+ this.env.log?.(`${TAG} ${message}`, "warn");
1295
1300
  }
1296
1301
  debug(message) {
1297
1302
  if (this.opts?.debug)
1298
- this.env.log?.(`[keyframer vitals] ${message}`, "debug");
1303
+ this.env.log?.(`${TAG} ${message}`, "debug");
1299
1304
  }
1300
1305
  }
1301
1306
 
@@ -1446,7 +1451,7 @@ var env = {
1446
1451
  setTimeout: (fn, ms) => setTimeout(fn, ms),
1447
1452
  clearTimeout: (h) => clearTimeout(h),
1448
1453
  platform: { os: Platform.OS === "ios" ? "ios" : "android", osMajor: osMajor() },
1449
- log: (m, level) => level === "debug" || level === "info" ? console.log(m) : console.warn(m)
1454
+ log: (m, level) => level === "debug" ? console.debug(m) : level === "info" ? console.info(m) : console.warn(m)
1450
1455
  };
1451
1456
  var controller = new VitalsController(env);
1452
1457
  var jsHook = createJsHook(controller, () => checkScreen());
@@ -1,3 +1,3 @@
1
1
  /** This package's version: sent in every report's `sdk`, and compared with the config's `minSdk`. Keep it in step with package.json. */
2
2
  export declare const SDK_NAME = "@keyframerdev/vitals";
3
- export declare const SDK_VERSION = "0.1.3";
3
+ export declare const SDK_VERSION = "0.1.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyframerdev/vitals",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Motion Vitals for React Native: slow frames and janky animations from production, by screen and call site",
5
5
  "keywords": [
6
6
  "react-native",