Releases: trysurface/scripts
Releases · trysurface/scripts
Release list
Page element tracker system for Surface CMS
Includes:
- feat: bundle the Surface CMS review bridge into the tag #66
Fix Race condition due to : Query params based trigger to open surface forms
What's Changed
- fix(open-trigger): reuse same-mode embed exactly, else isolated overlay (honors configured mode) by @paragmore in #65
Full Changelog: v1.0.1...v1.1.2
Query params based trigger to open surface forms
What's Changed
- SURF-1081 feat(open-trigger): auto-open a form from a URL query-param (edge map) by @paragmore in #64
Full Changelog: 1.1.0...v1.1.1
Content Analytics Tracking
Release Notes — Surface Tag
PR: #63 — feat(content-analytics): include environment in track metadata
Features
- Environment ID in pageview tracking — the user journey
/api/v1/lead/trackpayload now includesenvironmentIdin itsmetadatafor both initial pageviews and SPA route-change pageviews. This lets the Surface Forms backend (Content Analytics) aggregate pageviews per environment. - The environment id is resolved once at startup from the
<script>tag (getSiteIdFromScript) and threaded throughSurfaceStore→initializeUserJourneyTracking/updateUserJourneyOnRouteChange.
How it works
src/index.tsnow reads the environment id up front, callssetEnvironmentId(...), and passes it intonew SurfaceStore(environmentId). The previous IIFE auto-init block was folded into this top-level initialization — same behavior, no duplicategetSiteIdFromScript/setEnvironmentIdcall.SurfaceStorestores the id asthis.environmentId(constructor param defaults tonullfor backwards compatibility) and forwards it to both journey-tracking calls.environmentIdis spread intometadataonly when present (...(environmentId ? { environmentId } : {})), so payloads are unchanged when no id is available. ExistingsurfaceLeadDatafields are preserved.
Scope (intentionally not included)
- No new endpoint, no new pageview module, no forced identify calls, and no new route observers. This reuses the existing
/lead/trackpageview path the track endpoint already receives.
Build
- Rebuilt
surface_tag.jsand its synced copysurface_embed_v1.js. (Bundler-internal variable renames likeenvironmentId2→environmentId3are cosmetic and have no runtime effect.)
Unchanged
- CDN URL,
<script>tag API, publicwindowAPI, and the PostMessage protocol.
Verification
pnpm install,pnpm typecheck, andpnpm buildall pass.
Surface Tag Modularization
Release Notes — Surface Tag
PR: #60 — SURF-680: Modularize surface_tag.js into TypeScript
Refactor
- Modularized
surface_tag.js— the monolithic 2431-line script is now 40 TypeScript modules undersrc/, bundled by esbuild into the same single-file IIFE. No changes to the public API or CDN URL —new SurfaceEmbed(...),new SurfaceExternalForm(...), andSurfaceTagStorework identically. - Output is 62.9KB uncompressed (down from ~73KB after DRY consolidation); ~9.8KB minified+gzipped via jsdelivr (unchanged).
Bug fixes
- HTTPS enforcement — non-HTTPS iframe URLs were logged but loaded anyway; they're now blocked.
- Listener stacking on SPA navigation —
initializeMessageListenerwas re-called on every route change, stacking duplicatewindow.addEventListener("message")handlers. Fixed. - Input mutation —
ensureDefault()was mutating the user-provided responsive embed-type config object; it now returns a new object. - Cookie maxAge default — cookie handling now uses nullish coalescing so the default
maxAgeis applied correctly when0or falsy values are passed.
Developer experience
- TypeScript with strict mode and full type definitions.
pnpm run build/pnpm run dev/pnpm run typecheck(esbuild, ~10ms builds).- Postbuild step automatically syncs
surface_tag.js→surface_embed_v1.js. - Structured logging across all modules (
{ prefix, message, response }). - Shared utilities replace duplicated route observer, beacon, logger, and cookie code across Store/Embed/ExternalForm.
Unchanged
- CDN URL (
jsdelivr.net/gh/trysurface/scripts@latest/surface_tag.min.js) <script>tag API- PostMessage protocol (
STORE_UPDATE,LEAD_DATA_UPDATE,SEND_DATA) surface_tracking.jsand legacy customer scripts
Verification
19/19 manual + Playwright tests passing across static pages and a Next.js App Router SPA (popup, slideover, inline, input-trigger, SPA navigation, user journey tracking, postMessage protocol).
v0.1.45
Includes:
- Removes website de-anon from tag.
Support tabbing in embeds
Includes
- Support tabbing in embeds
Increasing user journey tracking window
- Increasing user journey tracking window to 60 days (sliding window)
Fix: Multiple input form triggers
- Fix multiple input (HTML) form triggers
Sync User Journey with Apex domains
- Sync User Journey with Apex domains