sitepong 0.2.6 → 0.2.7

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.
@@ -15,6 +15,11 @@ public struct CaptureEvent: Codable {
15
15
  public var device_model: String?
16
16
  public var os_version: String?
17
17
 
18
+ // identity traits — only populated on an "identify" event (Watchtower.setUser
19
+ // with email/name), so PII is sent once per identify, not on every tap.
20
+ public var email: String?
21
+ public var name: String?
22
+
18
23
  // screen_view
19
24
  public var screen_name: String?
20
25
  public var prev_screen_name: String?
@@ -58,12 +58,18 @@ public enum Watchtower {
58
58
  /// Identity (§1.1 distinct_id): stamped on every subsequent event. Pass nil
59
59
  /// to return to anonymous. The RN layer feeds the SDK's identify() through
60
60
  /// this; native hosts call it directly.
61
- public static func setUser(_ distinctId: String?) {
61
+ ///
62
+ /// Optionally pass `email` / `name` traits: they are sent once as an
63
+ /// `identify` event (not stamped on every tap) so the dashboard can label
64
+ /// the user by name/email instead of a raw id.
65
+ public static func setUser(_ distinctId: String?, email: String? = nil, name: String? = nil) {
62
66
  #if canImport(UIKit)
63
67
  if Thread.isMainThread {
64
- WatchtowerEngine.shared.setUser(distinctId)
68
+ WatchtowerEngine.shared.setUser(distinctId, email: email, name: name)
65
69
  } else {
66
- DispatchQueue.main.async { WatchtowerEngine.shared.setUser(distinctId) }
70
+ DispatchQueue.main.async {
71
+ WatchtowerEngine.shared.setUser(distinctId, email: email, name: name)
72
+ }
67
73
  }
68
74
  #endif
69
75
  }
@@ -15,6 +15,9 @@ final class WatchtowerEngine {
15
15
  private var appVersion: String?
16
16
  /// Identity from Watchtower.setUser (§1.1 distinct_id). nil = anonymous.
17
17
  private var distinctId: String?
18
+ /// Optional identity traits, sent once via an "identify" event.
19
+ private var userEmail: String?
20
+ private var userName: String?
18
21
  /// Hardware identifier (utsname.machine, e.g. "iPhone17,1") + OS version,
19
22
  /// stamped on every event (§1.1).
20
23
  private var deviceModel: String?
@@ -103,8 +106,17 @@ final class WatchtowerEngine {
103
106
  transport = nil
104
107
  }
105
108
 
106
- func setUser(_ id: String?) {
109
+ func setUser(_ id: String?, email: String? = nil, name: String? = nil) {
107
110
  distinctId = id
111
+ userEmail = email
112
+ userName = name
113
+ // Emit a one-shot identify so downstream can attach name/email to this
114
+ // distinct_id without stamping PII on every tap. No-op until running.
115
+ guard isRunning, id != nil || email != nil || name != nil else { return }
116
+ var ev = baseEvent(type: "identify")
117
+ ev.email = email
118
+ ev.name = name
119
+ emit(ev)
108
120
  }
109
121
 
110
122
  var currentSessionId: String? { isRunning ? sessionId : nil }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sitepong",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Official SitePong SDK for error tracking and monitoring",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",