Skip to content

refactor: update persistence module to TS#1261

Open
jaissica12 wants to merge 4 commits into
developmentfrom
refactor/SDKE-1107-update-persistence-to-TS
Open

refactor: update persistence module to TS#1261
jaissica12 wants to merge 4 commits into
developmentfrom
refactor/SDKE-1107-update-persistence-to-TS

Conversation

@jaissica12
Copy link
Copy Markdown
Contributor

@jaissica12 jaissica12 commented May 12, 2026

Background

  • Continuing the effort to migrate remaining JavaScript modules to TypeScript for improved type safety and developer experience across the SDK codebase.

What Has Changed

  • Converted src/persistence.js to src/persistence.ts with full type annotations on all methods, parameters, and return types
  • Updated src/persistence.interfaces.ts with corrected and expanded interface definitions to support the conversion
  • Updated test/jest/persistence.spec.ts with type adjustments for the converted module

Screenshots/Video

  • Tested on rokt-web-playground

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

  • var declarations replaced with const/let (SonarCloud compliance)
  • toGMTString() replaced with toUTCString() (functionally equivalent, toGMTString is deprecated)
  • JSON.stringify(..., 0, 2) replaced with JSON.stringify(..., null, 2) (functionally equivalent, satisfies TS type checker)

Reference Issue (For employees only. Ignore if you are an outside contributor)

@jaissica12 jaissica12 changed the base branch from master to development May 21, 2026 04:06
@jaissica12 jaissica12 force-pushed the refactor/SDKE-1107-update-persistence-to-TS branch from 9654bfd to d93d539 Compare May 25, 2026 22:04
@sonarqubecloud
Copy link
Copy Markdown

@jaissica12 jaissica12 marked this pull request as ready for review May 26, 2026 11:32
@jaissica12 jaissica12 requested a review from a team as a code owner May 26, 2026 11:32
@cursor
Copy link
Copy Markdown

cursor Bot commented May 26, 2026

PR Summary

Medium Risk
Touches cookie/localStorage and MPID persistence used across identity and sync; changes are typing-focused but any subtle decode/encode or null-handling mismatch could affect stored user state.

Overview
Migrates the persistence layer from JavaScript to TypeScript: persistence.js becomes persistence.ts, with the constructor and all cookie/localStorage methods typed against IPersistence / IPersistenceMinified.

persistence.interfaces.ts is tightened to match runtime behavior: nullable getPersistence, numeric first/last seen times, optional MPID/time args, encodePersistence taking a JSON string, decodePersistence returning string | null, and getDomain using Document.

Implementation edits are mostly typing and style: varconst/let, closure selfthis, Dictionary casts where store/helpers are not fully typed, and toGMTString()toUTCString() for cookie expiry. Jest persistence tests now hold an IPersistence instance instead of the untyped class.

Reviewed by Cursor Bugbot for commit 4928096. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

2 participants