@blipit/react-native 0.1.0 → 0.2.1

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/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 0.2.1
2
+
3
+ - Events carry the `npm:@blipit/react-native` package and version, so the dashboard can show when this app runs an old Blipit SDK. A `beforeSend` you pass still runs after it. `VERSION` is exported.
4
+ - No development console notice: events leave through the native transport, which does not expose response headers, and swapping it for the fetch transport in development would change how events are queued offline. The dashboard banner covers updates instead.
5
+
6
+ ## 0.2.0
7
+
8
+ - `init` with an empty key or project id logs a warning, returns false and leaves Blipit off instead of throwing. It returns true when started.
package/README.md CHANGED
@@ -23,7 +23,7 @@ Blipit.init({ key: "<public key>", project: <project id>, environment: "producti
23
23
  export default Blipit.wrap(App);
24
24
  ```
25
25
 
26
- Both values are on the project's Keys page at app.blipit.io. Unhandled JavaScript errors and native crashes are reported on their own.
26
+ Both values are on the project's Keys page at app.blipit.io. If the key or project id is empty, `init` logs a warning, returns `false` and Blipit stays off; it never throws, so a missing key cannot crash the app at launch. Unhandled JavaScript errors and native crashes are reported on their own.
27
27
 
28
28
  ## Manual capture
29
29
 
@@ -42,3 +42,7 @@ await Blipit.flush();
42
42
  Pass `tracesSampleRate: 0.2` to `init` and screen loads and requests show up on the Performance page.
43
43
 
44
44
  Docs: https://docs.blipit.io/mobile
45
+
46
+ ## Updates
47
+
48
+ The project page on app.blipit.io shows a banner when this app sends events from an older version, with the command. Update with `npm install @blipit/react-native@latest`. Details: https://docs.blipit.io/updates
package/dist/index.cjs CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  DEFAULT_ENDPOINT: () => DEFAULT_ENDPOINT,
34
+ VERSION: () => VERSION,
34
35
  addBreadcrumb: () => import_react_native.addBreadcrumb,
35
36
  captureException: () => import_react_native.captureException,
36
37
  captureMessage: () => import_react_native.captureMessage,
@@ -40,28 +41,52 @@ __export(index_exports, {
40
41
  init: () => init2,
41
42
  setTag: () => import_react_native.setTag,
42
43
  setUser: () => import_react_native.setUser,
44
+ withIdentity: () => withIdentity,
43
45
  wrap: () => import_react_native.wrap
44
46
  });
45
47
  module.exports = __toCommonJS(index_exports);
46
48
  var Sentry = __toESM(require("@sentry/react-native"), 1);
47
49
  var import_react_native = require("@sentry/react-native");
48
50
  var DEFAULT_ENDPOINT = "https://in.blipit.io";
51
+ var VERSION = "0.2.1";
52
+ var PACKAGE = { name: "npm:@blipit/react-native", version: VERSION };
53
+ function withIdentity(user) {
54
+ return (event, hint) => {
55
+ try {
56
+ const sdk = event.sdk ??= {};
57
+ const packages = sdk.packages ?? [];
58
+ if (!packages.some((p) => p?.name === PACKAGE.name)) sdk.packages = [...packages, { ...PACKAGE }];
59
+ } catch {
60
+ }
61
+ return user ? user(event, hint) : event;
62
+ };
63
+ }
49
64
  function dsn(key, project, endpoint = DEFAULT_ENDPOINT) {
50
65
  const host = endpoint.split("://").pop().replace(/\/+$/, "");
51
66
  const scheme = endpoint.startsWith("http://") ? "http" : "https";
52
67
  return `${scheme}://${key}@${host}/${project}`;
53
68
  }
69
+ var MISSING_KEY = "[blipit] Blipit.init got no key, so Blipit is off and nothing is sent. Pass the project's public key (app.blipit.io, Keys); with Expo, check that EXPO_PUBLIC_BLIPIT_KEY is set at build time.";
70
+ var MISSING_PROJECT = "[blipit] Blipit.init got no project id, so Blipit is off and nothing is sent. Pass project with the id from the project's Keys page at app.blipit.io.";
54
71
  function init2(options) {
55
- const { key, publicKey, project, endpoint, ...rest } = options;
56
- const k = key ?? publicKey;
57
- if (!k) throw new Error("Blipit.init needs the project's public key");
58
- if (project === void 0 || project === null || project === "") throw new Error("Blipit.init needs the project id");
72
+ const { key, publicKey, project, endpoint, ...rest } = options ?? {};
73
+ const k = (key ?? publicKey ?? "").trim();
74
+ if (!k) {
75
+ console.warn(MISSING_KEY);
76
+ return false;
77
+ }
78
+ if (project === void 0 || project === null || String(project).trim() === "") {
79
+ console.warn(MISSING_PROJECT);
80
+ return false;
81
+ }
59
82
  Sentry.init({
60
83
  dsn: dsn(k, project, endpoint),
61
84
  sendDefaultPii: false,
62
85
  tracesSampleRate: 0,
63
- ...rest
86
+ ...rest,
87
+ beforeSend: withIdentity(rest.beforeSend)
64
88
  });
89
+ return true;
65
90
  }
66
91
  function captureSecurity(kind, actor, details = {}) {
67
92
  const context = { kind, actor };
@@ -79,6 +104,7 @@ function captureSecurity(kind, actor, details = {}) {
79
104
  // Annotate the CommonJS export names for ESM import in node:
80
105
  0 && (module.exports = {
81
106
  DEFAULT_ENDPOINT,
107
+ VERSION,
82
108
  addBreadcrumb,
83
109
  captureException,
84
110
  captureMessage,
@@ -88,5 +114,6 @@ function captureSecurity(kind, actor, details = {}) {
88
114
  init,
89
115
  setTag,
90
116
  setUser,
117
+ withIdentity,
91
118
  wrap
92
119
  });
package/dist/index.d.cts CHANGED
@@ -2,6 +2,9 @@ import { ReactNativeOptions } from '@sentry/react-native';
2
2
  export { addBreadcrumb, captureException, captureMessage, flush, setTag, setUser, wrap } from '@sentry/react-native';
3
3
 
4
4
  declare const DEFAULT_ENDPOINT = "https://in.blipit.io";
5
+ declare const VERSION = "0.2.1";
6
+ type BeforeSend = NonNullable<ReactNativeOptions["beforeSend"]>;
7
+ declare function withIdentity(user?: BeforeSend): BeforeSend;
5
8
  interface BlipitOptions extends Omit<ReactNativeOptions, "dsn"> {
6
9
  key?: string;
7
10
  publicKey?: string;
@@ -16,7 +19,7 @@ interface SecurityDetails {
16
19
  target?: string;
17
20
  }
18
21
  declare function dsn(key: string, project: string | number, endpoint?: string): string;
19
- declare function init(options: BlipitOptions): void;
22
+ declare function init(options: BlipitOptions): boolean;
20
23
  declare function captureSecurity(kind: string, actor: string, details?: SecurityDetails): void;
21
24
 
22
- export { type BlipitOptions, DEFAULT_ENDPOINT, type SecurityDetails, captureSecurity, dsn, init };
25
+ export { type BlipitOptions, DEFAULT_ENDPOINT, type SecurityDetails, VERSION, captureSecurity, dsn, init, withIdentity };
package/dist/index.d.ts CHANGED
@@ -2,6 +2,9 @@ import { ReactNativeOptions } from '@sentry/react-native';
2
2
  export { addBreadcrumb, captureException, captureMessage, flush, setTag, setUser, wrap } from '@sentry/react-native';
3
3
 
4
4
  declare const DEFAULT_ENDPOINT = "https://in.blipit.io";
5
+ declare const VERSION = "0.2.1";
6
+ type BeforeSend = NonNullable<ReactNativeOptions["beforeSend"]>;
7
+ declare function withIdentity(user?: BeforeSend): BeforeSend;
5
8
  interface BlipitOptions extends Omit<ReactNativeOptions, "dsn"> {
6
9
  key?: string;
7
10
  publicKey?: string;
@@ -16,7 +19,7 @@ interface SecurityDetails {
16
19
  target?: string;
17
20
  }
18
21
  declare function dsn(key: string, project: string | number, endpoint?: string): string;
19
- declare function init(options: BlipitOptions): void;
22
+ declare function init(options: BlipitOptions): boolean;
20
23
  declare function captureSecurity(kind: string, actor: string, details?: SecurityDetails): void;
21
24
 
22
- export { type BlipitOptions, DEFAULT_ENDPOINT, type SecurityDetails, captureSecurity, dsn, init };
25
+ export { type BlipitOptions, DEFAULT_ENDPOINT, type SecurityDetails, VERSION, captureSecurity, dsn, init, withIdentity };
package/dist/index.js CHANGED
@@ -2,22 +2,45 @@
2
2
  import * as Sentry from "@sentry/react-native";
3
3
  import { captureException, captureMessage as captureMessage2, setUser, setTag, addBreadcrumb, flush, wrap } from "@sentry/react-native";
4
4
  var DEFAULT_ENDPOINT = "https://in.blipit.io";
5
+ var VERSION = "0.2.1";
6
+ var PACKAGE = { name: "npm:@blipit/react-native", version: VERSION };
7
+ function withIdentity(user) {
8
+ return (event, hint) => {
9
+ try {
10
+ const sdk = event.sdk ??= {};
11
+ const packages = sdk.packages ?? [];
12
+ if (!packages.some((p) => p?.name === PACKAGE.name)) sdk.packages = [...packages, { ...PACKAGE }];
13
+ } catch {
14
+ }
15
+ return user ? user(event, hint) : event;
16
+ };
17
+ }
5
18
  function dsn(key, project, endpoint = DEFAULT_ENDPOINT) {
6
19
  const host = endpoint.split("://").pop().replace(/\/+$/, "");
7
20
  const scheme = endpoint.startsWith("http://") ? "http" : "https";
8
21
  return `${scheme}://${key}@${host}/${project}`;
9
22
  }
23
+ var MISSING_KEY = "[blipit] Blipit.init got no key, so Blipit is off and nothing is sent. Pass the project's public key (app.blipit.io, Keys); with Expo, check that EXPO_PUBLIC_BLIPIT_KEY is set at build time.";
24
+ var MISSING_PROJECT = "[blipit] Blipit.init got no project id, so Blipit is off and nothing is sent. Pass project with the id from the project's Keys page at app.blipit.io.";
10
25
  function init2(options) {
11
- const { key, publicKey, project, endpoint, ...rest } = options;
12
- const k = key ?? publicKey;
13
- if (!k) throw new Error("Blipit.init needs the project's public key");
14
- if (project === void 0 || project === null || project === "") throw new Error("Blipit.init needs the project id");
26
+ const { key, publicKey, project, endpoint, ...rest } = options ?? {};
27
+ const k = (key ?? publicKey ?? "").trim();
28
+ if (!k) {
29
+ console.warn(MISSING_KEY);
30
+ return false;
31
+ }
32
+ if (project === void 0 || project === null || String(project).trim() === "") {
33
+ console.warn(MISSING_PROJECT);
34
+ return false;
35
+ }
15
36
  Sentry.init({
16
37
  dsn: dsn(k, project, endpoint),
17
38
  sendDefaultPii: false,
18
39
  tracesSampleRate: 0,
19
- ...rest
40
+ ...rest,
41
+ beforeSend: withIdentity(rest.beforeSend)
20
42
  });
43
+ return true;
21
44
  }
22
45
  function captureSecurity(kind, actor, details = {}) {
23
46
  const context = { kind, actor };
@@ -34,6 +57,7 @@ function captureSecurity(kind, actor, details = {}) {
34
57
  }
35
58
  export {
36
59
  DEFAULT_ENDPOINT,
60
+ VERSION,
37
61
  addBreadcrumb,
38
62
  captureException,
39
63
  captureMessage2 as captureMessage,
@@ -43,5 +67,6 @@ export {
43
67
  init2 as init,
44
68
  setTag,
45
69
  setUser,
70
+ withIdentity,
46
71
  wrap
47
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blipit/react-native",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Blipit error monitoring for React Native and Expo. Know your app broke before your users tell you.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,14 +15,10 @@
15
15
  }
16
16
  },
17
17
  "files": [
18
- "dist"
18
+ "dist",
19
+ "CHANGELOG.md"
19
20
  ],
20
21
  "sideEffects": false,
21
- "scripts": {
22
- "build": "tsup src/index.ts --format esm,cjs --dts --clean",
23
- "typecheck": "tsc -p tsconfig.json --noEmit",
24
- "test": "node --experimental-strip-types --experimental-test-module-mocks --test test/init.test.ts"
25
- },
26
22
  "peerDependencies": {
27
23
  "@sentry/react-native": ">=6"
28
24
  },
@@ -53,5 +49,10 @@
53
49
  "expo",
54
50
  "error-monitoring",
55
51
  "blipit"
56
- ]
57
- }
52
+ ],
53
+ "scripts": {
54
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
55
+ "typecheck": "tsc -p tsconfig.json --noEmit",
56
+ "test": "node --experimental-strip-types --experimental-test-module-mocks --test test/init.test.ts"
57
+ }
58
+ }