@m13v/seo-components 0.14.0 → 0.15.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.
- package/package.json +1 -1
- package/src/components/SeoComponentsStyles.tsx +2 -1
- package/src/index.ts +4 -0
- package/src/lib/track.ts +53 -0
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@ const cssPath = path.join(here, "..", "..", "dist", "styles.css");
|
|
|
8
8
|
let cachedCss: string | null = null;
|
|
9
9
|
function loadCss(): string {
|
|
10
10
|
if (cachedCss !== null) return cachedCss;
|
|
11
|
-
|
|
11
|
+
const raw = fs.readFileSync(cssPath, "utf8");
|
|
12
|
+
cachedCss = `@layer seo-components { ${raw} }`;
|
|
12
13
|
return cachedCss;
|
|
13
14
|
}
|
|
14
15
|
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,10 @@ export { MetricsRow } from "./components/MetricsRow";
|
|
|
37
37
|
export { InlineCta } from "./components/InlineCta";
|
|
38
38
|
export { StickyBottomCta } from "./components/StickyBottomCta";
|
|
39
39
|
|
|
40
|
+
// Canonical analytics helpers (schedule_click, etc.)
|
|
41
|
+
export { trackScheduleClick } from "./lib/track";
|
|
42
|
+
export type { ScheduleClickProps } from "./lib/track";
|
|
43
|
+
|
|
40
44
|
// Proof / social proof
|
|
41
45
|
export { ProofBanner } from "./components/ProofBanner";
|
|
42
46
|
|
package/src/lib/track.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Canonical analytics helpers. Use these instead of calling
|
|
2
|
+
// `posthog.capture("cta_click", ...)` directly so every consumer site
|
|
3
|
+
// fires the same event names with the same property shape.
|
|
4
|
+
//
|
|
5
|
+
// All helpers are no-ops on the server and when PostHog is not loaded.
|
|
6
|
+
|
|
7
|
+
type PostHogLike = {
|
|
8
|
+
capture: (event: string, properties?: Record<string, unknown>) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
function ph(): PostHogLike | undefined {
|
|
12
|
+
if (typeof window === "undefined") return undefined;
|
|
13
|
+
const w = window as unknown as { posthog?: PostHogLike };
|
|
14
|
+
return w.posthog;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ScheduleClickProps {
|
|
18
|
+
/** Absolute URL the click sends the user to (e.g. https://cal.com/team/mediar/demo). */
|
|
19
|
+
destination: string;
|
|
20
|
+
/** Short slug identifying the site (e.g. "mediar", "fazm", "cyrano"). Optional: PostHog $host already identifies the site. */
|
|
21
|
+
site?: string;
|
|
22
|
+
/** Section of the page the CTA lives in (e.g. "hero", "footer", "guide-navbar"). */
|
|
23
|
+
section?: string;
|
|
24
|
+
/** Visible button/link text. */
|
|
25
|
+
text?: string;
|
|
26
|
+
/** Name of the rendering component (e.g. "CTAButton", "LeadCaptureModal"). */
|
|
27
|
+
component?: string;
|
|
28
|
+
/** Free-form extra properties — merged last, cannot override reserved keys above. */
|
|
29
|
+
extra?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Fire the canonical `schedule_click` PostHog event. Use for every CTA that
|
|
34
|
+
* sends the user to a booking/scheduling tool (Cal.com, Calendly, meetings.hubspot.com).
|
|
35
|
+
*
|
|
36
|
+
* The dashboard at social-autoposter/scripts/project_stats_json.py counts this
|
|
37
|
+
* event per `$host` to produce the "Schedule Clicks" column in the Project
|
|
38
|
+
* Funnel Stats table.
|
|
39
|
+
*/
|
|
40
|
+
export function trackScheduleClick(props: ScheduleClickProps): void {
|
|
41
|
+
const posthog = ph();
|
|
42
|
+
if (!posthog) return;
|
|
43
|
+
const { destination, site, section, text, component, extra } = props;
|
|
44
|
+
posthog.capture("schedule_click", {
|
|
45
|
+
...(extra || {}),
|
|
46
|
+
destination,
|
|
47
|
+
site,
|
|
48
|
+
section,
|
|
49
|
+
text,
|
|
50
|
+
component,
|
|
51
|
+
page: typeof window !== "undefined" ? window.location.pathname : undefined,
|
|
52
|
+
});
|
|
53
|
+
}
|