@funnelsgrove/analytics 0.1.106 → 0.1.111
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PostHogDelivery } from './posthog-delivery.js';
|
|
2
|
-
import { FUNNEL_ANALYTICS_EVENT_CONTRACTS, funnelSdkService, FUNNEL_STEP_CONTRACTS, } from '@funnelsgrove/runtime';
|
|
2
|
+
import { FUNNEL_ANALYTICS_EVENT_CONTRACTS, funnelSdkService, getPaywallUser, FUNNEL_STEP_CONTRACTS, } from '@funnelsgrove/runtime';
|
|
3
3
|
import { APP_DEALS_API_BASE_URL, FUNNEL_ID, FUNNEL_VERSION_ID, getFunnelSdkPublishableKey, PROJECT_ID, } from './runtime-api.config.js';
|
|
4
4
|
import { canUseDom, getOrCreateUserId, persistUserId, readStoredUserId, } from './sdk-user-id.storage.js';
|
|
5
5
|
import { mapAnalyticsEventToMetaPixelEvent, metaPixelService, } from './meta-pixel.service.js';
|
|
@@ -186,6 +186,9 @@ export class PublicAnalyticsSdkService {
|
|
|
186
186
|
}
|
|
187
187
|
async identify(input = {}) {
|
|
188
188
|
var _a;
|
|
189
|
+
const bound = getPaywallUser();
|
|
190
|
+
if (bound)
|
|
191
|
+
return bound.user_id;
|
|
189
192
|
const userId = await this.resolveBootstrapUserId(input.user_id);
|
|
190
193
|
const publishableKey = getFunnelSdkPublishableKey();
|
|
191
194
|
if (!publishableKey) {
|
|
@@ -518,6 +521,9 @@ export class PublicAnalyticsSdkService {
|
|
|
518
521
|
return this.delivery.flush();
|
|
519
522
|
}
|
|
520
523
|
ensureUserId() {
|
|
524
|
+
const bound = getPaywallUser();
|
|
525
|
+
if (bound)
|
|
526
|
+
return bound.user_id;
|
|
521
527
|
if (this.userId) {
|
|
522
528
|
return this.userId;
|
|
523
529
|
}
|
|
@@ -545,14 +551,14 @@ export class PublicAnalyticsSdkService {
|
|
|
545
551
|
return persistUserId(validatedUserId || fallbackUserId, FUNNEL_ID);
|
|
546
552
|
}
|
|
547
553
|
toPostHogEvent(event) {
|
|
548
|
-
var _a, _b, _c;
|
|
554
|
+
var _a, _b, _c, _d;
|
|
549
555
|
const analyticsEnvironment = resolveAnalyticsEnvironment();
|
|
550
556
|
const eventEnvironment = event.environment || analyticsEnvironment;
|
|
551
557
|
return {
|
|
552
558
|
event: toPostHogEventName(event.eventType),
|
|
553
|
-
properties: buildDefinedRecord(Object.assign(Object.assign({ distinct_id: event.userId || this.ensureUserId(), $groups: {
|
|
559
|
+
properties: buildDefinedRecord(Object.assign(Object.assign({ distinct_id: ((_a = getPaywallUser()) === null || _a === void 0 ? void 0 : _a.user_id) || event.userId || this.ensureUserId(), $groups: {
|
|
554
560
|
project: PROJECT_ID,
|
|
555
|
-
}, $insert_id: event.eventId, project_id: PROJECT_ID, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, environment: eventEnvironment, test: eventEnvironment === 'test' || undefined, step_id: event.stepId || undefined, step_name: event.stepName || undefined, step_type: event.stepType || undefined, started_at: event.startedAt || undefined, ended_at: event.endedAt || undefined, duration_ms: (
|
|
561
|
+
}, $insert_id: event.eventId, project_id: PROJECT_ID, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, environment: eventEnvironment, test: eventEnvironment === 'test' || undefined, step_id: event.stepId || undefined, step_name: event.stepName || undefined, step_type: event.stepType || undefined, started_at: event.startedAt || undefined, ended_at: event.endedAt || undefined, duration_ms: (_b = event.durationMs) !== null && _b !== void 0 ? _b : undefined, exit_reason: event.exitReason || undefined, step_contract_version: (_c = event.stepContractVersion) !== null && _c !== void 0 ? _c : undefined, engagement_threshold_ms: (_d = event.engagementThresholdMs) !== null && _d !== void 0 ? _d : undefined, user_agent: currentBrowserUserAgent(), event_source: 'client' }, buildFeatureFlagProperties(event.featureFlags)), { selected: Object.keys(event.selected).length > 0 ? event.selected : undefined, payload: Object.keys(event.payload).length > 0 ? event.payload : undefined, context: Object.keys(event.context).length > 0 ? event.context : undefined, metadata: Object.keys(event.metadata).length > 0 ? event.metadata : undefined })),
|
|
556
562
|
timestamp: event.occurredAt,
|
|
557
563
|
};
|
|
558
564
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/analytics",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.111",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test:run": "vitest run --passWithNoTests"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@funnelsgrove/runtime": "0.
|
|
39
|
+
"@funnelsgrove/runtime": "0.19.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^20",
|