lytx 0.3.8 → 0.3.10

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
@@ -68,7 +68,7 @@ export default app satisfies ExportedHandler<Env>;
68
68
  - `db.dbAdapter` (`"sqlite" | "postgres" | "singlestore" | "analytics_engine"`)
69
69
  - `db.eventStore` (`db.dbAdapter` values + `"durable_objects"`; defaults to `"durable_objects"`)
70
70
  - `useQueueIngestion` (`true`/`false`)
71
- - `includeLegacyTagRoutes` (`true` by default for `/lytx.js` and `/trackWebEvent` compatibility)
71
+ - `includeLegacyTagRoutes` (`true` by default for `/lytx.v2.js` and `/trackWebEvent.v2` compatibility)
72
72
  - `trackingRoutePrefix` (prefix all tracking routes, e.g. `/collect`)
73
73
  - `tagRoutes.scriptPath` + `tagRoutes.eventPath` (custom v2 route paths)
74
74
  - `auth.emailPasswordEnabled`, `auth.requireEmailVerification`, `auth.socialProviders.google`, `auth.socialProviders.github`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lytx",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -67,7 +67,7 @@ function checkIfTagManager(events: PageEvent[], allowed = false) {
67
67
 
68
68
  }
69
69
 
70
- export const lytxTag = (adapter: DBAdapter, route_path = "/lytx.v2.js") => route(route_path, [corsMiddleware, async ({ request }) => {
70
+ export const lytxTag = (adapter: DBAdapter, route_path = "/lytx.js") => route(route_path, [corsMiddleware, async ({ request }) => {
71
71
  if (request.method !== "GET") return new Response("Not Found.", { status: 404 });
72
72
  const url = new URL(request.url);
73
73
  const lytxDomain = url.origin;
@@ -116,12 +116,12 @@ export const lytxTag = (adapter: DBAdapter, route_path = "/lytx.v2.js") => route
116
116
  events = [];
117
117
  }
118
118
  }
119
- ///trackWebEvent.v2
119
+ ///trackWebEvent
120
120
  const lytx_script = (lytxDomain: string) => {
121
121
  // Use core bundle (no vendors) when tag_manager is disabled, full bundle otherwise
122
122
  const baseScript = config.tag_manager ? script_tag_manager : script_core;
123
- // Replace the placeholder with the actual domain (includes protocol)
124
- const domain = IS_DEV ? "http://localhost:6123" : lytxDomain;
123
+ // Replace the placeholder with the script request origin so local ports stay aligned.
124
+ const domain = lytxDomain;
125
125
  return baseScript.replace("__LYTX_DOMAIN__", domain);
126
126
  }
127
127
  if (!events) return new Response("Not Found.", { status: 404 });
@@ -152,7 +152,7 @@ type TrackWebEventOptions = {
152
152
 
153
153
  export const trackWebEvent = (
154
154
  adapter: DBAdapter,
155
- route_path = "/trackWebEvent.v2",
155
+ route_path = "/trackWebEvent",
156
156
  options: TrackWebEventOptions = {},
157
157
  ) => route(route_path, [corsMiddleware, async ({ request }) => {
158
158
  // Handle CORS preflight
@@ -3,4 +3,4 @@
3
3
  */
4
4
 
5
5
  /** The path to the Lytx tracking script */
6
- export const LYTX_SCRIPT_PATH = "/lytx.v2.js";
6
+ export const LYTX_SCRIPT_PATH = "/lytx.js";
@@ -128,7 +128,6 @@ const createLytxAppConfigSchema = z
128
128
  .object({
129
129
  enableRequestLogging: z.boolean().optional(),
130
130
  db: dbConfigSchema.optional(),
131
- dbAdapter: dbAdapterSchema.optional(),
132
131
  useQueueIngestion: z.boolean().optional(),
133
132
  includeLegacyTagRoutes: z.boolean().optional(),
134
133
  trackingRoutePrefix: routePrefixSchema.optional(),
@@ -212,14 +211,6 @@ const createLytxAppConfigSchema = z
212
211
  })
213
212
  .strict()
214
213
  .superRefine((value, ctx) => {
215
- if (value.db?.dbAdapter && value.dbAdapter && value.db.dbAdapter !== value.dbAdapter) {
216
- ctx.addIssue({
217
- code: z.ZodIssueCode.custom,
218
- path: ["db", "dbAdapter"],
219
- message: "db.dbAdapter must match top-level dbAdapter when both are provided",
220
- });
221
- }
222
-
223
214
  if (value.features?.dashboard === true && value.features?.auth === false) {
224
215
  ctx.addIssue({
225
216
  code: z.ZodIssueCode.custom,
@@ -152,7 +152,7 @@ export function trackEvents(
152
152
  // __LYTX_DOMAIN__ is replaced at runtime by the tag API
153
153
  const lytxDomain = "__LYTX_DOMAIN__";
154
154
  const req = await window.fetch(
155
- `${lytxDomain}/trackWebEvent.v2?account=${account}&platform=${platformName}`,
155
+ `${lytxDomain}/trackWebEvent?account=${account}&platform=${platformName}`,
156
156
  {
157
157
  method: "POST",
158
158
  body: JSON.stringify(data),
package/src/worker.tsx CHANGED
@@ -14,7 +14,6 @@ import { resendVerificationEmailRoute, userApiRoutes } from "@api/auth_api";
14
14
  import { eventLabelsApi } from "@api/event_labels_api";
15
15
  import { reportsApi } from "@api/reports_api";
16
16
  import {
17
- legacyContainerRoute,
18
17
  newSiteSetup,
19
18
  } from "@api/tag_api";
20
19
  import { lytxTag, trackWebEvent } from "@api/tag_api_v2";
@@ -65,10 +64,10 @@ export type { AppContext };
65
64
  export type { CreateLytxAppConfig } from "@/config/createLytxAppConfig";
66
65
 
67
66
  const DEFAULT_TAG_DB_ADAPTER: DBAdapter = "sqlite";
68
- const DEFAULT_TAG_SCRIPT_PATH = "/lytx.v2.js";
69
- const DEFAULT_LEGACY_TAG_SCRIPT_PATH = "/lytx.js";
70
- const DEFAULT_TRACK_WEB_EVENT_PATH = "/trackWebEvent.v2";
71
- const DEFAULT_LEGACY_TRACK_WEB_EVENT_PATH = "/trackWebEvent";
67
+ const DEFAULT_TAG_SCRIPT_PATH = "/lytx.js";
68
+ const DEFAULT_LEGACY_TAG_SCRIPT_PATH = "/lytx.v2.js";
69
+ const DEFAULT_TRACK_WEB_EVENT_PATH = "/trackWebEvent";
70
+ const DEFAULT_LEGACY_TRACK_WEB_EVENT_PATH = "/trackWebEvent.v2";
72
71
 
73
72
  const normalizeRoutePrefix = (value?: string): string => {
74
73
  if (!value) return "";
@@ -222,7 +221,7 @@ export function createLytxApp(config: CreateLytxAppConfig = {}) {
222
221
  const eventsEnabled = parsed_config.features?.events ?? isEventsEnabled();
223
222
  const aiEnabled = dashboardEnabled && (parsed_config.features?.ai ?? isAiFeatureEnabled());
224
223
  const tagScriptEnabled = parsed_config.features?.tagScript ?? isTagScriptEnabled();
225
- const tagRouteDbAdapter = parsed_config.db?.dbAdapter ?? parsed_config.dbAdapter ?? DEFAULT_TAG_DB_ADAPTER;
224
+ const tagRouteDbAdapter = parsed_config.db?.dbAdapter ?? DEFAULT_TAG_DB_ADAPTER;
226
225
  const tagRouteEventStore = parsed_config.db?.eventStore ?? "durable_objects";
227
226
  const tagRouteQueueIngestionEnabled = parsed_config.useQueueIngestion ?? (tagRouteEventStore === "durable_objects");
228
227
  const includeLegacyTagRoutes = parsed_config.includeLegacyTagRoutes ?? true;
@@ -248,13 +247,7 @@ export function createLytxApp(config: CreateLytxAppConfig = {}) {
248
247
  const askAiEnabled =
249
248
  aiEnabled && (parsed_config.features?.askAiEnabled ?? (reportBuilderEnabled && isAskAiEnabled()));
250
249
 
251
- const tagRoutes: Array<
252
- typeof legacyContainerRoute | ReturnType<typeof lytxTag> | ReturnType<typeof trackWebEvent>
253
- > = [];
254
-
255
- if (includeLegacyTagRoutes && tagScriptEnabled) {
256
- tagRoutes.push(legacyContainerRoute);
257
- }
250
+ const tagRoutes: Array<ReturnType<typeof lytxTag> | ReturnType<typeof trackWebEvent>> = [];
258
251
 
259
252
  if (tagScriptEnabled) {
260
253
  tagRoutes.push(lytxTag(tagRouteDbAdapter, tagScriptPath));