@drivemetadata-ai/sdk 0.1.1-beta.1 → 0.1.1-beta.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.
Files changed (42) hide show
  1. package/README.md +18 -15
  2. package/dist/angular/index.cjs +118 -115
  3. package/dist/angular/index.cjs.map +1 -1
  4. package/dist/angular/index.d.cts +2 -2
  5. package/dist/angular/index.d.ts +2 -2
  6. package/dist/angular/index.js +118 -115
  7. package/dist/angular/index.js.map +1 -1
  8. package/dist/browser/index.cjs +119 -116
  9. package/dist/browser/index.cjs.map +1 -1
  10. package/dist/browser/index.d.cts +5 -68
  11. package/dist/browser/index.d.ts +5 -68
  12. package/dist/browser/index.js +119 -116
  13. package/dist/browser/index.js.map +1 -1
  14. package/dist/next/index.cjs +119 -115
  15. package/dist/next/index.cjs.map +1 -1
  16. package/dist/next/index.d.cts +1 -1
  17. package/dist/next/index.d.ts +1 -1
  18. package/dist/next/index.js +119 -115
  19. package/dist/next/index.js.map +1 -1
  20. package/dist/node/index.cjs +80 -7
  21. package/dist/node/index.cjs.map +1 -1
  22. package/dist/node/index.d.cts +7 -1
  23. package/dist/node/index.d.ts +7 -1
  24. package/dist/node/index.js +80 -7
  25. package/dist/node/index.js.map +1 -1
  26. package/dist/react/index.cjs +119 -115
  27. package/dist/react/index.cjs.map +1 -1
  28. package/dist/react/index.d.cts +2 -2
  29. package/dist/react/index.d.ts +2 -2
  30. package/dist/react/index.js +119 -115
  31. package/dist/react/index.js.map +1 -1
  32. package/dist/{types-BwtS0ZDu.d.cts → types--V8TVIqT.d.cts} +7 -3
  33. package/dist/{types-BwtS0ZDu.d.ts → types--V8TVIqT.d.ts} +7 -3
  34. package/docs/angular-integration.md +6 -6
  35. package/docs/index.md +4 -6
  36. package/docs/integration.md +322 -0
  37. package/docs/node-server-integration.md +16 -7
  38. package/docs/npm-browser-sdk.md +4 -8
  39. package/docs/react-next-integration.md +9 -9
  40. package/docs/security-privacy.md +11 -11
  41. package/package.json +4 -5
  42. package/docs/migration-cdn-to-npm.md +0 -99
@@ -1,71 +1,8 @@
1
- import { a as DmdBrowserConfig, j as DmdEventOptions, b as DmdConsentInput, l as DmdHealthStatus, D as DmdBrowserClient } from '../types-BwtS0ZDu.cjs';
2
- export { c as DmdConsentPurpose, d as DmdConsentState, e as DmdDeliveryDropReason, f as DmdDeliveryEventDiagnostic, g as DmdDroppedEventDiagnostic, h as DmdDroppedEventReason, i as DmdDroppedEventType, k as DmdEventPayload } from '../types-BwtS0ZDu.cjs';
1
+ import { j as DmdEventOptions, b as DmdConsentInput, l as DmdHealthStatus, D as DmdBrowserClient, a as DmdBrowserConfig } from '../types--V8TVIqT.cjs';
2
+ export { c as DmdConsentPurpose, d as DmdConsentState, e as DmdDeliveryDropReason, f as DmdDeliveryEventDiagnostic, g as DmdDroppedEventDiagnostic, h as DmdDroppedEventReason, i as DmdDroppedEventType, k as DmdEventPayload } from '../types--V8TVIqT.cjs';
3
3
 
4
- declare class DriveMetaDataSDK {
5
- initialized: boolean;
6
- queue: unknown[];
7
- offline: boolean;
8
- gdprConsent: 'granted' | 'denied' | 'pending';
9
- private readonly endpoint;
10
- private readonly config;
11
- private readonly writeKey;
12
- private readonly delivery;
13
- private identity;
14
- private consentState;
15
- private droppedEvents;
16
- private lastError;
17
- private lastDroppedEvent;
18
- private retryTimer;
19
- private retryDelayMs;
20
- private readonly initialRetryDelayMs;
21
- private readonly maxRetryDelayMs;
22
- private lifecycleCleanup;
23
- constructor(config: DmdBrowserConfig);
24
- trackEvent(event: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
25
- page(name?: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
26
- trackPageview(): void;
27
- identify(userId: string, traits?: Record<string, unknown>, options?: DmdEventOptions): void;
28
- identifyUser(userId: string, traits?: Record<string, unknown>): void;
29
- group(groupId: string, traits?: Record<string, unknown>, options?: DmdEventOptions): void;
30
- alias(previousId: string, userId: string, options?: DmdEventOptions): void;
31
- flush(): Promise<void>;
32
- reset(): void;
33
- setConsent(consent: DmdConsentInput): void;
34
- getHealth(): DmdHealthStatus;
35
- sendEvent(payload: unknown): void;
36
- private installLifecycleFlush;
37
- private scheduleRetryFlush;
38
- private sendPreparedEvent;
39
- private prepareAndSendEvent;
40
- private recordDrop;
41
- }
42
-
43
- interface LegacySdkInstance {
44
- sendEvent?: (payload: unknown) => void;
45
- trackEvent?: (event: string, properties?: Record<string, unknown>, options?: unknown) => void;
46
- identify?: (userId: string, traits?: Record<string, unknown>, options?: unknown) => void;
47
- identifyUser?: (userId: string, traits?: Record<string, unknown>) => void;
48
- page?: (name?: string, properties?: Record<string, unknown>, options?: unknown) => void;
49
- group?: (groupId: string, traits?: Record<string, unknown>, options?: unknown) => void;
50
- alias?: (previousId: string, userId: string, options?: unknown) => void;
51
- flush?: () => Promise<void>;
52
- reset?: () => void;
53
- setConsent?: (consent: unknown) => void;
54
- getHealth?: () => unknown;
55
- trackPageview?: () => void;
56
- blockTrackingForMe?: () => void;
57
- gdprConsent?: 'granted' | 'denied' | 'pending';
58
- initialized?: boolean;
59
- queue?: unknown[];
60
- offline?: boolean;
61
- }
62
-
63
- type DmdRuntimeInstance = LegacySdkInstance | DriveMetaDataSDK;
64
- interface DmdBrowserClientWithLegacy extends DmdBrowserClient {
65
- __legacy: DmdRuntimeInstance;
66
- }
67
- declare function initDmdSDK(config: DmdBrowserConfig): DmdBrowserClientWithLegacy;
68
- declare function getDmdSDK(): DmdBrowserClientWithLegacy | undefined;
4
+ declare function initDmdSDK(config: DmdBrowserConfig): DmdBrowserClient;
5
+ declare function getDmdSDK(): DmdBrowserClient | undefined;
69
6
  declare function track(event: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
70
7
  declare function identify(userId: string, traits?: Record<string, unknown>, options?: DmdEventOptions): void;
71
8
  declare function page(name?: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
@@ -77,7 +14,7 @@ declare function setConsent(consent: DmdConsentInput): void;
77
14
  declare const consent: {
78
15
  update(state: DmdConsentInput): void;
79
16
  };
80
- declare function ready(): Promise<DmdBrowserClientWithLegacy | undefined>;
17
+ declare function ready(): Promise<DmdBrowserClient | undefined>;
81
18
  declare function getDmdHealth(): DmdHealthStatus;
82
19
  declare function resetDmdSDKForTests(): void;
83
20
 
@@ -1,71 +1,8 @@
1
- import { a as DmdBrowserConfig, j as DmdEventOptions, b as DmdConsentInput, l as DmdHealthStatus, D as DmdBrowserClient } from '../types-BwtS0ZDu.js';
2
- export { c as DmdConsentPurpose, d as DmdConsentState, e as DmdDeliveryDropReason, f as DmdDeliveryEventDiagnostic, g as DmdDroppedEventDiagnostic, h as DmdDroppedEventReason, i as DmdDroppedEventType, k as DmdEventPayload } from '../types-BwtS0ZDu.js';
1
+ import { j as DmdEventOptions, b as DmdConsentInput, l as DmdHealthStatus, D as DmdBrowserClient, a as DmdBrowserConfig } from '../types--V8TVIqT.js';
2
+ export { c as DmdConsentPurpose, d as DmdConsentState, e as DmdDeliveryDropReason, f as DmdDeliveryEventDiagnostic, g as DmdDroppedEventDiagnostic, h as DmdDroppedEventReason, i as DmdDroppedEventType, k as DmdEventPayload } from '../types--V8TVIqT.js';
3
3
 
4
- declare class DriveMetaDataSDK {
5
- initialized: boolean;
6
- queue: unknown[];
7
- offline: boolean;
8
- gdprConsent: 'granted' | 'denied' | 'pending';
9
- private readonly endpoint;
10
- private readonly config;
11
- private readonly writeKey;
12
- private readonly delivery;
13
- private identity;
14
- private consentState;
15
- private droppedEvents;
16
- private lastError;
17
- private lastDroppedEvent;
18
- private retryTimer;
19
- private retryDelayMs;
20
- private readonly initialRetryDelayMs;
21
- private readonly maxRetryDelayMs;
22
- private lifecycleCleanup;
23
- constructor(config: DmdBrowserConfig);
24
- trackEvent(event: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
25
- page(name?: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
26
- trackPageview(): void;
27
- identify(userId: string, traits?: Record<string, unknown>, options?: DmdEventOptions): void;
28
- identifyUser(userId: string, traits?: Record<string, unknown>): void;
29
- group(groupId: string, traits?: Record<string, unknown>, options?: DmdEventOptions): void;
30
- alias(previousId: string, userId: string, options?: DmdEventOptions): void;
31
- flush(): Promise<void>;
32
- reset(): void;
33
- setConsent(consent: DmdConsentInput): void;
34
- getHealth(): DmdHealthStatus;
35
- sendEvent(payload: unknown): void;
36
- private installLifecycleFlush;
37
- private scheduleRetryFlush;
38
- private sendPreparedEvent;
39
- private prepareAndSendEvent;
40
- private recordDrop;
41
- }
42
-
43
- interface LegacySdkInstance {
44
- sendEvent?: (payload: unknown) => void;
45
- trackEvent?: (event: string, properties?: Record<string, unknown>, options?: unknown) => void;
46
- identify?: (userId: string, traits?: Record<string, unknown>, options?: unknown) => void;
47
- identifyUser?: (userId: string, traits?: Record<string, unknown>) => void;
48
- page?: (name?: string, properties?: Record<string, unknown>, options?: unknown) => void;
49
- group?: (groupId: string, traits?: Record<string, unknown>, options?: unknown) => void;
50
- alias?: (previousId: string, userId: string, options?: unknown) => void;
51
- flush?: () => Promise<void>;
52
- reset?: () => void;
53
- setConsent?: (consent: unknown) => void;
54
- getHealth?: () => unknown;
55
- trackPageview?: () => void;
56
- blockTrackingForMe?: () => void;
57
- gdprConsent?: 'granted' | 'denied' | 'pending';
58
- initialized?: boolean;
59
- queue?: unknown[];
60
- offline?: boolean;
61
- }
62
-
63
- type DmdRuntimeInstance = LegacySdkInstance | DriveMetaDataSDK;
64
- interface DmdBrowserClientWithLegacy extends DmdBrowserClient {
65
- __legacy: DmdRuntimeInstance;
66
- }
67
- declare function initDmdSDK(config: DmdBrowserConfig): DmdBrowserClientWithLegacy;
68
- declare function getDmdSDK(): DmdBrowserClientWithLegacy | undefined;
4
+ declare function initDmdSDK(config: DmdBrowserConfig): DmdBrowserClient;
5
+ declare function getDmdSDK(): DmdBrowserClient | undefined;
69
6
  declare function track(event: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
70
7
  declare function identify(userId: string, traits?: Record<string, unknown>, options?: DmdEventOptions): void;
71
8
  declare function page(name?: string, properties?: Record<string, unknown>, options?: DmdEventOptions): void;
@@ -77,7 +14,7 @@ declare function setConsent(consent: DmdConsentInput): void;
77
14
  declare const consent: {
78
15
  update(state: DmdConsentInput): void;
79
16
  };
80
- declare function ready(): Promise<DmdBrowserClientWithLegacy | undefined>;
17
+ declare function ready(): Promise<DmdBrowserClient | undefined>;
81
18
  declare function getDmdHealth(): DmdHealthStatus;
82
19
  declare function resetDmdSDKForTests(): void;
83
20
 
@@ -1,50 +1,59 @@
1
- // src/core/config.ts
2
- function requireString(value, field) {
3
- if (typeof value !== "string" || value.trim() === "") {
4
- throw new Error(`DMD SDK config ${field} is required`);
1
+ // src/core/backend-payload.ts
2
+ function formatUtcTimestamp(value) {
3
+ if (typeof value !== "string") return (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19);
4
+ const date = new Date(value);
5
+ if (Number.isNaN(date.getTime())) return value;
6
+ return date.toISOString().replace("T", " ").slice(0, 19);
7
+ }
8
+ function cleanObject(value) {
9
+ if (Array.isArray(value)) {
10
+ const cleaned = value.map((item) => cleanObject(item)).filter((item) => item !== null && item !== void 0 && item !== "");
11
+ return cleaned.length > 0 ? cleaned : void 0;
12
+ }
13
+ if (value && typeof value === "object") {
14
+ const cleaned = Object.fromEntries(
15
+ Object.entries(value).map(([key, item]) => [key, cleanObject(item)]).filter(([, item]) => {
16
+ if (item === null || item === void 0 || item === "") return false;
17
+ if (typeof item === "object" && !Array.isArray(item) && Object.keys(item).length === 0) return false;
18
+ return true;
19
+ })
20
+ );
21
+ return Object.keys(cleaned).length > 0 ? cleaned : void 0;
5
22
  }
6
23
  return value;
7
24
  }
8
- function normalizeBrowserConfig(config) {
9
- const writeKey = config.writeKey || config.token;
10
- const legacyConfig = {
11
- client_id: requireString(config.clientId, "clientId"),
12
- workspace_id: requireString(config.workspaceId, "workspaceId"),
13
- app_id: requireString(config.appId, "appId"),
14
- token: requireString(writeKey, "writeKey")
25
+ function createBackendCollectorPayload(input) {
26
+ const eventData = input.eventData && typeof input.eventData === "object" ? input.eventData : {};
27
+ const page2 = eventData.page && typeof eventData.page === "object" ? eventData.page : {};
28
+ const timestamp = formatUtcTimestamp(eventData.timestamp ?? input.timestamp);
29
+ const normalizedEventData = {
30
+ ...eventData,
31
+ timestamp,
32
+ requestSentAt: formatUtcTimestamp(eventData.requestSentAt ?? input.requestSentAt ?? timestamp),
33
+ requestReceivedAt: formatUtcTimestamp(eventData.requestReceivedAt ?? input.requestReceivedAt ?? timestamp)
34
+ };
35
+ const metaData = {
36
+ ...normalizedEventData,
37
+ requestId: input.requestId,
38
+ timestamp,
39
+ eventType: input.eventType,
40
+ requestFrom: input.requestFrom ?? "3",
41
+ clientId: input.clientId,
42
+ workspaceId: input.workspaceId,
43
+ token: input.token,
44
+ anonymousId: eventData.anonymousId ?? input.anonymousId,
45
+ sessionId: eventData.sessionId ?? input.sessionId,
46
+ ua: input.ua,
47
+ appDetails: { app_id: input.appId },
48
+ page: { ...page2, url: page2.url ?? input.pageUrl },
49
+ requestSentAt: normalizedEventData.requestSentAt,
50
+ requestReceivedAt: normalizedEventData.requestReceivedAt
15
51
  };
16
- if (config.apiHost !== void 0) legacyConfig.api_host = config.apiHost;
17
- if (config.uiHost !== void 0) legacyConfig.ui_host = config.uiHost;
18
- if (config.deeplink !== void 0) legacyConfig.deeplink = config.deeplink;
19
- if (config.debug !== void 0) legacyConfig.debug = config.debug;
20
- if (config.consent !== void 0) legacyConfig.consent = config.consent;
21
- if (config.gdprConsent !== void 0) legacyConfig.gdprConsent = config.gdprConsent;
22
- if (config.autocapture !== void 0) legacyConfig.autocapture = config.autocapture;
23
- if (config.capturePageview !== void 0) legacyConfig.capture_pageview = config.capturePageview;
24
- if (config.capturePageleave !== void 0) legacyConfig.capture_pageleave = config.capturePageleave;
25
- if (config.captureDeadClicks !== void 0) legacyConfig.capture_dead_clicks = config.captureDeadClicks;
26
- if (config.crossSubdomainCookie !== void 0) legacyConfig.cross_subdomain_cookie = config.crossSubdomainCookie;
27
- if (config.disablePersistence !== void 0) legacyConfig.disable_persistence = config.disablePersistence;
28
- if (config.disableSurveys !== void 0) legacyConfig.disable_surveys = config.disableSurveys;
29
- if (config.disableSessionRecording !== void 0) legacyConfig.disable_session_recording = config.disableSessionRecording;
30
- if (config.enableHeatmaps !== void 0) legacyConfig.enable_heatmaps = config.enableHeatmaps;
31
- if (config.maskAllText !== void 0) legacyConfig.mask_all_text = config.maskAllText;
32
- if (config.maskAllElementAttributes !== void 0) {
33
- legacyConfig.mask_all_element_attributes = config.maskAllElementAttributes;
34
- }
35
- if (config.persistence !== void 0) legacyConfig.persistence = config.persistence;
36
- if (config.propertyDenylist !== void 0) legacyConfig.property_denylist = config.propertyDenylist;
37
- if (config.sessionIdleTimeoutSeconds !== void 0) {
38
- legacyConfig.session_idle_timeout_seconds = config.sessionIdleTimeoutSeconds;
39
- }
40
- if (config.beforeSend !== void 0) legacyConfig.before_send = config.beforeSend;
41
- return legacyConfig;
52
+ const payload = { metaData };
53
+ return cleanObject(payload);
42
54
  }
43
55
 
44
56
  // src/core/environment.ts
45
- function isBrowserRuntime() {
46
- return typeof window !== "undefined" && typeof document !== "undefined";
47
- }
48
57
  function getBrowserWindow() {
49
58
  return typeof window === "undefined" ? void 0 : window;
50
59
  }
@@ -104,8 +113,9 @@ function stableStringify(value) {
104
113
  );
105
114
  }
106
115
  function createIdempotencyKey(payload, messageId) {
107
- const event = String(payload.event ?? payload.type ?? "event");
108
- const properties = payload.properties;
116
+ const metaData = payload.metaData;
117
+ const event = String(metaData?.eventType ?? payload.event ?? payload.type ?? "event");
118
+ const properties = metaData ?? payload.properties;
109
119
  const orderId = properties?.orderId ?? properties?.order_id ?? properties?.transaction_id;
110
120
  if (orderId !== void 0) return `${event}:${String(orderId)}`;
111
121
  return `${event}:${stableStringify(properties ?? {}) || messageId}`;
@@ -206,7 +216,17 @@ function createDeliveryManager(config) {
206
216
  persistQueue();
207
217
  }
208
218
  function withEnvelope(payload) {
209
- const messageId = String(payload.messageId ?? createId("msg"));
219
+ const metaData = payload.metaData;
220
+ const messageId = String(metaData?.requestId ?? payload.messageId ?? createId("msg"));
221
+ if (metaData) {
222
+ return {
223
+ ...payload,
224
+ metaData: {
225
+ ...metaData,
226
+ requestId: messageId
227
+ }
228
+ };
229
+ }
210
230
  return {
211
231
  ...payload,
212
232
  messageId,
@@ -232,7 +252,7 @@ function createDeliveryManager(config) {
232
252
  const body = withEnvelope(payload);
233
253
  if (payloadByteLength(body) > maxPayloadBytes) {
234
254
  recordDrop({
235
- messageId: String(body.messageId),
255
+ messageId: String(body.metaData?.requestId ?? body.messageId),
236
256
  reason: "payload_too_large",
237
257
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
238
258
  });
@@ -245,7 +265,7 @@ function createDeliveryManager(config) {
245
265
  const deliveryError = error instanceof Error ? error : new Error(String(error));
246
266
  recordError(deliveryError);
247
267
  enqueue({
248
- messageId: String(body.messageId),
268
+ messageId: String(body.metaData?.requestId ?? body.messageId),
249
269
  savedAt: Date.now(),
250
270
  attempts: 1,
251
271
  lastError: deliveryError.message,
@@ -420,6 +440,12 @@ function endpointFromConfig(config) {
420
440
  const host = config.apiHost ?? "https://sdk.drivemetadata.com/v2";
421
441
  return `${host.replace(/\/$/, "")}/data-collector`;
422
442
  }
443
+ function requireConfigString(value, field) {
444
+ if (typeof value !== "string" || value.trim() === "") {
445
+ throw new Error(`DMD SDK config ${field} is required`);
446
+ }
447
+ return value;
448
+ }
423
449
  function getBrowserStorage() {
424
450
  const browserWindow = getBrowserWindow();
425
451
  try {
@@ -434,6 +460,10 @@ var DriveMetaDataSDK = class {
434
460
  this.queue = [];
435
461
  this.offline = false;
436
462
  this.droppedEvents = 0;
463
+ requireConfigString(config.clientId, "clientId");
464
+ requireConfigString(config.workspaceId, "workspaceId");
465
+ requireConfigString(config.appId, "appId");
466
+ requireConfigString(config.writeKey || config.token, "writeKey or token");
437
467
  this.config = config;
438
468
  this.endpoint = endpointFromConfig(config);
439
469
  const storage = getBrowserStorage();
@@ -457,6 +487,7 @@ var DriveMetaDataSDK = class {
457
487
  this.maxRetryDelayMs = config.delivery?.maxRetryDelayMs ?? 3e4;
458
488
  this.writeKey = config.writeKey || config.token || "";
459
489
  this.identity = { anonymousId: createId2("anon") };
490
+ this.sessionId = createId2("session");
460
491
  this.consentState = normalizeConsent(config.gdprConsent ?? config.consent);
461
492
  this.gdprConsent = this.consentState.analytics;
462
493
  if (!config.delivery?.disableLifecycleFlush) {
@@ -602,7 +633,8 @@ var DriveMetaDataSDK = class {
602
633
  workspaceId: this.config.workspaceId,
603
634
  appId: this.config.appId,
604
635
  writeKey: this.writeKey,
605
- consent: this.consentState
636
+ consent: this.consentState,
637
+ sessionId: this.sessionId
606
638
  };
607
639
  if (this.identity.userId !== void 0) prepared.userId = this.identity.userId;
608
640
  if (this.identity.groupId !== void 0) prepared.groupId = this.identity.groupId;
@@ -626,7 +658,31 @@ var DriveMetaDataSDK = class {
626
658
  if (!validation.ok) {
627
659
  this.lastError = `DMD SDK schema warning: ${validation.errors.join(", ")}`;
628
660
  }
629
- this.sendEvent(prepared);
661
+ this.sendEvent(this.toCollectorPayload(prepared));
662
+ }
663
+ toCollectorPayload(prepared) {
664
+ const browserWindow = getBrowserWindow();
665
+ return createBackendCollectorPayload({
666
+ requestId: prepared.messageId,
667
+ timestamp: prepared.timestamp,
668
+ eventType: prepared.event,
669
+ clientId: prepared.clientId,
670
+ workspaceId: prepared.workspaceId,
671
+ token: prepared.writeKey,
672
+ anonymousId: prepared.anonymousId,
673
+ sessionId: prepared.sessionId,
674
+ ua: browserWindow?.navigator?.userAgent,
675
+ appId: prepared.appId,
676
+ pageUrl: browserWindow?.location?.href,
677
+ eventData: {
678
+ ...prepared.properties,
679
+ anonymousId: prepared.anonymousId,
680
+ sessionId: prepared.sessionId,
681
+ timestamp: prepared.timestamp,
682
+ requestSentAt: prepared.timestamp,
683
+ requestReceivedAt: prepared.timestamp
684
+ }
685
+ });
630
686
  }
631
687
  recordDrop(type, reason, event) {
632
688
  this.droppedEvents += 1;
@@ -640,22 +696,6 @@ var DriveMetaDataSDK = class {
640
696
  }
641
697
  };
642
698
 
643
- // src/browser/legacy-loader.ts
644
- function getLegacySdkInstanceFromWindow() {
645
- const browserWindow = getBrowserWindow();
646
- return browserWindow?.__DriveMetaDataSDKInstance;
647
- }
648
- function ensureLegacySdkLoaded() {
649
- if (!isBrowserRuntime()) {
650
- throw new Error("DMD legacy SDK is only available in a browser runtime");
651
- }
652
- const browserWindow = getBrowserWindow();
653
- if (!browserWindow?.DriveMetaDataSDK) {
654
- throw new Error("DMD legacy SDK constructor is missing from window.DriveMetaDataSDK");
655
- }
656
- return browserWindow.DriveMetaDataSDK;
657
- }
658
-
659
699
  // src/browser/client.ts
660
700
  var singleton;
661
701
  var publicSingleton;
@@ -664,56 +704,34 @@ var lastError;
664
704
  var lastDroppedEvent;
665
705
  function createPublicClient(instance) {
666
706
  return {
667
- __legacy: instance,
668
707
  track(event, properties, options) {
669
- if (instance.trackEvent) {
670
- instance.trackEvent(event, properties, options);
671
- return;
672
- }
673
- instance.sendEvent?.({ eventName: event, event, properties, options });
708
+ instance.trackEvent(event, properties, options);
674
709
  },
675
710
  identify(userId, traits, options) {
676
- if (instance.identify) {
677
- instance.identify(userId, traits, options);
678
- return;
679
- }
680
- instance.identifyUser?.(userId, traits);
711
+ instance.identify(userId, traits, options);
681
712
  },
682
713
  page(name, properties, options) {
683
- if (instance.page) {
684
- instance.page(name, properties, options);
685
- return;
686
- }
687
- instance.trackPageview?.();
714
+ instance.page(name, properties, options);
688
715
  },
689
716
  group(groupId, traits, options) {
690
- instance.group?.(groupId, traits, options);
717
+ instance.group(groupId, traits, options);
691
718
  },
692
719
  alias(previousId, userId, options) {
693
- instance.alias?.(previousId, userId, options);
720
+ instance.alias(previousId, userId, options);
694
721
  },
695
722
  async flush() {
696
- await instance.flush?.();
723
+ await instance.flush();
697
724
  },
698
725
  reset() {
699
- instance.reset?.();
726
+ instance.reset();
700
727
  singleton = void 0;
701
728
  publicSingleton = void 0;
702
729
  },
703
730
  setConsent(consent2) {
704
- if (instance.setConsent) {
705
- instance.setConsent(consent2);
706
- return;
707
- }
708
- if (typeof consent2 === "string") {
709
- instance.gdprConsent = consent2;
710
- }
731
+ instance.setConsent(consent2);
711
732
  },
712
733
  getHealth() {
713
- if (instance.getHealth) {
714
- return instance.getHealth();
715
- }
716
- return getDmdHealth();
734
+ return instance.getHealth();
717
735
  }
718
736
  };
719
737
  }
@@ -738,23 +756,8 @@ function initDmdSDK(config) {
738
756
  if (publicSingleton) {
739
757
  return publicSingleton;
740
758
  }
741
- const legacyConfig = normalizeBrowserConfig(config);
742
- const existingInstance = getLegacySdkInstanceFromWindow();
743
- if (existingInstance) {
744
- return setSingleton(existingInstance);
745
- }
746
759
  try {
747
- let instance;
748
- try {
749
- const LegacySdk = ensureLegacySdkLoaded();
750
- instance = new LegacySdk(legacyConfig);
751
- } catch (error) {
752
- if (error instanceof Error && error.message.includes("constructor is missing")) {
753
- instance = new DriveMetaDataSDK(config);
754
- } else {
755
- throw error;
756
- }
757
- }
760
+ const instance = new DriveMetaDataSDK(config);
758
761
  return setSingleton(instance);
759
762
  } catch (error) {
760
763
  lastError = error instanceof Error ? error.message : String(error);
@@ -829,14 +832,14 @@ async function ready() {
829
832
  return getDmdSDK();
830
833
  }
831
834
  function getDmdHealth() {
832
- if (singleton?.getHealth) {
835
+ if (singleton) {
833
836
  return singleton.getHealth();
834
837
  }
835
838
  const health = {
836
- initialized: Boolean(singleton?.initialized ?? singleton),
837
- consent: singleton?.gdprConsent ?? "pending",
838
- queueSize: singleton?.queue?.length ?? 0,
839
- offline: Boolean(singleton?.offline),
839
+ initialized: false,
840
+ consent: "pending",
841
+ queueSize: 0,
842
+ offline: false,
840
843
  droppedEvents
841
844
  };
842
845
  if (lastError !== void 0) {
@@ -848,7 +851,7 @@ function getDmdHealth() {
848
851
  return health;
849
852
  }
850
853
  function resetDmdSDKForTests() {
851
- singleton?.reset?.();
854
+ singleton?.reset();
852
855
  singleton = void 0;
853
856
  publicSingleton = void 0;
854
857
  droppedEvents = 0;