@nagoorkani/session-capture-expo 0.1.4 → 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 +5 -1
- package/dist/index.js +21 -3
- package/dist/index.mjs +21 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -33,6 +33,10 @@ init({
|
|
|
33
33
|
projectId: 'project_...',
|
|
34
34
|
endpoint: 'https://ingest.example.com',
|
|
35
35
|
appVersion: '1.4.0',
|
|
36
|
+
// Optional: your signed-in user, recorded on every session. Leave out for
|
|
37
|
+
// anonymous users; call identify() after a later login.
|
|
38
|
+
appUserId: currentUser?.id,
|
|
39
|
+
appUserEmail: currentUser?.email,
|
|
36
40
|
})
|
|
37
41
|
```
|
|
38
42
|
|
|
@@ -67,7 +71,7 @@ import { track, screen, identify } from '@nagoorkani/session-capture-expo'
|
|
|
67
71
|
|
|
68
72
|
screen('Checkout')
|
|
69
73
|
track('checkout_started', { cartValue: 4200 })
|
|
70
|
-
identify('user_123', { plan: 'pro' })
|
|
74
|
+
identify('user_123', { email: 'ana@example.com', plan: 'pro' })
|
|
71
75
|
```
|
|
72
76
|
|
|
73
77
|
```ts
|
package/dist/index.js
CHANGED
|
@@ -574,7 +574,7 @@ var SessionManager = class {
|
|
|
574
574
|
};
|
|
575
575
|
|
|
576
576
|
// ../core/src/core.ts
|
|
577
|
-
var SDK_VERSION = "0.1.
|
|
577
|
+
var SDK_VERSION = "0.1.4";
|
|
578
578
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
579
579
|
var ALWAYS_CAPTURED = /* @__PURE__ */ new Set([
|
|
580
580
|
"error"
|
|
@@ -605,6 +605,12 @@ var SdkCore = class {
|
|
|
605
605
|
this.sessionListeners = /* @__PURE__ */ new Set();
|
|
606
606
|
/** Events discarded because remote config disabled capture. Diagnostics. */
|
|
607
607
|
this.dropOnKill = 0;
|
|
608
|
+
/**
|
|
609
|
+
* Who `identify` last named, repeated on every later `session_start` so a
|
|
610
|
+
* rotated session is not anonymous. Memory only: a relaunch or reload
|
|
611
|
+
* forgets it, and the host calls `identify` again once it knows the user.
|
|
612
|
+
*/
|
|
613
|
+
this.user = null;
|
|
608
614
|
this.now = deps.now ?? Date.now;
|
|
609
615
|
this.onFlush = deps.onFlush ?? (() => {
|
|
610
616
|
});
|
|
@@ -628,6 +634,9 @@ var SdkCore = class {
|
|
|
628
634
|
this.options = options;
|
|
629
635
|
this.enabled = options.enabled ?? true;
|
|
630
636
|
this.started = true;
|
|
637
|
+
if (options.appUserId) {
|
|
638
|
+
this.user = options.appUserEmail ? { userId: options.appUserId, email: options.appUserEmail } : { userId: options.appUserId };
|
|
639
|
+
}
|
|
631
640
|
this.sessions = new SessionManager({
|
|
632
641
|
timeoutMs: SESSION_TIMEOUT_MS,
|
|
633
642
|
initial: this.restoreSession(),
|
|
@@ -644,6 +653,9 @@ var SdkCore = class {
|
|
|
644
653
|
onFlush: (events) => this.deliver(events)
|
|
645
654
|
});
|
|
646
655
|
this.startSessionIfNeeded();
|
|
656
|
+
if (this.user) {
|
|
657
|
+
this.capture("user_action", { action: "identify", ...this.user });
|
|
658
|
+
}
|
|
647
659
|
}
|
|
648
660
|
/**
|
|
649
661
|
* Whether capture is currently active.
|
|
@@ -824,6 +836,12 @@ var SdkCore = class {
|
|
|
824
836
|
markReady() {
|
|
825
837
|
this.capture("performance", { ...timeToReady(this.now()) });
|
|
826
838
|
}
|
|
839
|
+
/** Attach an end user to this session and every later one in this run. */
|
|
840
|
+
identify(userId, traits) {
|
|
841
|
+
const email = typeof traits?.email === "string" ? traits.email : void 0;
|
|
842
|
+
this.user = email ? { userId, email } : { userId };
|
|
843
|
+
this.capture("user_action", { action: "identify", userId, ...traits });
|
|
844
|
+
}
|
|
827
845
|
screen(name) {
|
|
828
846
|
if (!this.isEnabled() || !this.sessions) return;
|
|
829
847
|
this.sessions.setScreen(name);
|
|
@@ -869,7 +887,7 @@ var SdkCore = class {
|
|
|
869
887
|
* rotation takes 1.
|
|
870
888
|
*/
|
|
871
889
|
announce(sessionId) {
|
|
872
|
-
this.capture("session_start", { ...this.deviceContext() });
|
|
890
|
+
this.capture("session_start", { ...this.deviceContext(), ...this.user });
|
|
873
891
|
for (const listener of this.sessionListeners) {
|
|
874
892
|
try {
|
|
875
893
|
listener(sessionId);
|
|
@@ -1873,7 +1891,7 @@ var screen = safe((name) => {
|
|
|
1873
1891
|
}, void 0, "screen");
|
|
1874
1892
|
var identify = safe(
|
|
1875
1893
|
(userId, traits) => {
|
|
1876
|
-
core?.
|
|
1894
|
+
core?.identify(userId, traits);
|
|
1877
1895
|
},
|
|
1878
1896
|
void 0,
|
|
1879
1897
|
"identify"
|
package/dist/index.mjs
CHANGED
|
@@ -522,7 +522,7 @@ var SessionManager = class {
|
|
|
522
522
|
};
|
|
523
523
|
|
|
524
524
|
// ../core/src/core.ts
|
|
525
|
-
var SDK_VERSION = "0.1.
|
|
525
|
+
var SDK_VERSION = "0.1.4";
|
|
526
526
|
var SESSION_TIMEOUT_MS = 30 * 60 * 1e3;
|
|
527
527
|
var ALWAYS_CAPTURED = /* @__PURE__ */ new Set([
|
|
528
528
|
"error"
|
|
@@ -553,6 +553,12 @@ var SdkCore = class {
|
|
|
553
553
|
this.sessionListeners = /* @__PURE__ */ new Set();
|
|
554
554
|
/** Events discarded because remote config disabled capture. Diagnostics. */
|
|
555
555
|
this.dropOnKill = 0;
|
|
556
|
+
/**
|
|
557
|
+
* Who `identify` last named, repeated on every later `session_start` so a
|
|
558
|
+
* rotated session is not anonymous. Memory only: a relaunch or reload
|
|
559
|
+
* forgets it, and the host calls `identify` again once it knows the user.
|
|
560
|
+
*/
|
|
561
|
+
this.user = null;
|
|
556
562
|
this.now = deps.now ?? Date.now;
|
|
557
563
|
this.onFlush = deps.onFlush ?? (() => {
|
|
558
564
|
});
|
|
@@ -576,6 +582,9 @@ var SdkCore = class {
|
|
|
576
582
|
this.options = options;
|
|
577
583
|
this.enabled = options.enabled ?? true;
|
|
578
584
|
this.started = true;
|
|
585
|
+
if (options.appUserId) {
|
|
586
|
+
this.user = options.appUserEmail ? { userId: options.appUserId, email: options.appUserEmail } : { userId: options.appUserId };
|
|
587
|
+
}
|
|
579
588
|
this.sessions = new SessionManager({
|
|
580
589
|
timeoutMs: SESSION_TIMEOUT_MS,
|
|
581
590
|
initial: this.restoreSession(),
|
|
@@ -592,6 +601,9 @@ var SdkCore = class {
|
|
|
592
601
|
onFlush: (events) => this.deliver(events)
|
|
593
602
|
});
|
|
594
603
|
this.startSessionIfNeeded();
|
|
604
|
+
if (this.user) {
|
|
605
|
+
this.capture("user_action", { action: "identify", ...this.user });
|
|
606
|
+
}
|
|
595
607
|
}
|
|
596
608
|
/**
|
|
597
609
|
* Whether capture is currently active.
|
|
@@ -772,6 +784,12 @@ var SdkCore = class {
|
|
|
772
784
|
markReady() {
|
|
773
785
|
this.capture("performance", { ...timeToReady(this.now()) });
|
|
774
786
|
}
|
|
787
|
+
/** Attach an end user to this session and every later one in this run. */
|
|
788
|
+
identify(userId, traits) {
|
|
789
|
+
const email = typeof traits?.email === "string" ? traits.email : void 0;
|
|
790
|
+
this.user = email ? { userId, email } : { userId };
|
|
791
|
+
this.capture("user_action", { action: "identify", userId, ...traits });
|
|
792
|
+
}
|
|
775
793
|
screen(name) {
|
|
776
794
|
if (!this.isEnabled() || !this.sessions) return;
|
|
777
795
|
this.sessions.setScreen(name);
|
|
@@ -817,7 +835,7 @@ var SdkCore = class {
|
|
|
817
835
|
* rotation takes 1.
|
|
818
836
|
*/
|
|
819
837
|
announce(sessionId) {
|
|
820
|
-
this.capture("session_start", { ...this.deviceContext() });
|
|
838
|
+
this.capture("session_start", { ...this.deviceContext(), ...this.user });
|
|
821
839
|
for (const listener of this.sessionListeners) {
|
|
822
840
|
try {
|
|
823
841
|
listener(sessionId);
|
|
@@ -1821,7 +1839,7 @@ var screen = safe((name) => {
|
|
|
1821
1839
|
}, void 0, "screen");
|
|
1822
1840
|
var identify = safe(
|
|
1823
1841
|
(userId, traits) => {
|
|
1824
|
-
core?.
|
|
1842
|
+
core?.identify(userId, traits);
|
|
1825
1843
|
},
|
|
1826
1844
|
void 0,
|
|
1827
1845
|
"identify"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nagoorkani/session-capture-expo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Lightweight session capture and observability for Expo / React Native",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"analytics"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nagoorkani/session-capture-core": "^0.1.
|
|
23
|
+
"@nagoorkani/session-capture-core": "^0.1.4"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"expo": ">=50",
|