@analyticscli/sdk 0.1.0-preview.8 → 0.1.0-preview.9
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/dist/browser.cjs +54 -1
- package/dist/browser.js +1 -1
- package/dist/{chunk-S3MLRL5U.js → chunk-FRXYHOBX.js} +54 -1
- package/dist/index.cjs +54 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/react-native.cjs +54 -1
- package/dist/react-native.js +1 -1
- package/package.json +1 -1
package/dist/browser.cjs
CHANGED
|
@@ -588,6 +588,27 @@ var sanitizeSurveyResponseInput = (input) => {
|
|
|
588
588
|
// src/analytics-client.ts
|
|
589
589
|
var DEFAULT_CONSENT_STORAGE_KEY = "analyticscli:consent:v1";
|
|
590
590
|
var AUTH_FAILURE_FLUSH_PAUSE_MS = 6e4;
|
|
591
|
+
var resolveDefaultOsNameFromPlatform = (platform) => {
|
|
592
|
+
if (!platform) {
|
|
593
|
+
return void 0;
|
|
594
|
+
}
|
|
595
|
+
if (platform === "ios") {
|
|
596
|
+
return "iOS";
|
|
597
|
+
}
|
|
598
|
+
if (platform === "android") {
|
|
599
|
+
return "Android";
|
|
600
|
+
}
|
|
601
|
+
if (platform === "web") {
|
|
602
|
+
return "Web";
|
|
603
|
+
}
|
|
604
|
+
if (platform === "mac") {
|
|
605
|
+
return "macOS";
|
|
606
|
+
}
|
|
607
|
+
if (platform === "windows") {
|
|
608
|
+
return "Windows";
|
|
609
|
+
}
|
|
610
|
+
return void 0;
|
|
611
|
+
};
|
|
591
612
|
var IngestSendError = class extends Error {
|
|
592
613
|
retryable;
|
|
593
614
|
attempts;
|
|
@@ -668,7 +689,12 @@ var AnalyticsClient = class {
|
|
|
668
689
|
this.projectSurface = this.normalizeProjectSurfaceOption(normalizedOptions.projectSurface);
|
|
669
690
|
this.appVersion = this.readRequiredStringOption(normalizedOptions.appVersion) || detectDefaultAppVersion();
|
|
670
691
|
this.identityTrackingMode = this.resolveIdentityTrackingModeOption(normalizedOptions);
|
|
671
|
-
|
|
692
|
+
const initialContext = { ...normalizedOptions.context ?? {} };
|
|
693
|
+
const hasExplicitOsName = this.readRequiredStringOption(initialContext.osName).length > 0;
|
|
694
|
+
this.context = {
|
|
695
|
+
...initialContext,
|
|
696
|
+
osName: hasExplicitOsName ? initialContext.osName : resolveDefaultOsNameFromPlatform(this.platform) ?? initialContext.osName
|
|
697
|
+
};
|
|
672
698
|
this.runtimeEnv = detectRuntimeEnv();
|
|
673
699
|
this.persistConsentState = normalizedOptions.persistConsentState ?? false;
|
|
674
700
|
this.consentStorageKey = this.readRequiredStringOption(normalizedOptions.consentStorageKey) || DEFAULT_CONSENT_STORAGE_KEY;
|
|
@@ -701,6 +727,7 @@ var AnalyticsClient = class {
|
|
|
701
727
|
this.writePersistedConsent(this.configuredStorage, this.fullTrackingConsentGranted);
|
|
702
728
|
}
|
|
703
729
|
this.hydrationPromise = this.hydrateIdentityFromStorage();
|
|
730
|
+
this.enqueueInitialSessionStart();
|
|
704
731
|
this.startAutoFlush();
|
|
705
732
|
}
|
|
706
733
|
/**
|
|
@@ -758,6 +785,32 @@ var AnalyticsClient = class {
|
|
|
758
785
|
...context
|
|
759
786
|
};
|
|
760
787
|
}
|
|
788
|
+
enqueueInitialSessionStart() {
|
|
789
|
+
if (!this.consentGranted) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (this.shouldDeferEventsUntilHydrated()) {
|
|
793
|
+
this.deferEventUntilHydrated(() => {
|
|
794
|
+
this.enqueueInitialSessionStart();
|
|
795
|
+
});
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const sessionId = this.getSessionId();
|
|
799
|
+
this.enqueue({
|
|
800
|
+
eventId: randomId(),
|
|
801
|
+
eventName: "session_start",
|
|
802
|
+
ts: nowIso(),
|
|
803
|
+
sessionId,
|
|
804
|
+
anonId: this.anonId,
|
|
805
|
+
userId: this.getEventUserId(),
|
|
806
|
+
properties: this.withRuntimeMetadata({ source: "sdk_mount" }, sessionId),
|
|
807
|
+
platform: this.platform,
|
|
808
|
+
projectSurface: this.projectSurface,
|
|
809
|
+
appVersion: this.appVersion,
|
|
810
|
+
...this.withEventContext(),
|
|
811
|
+
type: "track"
|
|
812
|
+
});
|
|
813
|
+
}
|
|
761
814
|
/**
|
|
762
815
|
* Associates following events with a known user id.
|
|
763
816
|
* Anonymous history remains linked by anonId/sessionId.
|
package/dist/browser.js
CHANGED
|
@@ -547,6 +547,27 @@ var sanitizeSurveyResponseInput = (input) => {
|
|
|
547
547
|
// src/analytics-client.ts
|
|
548
548
|
var DEFAULT_CONSENT_STORAGE_KEY = "analyticscli:consent:v1";
|
|
549
549
|
var AUTH_FAILURE_FLUSH_PAUSE_MS = 6e4;
|
|
550
|
+
var resolveDefaultOsNameFromPlatform = (platform) => {
|
|
551
|
+
if (!platform) {
|
|
552
|
+
return void 0;
|
|
553
|
+
}
|
|
554
|
+
if (platform === "ios") {
|
|
555
|
+
return "iOS";
|
|
556
|
+
}
|
|
557
|
+
if (platform === "android") {
|
|
558
|
+
return "Android";
|
|
559
|
+
}
|
|
560
|
+
if (platform === "web") {
|
|
561
|
+
return "Web";
|
|
562
|
+
}
|
|
563
|
+
if (platform === "mac") {
|
|
564
|
+
return "macOS";
|
|
565
|
+
}
|
|
566
|
+
if (platform === "windows") {
|
|
567
|
+
return "Windows";
|
|
568
|
+
}
|
|
569
|
+
return void 0;
|
|
570
|
+
};
|
|
550
571
|
var IngestSendError = class extends Error {
|
|
551
572
|
retryable;
|
|
552
573
|
attempts;
|
|
@@ -627,7 +648,12 @@ var AnalyticsClient = class {
|
|
|
627
648
|
this.projectSurface = this.normalizeProjectSurfaceOption(normalizedOptions.projectSurface);
|
|
628
649
|
this.appVersion = this.readRequiredStringOption(normalizedOptions.appVersion) || detectDefaultAppVersion();
|
|
629
650
|
this.identityTrackingMode = this.resolveIdentityTrackingModeOption(normalizedOptions);
|
|
630
|
-
|
|
651
|
+
const initialContext = { ...normalizedOptions.context ?? {} };
|
|
652
|
+
const hasExplicitOsName = this.readRequiredStringOption(initialContext.osName).length > 0;
|
|
653
|
+
this.context = {
|
|
654
|
+
...initialContext,
|
|
655
|
+
osName: hasExplicitOsName ? initialContext.osName : resolveDefaultOsNameFromPlatform(this.platform) ?? initialContext.osName
|
|
656
|
+
};
|
|
631
657
|
this.runtimeEnv = detectRuntimeEnv();
|
|
632
658
|
this.persistConsentState = normalizedOptions.persistConsentState ?? false;
|
|
633
659
|
this.consentStorageKey = this.readRequiredStringOption(normalizedOptions.consentStorageKey) || DEFAULT_CONSENT_STORAGE_KEY;
|
|
@@ -660,6 +686,7 @@ var AnalyticsClient = class {
|
|
|
660
686
|
this.writePersistedConsent(this.configuredStorage, this.fullTrackingConsentGranted);
|
|
661
687
|
}
|
|
662
688
|
this.hydrationPromise = this.hydrateIdentityFromStorage();
|
|
689
|
+
this.enqueueInitialSessionStart();
|
|
663
690
|
this.startAutoFlush();
|
|
664
691
|
}
|
|
665
692
|
/**
|
|
@@ -717,6 +744,32 @@ var AnalyticsClient = class {
|
|
|
717
744
|
...context
|
|
718
745
|
};
|
|
719
746
|
}
|
|
747
|
+
enqueueInitialSessionStart() {
|
|
748
|
+
if (!this.consentGranted) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
if (this.shouldDeferEventsUntilHydrated()) {
|
|
752
|
+
this.deferEventUntilHydrated(() => {
|
|
753
|
+
this.enqueueInitialSessionStart();
|
|
754
|
+
});
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const sessionId = this.getSessionId();
|
|
758
|
+
this.enqueue({
|
|
759
|
+
eventId: randomId(),
|
|
760
|
+
eventName: "session_start",
|
|
761
|
+
ts: nowIso(),
|
|
762
|
+
sessionId,
|
|
763
|
+
anonId: this.anonId,
|
|
764
|
+
userId: this.getEventUserId(),
|
|
765
|
+
properties: this.withRuntimeMetadata({ source: "sdk_mount" }, sessionId),
|
|
766
|
+
platform: this.platform,
|
|
767
|
+
projectSurface: this.projectSurface,
|
|
768
|
+
appVersion: this.appVersion,
|
|
769
|
+
...this.withEventContext(),
|
|
770
|
+
type: "track"
|
|
771
|
+
});
|
|
772
|
+
}
|
|
720
773
|
/**
|
|
721
774
|
* Associates following events with a known user id.
|
|
722
775
|
* Anonymous history remains linked by anonId/sessionId.
|
package/dist/index.cjs
CHANGED
|
@@ -588,6 +588,27 @@ var sanitizeSurveyResponseInput = (input) => {
|
|
|
588
588
|
// src/analytics-client.ts
|
|
589
589
|
var DEFAULT_CONSENT_STORAGE_KEY = "analyticscli:consent:v1";
|
|
590
590
|
var AUTH_FAILURE_FLUSH_PAUSE_MS = 6e4;
|
|
591
|
+
var resolveDefaultOsNameFromPlatform = (platform) => {
|
|
592
|
+
if (!platform) {
|
|
593
|
+
return void 0;
|
|
594
|
+
}
|
|
595
|
+
if (platform === "ios") {
|
|
596
|
+
return "iOS";
|
|
597
|
+
}
|
|
598
|
+
if (platform === "android") {
|
|
599
|
+
return "Android";
|
|
600
|
+
}
|
|
601
|
+
if (platform === "web") {
|
|
602
|
+
return "Web";
|
|
603
|
+
}
|
|
604
|
+
if (platform === "mac") {
|
|
605
|
+
return "macOS";
|
|
606
|
+
}
|
|
607
|
+
if (platform === "windows") {
|
|
608
|
+
return "Windows";
|
|
609
|
+
}
|
|
610
|
+
return void 0;
|
|
611
|
+
};
|
|
591
612
|
var IngestSendError = class extends Error {
|
|
592
613
|
retryable;
|
|
593
614
|
attempts;
|
|
@@ -668,7 +689,12 @@ var AnalyticsClient = class {
|
|
|
668
689
|
this.projectSurface = this.normalizeProjectSurfaceOption(normalizedOptions.projectSurface);
|
|
669
690
|
this.appVersion = this.readRequiredStringOption(normalizedOptions.appVersion) || detectDefaultAppVersion();
|
|
670
691
|
this.identityTrackingMode = this.resolveIdentityTrackingModeOption(normalizedOptions);
|
|
671
|
-
|
|
692
|
+
const initialContext = { ...normalizedOptions.context ?? {} };
|
|
693
|
+
const hasExplicitOsName = this.readRequiredStringOption(initialContext.osName).length > 0;
|
|
694
|
+
this.context = {
|
|
695
|
+
...initialContext,
|
|
696
|
+
osName: hasExplicitOsName ? initialContext.osName : resolveDefaultOsNameFromPlatform(this.platform) ?? initialContext.osName
|
|
697
|
+
};
|
|
672
698
|
this.runtimeEnv = detectRuntimeEnv();
|
|
673
699
|
this.persistConsentState = normalizedOptions.persistConsentState ?? false;
|
|
674
700
|
this.consentStorageKey = this.readRequiredStringOption(normalizedOptions.consentStorageKey) || DEFAULT_CONSENT_STORAGE_KEY;
|
|
@@ -701,6 +727,7 @@ var AnalyticsClient = class {
|
|
|
701
727
|
this.writePersistedConsent(this.configuredStorage, this.fullTrackingConsentGranted);
|
|
702
728
|
}
|
|
703
729
|
this.hydrationPromise = this.hydrateIdentityFromStorage();
|
|
730
|
+
this.enqueueInitialSessionStart();
|
|
704
731
|
this.startAutoFlush();
|
|
705
732
|
}
|
|
706
733
|
/**
|
|
@@ -758,6 +785,32 @@ var AnalyticsClient = class {
|
|
|
758
785
|
...context
|
|
759
786
|
};
|
|
760
787
|
}
|
|
788
|
+
enqueueInitialSessionStart() {
|
|
789
|
+
if (!this.consentGranted) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (this.shouldDeferEventsUntilHydrated()) {
|
|
793
|
+
this.deferEventUntilHydrated(() => {
|
|
794
|
+
this.enqueueInitialSessionStart();
|
|
795
|
+
});
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const sessionId = this.getSessionId();
|
|
799
|
+
this.enqueue({
|
|
800
|
+
eventId: randomId(),
|
|
801
|
+
eventName: "session_start",
|
|
802
|
+
ts: nowIso(),
|
|
803
|
+
sessionId,
|
|
804
|
+
anonId: this.anonId,
|
|
805
|
+
userId: this.getEventUserId(),
|
|
806
|
+
properties: this.withRuntimeMetadata({ source: "sdk_mount" }, sessionId),
|
|
807
|
+
platform: this.platform,
|
|
808
|
+
projectSurface: this.projectSurface,
|
|
809
|
+
appVersion: this.appVersion,
|
|
810
|
+
...this.withEventContext(),
|
|
811
|
+
type: "track"
|
|
812
|
+
});
|
|
813
|
+
}
|
|
761
814
|
/**
|
|
762
815
|
* Associates following events with a known user id.
|
|
763
816
|
* Anonymous history remains linked by anonId/sessionId.
|
package/dist/index.d.cts
CHANGED
|
@@ -365,6 +365,7 @@ declare class AnalyticsClient {
|
|
|
365
365
|
* Sets or updates shared event context fields (useful for mobile device/app metadata).
|
|
366
366
|
*/
|
|
367
367
|
setContext(context: EventContext): void;
|
|
368
|
+
private enqueueInitialSessionStart;
|
|
368
369
|
/**
|
|
369
370
|
* Associates following events with a known user id.
|
|
370
371
|
* Anonymous history remains linked by anonId/sessionId.
|
package/dist/index.d.ts
CHANGED
|
@@ -365,6 +365,7 @@ declare class AnalyticsClient {
|
|
|
365
365
|
* Sets or updates shared event context fields (useful for mobile device/app metadata).
|
|
366
366
|
*/
|
|
367
367
|
setContext(context: EventContext): void;
|
|
368
|
+
private enqueueInitialSessionStart;
|
|
368
369
|
/**
|
|
369
370
|
* Associates following events with a known user id.
|
|
370
371
|
* Anonymous history remains linked by anonId/sessionId.
|
package/dist/index.js
CHANGED
package/dist/react-native.cjs
CHANGED
|
@@ -588,6 +588,27 @@ var sanitizeSurveyResponseInput = (input) => {
|
|
|
588
588
|
// src/analytics-client.ts
|
|
589
589
|
var DEFAULT_CONSENT_STORAGE_KEY = "analyticscli:consent:v1";
|
|
590
590
|
var AUTH_FAILURE_FLUSH_PAUSE_MS = 6e4;
|
|
591
|
+
var resolveDefaultOsNameFromPlatform = (platform) => {
|
|
592
|
+
if (!platform) {
|
|
593
|
+
return void 0;
|
|
594
|
+
}
|
|
595
|
+
if (platform === "ios") {
|
|
596
|
+
return "iOS";
|
|
597
|
+
}
|
|
598
|
+
if (platform === "android") {
|
|
599
|
+
return "Android";
|
|
600
|
+
}
|
|
601
|
+
if (platform === "web") {
|
|
602
|
+
return "Web";
|
|
603
|
+
}
|
|
604
|
+
if (platform === "mac") {
|
|
605
|
+
return "macOS";
|
|
606
|
+
}
|
|
607
|
+
if (platform === "windows") {
|
|
608
|
+
return "Windows";
|
|
609
|
+
}
|
|
610
|
+
return void 0;
|
|
611
|
+
};
|
|
591
612
|
var IngestSendError = class extends Error {
|
|
592
613
|
retryable;
|
|
593
614
|
attempts;
|
|
@@ -668,7 +689,12 @@ var AnalyticsClient = class {
|
|
|
668
689
|
this.projectSurface = this.normalizeProjectSurfaceOption(normalizedOptions.projectSurface);
|
|
669
690
|
this.appVersion = this.readRequiredStringOption(normalizedOptions.appVersion) || detectDefaultAppVersion();
|
|
670
691
|
this.identityTrackingMode = this.resolveIdentityTrackingModeOption(normalizedOptions);
|
|
671
|
-
|
|
692
|
+
const initialContext = { ...normalizedOptions.context ?? {} };
|
|
693
|
+
const hasExplicitOsName = this.readRequiredStringOption(initialContext.osName).length > 0;
|
|
694
|
+
this.context = {
|
|
695
|
+
...initialContext,
|
|
696
|
+
osName: hasExplicitOsName ? initialContext.osName : resolveDefaultOsNameFromPlatform(this.platform) ?? initialContext.osName
|
|
697
|
+
};
|
|
672
698
|
this.runtimeEnv = detectRuntimeEnv();
|
|
673
699
|
this.persistConsentState = normalizedOptions.persistConsentState ?? false;
|
|
674
700
|
this.consentStorageKey = this.readRequiredStringOption(normalizedOptions.consentStorageKey) || DEFAULT_CONSENT_STORAGE_KEY;
|
|
@@ -701,6 +727,7 @@ var AnalyticsClient = class {
|
|
|
701
727
|
this.writePersistedConsent(this.configuredStorage, this.fullTrackingConsentGranted);
|
|
702
728
|
}
|
|
703
729
|
this.hydrationPromise = this.hydrateIdentityFromStorage();
|
|
730
|
+
this.enqueueInitialSessionStart();
|
|
704
731
|
this.startAutoFlush();
|
|
705
732
|
}
|
|
706
733
|
/**
|
|
@@ -758,6 +785,32 @@ var AnalyticsClient = class {
|
|
|
758
785
|
...context
|
|
759
786
|
};
|
|
760
787
|
}
|
|
788
|
+
enqueueInitialSessionStart() {
|
|
789
|
+
if (!this.consentGranted) {
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (this.shouldDeferEventsUntilHydrated()) {
|
|
793
|
+
this.deferEventUntilHydrated(() => {
|
|
794
|
+
this.enqueueInitialSessionStart();
|
|
795
|
+
});
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const sessionId = this.getSessionId();
|
|
799
|
+
this.enqueue({
|
|
800
|
+
eventId: randomId(),
|
|
801
|
+
eventName: "session_start",
|
|
802
|
+
ts: nowIso(),
|
|
803
|
+
sessionId,
|
|
804
|
+
anonId: this.anonId,
|
|
805
|
+
userId: this.getEventUserId(),
|
|
806
|
+
properties: this.withRuntimeMetadata({ source: "sdk_mount" }, sessionId),
|
|
807
|
+
platform: this.platform,
|
|
808
|
+
projectSurface: this.projectSurface,
|
|
809
|
+
appVersion: this.appVersion,
|
|
810
|
+
...this.withEventContext(),
|
|
811
|
+
type: "track"
|
|
812
|
+
});
|
|
813
|
+
}
|
|
761
814
|
/**
|
|
762
815
|
* Associates following events with a known user id.
|
|
763
816
|
* Anonymous history remains linked by anonId/sessionId.
|
package/dist/react-native.js
CHANGED
package/package.json
CHANGED