@redthreadlabs/tracelog-client 1.4.0 → 1.5.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.
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventBuilder = void 0;
4
+ const util_1 = require("./util");
4
5
  class EventBuilder {
5
6
  constructor(enqueue, type) {
6
7
  this._level = 'info';
@@ -82,6 +83,7 @@ class EventBuilder {
82
83
  timestamp: Date.now(),
83
84
  level: this._level,
84
85
  message: this._message,
86
+ tz_offset: (0, util_1.tzOffsetMinutes)(),
85
87
  };
86
88
  if (this._duration !== undefined)
87
89
  event.duration = this._duration;
package/dist/LogClient.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LogClient = void 0;
4
4
  const EventBuilder_1 = require("./EventBuilder");
5
+ const util_1 = require("./util");
5
6
  // Default constants (matching the original AppLogRecorder)
6
7
  const DEFAULT_FLUSH_INTERVAL_MS = 5000;
7
8
  const DEFAULT_MAX_BUFFER_SIZE = 100;
@@ -37,6 +38,7 @@ class LogClient {
37
38
  const active = {
38
39
  token,
39
40
  startTime: now(),
41
+ tzOffset: (0, util_1.tzOffsetMinutes)(),
40
42
  parentToken: parent,
41
43
  children: [],
42
44
  };
@@ -71,6 +73,7 @@ class LogClient {
71
73
  timestamp: Math.round(active.startTime),
72
74
  duration: Math.round(duration),
73
75
  outcome: 'success',
76
+ tz_offset: active.tzOffset,
74
77
  };
75
78
  if (active.parentToken) {
76
79
  timer.parent_id = active.parentToken.id;
package/dist/types.d.ts CHANGED
@@ -1,85 +1,5 @@
1
- export type JsonValue = string | number | boolean | null | JsonValue[] | {
2
- [key: string]: JsonValue;
3
- };
4
- export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
5
- export interface LogBatch {
6
- client: ClientInfo;
7
- user_id?: string;
8
- session_ref?: string;
9
- device_id?: string;
10
- events: LogEventItem[];
11
- timers: TimerItem[];
12
- }
13
- export interface LogEventItem {
14
- /** Event category, e.g. 'auth', 'billing', 'startup'. Default: 'client-log' */
15
- type: string;
16
- /** Epoch milliseconds */
17
- timestamp: number;
18
- level: LogLevel;
19
- message: string;
20
- /** Duration in milliseconds (for timed events that aren't span-shaped) */
21
- duration?: number;
22
- /** Serialized error info. `code` is the structured error code (ShareDB,
23
- * Node `err.code`, etc.) — facetable downstream, unlike a code folded
24
- * into the message text. */
25
- error?: {
26
- message: string;
27
- type?: string;
28
- code?: string;
29
- stack?: string;
30
- };
31
- /** Arbitrary key-value event data */
32
- params?: Record<string, JsonValue>;
33
- }
34
- export interface TimerItem {
35
- /** 16-char hex ID, generated client-side */
36
- id: string;
37
- /** 32-char hex trace ID, shared by parent + children */
38
- trace_id: string;
39
- /** ID of the root timer in this trace (for transaction_id on spans) */
40
- root_id: string;
41
- /** 16-char hex ID of parent timer (absent for root timers) */
42
- parent_id?: string;
43
- /** Operation name, e.g. 'content-store-startup' */
44
- name: string;
45
- /** Timer category. Default: 'client-perf' */
46
- type: string;
47
- /** Start time, epoch milliseconds */
48
- timestamp: number;
49
- /** Duration in milliseconds */
50
- duration: number;
51
- outcome: 'success' | 'failure' | 'unknown';
52
- context?: {
53
- tags?: Record<string, JsonValue>;
54
- };
55
- }
56
- export interface ClientInfo {
57
- /** Application name, e.g. 'duiduidui-app' */
58
- name: string;
59
- /** Application version */
60
- version: string;
61
- os: {
62
- name: string;
63
- version: string;
64
- };
65
- device: {
66
- model?: string;
67
- brand?: string;
68
- type: string;
69
- };
70
- runtime: {
71
- name: string;
72
- version: string;
73
- };
74
- screen?: {
75
- width: number;
76
- height: number;
77
- pixel_ratio: number;
78
- };
79
- locale?: string;
80
- timezone?: string;
81
- device_year_class?: number;
82
- }
1
+ import type { ClientInfo } from '@redthreadlabs/tracelog-schema';
2
+ export type { JsonValue, LogLevel, LogBatch, LogEventItem, TimerItem, ClientInfo, } from '@redthreadlabs/tracelog-schema';
83
3
  export interface TimerToken {
84
4
  /** 16-char hex ID for this timer */
85
5
  id: string;
package/dist/types.js CHANGED
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
- // ---- JSON value type (any valid JSON) ----
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
package/dist/util.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Minutes east of UTC right now (ISO-8601 sign: localWallClock = UTC + offset).
3
+ * `Date.prototype.getTimezoneOffset()` returns minutes to ADD to local to get
4
+ * UTC (so it's inverted, e.g. +300 for EST); negating gives the conventional
5
+ * eastward offset (EST = -300, IST = +330). Captured at record time so a
6
+ * buffered event reflects where/when it actually happened.
7
+ */
8
+ export declare function tzOffsetMinutes(): number;
package/dist/util.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tzOffsetMinutes = tzOffsetMinutes;
4
+ /**
5
+ * Minutes east of UTC right now (ISO-8601 sign: localWallClock = UTC + offset).
6
+ * `Date.prototype.getTimezoneOffset()` returns minutes to ADD to local to get
7
+ * UTC (so it's inverted, e.g. +300 for EST); negating gives the conventional
8
+ * eastward offset (EST = -300, IST = +330). Captured at record time so a
9
+ * buffered event reflects where/when it actually happened.
10
+ */
11
+ function tzOffsetMinutes() {
12
+ return -new Date().getTimezoneOffset();
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redthreadlabs/tracelog-client",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Lightweight logging client for tracelog — works in React Native and browsers",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -19,5 +19,8 @@
19
19
  },
20
20
  "devDependencies": {
21
21
  "typescript": "latest"
22
+ },
23
+ "dependencies": {
24
+ "@redthreadlabs/tracelog-schema": "^0.1.0"
22
25
  }
23
26
  }