@oxy.so/telemetry 0.1.0 → 0.1.2

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 CHANGED
@@ -4,7 +4,7 @@ Framework-agnostic primitives for anonymous, real-time Oxy activity telemetry.
4
4
  The package has no runtime dependencies and does not import Express, Socket.IO,
5
5
  Redis, React, React Native or Expo.
6
6
 
7
- Version: `0.1.0`. This workspace package is not published yet.
7
+ Version: `0.1.2`.
8
8
 
9
9
  ## Entry points
10
10
 
@@ -90,9 +90,8 @@ replace their local validation and bucketing logic with
90
90
  re-export: consumers move imports directly to the new owner, then the old
91
91
  private implementations are deleted in the same integration change.
92
92
 
93
- The central API uses the server entry point in `0.1.0`. Core temporarily retains
94
- its compatible browser helpers until this package is published and applications
95
- can migrate without a broken registry dependency.
93
+ The central API uses the server entry point. Core retains deprecated compatibility
94
+ exports while applications migrate their direct imports.
96
95
 
97
96
  ## Collector, realtime and reconnect
98
97
 
@@ -28,8 +28,9 @@ function createBrowserTelemetry(options = {}) {
28
28
  let activityIdCreatedAt = 0;
29
29
  let edgePopPromise = null;
30
30
  const getActivityIdHeader = () => {
31
- const browserLocation = options.location ?? (typeof window === 'undefined' ? undefined : window.location);
32
- if (!browserLocation)
31
+ const hasInjectedBrowser = Boolean(options.location);
32
+ const hasBrowserRuntime = typeof window !== 'undefined' && typeof document !== 'undefined';
33
+ if (!hasInjectedBrowser && !hasBrowserRuntime)
33
34
  return {};
34
35
  const now = (options.now ?? Date.now)();
35
36
  if (!activityId || now < activityIdCreatedAt || now - activityIdCreatedAt >= (options.activityIdRotationMs ?? exports.DEFAULT_ACTIVITY_ID_ROTATION_MS)) {
@@ -24,8 +24,9 @@ export function createBrowserTelemetry(options = {}) {
24
24
  let activityIdCreatedAt = 0;
25
25
  let edgePopPromise = null;
26
26
  const getActivityIdHeader = () => {
27
- const browserLocation = options.location ?? (typeof window === 'undefined' ? undefined : window.location);
28
- if (!browserLocation)
27
+ const hasInjectedBrowser = Boolean(options.location);
28
+ const hasBrowserRuntime = typeof window !== 'undefined' && typeof document !== 'undefined';
29
+ if (!hasInjectedBrowser && !hasBrowserRuntime)
29
30
  return {};
30
31
  const now = (options.now ?? Date.now)();
31
32
  if (!activityId || now < activityIdCreatedAt || now - activityIdCreatedAt >= (options.activityIdRotationMs ?? DEFAULT_ACTIVITY_ID_ROTATION_MS)) {
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@oxy.so/telemetry",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Framework-agnostic anonymous activity telemetry primitives for Oxy services.",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.js",
8
8
  "types": "dist/types/index.d.ts",
9
+ "typesVersions": {
10
+ "*": {
11
+ "browser": ["dist/types/browser.d.ts"],
12
+ "server": ["dist/types/server.d.ts"]
13
+ }
14
+ },
9
15
  "sideEffects": false,
10
16
  "publishConfig": {
11
17
  "access": "public"
@@ -23,7 +29,14 @@
23
29
  },
24
30
  "./browser": {
25
31
  "browser": {
26
- "types": "./dist/types/browser.d.ts",
32
+ "import": {
33
+ "types": "./dist/types/browser.d.ts",
34
+ "default": "./dist/esm/browser.js"
35
+ },
36
+ "require": {
37
+ "types": "./dist/types/browser.d.ts",
38
+ "default": "./dist/cjs/browser.js"
39
+ },
27
40
  "default": "./dist/esm/browser.js"
28
41
  },
29
42
  "import": {
package/src/browser.ts CHANGED
@@ -47,8 +47,9 @@ export function createBrowserTelemetry(options: BrowserTelemetryOptions = {}): B
47
47
  let edgePopPromise: Promise<string | null> | null = null;
48
48
 
49
49
  const getActivityIdHeader = (): Record<string, string> => {
50
- const browserLocation = options.location ?? (typeof window === 'undefined' ? undefined : window.location);
51
- if (!browserLocation) return {};
50
+ const hasInjectedBrowser = Boolean(options.location);
51
+ const hasBrowserRuntime = typeof window !== 'undefined' && typeof document !== 'undefined';
52
+ if (!hasInjectedBrowser && !hasBrowserRuntime) return {};
52
53
  const now = (options.now ?? Date.now)();
53
54
  if (!activityId || now < activityIdCreatedAt || now - activityIdCreatedAt >= (options.activityIdRotationMs ?? DEFAULT_ACTIVITY_ID_ROTATION_MS)) {
54
55
  activityId = createUuid(options.crypto ?? globalThis.crypto);