@goliapkg/sentori-react-native 6.2.0 → 6.3.0
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/SentoriReactNative.podspec +11 -4
- package/android/build.gradle +21 -1
- package/android/src/main/java-core/com/sentori/Sentori.kt +273 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriAnrWatchdog.kt +3 -0
- package/android/src/main/java-core/com/sentori/SentoriAttachment.kt +153 -0
- package/android/src/main/java-core/com/sentori/SentoriConfig.kt +61 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriCrashHandler.kt +22 -0
- package/android/src/main/java-core/com/sentori/SentoriDevice.kt +61 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriFirebaseMessagingService.kt +18 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriForegroundActivity.kt +3 -0
- package/android/src/main/java-core/com/sentori/SentoriIdentity.kt +101 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriMobileVitals.kt +3 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriNativeExceptionBridge.kt +3 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriNativeSignals.kt +3 -0
- package/android/src/main/java-core/com/sentori/SentoriNotificationTap.kt +148 -0
- package/android/src/main/java-core/com/sentori/SentoriPendingCrash.kt +154 -0
- package/android/src/main/java-core/com/sentori/SentoriPush.kt +588 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriPushNotifications.kt +171 -17
- package/android/src/main/{java → java-core}/com/sentori/SentoriReplayCapture.kt +3 -0
- package/android/src/main/java-core/com/sentori/SentoriScope.kt +107 -0
- package/android/src/main/{java → java-core}/com/sentori/SentoriScreenshotCapture.kt +3 -0
- package/android/src/main/java-core/com/sentori/SentoriSignalRing.kt +80 -0
- package/android/src/main/java-core/com/sentori/SentoriTransport.kt +476 -0
- package/android/src/test/java-core/com/sentori/SentoriAttachmentTest.kt +413 -0
- package/android/src/test/{java → java-core}/com/sentori/SentoriCrashHandlerTest.kt +3 -0
- package/android/src/test/java-core/com/sentori/SentoriIdentityTest.kt +107 -0
- package/android/src/test/java-core/com/sentori/SentoriLiveServerTest.kt +149 -0
- package/android/src/test/java-core/com/sentori/SentoriPendingCrashTest.kt +194 -0
- package/android/src/test/java-core/com/sentori/SentoriPushTest.kt +707 -0
- package/android/src/test/{java → java-core}/com/sentori/SentoriScreenshotCaptureTest.kt +3 -0
- package/android/src/test/java-core/com/sentori/SentoriVerbsTest.kt +185 -0
- package/ios/core/SentoriAttachment.swift +129 -0
- package/ios/{SentoriCrashHandler.swift → core/SentoriCrashHandler.swift} +31 -0
- package/ios/{SentoriHangWatchdog.swift → core/SentoriHangWatchdog.swift} +3 -0
- package/ios/{SentoriMobileVitals.swift → core/SentoriMobileVitals.swift} +3 -0
- package/ios/{SentoriNativeExceptionBridge.swift → core/SentoriNativeExceptionBridge.swift} +3 -0
- package/ios/{SentoriPushNotifications.swift → core/SentoriPushNotifications.swift} +50 -0
- package/ios/{SentoriReplayCapture.swift → core/SentoriReplayCapture.swift} +3 -0
- package/ios/{SentoriScreenshotCapture.swift → core/SentoriScreenshotCapture.swift} +14 -0
- package/ios/{SentoriThreadSampler.swift → core/SentoriThreadSampler.swift} +3 -0
- package/lib/push.d.ts.map +1 -1
- package/lib/push.js +51 -1
- package/lib/push.js.map +1 -1
- package/lib/scope.d.ts +6 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +45 -1
- package/lib/scope.js.map +1 -1
- package/lib/transport.js +1 -1
- package/package.json +2 -2
- package/src/__tests__/push.test.ts +99 -1
- package/src/push.ts +49 -1
- package/src/scope.ts +50 -1
- package/src/transport.ts +1 -1
- package/ios/Tests/SentoriCrashHandlerTests.swift +0 -59
- package/ios/Tests/SentoriScreenshotCaptureTests.swift +0 -59
- package/ios/Tests/SentoriThreadSamplerTests.swift +0 -96
package/lib/push.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":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BAAiB,IAAI,IAAI;QAAE,OAAO,iBAAiB,CAAA;IACvD,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,CAAmC,CAAA;QACpE,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAA;QAC1B,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,SAAS;YAAE,OAAO,EAAE,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,8BAA8B;IAChC,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
package/lib/scope.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type { User } from '@goliapkg/sentori-core';
|
|
2
|
+
/** Register interest in identity changes. Only push does. */
|
|
3
|
+
export declare const onIdentityChange: (fn: (() => void) | undefined) => void;
|
|
2
4
|
export declare const setUser: (u: User | null) => void | undefined;
|
|
3
5
|
export declare const patchContext: (patch: Record<string, unknown>) => void | undefined;
|
|
4
6
|
export declare const currentUserKey: () => string | undefined;
|
|
7
|
+
/** The person's attributes, for the device row. Undefined when the
|
|
8
|
+
* host has not set any — which is different from `{}`, the value that
|
|
9
|
+
* clears them. */
|
|
10
|
+
export declare const currentUserTraits: () => Record<string, unknown> | undefined;
|
|
5
11
|
export declare const currentContext: () => Record<string, unknown> | undefined;
|
|
6
12
|
export declare const __resetForTests: () => void;
|
|
7
13
|
//# sourceMappingURL=scope.d.ts.map
|
package/lib/scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAoBnD,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,OAAQ,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,KAAG,IAE/D,CAAC;AAUF,eAAO,MAAM,OAAO,sCAkClB,CAAC;AAEH,eAAO,MAAM,YAAY,sDAIvB,CAAC;AAEH,eAAO,MAAM,cAAc,QAAO,MAAM,GAAG,SAAqB,CAAC;AAEjE;;mBAEmB;AACnB,eAAO,MAAM,iBAAiB,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SACX,CAAC;AAErD,eAAO,MAAM,cAAc,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SACI,CAAC;AAEjE,eAAO,MAAM,eAAe,QAAO,IAOlC,CAAC"}
|
package/lib/scope.js
CHANGED
|
@@ -6,12 +6,47 @@ let _user = null;
|
|
|
6
6
|
let _userKey;
|
|
7
7
|
let _context = {};
|
|
8
8
|
let _hashGeneration = 0;
|
|
9
|
+
let _traits;
|
|
10
|
+
// What to tell when the person changes.
|
|
11
|
+
//
|
|
12
|
+
// The device row carries the identity, and until now nothing updated
|
|
13
|
+
// it after registration: an app that registers for push at launch and
|
|
14
|
+
// signs in ten seconds later — which is every app with a login screen
|
|
15
|
+
// — held a row with no user on it for the life of the install. A send
|
|
16
|
+
// aimed at that user reached nobody and reported success.
|
|
17
|
+
//
|
|
18
|
+
// A callback rather than a direct call because push.ts already imports
|
|
19
|
+
// this file; the arrow has to point one way.
|
|
20
|
+
let _onIdentityChange;
|
|
21
|
+
/** Register interest in identity changes. Only push does. */
|
|
22
|
+
export const onIdentityChange = (fn) => {
|
|
23
|
+
_onIdentityChange = fn;
|
|
24
|
+
};
|
|
25
|
+
const announce = () => {
|
|
26
|
+
try {
|
|
27
|
+
_onIdentityChange?.();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// NEVER rule: whatever the listener does, user() returns.
|
|
31
|
+
}
|
|
32
|
+
};
|
|
9
33
|
export const setUser = safeFn('user', function setUser(u) {
|
|
10
34
|
_user = u;
|
|
11
35
|
_userKey = undefined;
|
|
36
|
+
// A call to `user()` describes the person completely, so one made
|
|
37
|
+
// without traits means they have none — not "leave the last ones".
|
|
38
|
+
// Absent and empty are different on the wire: absent keeps what the
|
|
39
|
+
// row has, and a signed-out device that kept them would still be
|
|
40
|
+
// selectable as whoever just left.
|
|
41
|
+
_traits = u?.traits == null ? {} : { ...u.traits };
|
|
12
42
|
const generation = ++_hashGeneration;
|
|
13
|
-
if (u === null)
|
|
43
|
+
if (u === null) {
|
|
44
|
+
// Signing out is an identity change too, and the one where a
|
|
45
|
+
// stale row matters most: the device would otherwise keep
|
|
46
|
+
// answering to the person who just left.
|
|
47
|
+
announce();
|
|
14
48
|
return;
|
|
49
|
+
}
|
|
15
50
|
// The wire carries only a salted hash — raw identity never leaves
|
|
16
51
|
// the device (breadth × depth needs distinctness, not identity).
|
|
17
52
|
// Hashing is async (WebCrypto); the verb stays synchronous and the
|
|
@@ -21,6 +56,9 @@ export const setUser = safeFn('user', function setUser(u) {
|
|
|
21
56
|
.then((hashes) => {
|
|
22
57
|
if (generation === _hashGeneration) {
|
|
23
58
|
_userKey = hashes.id ?? hashes.email;
|
|
59
|
+
// Announced after the hash lands, not before: the whole point
|
|
60
|
+
// is to send the new key, and the key is what arrives late.
|
|
61
|
+
announce();
|
|
24
62
|
}
|
|
25
63
|
})
|
|
26
64
|
.catch(() => {
|
|
@@ -31,11 +69,17 @@ export const patchContext = safeFn('context', function patchContext(patch) {
|
|
|
31
69
|
_context = { ..._context, ...patch };
|
|
32
70
|
});
|
|
33
71
|
export const currentUserKey = () => _userKey;
|
|
72
|
+
/** The person's attributes, for the device row. Undefined when the
|
|
73
|
+
* host has not set any — which is different from `{}`, the value that
|
|
74
|
+
* clears them. */
|
|
75
|
+
export const currentUserTraits = () => _traits === undefined ? undefined : { ..._traits };
|
|
34
76
|
export const currentContext = () => Object.keys(_context).length > 0 ? { ..._context } : undefined;
|
|
35
77
|
export const __resetForTests = () => {
|
|
36
78
|
_user = null;
|
|
37
79
|
_userKey = undefined;
|
|
80
|
+
_traits = undefined;
|
|
38
81
|
_context = {};
|
|
82
|
+
_onIdentityChange = undefined;
|
|
39
83
|
_hashGeneration++;
|
|
40
84
|
};
|
|
41
85
|
//# sourceMappingURL=scope.js.map
|
package/lib/scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,gEAAgE;AAChE,wCAAwC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhE,IAAI,KAAK,GAAgB,IAAI,CAAC;AAC9B,IAAI,QAA4B,CAAC;AACjC,IAAI,QAAQ,GAA4B,EAAE,CAAC;AAC3C,IAAI,eAAe,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.js","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,gEAAgE;AAChE,wCAAwC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhE,IAAI,KAAK,GAAgB,IAAI,CAAC;AAC9B,IAAI,QAA4B,CAAC;AACjC,IAAI,QAAQ,GAA4B,EAAE,CAAC;AAC3C,IAAI,eAAe,GAAG,CAAC,CAAC;AACxB,IAAI,OAA4C,CAAC;AAEjD,wCAAwC;AACxC,EAAE;AACF,qEAAqE;AACrE,sEAAsE;AACtE,sEAAsE;AACtE,sEAAsE;AACtE,0DAA0D;AAC1D,EAAE;AACF,uEAAuE;AACvE,6CAA6C;AAC7C,IAAI,iBAA2C,CAAC;AAEhD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAA4B,EAAQ,EAAE;IACrE,iBAAiB,GAAG,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG,GAAS,EAAE;IAC1B,IAAI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,QAAQ,GAAG,EAAE,GAAG,QAAQ,EAAE,GAAG,KAAK,EAAE,CAAC;AACvC,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAuB,EAAE,CAAC,QAAQ,CAAC;AAEjE;;mBAEmB;AACnB,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAwC,EAAE,CACzE,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAwC,EAAE,CACtE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAEjE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAS,EAAE;IACxC,KAAK,GAAG,IAAI,CAAC;IACb,QAAQ,GAAG,SAAS,CAAC;IACrB,OAAO,GAAG,SAAS,CAAC;IACpB,QAAQ,GAAG,EAAE,CAAC;IACd,iBAAiB,GAAG,SAAS,CAAC;IAC9B,eAAe,EAAE,CAAC;AACpB,CAAC,CAAC"}
|
package/lib/transport.js
CHANGED
|
@@ -15,7 +15,7 @@ const MAX_RETRY = 3;
|
|
|
15
15
|
const STORAGE_KEY = '@sentori/pending';
|
|
16
16
|
const MAX_PERSISTED = 1000;
|
|
17
17
|
// Pinned to package.json by a test — bump both together.
|
|
18
|
-
const SDK_VERSION = '6.
|
|
18
|
+
const SDK_VERSION = '6.3.0';
|
|
19
19
|
let _queue = [];
|
|
20
20
|
let _assertStats = new Map();
|
|
21
21
|
let _flushTimer = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goliapkg/sentori-react-native",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "Sentori SDK for React Native — JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"author": "GOLIA K.K. <takagi@golia.jp> (https://golia.jp)",
|
|
@@ -85,6 +85,6 @@
|
|
|
85
85
|
"access": "public"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@goliapkg/sentori-core": "^2.
|
|
88
|
+
"@goliapkg/sentori-core": "^2.3.0"
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
register,
|
|
16
16
|
} from '../push';
|
|
17
17
|
import { __resetForTests as resetConfig, setConfig } from '../config';
|
|
18
|
-
import { __resetForTests as resetScope } from '../scope';
|
|
18
|
+
import { __resetForTests as resetScope, setUser } from '../scope';
|
|
19
19
|
|
|
20
20
|
const baseConfig = {
|
|
21
21
|
token: 'st_test',
|
|
@@ -202,3 +202,101 @@ describe('push.register', () => {
|
|
|
202
202
|
expect(seen).not.toBeNull();
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
|
+
|
|
206
|
+
// A device registers at launch; the person signs in ten seconds
|
|
207
|
+
// later. Until now nothing updated the row, so it carried no user for
|
|
208
|
+
// the life of the install — and a send aimed at that user reached
|
|
209
|
+
// nobody and reported success.
|
|
210
|
+
describe('push registration follows the person', () => {
|
|
211
|
+
/** Record every /v1/push/tokens body, so a test can say what the
|
|
212
|
+
* server was told rather than that it was told something. */
|
|
213
|
+
function recordingFetch(): Array<Record<string, unknown>> {
|
|
214
|
+
const seen: Array<Record<string, unknown>> = [];
|
|
215
|
+
globalThis.fetch = ((_url: string, init?: { body?: string }) => {
|
|
216
|
+
if (init?.body != null) {
|
|
217
|
+
seen.push(JSON.parse(init.body) as Record<string, unknown>);
|
|
218
|
+
}
|
|
219
|
+
return Promise.resolve({
|
|
220
|
+
ok: true,
|
|
221
|
+
status: 202,
|
|
222
|
+
json: () => Promise.resolve({ spToken: 'dev-1', token_id: 'dev-1' }),
|
|
223
|
+
});
|
|
224
|
+
}) as unknown as typeof fetch;
|
|
225
|
+
return seen;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** `user()` hashes on a promise, so the key lands a tick later and
|
|
229
|
+
* the re-registration is sent after that. */
|
|
230
|
+
const settle = () => new Promise((r) => setTimeout(r, 10));
|
|
231
|
+
|
|
232
|
+
beforeEach(() => {
|
|
233
|
+
resetPush();
|
|
234
|
+
resetConfig();
|
|
235
|
+
resetScope();
|
|
236
|
+
setPlatform('ios');
|
|
237
|
+
setConfig(baseConfig);
|
|
238
|
+
__setNativeForTests(grantingNative());
|
|
239
|
+
});
|
|
240
|
+
afterEach(() => {
|
|
241
|
+
resetPush();
|
|
242
|
+
resetConfig();
|
|
243
|
+
resetScope();
|
|
244
|
+
setPlatform(null);
|
|
245
|
+
__setNativeForTests(undefined);
|
|
246
|
+
globalThis.fetch = realFetch;
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('sends the identity when the person signs in after registering', async () => {
|
|
250
|
+
const seen = recordingFetch();
|
|
251
|
+
await register();
|
|
252
|
+
expect(seen).toHaveLength(1);
|
|
253
|
+
expect(seen[0]?.userKey).toBeUndefined();
|
|
254
|
+
|
|
255
|
+
setUser({ id: 'usr_123', traits: { plan: 'pro' } });
|
|
256
|
+
await settle();
|
|
257
|
+
|
|
258
|
+
// Two assertions, because either alone passes on a mistake: a
|
|
259
|
+
// count alone passes if the update carries nothing, and a key
|
|
260
|
+
// alone passes if the update never happened and this is still the
|
|
261
|
+
// first request.
|
|
262
|
+
expect(seen).toHaveLength(2);
|
|
263
|
+
expect(typeof seen[1]?.userKey).toBe('string');
|
|
264
|
+
expect(seen[1]?.traits).toEqual({ plan: 'pro' });
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('does not send anything when the same person is set again', async () => {
|
|
268
|
+
const seen = recordingFetch();
|
|
269
|
+
await register();
|
|
270
|
+
setUser({ id: 'usr_123', traits: { plan: 'pro' } });
|
|
271
|
+
await settle();
|
|
272
|
+
const after = seen.length;
|
|
273
|
+
|
|
274
|
+
// `user()` is a verb an app may call on every screen. One request
|
|
275
|
+
// per call is not free to a host, and the iron rule is that we are.
|
|
276
|
+
setUser({ id: 'usr_123', traits: { plan: 'pro' } });
|
|
277
|
+
await settle();
|
|
278
|
+
expect(seen).toHaveLength(after);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('clears the traits when the person signs out', async () => {
|
|
282
|
+
const seen = recordingFetch();
|
|
283
|
+
await register();
|
|
284
|
+
setUser({ id: 'usr_123', traits: { plan: 'pro' } });
|
|
285
|
+
await settle();
|
|
286
|
+
setUser(null);
|
|
287
|
+
await settle();
|
|
288
|
+
|
|
289
|
+
const last = seen[seen.length - 1];
|
|
290
|
+
expect(last?.userKey).toBeUndefined();
|
|
291
|
+
// `{}` rather than absent: absent means "keep what is there", so
|
|
292
|
+
// a signed-out device would stay selectable as a pro user.
|
|
293
|
+
expect(last?.traits).toEqual({});
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('does not register a device that never registered', async () => {
|
|
297
|
+
const seen = recordingFetch();
|
|
298
|
+
setUser({ id: 'usr_123' });
|
|
299
|
+
await settle();
|
|
300
|
+
expect(seen).toHaveLength(0);
|
|
301
|
+
});
|
|
302
|
+
});
|
package/src/push.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { logger, pushSignal } from '@goliapkg/sentori-core'
|
|
25
25
|
|
|
26
|
-
import { currentUserKey } from './scope.js'
|
|
26
|
+
import { currentUserKey, currentUserTraits, onIdentityChange } from './scope.js'
|
|
27
27
|
|
|
28
28
|
// AppState is RN-only; we treat it dynamically so the SDK keeps
|
|
29
29
|
// importing cleanly under Bun / web.
|
|
@@ -46,6 +46,14 @@ import {
|
|
|
46
46
|
const STORAGE_KEY = 'sentori.push.ipt'
|
|
47
47
|
|
|
48
48
|
let _cachedIpt: null | string = null
|
|
49
|
+
// The last token the vendor handed us, kept so a sign-in can re-send
|
|
50
|
+
// the registration without asking the OS for a token again.
|
|
51
|
+
let _lastNativeToken: null | string = null
|
|
52
|
+
let _lastOptions: PushRegisterOptions = {}
|
|
53
|
+
// What the server was last told. A re-registration that would send
|
|
54
|
+
// the same thing is not sent: `user()` is a verb an app may call on
|
|
55
|
+
// every screen, and one HTTP request per call is not free to a host.
|
|
56
|
+
let _lastSentIdentity: string | null = null
|
|
49
57
|
let _drainInterval: ReturnType<typeof setInterval> | null = null
|
|
50
58
|
let _appStateSubscription: { remove: () => void } | null = null
|
|
51
59
|
let _backgrounded = false
|
|
@@ -176,9 +184,13 @@ export async function register(opts: PushRegisterOptions = {}): Promise<PushRegi
|
|
|
176
184
|
const token = await waitForToken(opts.tokenTimeoutMs ?? 8000)
|
|
177
185
|
const ipt = await registerWithServer(cfg, token, opts)
|
|
178
186
|
_cachedIpt = ipt
|
|
187
|
+
_lastNativeToken = token
|
|
188
|
+
_lastOptions = opts
|
|
179
189
|
void persistIpt(ipt)
|
|
180
190
|
opts.onToken?.(ipt)
|
|
181
191
|
bindBufferDrain(opts.onMessage, opts.onTap)
|
|
192
|
+
// From here on, signing in or out updates the row by itself.
|
|
193
|
+
onIdentityChange(reRegisterAfterIdentityChange)
|
|
182
194
|
return { ok: true, ipt }
|
|
183
195
|
} catch (e) {
|
|
184
196
|
const err = e instanceof Error ? e : new Error(String(e))
|
|
@@ -199,6 +211,29 @@ function fail(
|
|
|
199
211
|
return { ok: false, message, reason }
|
|
200
212
|
}
|
|
201
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Send the registration again because the person changed.
|
|
216
|
+
*
|
|
217
|
+
* Only for a device that has already registered — the vendor token is
|
|
218
|
+
* the evidence, the same rule the native SDKs use for a rotated
|
|
219
|
+
* token. Nothing here throws and nothing here is awaited by the host:
|
|
220
|
+
* `user()` is synchronous and stays that way.
|
|
221
|
+
*/
|
|
222
|
+
function reRegisterAfterIdentityChange(): void {
|
|
223
|
+
const token = _lastNativeToken
|
|
224
|
+
const cfg = tryGetRuntimeConfig()
|
|
225
|
+
if (token == null || cfg == null) return
|
|
226
|
+
const identity = JSON.stringify([currentUserKey() ?? null, currentUserTraits() ?? null])
|
|
227
|
+
if (identity === _lastSentIdentity) return
|
|
228
|
+
_lastSentIdentity = identity
|
|
229
|
+
void registerWithServer(cfg, token, _lastOptions).catch((e: unknown) => {
|
|
230
|
+
// A failed update leaves the row pointing at the previous person,
|
|
231
|
+
// so the next change must be allowed to try again.
|
|
232
|
+
_lastSentIdentity = null
|
|
233
|
+
logger.warn('push', 'updating the device after a sign-in failed', e)
|
|
234
|
+
})
|
|
235
|
+
}
|
|
236
|
+
|
|
202
237
|
/** Internal carrier so the helpers below can name which failure they
|
|
203
238
|
* are without every one of them returning a result object. */
|
|
204
239
|
class PushRegisterError extends Error {
|
|
@@ -228,6 +263,9 @@ export async function unregister(): Promise<void> {
|
|
|
228
263
|
}
|
|
229
264
|
}
|
|
230
265
|
nativePushUnregister()
|
|
266
|
+
onIdentityChange(undefined)
|
|
267
|
+
_lastNativeToken = null
|
|
268
|
+
_lastSentIdentity = null
|
|
231
269
|
_cachedIpt = null
|
|
232
270
|
void clearPersistedIpt()
|
|
233
271
|
teardownBufferDrain()
|
|
@@ -310,6 +348,12 @@ async function registerWithServer(
|
|
|
310
348
|
// out it went nowhere. (Insight asked whether it was stored; it was
|
|
311
349
|
// not — 2026-08-11.)
|
|
312
350
|
if (opts.metadata != null) body.metadata = opts.metadata
|
|
351
|
+
// Attributes of the person rather than of the device, kept apart so
|
|
352
|
+
// a build channel called "pro" cannot answer a send aimed at the pro
|
|
353
|
+
// plan. Absent leaves whatever the row already had; `{}` clears it,
|
|
354
|
+
// which is what signing out sends.
|
|
355
|
+
const traits = currentUserTraits()
|
|
356
|
+
if (traits != null) body.traits = traits
|
|
313
357
|
const res = await fetch(joinUrl(cfg.ingestUrl, '/v1/push/tokens'), {
|
|
314
358
|
method: 'POST',
|
|
315
359
|
headers: {
|
|
@@ -545,6 +589,10 @@ export function __resetForTests(): void {
|
|
|
545
589
|
_onMessage = undefined
|
|
546
590
|
_onTap = undefined
|
|
547
591
|
_ackQueue = []
|
|
592
|
+
_lastNativeToken = null
|
|
593
|
+
_lastOptions = {}
|
|
594
|
+
_lastSentIdentity = null
|
|
595
|
+
onIdentityChange(undefined)
|
|
548
596
|
teardownBufferDrain()
|
|
549
597
|
}
|
|
550
598
|
|
package/src/scope.ts
CHANGED
|
@@ -9,12 +9,50 @@ let _user: User | null = null;
|
|
|
9
9
|
let _userKey: string | undefined;
|
|
10
10
|
let _context: Record<string, unknown> = {};
|
|
11
11
|
let _hashGeneration = 0;
|
|
12
|
+
let _traits: Record<string, unknown> | undefined;
|
|
13
|
+
|
|
14
|
+
// What to tell when the person changes.
|
|
15
|
+
//
|
|
16
|
+
// The device row carries the identity, and until now nothing updated
|
|
17
|
+
// it after registration: an app that registers for push at launch and
|
|
18
|
+
// signs in ten seconds later — which is every app with a login screen
|
|
19
|
+
// — held a row with no user on it for the life of the install. A send
|
|
20
|
+
// aimed at that user reached nobody and reported success.
|
|
21
|
+
//
|
|
22
|
+
// A callback rather than a direct call because push.ts already imports
|
|
23
|
+
// this file; the arrow has to point one way.
|
|
24
|
+
let _onIdentityChange: (() => void) | undefined;
|
|
25
|
+
|
|
26
|
+
/** Register interest in identity changes. Only push does. */
|
|
27
|
+
export const onIdentityChange = (fn: (() => void) | undefined): void => {
|
|
28
|
+
_onIdentityChange = fn;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const announce = (): void => {
|
|
32
|
+
try {
|
|
33
|
+
_onIdentityChange?.();
|
|
34
|
+
} catch {
|
|
35
|
+
// NEVER rule: whatever the listener does, user() returns.
|
|
36
|
+
}
|
|
37
|
+
};
|
|
12
38
|
|
|
13
39
|
export const setUser = safeFn('user', function setUser(u: User | null): void {
|
|
14
40
|
_user = u;
|
|
15
41
|
_userKey = undefined;
|
|
42
|
+
// A call to `user()` describes the person completely, so one made
|
|
43
|
+
// without traits means they have none — not "leave the last ones".
|
|
44
|
+
// Absent and empty are different on the wire: absent keeps what the
|
|
45
|
+
// row has, and a signed-out device that kept them would still be
|
|
46
|
+
// selectable as whoever just left.
|
|
47
|
+
_traits = u?.traits == null ? {} : { ...u.traits };
|
|
16
48
|
const generation = ++_hashGeneration;
|
|
17
|
-
if (u === null)
|
|
49
|
+
if (u === null) {
|
|
50
|
+
// Signing out is an identity change too, and the one where a
|
|
51
|
+
// stale row matters most: the device would otherwise keep
|
|
52
|
+
// answering to the person who just left.
|
|
53
|
+
announce();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
18
56
|
// The wire carries only a salted hash — raw identity never leaves
|
|
19
57
|
// the device (breadth × depth needs distinctness, not identity).
|
|
20
58
|
// Hashing is async (WebCrypto); the verb stays synchronous and the
|
|
@@ -24,6 +62,9 @@ export const setUser = safeFn('user', function setUser(u: User | null): void {
|
|
|
24
62
|
.then((hashes) => {
|
|
25
63
|
if (generation === _hashGeneration) {
|
|
26
64
|
_userKey = hashes.id ?? hashes.email;
|
|
65
|
+
// Announced after the hash lands, not before: the whole point
|
|
66
|
+
// is to send the new key, and the key is what arrives late.
|
|
67
|
+
announce();
|
|
27
68
|
}
|
|
28
69
|
})
|
|
29
70
|
.catch(() => {
|
|
@@ -39,12 +80,20 @@ export const patchContext = safeFn('context', function patchContext(
|
|
|
39
80
|
|
|
40
81
|
export const currentUserKey = (): string | undefined => _userKey;
|
|
41
82
|
|
|
83
|
+
/** The person's attributes, for the device row. Undefined when the
|
|
84
|
+
* host has not set any — which is different from `{}`, the value that
|
|
85
|
+
* clears them. */
|
|
86
|
+
export const currentUserTraits = (): Record<string, unknown> | undefined =>
|
|
87
|
+
_traits === undefined ? undefined : { ..._traits };
|
|
88
|
+
|
|
42
89
|
export const currentContext = (): Record<string, unknown> | undefined =>
|
|
43
90
|
Object.keys(_context).length > 0 ? { ..._context } : undefined;
|
|
44
91
|
|
|
45
92
|
export const __resetForTests = (): void => {
|
|
46
93
|
_user = null;
|
|
47
94
|
_userKey = undefined;
|
|
95
|
+
_traits = undefined;
|
|
48
96
|
_context = {};
|
|
97
|
+
_onIdentityChange = undefined;
|
|
49
98
|
_hashGeneration++;
|
|
50
99
|
};
|
package/src/transport.ts
CHANGED
|
@@ -20,7 +20,7 @@ const STORAGE_KEY = '@sentori/pending';
|
|
|
20
20
|
const MAX_PERSISTED = 1000;
|
|
21
21
|
|
|
22
22
|
// Pinned to package.json by a test — bump both together.
|
|
23
|
-
const SDK_VERSION = '6.
|
|
23
|
+
const SDK_VERSION = '6.3.0';
|
|
24
24
|
|
|
25
25
|
let _queue: WireEvent[] = [];
|
|
26
26
|
let _assertStats = new Map<string, AssertStat>();
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Phase 16 sub-E: XCTest coverage for SentoriCrashHandler (回填 Phase 7).
|
|
2
|
-
//
|
|
3
|
-
// Run via Xcode (target → SentoriTests, ⌘U) or via xcodebuild from the
|
|
4
|
-
// iOS host:
|
|
5
|
-
// xcodebuild test \
|
|
6
|
-
// -scheme SentoriTests \
|
|
7
|
-
// -destination 'platform=iOS Simulator,name=iPhone 15'
|
|
8
|
-
//
|
|
9
|
-
// The handler writes one JSON file per crash to
|
|
10
|
-
// <Documents>/sentori/pending/<uuid>.json
|
|
11
|
-
// We can't easily re-raise NSException (it tears down the test
|
|
12
|
-
// process), so we exercise the persistence helper directly instead.
|
|
13
|
-
|
|
14
|
-
import XCTest
|
|
15
|
-
@testable import SentoriCrashHandler
|
|
16
|
-
|
|
17
|
-
final class SentoriCrashHandlerTests: XCTestCase {
|
|
18
|
-
private var pendingDir: URL!
|
|
19
|
-
|
|
20
|
-
override func setUpWithError() throws {
|
|
21
|
-
let docs = try FileManager.default.url(
|
|
22
|
-
for: .documentDirectory,
|
|
23
|
-
in: .userDomainMask,
|
|
24
|
-
appropriateFor: nil,
|
|
25
|
-
create: true
|
|
26
|
-
)
|
|
27
|
-
pendingDir = docs.appendingPathComponent("sentori/pending", isDirectory: true)
|
|
28
|
-
try? FileManager.default.removeItem(at: pendingDir)
|
|
29
|
-
try FileManager.default.createDirectory(at: pendingDir, withIntermediateDirectories: true)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
func testWritePendingProducesValidEventJson() throws {
|
|
33
|
-
// Synthesize a payload like the @convention(c) handler would.
|
|
34
|
-
let exception = NSException(
|
|
35
|
-
name: NSExceptionName("XCTestSyntheticException"),
|
|
36
|
-
reason: "boom",
|
|
37
|
-
userInfo: nil
|
|
38
|
-
)
|
|
39
|
-
SentoriCrashHandler.persistForTesting(exception: exception)
|
|
40
|
-
|
|
41
|
-
let files = try FileManager.default.contentsOfDirectory(atPath: pendingDir.path)
|
|
42
|
-
.filter { $0.hasSuffix(".json") }
|
|
43
|
-
XCTAssertEqual(files.count, 1, "expected exactly one pending file, got \(files.count)")
|
|
44
|
-
|
|
45
|
-
let url = pendingDir.appendingPathComponent(files[0])
|
|
46
|
-
let data = try Data(contentsOf: url)
|
|
47
|
-
let payload = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
|
|
48
|
-
XCTAssertNotNil(payload, "pending file is not valid JSON")
|
|
49
|
-
|
|
50
|
-
// Spot-check the protocol shape (Phase 1 schema).
|
|
51
|
-
XCTAssertEqual(payload?["kind"] as? String, "error")
|
|
52
|
-
XCTAssertEqual(payload?["platform"] as? String, "ios")
|
|
53
|
-
XCTAssertNotNil(payload?["id"] as? String)
|
|
54
|
-
XCTAssertNotNil(payload?["timestamp"] as? String)
|
|
55
|
-
let error = payload?["error"] as? [String: Any]
|
|
56
|
-
XCTAssertEqual(error?["type"] as? String, "XCTestSyntheticException")
|
|
57
|
-
XCTAssertEqual(error?["message"] as? String, "boom")
|
|
58
|
-
}
|
|
59
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Phase 42 sub-E.10 — XCTest coverage for SentoriScreenshotCapture.
|
|
2
|
-
//
|
|
3
|
-
// Run via Xcode (target → SentoriTests, ⌘U) or via xcodebuild from
|
|
4
|
-
// the iOS host:
|
|
5
|
-
// xcodebuild test \
|
|
6
|
-
// -scheme SentoriTests \
|
|
7
|
-
// -destination 'platform=iOS Simulator,name=iPhone 15'
|
|
8
|
-
//
|
|
9
|
-
// We can't drive a real key window in a unit-test target (UIScene
|
|
10
|
-
// isn't connected), so each assertion below targets the helpers
|
|
11
|
-
// against a synthesized UIView hierarchy. The full crash-time flow
|
|
12
|
-
// (window→JPEG→base64→event JSON) is covered by the manual smoke
|
|
13
|
-
// step (E.11): trigger a real NSException in the example app and
|
|
14
|
-
// confirm the dashboard's "Captured at error" gallery fills in.
|
|
15
|
-
|
|
16
|
-
import XCTest
|
|
17
|
-
import UIKit
|
|
18
|
-
@testable import SentoriScreenshotCapture
|
|
19
|
-
|
|
20
|
-
final class SentoriScreenshotCaptureTests: XCTestCase {
|
|
21
|
-
|
|
22
|
-
/// `captureKeyWindow` returns nil when the app has no attached
|
|
23
|
-
/// scene — the typical test-host situation. This guards against
|
|
24
|
-
/// regressions where the helper would crash instead of failing
|
|
25
|
-
/// gracefully (e.g. force-unwrapping `UIApplication.shared.windows.first`).
|
|
26
|
-
func testCaptureKeyWindowReturnsNilWithoutWindow() {
|
|
27
|
-
// No UIScene is connected in a vanilla XCTest host — the
|
|
28
|
-
// helper must short-circuit, not crash.
|
|
29
|
-
let result = SentoriScreenshotCapture.captureKeyWindow()
|
|
30
|
-
// We don't assert nil vs non-nil rigidly because test hosts
|
|
31
|
-
// can attach a UIWindow as a side effect; the contract is
|
|
32
|
-
// simply "must not throw / crash".
|
|
33
|
-
_ = result
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/// Performance gate: capture-on-a-known-size-view-hierarchy
|
|
37
|
-
/// must complete in <30 ms on a synthesized tree, matching the
|
|
38
|
-
/// budget in `ROADMAP.md` (sub-E.10 perf bench).
|
|
39
|
-
///
|
|
40
|
-
/// The hierarchy under test is 50 nested UIView levels — much
|
|
41
|
-
/// deeper than any real app. The depth cap inside the helper
|
|
42
|
-
/// (`maxTreeDepth=10`) keeps the walk bounded so we shouldn't
|
|
43
|
-
/// blow past the budget even at extreme depth.
|
|
44
|
-
func testTreeWalkRespectsDepthCap() {
|
|
45
|
-
let root = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
|
46
|
-
var cursor = root
|
|
47
|
-
for _ in 0..<50 {
|
|
48
|
-
let child = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
|
|
49
|
-
cursor.addSubview(child)
|
|
50
|
-
cursor = child
|
|
51
|
-
}
|
|
52
|
-
measure {
|
|
53
|
-
// private method — guarded by `@testable` access.
|
|
54
|
-
// We're not asserting the output, just the timing budget.
|
|
55
|
-
_ = SentoriScreenshotCapture.value(forKey: "viewTreeForTesting")
|
|
56
|
-
.map { _ in 0 } ?? 0
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|