@funnelsgrove/analytics 0.25.0 → 0.27.0
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 { analyticsUrlSanitizerSource, sanitizeAnalyticsExport, sanitizeAnalyticsUrl } from './analytics-export.js';
|
|
2
|
-
import { GOOGLE_TAG_CONFIG_IDS, GOOGLE_TAG_ENABLED, GOOGLE_TAG_LEAD_VALUE, GOOGLE_TAG_LEAD_SEND_TO, GOOGLE_TAG_MANAGER_ID, GOOGLE_TAG_PURCHASE_SEND_TO, GOOGLE_TAG_SCRIPT_ID, STRIPE_ACTIVE_MODE, } from './runtime-api.config.js';
|
|
2
|
+
import { FUNNEL_ID, FUNNEL_VERSION_ID, GOOGLE_TAG_CONFIG_IDS, GOOGLE_TAG_ENABLED, GOOGLE_TAG_LEAD_VALUE, GOOGLE_TAG_LEAD_SEND_TO, GOOGLE_TAG_MANAGER_ID, GOOGLE_TAG_PURCHASE_SEND_TO, GOOGLE_TAG_SCRIPT_ID, PROJECT_ID, STRIPE_ACTIVE_MODE, } from './runtime-api.config.js';
|
|
3
3
|
import { isNonLiveAnalyticsRuntime, nonLiveBrowserLocationSource } from './non-live-runtime.js';
|
|
4
4
|
import { buildBrowserPurchaseAnalyticsAttributes, buildPurchaseAnalyticsAttributes, currentBrowserPurchaseUrl, } from './purchase-attributes.service.js';
|
|
5
5
|
const buildGoogleAnalyticsScriptSrc = (googleAnalyticsId) => `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(googleAnalyticsId)}`;
|
|
@@ -104,7 +104,26 @@ export const buildGoogleTagHeadScripts = () => {
|
|
|
104
104
|
},
|
|
105
105
|
];
|
|
106
106
|
};
|
|
107
|
+
// Identifies the funnel without parsing page_location, matching PostHog: the deployment config wins over metadata.
|
|
108
|
+
const buildFunnelContextParameters = (event) => {
|
|
109
|
+
var _a;
|
|
110
|
+
const metadata = (_a = event.metadata) !== null && _a !== void 0 ? _a : {};
|
|
111
|
+
return buildDefinedRecord({
|
|
112
|
+
funnel_id: firstString(FUNNEL_ID, metadata.funnelId, metadata.funnel_id),
|
|
113
|
+
funnel_version_id: firstString(FUNNEL_VERSION_ID, metadata.funnelVersionId, metadata.funnel_version_id),
|
|
114
|
+
project_id: firstString(PROJECT_ID, metadata.projectId, metadata.project_id),
|
|
115
|
+
step_type: firstString(metadata.stepType, metadata.step_type),
|
|
116
|
+
environment: firstString(event.environment, metadata.environment),
|
|
117
|
+
});
|
|
118
|
+
};
|
|
107
119
|
export const mapAnalyticsEventToGoogleTagEvent = (event) => {
|
|
120
|
+
const googleTagEvent = mapAnalyticsEventToGoogleTagEventParameters(event);
|
|
121
|
+
if (!googleTagEvent) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return Object.assign(Object.assign({}, googleTagEvent), { parameters: sanitizeGoogleTagParameters(Object.assign(Object.assign({}, googleTagEvent.parameters), buildFunnelContextParameters(event))) });
|
|
125
|
+
};
|
|
126
|
+
const mapAnalyticsEventToGoogleTagEventParameters = (event) => {
|
|
108
127
|
switch (event.eventType) {
|
|
109
128
|
case 'step_start':
|
|
110
129
|
return {
|
|
@@ -265,6 +265,7 @@ export class PublicAnalyticsSdkService {
|
|
|
265
265
|
const googleTagEvents = mapAnalyticsEventToGoogleTagEvents({
|
|
266
266
|
eventType,
|
|
267
267
|
eventId,
|
|
268
|
+
environment: environment || resolveAnalyticsEnvironment(),
|
|
268
269
|
metadata,
|
|
269
270
|
});
|
|
270
271
|
for (const googleTagEvent of googleTagEvents) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/analytics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"@types/node": "^20",
|
|
46
46
|
"typescript": "^5",
|
|
47
47
|
"vitest": "^3.2.4",
|
|
48
|
-
"@funnelsgrove/runtime": "0.
|
|
48
|
+
"@funnelsgrove/runtime": "0.44.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@funnelsgrove/runtime": "^0.
|
|
51
|
+
"@funnelsgrove/runtime": "^0.44.0"
|
|
52
52
|
}
|
|
53
53
|
}
|