@funnelsgrove/analytics 0.1.4 → 0.1.6
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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/services/google-tag.service.d.ts +36 -0
- package/dist/services/google-tag.service.js +143 -0
- package/dist/services/public-analytics-sdk.service.js +10 -0
- package/dist/services/purchase-attributes.service.d.ts +28 -0
- package/dist/services/purchase-attributes.service.js +101 -0
- package/dist/services/runtime-api.config.d.ts +4 -0
- package/dist/services/runtime-api.config.js +5 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './services/runtime-api.config.js';
|
|
2
2
|
export * from './services/sdk-user-id.storage.js';
|
|
3
3
|
export * from './services/bootstrap-public-analytics-user.js';
|
|
4
|
+
export * from './services/google-tag.service.js';
|
|
4
5
|
export * from './services/meta-pixel.service.js';
|
|
6
|
+
export * from './services/purchase-attributes.service.js';
|
|
5
7
|
export * from './services/public-analytics-sdk.service.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from './services/runtime-api.config.js';
|
|
2
2
|
export * from './services/sdk-user-id.storage.js';
|
|
3
3
|
export * from './services/bootstrap-public-analytics-user.js';
|
|
4
|
+
export * from './services/google-tag.service.js';
|
|
4
5
|
export * from './services/meta-pixel.service.js';
|
|
6
|
+
export * from './services/purchase-attributes.service.js';
|
|
5
7
|
export * from './services/public-analytics-sdk.service.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
type GoogleTagEventName = 'purchase';
|
|
2
|
+
export type GoogleTagHeadScript = {
|
|
3
|
+
id: string;
|
|
4
|
+
src?: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
};
|
|
7
|
+
export type GoogleTagTrackInput = {
|
|
8
|
+
eventName: GoogleTagEventName;
|
|
9
|
+
parameters?: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
export type AnalyticsEventForGoogleTag = {
|
|
12
|
+
eventId?: string | null;
|
|
13
|
+
eventType: string;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
declare global {
|
|
17
|
+
interface Window {
|
|
18
|
+
__funnelsgroveGoogleTagHeadReady?: boolean;
|
|
19
|
+
__funnelsgroveGoogleTagServiceReady?: boolean;
|
|
20
|
+
dataLayer?: unknown[];
|
|
21
|
+
gtag?: (...args: unknown[]) => void;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export declare const buildGoogleTagHeadScripts: () => GoogleTagHeadScript[];
|
|
25
|
+
export declare const mapAnalyticsEventToGoogleTagEvent: (event: AnalyticsEventForGoogleTag) => GoogleTagTrackInput | null;
|
|
26
|
+
export declare class GoogleTagService {
|
|
27
|
+
private initialized;
|
|
28
|
+
initialize(): void;
|
|
29
|
+
track(input: GoogleTagTrackInput): void;
|
|
30
|
+
private isConfigured;
|
|
31
|
+
private ensureInitialized;
|
|
32
|
+
private ensureDataLayer;
|
|
33
|
+
private installScript;
|
|
34
|
+
}
|
|
35
|
+
export declare const googleTagService: GoogleTagService;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { GOOGLE_ANALYTICS_ID, GOOGLE_TAG_ENABLED, GOOGLE_TAG_EVENT_TARGET, GOOGLE_TAG_MANAGER_ID, } from './runtime-api.config.js';
|
|
2
|
+
import { buildBrowserPurchaseAnalyticsAttributes } from './purchase-attributes.service.js';
|
|
3
|
+
const normalizeEventTarget = (value) => {
|
|
4
|
+
return value === 'dataLayer' || value === 'gtag' || value === 'both' ? value : 'both';
|
|
5
|
+
};
|
|
6
|
+
const buildGoogleAnalyticsScriptSrc = (googleAnalyticsId) => `https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(googleAnalyticsId)}`;
|
|
7
|
+
const buildGoogleTagManagerScriptSrc = (googleTagManagerId) => `https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(googleTagManagerId)}`;
|
|
8
|
+
export const buildGoogleTagHeadScripts = () => {
|
|
9
|
+
if (!GOOGLE_TAG_ENABLED || (!GOOGLE_ANALYTICS_ID && !GOOGLE_TAG_MANAGER_ID)) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const bootstrapLines = [
|
|
13
|
+
'window.dataLayer = window.dataLayer || [];',
|
|
14
|
+
'window.gtag = window.gtag || function(){ window.dataLayer.push(arguments); };',
|
|
15
|
+
'window.__funnelsgroveGoogleTagHeadReady = true;',
|
|
16
|
+
...(GOOGLE_ANALYTICS_ID
|
|
17
|
+
? [
|
|
18
|
+
'window.gtag("js", new Date());',
|
|
19
|
+
`window.gtag("config", ${JSON.stringify(GOOGLE_ANALYTICS_ID)});`,
|
|
20
|
+
]
|
|
21
|
+
: []),
|
|
22
|
+
...(GOOGLE_TAG_MANAGER_ID
|
|
23
|
+
? [
|
|
24
|
+
'window.dataLayer.push({"gtm.start": Date.now(), event: "gtm.js"});',
|
|
25
|
+
]
|
|
26
|
+
: []),
|
|
27
|
+
];
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
id: 'funnelsgrove-google-tag-bootstrap',
|
|
31
|
+
content: bootstrapLines.join('\n'),
|
|
32
|
+
},
|
|
33
|
+
...(GOOGLE_ANALYTICS_ID
|
|
34
|
+
? [
|
|
35
|
+
{
|
|
36
|
+
id: 'funnelsgrove-google-analytics',
|
|
37
|
+
src: buildGoogleAnalyticsScriptSrc(GOOGLE_ANALYTICS_ID),
|
|
38
|
+
},
|
|
39
|
+
]
|
|
40
|
+
: []),
|
|
41
|
+
...(GOOGLE_TAG_MANAGER_ID
|
|
42
|
+
? [
|
|
43
|
+
{
|
|
44
|
+
id: 'funnelsgrove-google-tag-manager',
|
|
45
|
+
src: buildGoogleTagManagerScriptSrc(GOOGLE_TAG_MANAGER_ID),
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
: []),
|
|
49
|
+
];
|
|
50
|
+
};
|
|
51
|
+
export const mapAnalyticsEventToGoogleTagEvent = (event) => {
|
|
52
|
+
var _a;
|
|
53
|
+
switch (event.eventType) {
|
|
54
|
+
case 'checkout_completed':
|
|
55
|
+
return {
|
|
56
|
+
eventName: 'purchase',
|
|
57
|
+
parameters: buildBrowserPurchaseAnalyticsAttributes(Object.assign(Object.assign({}, ((_a = event.metadata) !== null && _a !== void 0 ? _a : {})), { transactionId: event.eventId })),
|
|
58
|
+
};
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export class GoogleTagService {
|
|
64
|
+
constructor() {
|
|
65
|
+
this.initialized = false;
|
|
66
|
+
}
|
|
67
|
+
initialize() {
|
|
68
|
+
if (!this.isConfigured()) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.ensureInitialized();
|
|
72
|
+
}
|
|
73
|
+
track(input) {
|
|
74
|
+
var _a, _b, _c;
|
|
75
|
+
if (!this.isConfigured()) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.initialize();
|
|
79
|
+
const parameters = (_a = input.parameters) !== null && _a !== void 0 ? _a : {};
|
|
80
|
+
const eventTarget = normalizeEventTarget(GOOGLE_TAG_EVENT_TARGET);
|
|
81
|
+
if (eventTarget === 'dataLayer' || eventTarget === 'both') {
|
|
82
|
+
(_b = window.dataLayer) === null || _b === void 0 ? void 0 : _b.push(Object.assign({ event: input.eventName }, parameters));
|
|
83
|
+
}
|
|
84
|
+
if (eventTarget === 'gtag' || eventTarget === 'both') {
|
|
85
|
+
(_c = window.gtag) === null || _c === void 0 ? void 0 : _c.call(window, 'event', input.eventName, parameters);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
isConfigured() {
|
|
89
|
+
return Boolean(GOOGLE_TAG_ENABLED &&
|
|
90
|
+
(GOOGLE_ANALYTICS_ID || GOOGLE_TAG_MANAGER_ID) &&
|
|
91
|
+
typeof window !== 'undefined');
|
|
92
|
+
}
|
|
93
|
+
ensureInitialized() {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
if (this.initialized) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
this.initialized = true;
|
|
99
|
+
window.__funnelsgroveGoogleTagServiceReady = true;
|
|
100
|
+
this.ensureDataLayer();
|
|
101
|
+
if (window.__funnelsgroveGoogleTagHeadReady) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (GOOGLE_ANALYTICS_ID) {
|
|
105
|
+
this.installScript(buildGoogleAnalyticsScriptSrc(GOOGLE_ANALYTICS_ID));
|
|
106
|
+
(_a = window.gtag) === null || _a === void 0 ? void 0 : _a.call(window, 'js', new Date());
|
|
107
|
+
(_b = window.gtag) === null || _b === void 0 ? void 0 : _b.call(window, 'config', GOOGLE_ANALYTICS_ID);
|
|
108
|
+
}
|
|
109
|
+
if (GOOGLE_TAG_MANAGER_ID) {
|
|
110
|
+
(_c = window.dataLayer) === null || _c === void 0 ? void 0 : _c.push({
|
|
111
|
+
'gtm.start': Date.now(),
|
|
112
|
+
event: 'gtm.js',
|
|
113
|
+
});
|
|
114
|
+
this.installScript(buildGoogleTagManagerScriptSrc(GOOGLE_TAG_MANAGER_ID));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
ensureDataLayer() {
|
|
118
|
+
window.dataLayer = window.dataLayer || [];
|
|
119
|
+
window.gtag = window.gtag || ((...args) => {
|
|
120
|
+
var _a;
|
|
121
|
+
(_a = window.dataLayer) === null || _a === void 0 ? void 0 : _a.push(args);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
installScript(src) {
|
|
125
|
+
var _a;
|
|
126
|
+
if (typeof document === 'undefined') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if ((_a = document.querySelector) === null || _a === void 0 ? void 0 : _a.call(document, `script[src="${src}"]`)) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const firstScript = document.getElementsByTagName('script')[0];
|
|
133
|
+
const parent = firstScript === null || firstScript === void 0 ? void 0 : firstScript.parentNode;
|
|
134
|
+
if (!parent) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const script = document.createElement('script');
|
|
138
|
+
script.async = true;
|
|
139
|
+
script.src = src;
|
|
140
|
+
parent.insertBefore(script, firstScript);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export const googleTagService = new GoogleTagService();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildMainApiUrl, buildSdkHeaders, FUNNEL_ID, FUNNEL_VERSION_ID, getFunnelSdkPublishableKey, hasPostHogRuntimeConfig, POSTHOG_API_HOST, POSTHOG_PROJECT_API_KEY, PROJECT_ID, } from './runtime-api.config.js';
|
|
2
2
|
import { canUseDom, getOrCreateUserId, persistUserId, readStoredUserId, } from './sdk-user-id.storage.js';
|
|
3
3
|
import { mapAnalyticsEventToMetaPixelEvent, metaPixelService, } from './meta-pixel.service.js';
|
|
4
|
+
import { googleTagService, mapAnalyticsEventToGoogleTagEvent, } from './google-tag.service.js';
|
|
4
5
|
const DEFAULT_OPTIONS = {
|
|
5
6
|
batchSize: 20,
|
|
6
7
|
flushIntervalMs: 1500,
|
|
@@ -85,6 +86,7 @@ export class PublicAnalyticsSdkService {
|
|
|
85
86
|
this.flushTimerId = null;
|
|
86
87
|
this.inFlightFlush = null;
|
|
87
88
|
this.userId = null;
|
|
89
|
+
googleTagService.initialize();
|
|
88
90
|
}
|
|
89
91
|
getCurrentUserId() {
|
|
90
92
|
return this.ensureUserId();
|
|
@@ -176,6 +178,14 @@ export class PublicAnalyticsSdkService {
|
|
|
176
178
|
if (metaPixelEvent) {
|
|
177
179
|
metaPixelService.track(metaPixelEvent);
|
|
178
180
|
}
|
|
181
|
+
const googleTagEvent = mapAnalyticsEventToGoogleTagEvent({
|
|
182
|
+
eventType,
|
|
183
|
+
eventId,
|
|
184
|
+
metadata: asRecord(event.metadata),
|
|
185
|
+
});
|
|
186
|
+
if (googleTagEvent) {
|
|
187
|
+
googleTagService.track(googleTagEvent);
|
|
188
|
+
}
|
|
179
189
|
if (!getFunnelSdkPublishableKey()) {
|
|
180
190
|
return eventId;
|
|
181
191
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type PurchaseAnalyticsAttributesInput = {
|
|
2
|
+
amountCents?: unknown;
|
|
3
|
+
attribution?: unknown;
|
|
4
|
+
couponId?: unknown;
|
|
5
|
+
currency?: unknown;
|
|
6
|
+
environment?: unknown;
|
|
7
|
+
funnelId?: unknown;
|
|
8
|
+
funnelUserDocument?: unknown;
|
|
9
|
+
funnelVersion?: unknown;
|
|
10
|
+
funnelVersionId?: unknown;
|
|
11
|
+
geoCity?: unknown;
|
|
12
|
+
geoCountry?: unknown;
|
|
13
|
+
ipAddress?: unknown;
|
|
14
|
+
planId?: unknown;
|
|
15
|
+
projectId?: unknown;
|
|
16
|
+
providerPlanId?: unknown;
|
|
17
|
+
transactionId?: unknown;
|
|
18
|
+
url?: unknown;
|
|
19
|
+
userAgent?: unknown;
|
|
20
|
+
userId?: unknown;
|
|
21
|
+
value?: unknown;
|
|
22
|
+
};
|
|
23
|
+
export declare const buildPurchaseAnalyticsAttributes: (input?: PurchaseAnalyticsAttributesInput & Record<string, unknown>, options?: {
|
|
24
|
+
includeUrl?: boolean;
|
|
25
|
+
}) => Record<string, unknown>;
|
|
26
|
+
export declare const buildBrowserPurchaseAnalyticsAttributes: (input?: PurchaseAnalyticsAttributesInput & Record<string, unknown>) => Record<string, unknown>;
|
|
27
|
+
export declare const toStripeMetadata: (attributes: Record<string, unknown>) => Record<string, string>;
|
|
28
|
+
export declare const buildStripePurchaseMetadata: (input?: PurchaseAnalyticsAttributesInput & Record<string, unknown>) => Record<string, string>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const STRIPE_METADATA_KEY_MAX_LENGTH = 40;
|
|
2
|
+
const STRIPE_METADATA_VALUE_MAX_LENGTH = 500;
|
|
3
|
+
const isRecord = (value) => {
|
|
4
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
5
|
+
};
|
|
6
|
+
const asRecord = (value) => {
|
|
7
|
+
return isRecord(value) ? value : {};
|
|
8
|
+
};
|
|
9
|
+
const toString = (value) => {
|
|
10
|
+
if (typeof value !== 'string') {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const trimmed = value.trim();
|
|
14
|
+
return trimmed || undefined;
|
|
15
|
+
};
|
|
16
|
+
const toScalar = (value) => {
|
|
17
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
if (typeof value === 'boolean') {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return toString(value);
|
|
24
|
+
};
|
|
25
|
+
const toNumber = (value) => {
|
|
26
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
const normalized = toString(value);
|
|
30
|
+
if (!normalized) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const parsed = Number(normalized);
|
|
34
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
35
|
+
};
|
|
36
|
+
const toCurrency = (value) => {
|
|
37
|
+
var _a;
|
|
38
|
+
return (_a = toString(value)) === null || _a === void 0 ? void 0 : _a.toUpperCase();
|
|
39
|
+
};
|
|
40
|
+
const firstString = (...values) => {
|
|
41
|
+
for (const value of values) {
|
|
42
|
+
const normalized = toString(value);
|
|
43
|
+
if (normalized) {
|
|
44
|
+
return normalized;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
};
|
|
49
|
+
const buildDefinedRecord = (value) => {
|
|
50
|
+
return Object.fromEntries(Object.entries(value).filter(([, candidate]) => candidate !== undefined && candidate !== null && candidate !== ''));
|
|
51
|
+
};
|
|
52
|
+
const normalizeAttributionTouch = (value) => {
|
|
53
|
+
return Object.fromEntries(Object.entries(asRecord(value)).flatMap(([key, candidate]) => {
|
|
54
|
+
const normalizedKey = key.trim();
|
|
55
|
+
const normalizedValue = toScalar(candidate);
|
|
56
|
+
if (!normalizedKey || normalizedValue === undefined) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return [[normalizedKey, normalizedValue]];
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
const currentBrowserUrl = () => {
|
|
63
|
+
var _a;
|
|
64
|
+
if (typeof window === 'undefined') {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return toString((_a = window.location) === null || _a === void 0 ? void 0 : _a.href);
|
|
68
|
+
};
|
|
69
|
+
export const buildPurchaseAnalyticsAttributes = (input = {}, options = {}) => {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const document = asRecord(input.funnelUserDocument);
|
|
72
|
+
const attribution = asRecord((_a = input.attribution) !== null && _a !== void 0 ? _a : document.attribution);
|
|
73
|
+
const attributionContext = asRecord(attribution.context);
|
|
74
|
+
const transactionInfo = asRecord(document.transactionInfo);
|
|
75
|
+
const amountCents = toNumber(input.amountCents);
|
|
76
|
+
const value = (_b = toNumber(input.value)) !== null && _b !== void 0 ? _b : (amountCents === undefined ? undefined : amountCents / 100);
|
|
77
|
+
return buildDefinedRecord(Object.assign(Object.assign({}, normalizeAttributionTouch(attribution.firstTouch)), { currency: toCurrency(input.currency), value, plan_id: firstString(input.planId, input.plan_id), provider_plan_id: firstString(input.providerPlanId, input.provider_plan_id), coupon_id: firstString(input.couponId, input.coupon_id), environment: firstString(input.environment), user_id: firstString(input.userId, input.user_id), project_id: firstString(input.projectId, input.project_id), funnel_id: firstString(input.funnelId, input.funnel_id), funnel_version: firstString(input.funnelVersion, input.funnelVersionId, input.funnel_version), ip_address: firstString(input.ipAddress, input.ip_address, transactionInfo.ipAddress, transactionInfo.ip_address), user_agent: firstString(input.userAgent, input.user_agent, attributionContext.userAgent), geo_city: firstString(input.geoCity, input.geo_city, document.geo_city, document.geoCity, asRecord(document.geo).city, attributionContext.geo_city, attributionContext.geoCity, attributionContext.cityName, attributionContext.city), geo_country: firstString(input.geoCountry, input.geo_country, document.geo_country, document.geoCountry, asRecord(document.geo).country, attributionContext.geo_country, attributionContext.geoCountry, attributionContext.countryName, attributionContext.countryCode, attributionContext.country), transaction_id: firstString(input.transactionId, input.transaction_id), url: options.includeUrl ? firstString(input.url, currentBrowserUrl()) : undefined }));
|
|
78
|
+
};
|
|
79
|
+
export const buildBrowserPurchaseAnalyticsAttributes = (input = {}) => {
|
|
80
|
+
return buildPurchaseAnalyticsAttributes(input, { includeUrl: true });
|
|
81
|
+
};
|
|
82
|
+
const toStripeMetadataValue = (value) => {
|
|
83
|
+
const scalar = toScalar(value);
|
|
84
|
+
if (scalar === undefined) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return String(scalar).slice(0, STRIPE_METADATA_VALUE_MAX_LENGTH);
|
|
88
|
+
};
|
|
89
|
+
export const toStripeMetadata = (attributes) => {
|
|
90
|
+
return Object.fromEntries(Object.entries(attributes).flatMap(([key, value]) => {
|
|
91
|
+
const normalizedKey = key.trim().slice(0, STRIPE_METADATA_KEY_MAX_LENGTH);
|
|
92
|
+
const normalizedValue = toStripeMetadataValue(value);
|
|
93
|
+
if (!normalizedKey || normalizedValue === undefined) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
return [[normalizedKey, normalizedValue]];
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
export const buildStripePurchaseMetadata = (input = {}) => {
|
|
100
|
+
return toStripeMetadata(buildPurchaseAnalyticsAttributes(input, { includeUrl: false }));
|
|
101
|
+
};
|
|
@@ -7,6 +7,10 @@ export declare const POSTHOG_API_HOST = "https://us.i.posthog.com";
|
|
|
7
7
|
export declare const POSTHOG_PROJECT_API_KEY: string;
|
|
8
8
|
export declare const META_PIXEL_ENABLED: boolean;
|
|
9
9
|
export declare const META_PIXEL_ID: string;
|
|
10
|
+
export declare const GOOGLE_TAG_ENABLED: boolean;
|
|
11
|
+
export declare const GOOGLE_ANALYTICS_ID: string;
|
|
12
|
+
export declare const GOOGLE_TAG_MANAGER_ID: string;
|
|
13
|
+
export declare const GOOGLE_TAG_EVENT_TARGET: string;
|
|
10
14
|
export declare const hasRealFunnelSdkPublishableKey: (value?: string) => boolean;
|
|
11
15
|
export declare const getFunnelSdkPublishableKey: () => string | null;
|
|
12
16
|
export declare const hasPostHogRuntimeConfig: () => boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
2
2
|
import { resolveRuntimeSdkApiBaseUrl, runtimeEnvConfig, } from '@funnelsgrove/runtime/config/env.config';
|
|
3
3
|
const DEFAULT_API_BASE_URL = 'https://sdk-api.funnelsgrove.com';
|
|
4
4
|
const DEFAULT_FUNNEL_SDK_PUBLISHABLE_KEY = 'pk_test_app_deals_seed_public';
|
|
@@ -28,6 +28,10 @@ export const POSTHOG_API_HOST = 'https://us.i.posthog.com';
|
|
|
28
28
|
export const POSTHOG_PROJECT_API_KEY = ((_f = runtimeEnvConfig.posthogProjectApiKey) !== null && _f !== void 0 ? _f : '').trim();
|
|
29
29
|
export const META_PIXEL_ENABLED = ((_g = runtimeEnvConfig.metaPixelEnabled) !== null && _g !== void 0 ? _g : '').trim() === 'true';
|
|
30
30
|
export const META_PIXEL_ID = ((_h = runtimeEnvConfig.metaPixelId) !== null && _h !== void 0 ? _h : '').trim();
|
|
31
|
+
export const GOOGLE_TAG_ENABLED = ((_j = runtimeEnvConfig.googleTagEnabled) !== null && _j !== void 0 ? _j : '').trim() === 'true';
|
|
32
|
+
export const GOOGLE_ANALYTICS_ID = ((_k = runtimeEnvConfig.googleAnalyticsId) !== null && _k !== void 0 ? _k : '').trim();
|
|
33
|
+
export const GOOGLE_TAG_MANAGER_ID = ((_l = runtimeEnvConfig.googleTagManagerId) !== null && _l !== void 0 ? _l : '').trim();
|
|
34
|
+
export const GOOGLE_TAG_EVENT_TARGET = ((_m = runtimeEnvConfig.googleTagEventTarget) !== null && _m !== void 0 ? _m : '').trim();
|
|
31
35
|
export const hasRealFunnelSdkPublishableKey = (value = FUNNEL_SDK_PUBLISHABLE_KEY) => {
|
|
32
36
|
const normalized = value.trim();
|
|
33
37
|
return Boolean(normalized) && normalized !== DEFAULT_FUNNEL_SDK_PUBLISHABLE_KEY;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelsgrove/analytics",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test:run": "vitest run --passWithNoTests"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@funnelsgrove/runtime": "0.1.
|
|
29
|
+
"@funnelsgrove/runtime": "0.1.14"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^20",
|