Skip to content

Pass 1: W1, W3, W4, W13, W14, W15 - #28

Merged
czypnt merged 8 commits into
mainfrom
pass1-cleanup
Nov 22, 2026
Merged

czypnt merged 8 commits into
mainfrom
pass1-cleanup

Conversation

@czypnt

@czypnt czypnt commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

W1: npm package ships no test declarations and no source maps

  • What: the declaration build used tsconfig.json (include: src/**/*), so every src/**/*.test.ts produced a .test.d.ts + .test.d.ts.map in dist, and files: ["dist"] shipped them with all JS and declaration source maps. .npmignore was dead (files overrides it).
  • Fix: rollup.config.js uses a new tsconfig.build.json (extends tsconfig.json, adds src/**/*.test.ts to exclude) for all five entries. Jest (ts-jest) and npm run typecheck still use tsconfig.json and see the tests. package.json files is now ["dist", "!dist/**/*.map", "!dist/**/*.test.d.ts"] (decision: drop both declaration maps and JS source maps from npm; the CDN build is unaffected because dist/ itself still holds them). .npmignore deleted.
  • Proof: npm pack --dry-run --ignore-scripts --json run once on the existing dist (before). The after list applies the new files patterns to that same list (the new tsconfig also stops the .test.d.ts files from being emitted at all).
files unpacked
before 157 (86 *.test.d.ts + maps, 77 .map = 1.97 MB) 4.09 MB
after 37 2.11 MB

After list: LICENSE, README.md, package.json, dist/datalyr.js, dist/datalyr.min.js, dist/datalyr.esm.js, dist/datalyr.esm.min.js, dist/datalyr.cjs.js, dist/datalyr.pixels.min.js, dist/datalyr.replay.min.js, and 26 public declarations: dist/{attribution,auto-identify,config,container,destination-pixels,encryption,fingerprint,identity,in-app-handoff,index,queue,replay-loader,session,shopify-cart,shopify-product-view,storage,stripe-session,types,utils}.d.ts, dist/pixels/{applovin,index,linkedin,x}.d.ts, dist/replay/{heat,privacy,recorder,selector}.d.ts.

  • Test: CI npm run build + bundle guard. main / exports untouched (W2 later).

W3: three console.log calls not behind debug

  • What: src/session.ts:64 (creation already in progress), src/session.ts:121 (session id rotated), src/storage.ts:229 (legacy keys migrated) logged on every site.
  • Fix: SessionManager(timeout, debug = false) with a private log() like the queue's; storage.migrateFromLegacyPrefix(debug = false); src/index.ts passes this.config.debug to both.
  • Test: src/debug-logging.test.ts (rotation and migration print nothing without debug, and do with it; the "without" cases fail on main).

W4: options that do nothing

  • What: flushAt, trackSessions, cookiePrefix are read nowhere; the sessionTimeout comment said 60 minutes (code is 30 since 1.9.4, src/index.ts:192).
  • Fix: @deprecated JSDoc on the three in src/types.ts (still accepted, defaults in index.ts unchanged); sessionTimeout comment corrected. No behaviour change, so no test.

W13: getters threw a TypeError before init()

  • What: getters read this.identity / this.session / this.attribution / this.queue, which init() creates.
  • Fix: getAnonymousId, getVisitorId, getDistinctId, getUserId, getSessionId, getSessionData, getStripeMetadata, getWhopCheckoutMetadata, getAttribution, getJourney, getNetworkStatus check their manager, warn once per instance, and return an empty value. Least breaking choice: no return type changes. Ids typed string return ''; getUserId / getSessionData return null (already in their types); getStripeMetadata returns '' ids; getAttribution {}; getJourney []; getNetworkStatus { isOnline: navigator.onLine, lastOfflineAt: null, lastOnlineAt: null }. The guard checks the manager, not initialized, so nothing changes after init() (or after destroy(), which keeps the managers).
  • Test: src/getters-before-init.test.ts (each getter does not throw and returns its empty value; one warning per instance; getters that already handled this are unchanged).

W14: tests for untested modules

  • src/fingerprint.test.ts: minimal fields in strict mode and with enableFingerprinting: false; standard reads; screen rounding to 100px; dnt from DNT / GPC; client hints; generateHash with Web Crypto (SHA-256 of key-sorted JSON) and without (stable, order-independent).
  • src/pixels-module.test.ts: src/pixels/index.ts contract version and platforms; unknown and inherited keys blocked; load / track delegate with their arguments; a throwing platform is contained; window.DatalyrPixels registration and an existing one kept.
  • W13 tests above.

W15: changelog

Changes to what the SDK sends

None. No event id, name, payload field or send timing changes.

Not done

  • setAttribution() and startNewSession() also touch the managers before init(), but they are setters, not getters; left for a later item.
  • package.json main / exports (W2), dependencies (W19) and CI untouched as asked. No version bump.
  • Nothing run locally (no install, build or test); CI is the proof.

🤖 Generated with Claude Code


Prove it works
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

czypnt and others added 8 commits November 22, 2026 14:34
The declaration build used tsconfig.json (include src/**/*), so 43 *.test.d.ts
and their maps went into dist and the package. Rollup now uses
tsconfig.build.json, which excludes src/**/*.test.ts; jest and npm run
typecheck keep using tsconfig.json. files drops dist/**/*.map and
dist/**/*.test.d.ts; the dead .npmignore (files overrides it) is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
session.ts:64, session.ts:121 and storage.ts:229 called console.log on every
site. SessionManager takes the SDK debug flag and logs through a private
log(); migrateFromLegacyPrefix(debug) logs the count only in debug mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eout comment

The three options are read nowhere. They stay accepted, marked @deprecated.
The sessionTimeout default is 30 minutes since 1.9.4, not 60.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They read managers init() creates and threw a TypeError before it. Return
types are unchanged: '' for ids typed string, null where the type allows it,
{} / [] for attribution and journey, a navigator-based network status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s not on npm

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s reference them); changelog note on getStripeMetadata() before init()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@czypnt

czypnt commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Independent review: APPROVE (no change to what is sent; package still ships everything consumers and the main repo's dl.js build read). Follow-ups applied in the last commit: the JavaScript source maps ship again because the bundles reference them (only declaration maps and test type files are left out now), and the changelog notes that getStripeMetadata() before init() now returns empty values. Merge waits for the owner's yes.

@czypnt
czypnt merged commit 8dc3bbe into main Nov 22, 2026
2 checks passed
@czypnt
czypnt deleted the pass1-cleanup branch November 22, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant