sitepong 0.1.13 → 0.2.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/dist/cdn/sitepong.min.js +6 -6
- package/dist/cdn/sitepong.min.js.map +1 -1
- package/dist/entries/rn.js +453 -7
- package/dist/entries/rn.js.map +1 -1
- package/dist/entries/web.d.mts +1 -1
- package/dist/entries/web.d.ts +1 -1
- package/dist/entries/web.js +634 -133
- package/dist/entries/web.js.map +1 -1
- package/dist/entries/web.mjs +621 -133
- package/dist/entries/web.mjs.map +1 -1
- package/dist/index.d.mts +349 -21
- package/dist/index.d.ts +349 -21
- package/dist/index.js +307 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +294 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +307 -3
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +294 -3
- package/dist/react/index.mjs.map +1 -1
- package/package.json +162 -160
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import 'web-vitals';
|
|
2
|
+
|
|
1
3
|
// src/flags/anonymous-id.ts
|
|
2
4
|
var STORAGE_KEY = "sitepong_anonymous_id";
|
|
3
5
|
function generateUUID() {
|
|
@@ -1903,6 +1905,292 @@ var TracePropagator = class {
|
|
|
1903
1905
|
}
|
|
1904
1906
|
};
|
|
1905
1907
|
|
|
1908
|
+
// src/superlink/client.ts
|
|
1909
|
+
var DEFAULT_SUPERLINK_ENDPOINT = "https://pongl.ink";
|
|
1910
|
+
var SuperLinkClient = class {
|
|
1911
|
+
constructor(config = {}) {
|
|
1912
|
+
this.config = {
|
|
1913
|
+
endpoint: stripTrailingSlash(config.endpoint || DEFAULT_SUPERLINK_ENDPOINT),
|
|
1914
|
+
appId: config.appId,
|
|
1915
|
+
installId: config.installId,
|
|
1916
|
+
debug: config.debug ?? false
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
/** Replace config in place (used by init() so module-level helpers see updates). */
|
|
1920
|
+
configure(config) {
|
|
1921
|
+
if (config.endpoint) this.config.endpoint = stripTrailingSlash(config.endpoint);
|
|
1922
|
+
if (config.appId !== void 0) this.config.appId = config.appId;
|
|
1923
|
+
if (config.installId !== void 0) this.config.installId = config.installId;
|
|
1924
|
+
if (config.debug !== void 0) this.config.debug = config.debug;
|
|
1925
|
+
}
|
|
1926
|
+
log(...args) {
|
|
1927
|
+
if (this.config.debug) console.warn("[SuperLink]", ...args);
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* POST /match — ask the redirect engine to resolve a deferred deep link from
|
|
1931
|
+
* a click token (Android referrer / iOS clipboard) and/or a device
|
|
1932
|
+
* fingerprint. Returns `{ matched: false }` on any error.
|
|
1933
|
+
*/
|
|
1934
|
+
async match(body) {
|
|
1935
|
+
const payload = {
|
|
1936
|
+
...body,
|
|
1937
|
+
install_id: body.install_id ?? this.config.installId
|
|
1938
|
+
};
|
|
1939
|
+
try {
|
|
1940
|
+
const res = await fetch(`${this.config.endpoint}/match`, {
|
|
1941
|
+
method: "POST",
|
|
1942
|
+
headers: { "Content-Type": "application/json" },
|
|
1943
|
+
body: JSON.stringify(payload)
|
|
1944
|
+
});
|
|
1945
|
+
if (!res.ok) {
|
|
1946
|
+
this.log("match failed", res.status);
|
|
1947
|
+
return { matched: false };
|
|
1948
|
+
}
|
|
1949
|
+
const data = await res.json();
|
|
1950
|
+
return data ?? { matched: false };
|
|
1951
|
+
} catch (err) {
|
|
1952
|
+
this.log("match error", err);
|
|
1953
|
+
return { matched: false };
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
/**
|
|
1957
|
+
* POST /events — report a lifecycle event (opened / converted) back to the
|
|
1958
|
+
* redirect engine, which fans out to analytics + webhooks. Best-effort.
|
|
1959
|
+
*/
|
|
1960
|
+
async reportEvent(input) {
|
|
1961
|
+
try {
|
|
1962
|
+
const res = await fetch(`${this.config.endpoint}/events`, {
|
|
1963
|
+
method: "POST",
|
|
1964
|
+
headers: { "Content-Type": "application/json" },
|
|
1965
|
+
body: JSON.stringify({
|
|
1966
|
+
app_id: this.config.appId,
|
|
1967
|
+
install_id: this.config.installId,
|
|
1968
|
+
...input
|
|
1969
|
+
})
|
|
1970
|
+
});
|
|
1971
|
+
if (!res.ok) this.log("event failed", input.type, res.status);
|
|
1972
|
+
return res.ok;
|
|
1973
|
+
} catch (err) {
|
|
1974
|
+
this.log("event error", err);
|
|
1975
|
+
return false;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
function stripTrailingSlash(url) {
|
|
1980
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
1981
|
+
}
|
|
1982
|
+
var superlinkClient = new SuperLinkClient();
|
|
1983
|
+
|
|
1984
|
+
// src/superlink/parse.ts
|
|
1985
|
+
var UTM_KEYS = [
|
|
1986
|
+
["source", "utm_source"],
|
|
1987
|
+
["medium", "utm_medium"],
|
|
1988
|
+
["campaign", "utm_campaign"],
|
|
1989
|
+
["term", "utm_term"],
|
|
1990
|
+
["content", "utm_content"]
|
|
1991
|
+
];
|
|
1992
|
+
function parseUniversalLink(url) {
|
|
1993
|
+
let parsed;
|
|
1994
|
+
try {
|
|
1995
|
+
parsed = new URL(url);
|
|
1996
|
+
} catch {
|
|
1997
|
+
return null;
|
|
1998
|
+
}
|
|
1999
|
+
const params = parsed.searchParams;
|
|
2000
|
+
const utm = {};
|
|
2001
|
+
for (const [key, queryKey] of UTM_KEYS) {
|
|
2002
|
+
const value = params.get(queryKey);
|
|
2003
|
+
if (value) utm[key] = value;
|
|
2004
|
+
}
|
|
2005
|
+
const referral = {};
|
|
2006
|
+
const deep_link_data = {};
|
|
2007
|
+
params.forEach((value, key) => {
|
|
2008
|
+
if (key.startsWith("r_")) {
|
|
2009
|
+
referral[key.slice(2)] = value;
|
|
2010
|
+
} else if (key.startsWith("~")) {
|
|
2011
|
+
deep_link_data[key.slice(1)] = value;
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
const explicitPath = params.get("$deep_link_path") ?? params.get("dlp");
|
|
2015
|
+
const deep_link_path = explicitPath ?? (parsed.pathname && parsed.pathname !== "/" ? parsed.pathname : null);
|
|
2016
|
+
return {
|
|
2017
|
+
deep_link_path,
|
|
2018
|
+
deep_link_data,
|
|
2019
|
+
utm,
|
|
2020
|
+
referral,
|
|
2021
|
+
click_id: params.get("click_id"),
|
|
2022
|
+
match_type: "none",
|
|
2023
|
+
confidence: 1
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
// src/superlink/deferred.ts
|
|
2028
|
+
var handlers = /* @__PURE__ */ new Set();
|
|
2029
|
+
var lastMatched = null;
|
|
2030
|
+
function toDeepLink(res) {
|
|
2031
|
+
return {
|
|
2032
|
+
deep_link_path: res.deep_link_path ?? null,
|
|
2033
|
+
deep_link_data: res.deep_link_data ?? {},
|
|
2034
|
+
utm: res.utm ?? {},
|
|
2035
|
+
referral: res.referral ?? {},
|
|
2036
|
+
click_id: res.click_id ?? null,
|
|
2037
|
+
match_type: res.match_type ?? "fingerprint",
|
|
2038
|
+
confidence: res.confidence ?? (res.match_type && res.match_type !== "none" ? 1 : 0)
|
|
2039
|
+
};
|
|
2040
|
+
}
|
|
2041
|
+
function emitDeferredDeepLink(link) {
|
|
2042
|
+
lastMatched = link;
|
|
2043
|
+
for (const handler of handlers) {
|
|
2044
|
+
try {
|
|
2045
|
+
handler(link);
|
|
2046
|
+
} catch (err) {
|
|
2047
|
+
if (superlinkClient.config.debug) console.warn("[SuperLink] handler threw", err);
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
function onDeferredDeepLink(handler) {
|
|
2052
|
+
handlers.add(handler);
|
|
2053
|
+
if (lastMatched) {
|
|
2054
|
+
try {
|
|
2055
|
+
handler(lastMatched);
|
|
2056
|
+
} catch {
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
return () => {
|
|
2060
|
+
handlers.delete(handler);
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
function getMatchedDeepLink() {
|
|
2064
|
+
return lastMatched;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
// src/superlink/web.ts
|
|
2068
|
+
var STORAGE_KEY3 = "sp_superlink";
|
|
2069
|
+
var captured = null;
|
|
2070
|
+
var didCapture = false;
|
|
2071
|
+
function readStored() {
|
|
2072
|
+
if (typeof sessionStorage === "undefined") return null;
|
|
2073
|
+
try {
|
|
2074
|
+
const raw = sessionStorage.getItem(STORAGE_KEY3);
|
|
2075
|
+
if (!raw) return null;
|
|
2076
|
+
const parsed = JSON.parse(raw);
|
|
2077
|
+
return parsed && typeof parsed === "object" ? parsed : null;
|
|
2078
|
+
} catch {
|
|
2079
|
+
return null;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
function writeStored(link) {
|
|
2083
|
+
if (typeof sessionStorage === "undefined") return;
|
|
2084
|
+
try {
|
|
2085
|
+
sessionStorage.setItem(STORAGE_KEY3, JSON.stringify(link));
|
|
2086
|
+
} catch {
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
function hasPayload(link) {
|
|
2090
|
+
return Boolean(
|
|
2091
|
+
link.deep_link_path || link.click_id || Object.keys(link.deep_link_data).length > 0 || Object.keys(link.referral).length > 0 || Object.keys(link.utm).length > 0
|
|
2092
|
+
);
|
|
2093
|
+
}
|
|
2094
|
+
function writeClipboardToken(clickId) {
|
|
2095
|
+
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
2096
|
+
const url = `${superlinkClient.config.endpoint}/c/${clickId}`;
|
|
2097
|
+
navigator.clipboard.writeText(url).catch(() => {
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
function extractIdentityMetadata(url) {
|
|
2101
|
+
const href = url ?? (typeof window !== "undefined" && window.location ? window.location.href : null);
|
|
2102
|
+
if (!href) return void 0;
|
|
2103
|
+
let loc;
|
|
2104
|
+
try {
|
|
2105
|
+
loc = new URL(href);
|
|
2106
|
+
} catch {
|
|
2107
|
+
return void 0;
|
|
2108
|
+
}
|
|
2109
|
+
const email = loc.searchParams.get("email");
|
|
2110
|
+
const phone = loc.searchParams.get("phone");
|
|
2111
|
+
const userId = loc.searchParams.get("user_id");
|
|
2112
|
+
const id = loc.searchParams.get("id");
|
|
2113
|
+
const customRaw = loc.searchParams.get("custom");
|
|
2114
|
+
const identity = {};
|
|
2115
|
+
if (email) identity.email = email;
|
|
2116
|
+
if (phone) identity.phone = phone;
|
|
2117
|
+
if (userId) identity.user_id = userId;
|
|
2118
|
+
if (id) identity.id = id;
|
|
2119
|
+
if (customRaw) {
|
|
2120
|
+
try {
|
|
2121
|
+
const custom = JSON.parse(decodeURIComponent(customRaw));
|
|
2122
|
+
if (typeof custom === "object" && custom !== null) {
|
|
2123
|
+
identity.custom = custom;
|
|
2124
|
+
}
|
|
2125
|
+
} catch {
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
return Object.keys(identity).length > 0 ? identity : void 0;
|
|
2129
|
+
}
|
|
2130
|
+
function captureWebDeepLink() {
|
|
2131
|
+
if (didCapture) return captured;
|
|
2132
|
+
didCapture = true;
|
|
2133
|
+
const stored = readStored();
|
|
2134
|
+
if (stored) {
|
|
2135
|
+
captured = stored;
|
|
2136
|
+
return captured;
|
|
2137
|
+
}
|
|
2138
|
+
if (typeof window === "undefined" || !window.location) return null;
|
|
2139
|
+
const link = parseUniversalLink(window.location.href);
|
|
2140
|
+
if (link && hasPayload(link)) {
|
|
2141
|
+
captured = link;
|
|
2142
|
+
writeStored(link);
|
|
2143
|
+
void superlinkClient.reportEvent({
|
|
2144
|
+
type: "opened",
|
|
2145
|
+
click_id: link.click_id,
|
|
2146
|
+
platform: "desktop",
|
|
2147
|
+
properties: { surface: "web" }
|
|
2148
|
+
});
|
|
2149
|
+
}
|
|
2150
|
+
return captured;
|
|
2151
|
+
}
|
|
2152
|
+
function getDeepLink() {
|
|
2153
|
+
if (!didCapture) return captureWebDeepLink();
|
|
2154
|
+
return captured;
|
|
2155
|
+
}
|
|
2156
|
+
function webFingerprint() {
|
|
2157
|
+
const fp = { platform: "desktop" };
|
|
2158
|
+
if (typeof navigator !== "undefined") {
|
|
2159
|
+
if (navigator.userAgent) fp.user_agent = navigator.userAgent;
|
|
2160
|
+
const lang = navigator.language || navigator.languages && navigator.languages[0];
|
|
2161
|
+
if (lang) fp.language = lang;
|
|
2162
|
+
}
|
|
2163
|
+
return fp;
|
|
2164
|
+
}
|
|
2165
|
+
async function identify(identity) {
|
|
2166
|
+
if (!identity || Object.keys(identity).length === 0) return null;
|
|
2167
|
+
const res = await superlinkClient.match({
|
|
2168
|
+
identity,
|
|
2169
|
+
fingerprint: webFingerprint()
|
|
2170
|
+
});
|
|
2171
|
+
if (!res.matched) return null;
|
|
2172
|
+
const link = toDeepLink(res);
|
|
2173
|
+
emitDeferredDeepLink(link);
|
|
2174
|
+
return link;
|
|
2175
|
+
}
|
|
2176
|
+
async function completeFromScan(scanned) {
|
|
2177
|
+
if (!scanned) return null;
|
|
2178
|
+
const res = await superlinkClient.match({
|
|
2179
|
+
qr_token: scanned,
|
|
2180
|
+
fingerprint: webFingerprint()
|
|
2181
|
+
});
|
|
2182
|
+
if (!res.matched) return null;
|
|
2183
|
+
const link = toDeepLink(res);
|
|
2184
|
+
emitDeferredDeepLink(link);
|
|
2185
|
+
return link;
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
// src/superlink/index.ts
|
|
2189
|
+
function initSuperLink(config = {}) {
|
|
2190
|
+
superlinkClient.configure(config);
|
|
2191
|
+
captureWebDeepLink();
|
|
2192
|
+
}
|
|
2193
|
+
|
|
1906
2194
|
// src/index.ts
|
|
1907
2195
|
function installFallbackEnvironment() {
|
|
1908
2196
|
if (getEnvironment()) return;
|
|
@@ -2112,6 +2400,10 @@ var SitePongClient = class {
|
|
|
2112
2400
|
webVitals: config.performance.webVitals,
|
|
2113
2401
|
navigationTiming: config.performance.navigationTiming,
|
|
2114
2402
|
resourceTiming: config.performance.resourceTiming,
|
|
2403
|
+
capturePageLoadTimings: config.performance.capturePageLoadTimings,
|
|
2404
|
+
capturePageRenderTimings: config.performance.capturePageRenderTimings,
|
|
2405
|
+
excludedResourceUrls: config.performance.excludedResourceUrls,
|
|
2406
|
+
resourceNameSanitizer: config.performance.resourceNameSanitizer,
|
|
2115
2407
|
sampleRate: config.performance.sampleRate,
|
|
2116
2408
|
flushInterval: config.performance.flushInterval,
|
|
2117
2409
|
performanceEndpoint: config.performance.performanceEndpoint,
|
|
@@ -2820,7 +3112,7 @@ var areFlagsReady = sitepong.areFlagsReady.bind(sitepong);
|
|
|
2820
3112
|
var refreshFlags = sitepong.refreshFlags.bind(sitepong);
|
|
2821
3113
|
var track = sitepong.track.bind(sitepong);
|
|
2822
3114
|
var trackPageView = sitepong.trackPageView.bind(sitepong);
|
|
2823
|
-
var
|
|
3115
|
+
var identify2 = sitepong.identify.bind(sitepong);
|
|
2824
3116
|
var group = sitepong.group.bind(sitepong);
|
|
2825
3117
|
var resetAnalytics = sitepong.resetAnalytics.bind(sitepong);
|
|
2826
3118
|
var getVisitorId = sitepong.getVisitorId.bind(sitepong);
|
|
@@ -2861,6 +3153,6 @@ var onRemoteConfigChange = sitepong.onRemoteConfigChange.bind(sitepong);
|
|
|
2861
3153
|
var registerIdentifyHook = sitepong.registerIdentifyHook.bind(sitepong);
|
|
2862
3154
|
var src_default = sitepong;
|
|
2863
3155
|
|
|
2864
|
-
export { TracePropagator, addBreadcrumb, areFlagsReady, captureError, captureMessage, clearAnonymousId, clearUser, sitepong as client, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, src_default as default, endSpan, endTransaction, extractTrace, flush, flushMetrics, flushProfiles, generateSpanId, generateTraceId, getAllFlags, getAnonymousId, getDbNPlusOnePatterns, getDbQueryCount, getDeviceSignals, getFlag, getFraudCheck, getLatestProfile, getProfiles, getRemoteConfig, getReplaySessionId, getVariant, getVariantPayload2 as getVariantPayload, getVisitorId, getWebVitals, group, identify, init, initRN, isInitialized, isRemoteConfigFeatureEnabled, isReplayRecording, metricDistribution, metricGauge, metricHistogram, metricIncrement, metricStartTimer, metricTime, onRemoteConfigChange, profile, propagateTrace, refreshFlags, registerIdentifyHook, registerWebManagerFactories, resetAnalytics, resetDbQueryCount, setAnonymousId, setContext, setCurrentScreen, setEnvironment, setRNGetCurrentScreen, setTags, setUser, startProfileSpan, startReplay, startSpan, startTransaction, stopReplay, track, trackPageView, waitForFlags };
|
|
3156
|
+
export { DEFAULT_SUPERLINK_ENDPOINT, SuperLinkClient, TracePropagator, addBreadcrumb, areFlagsReady, captureError, captureMessage, captureWebDeepLink, clearAnonymousId, clearUser, sitepong as client, completeFromScan, createTraceContext, cronCheckin, cronStart, cronWrap, dbTrack, dbTrackSync, src_default as default, endSpan, endTransaction, extractIdentityMetadata, extractTrace, flush, flushMetrics, flushProfiles, generateSpanId, generateTraceId, getAllFlags, getAnonymousId, getDbNPlusOnePatterns, getDbQueryCount, getDeepLink, getDeviceSignals, getFlag, getFraudCheck, getLatestProfile, getMatchedDeepLink, getProfiles, getRemoteConfig, getReplaySessionId, getVariant, getVariantPayload2 as getVariantPayload, getVisitorId, getWebVitals, group, identify2 as identify, init, initRN, initSuperLink, isInitialized, isRemoteConfigFeatureEnabled, isReplayRecording, metricDistribution, metricGauge, metricHistogram, metricIncrement, metricStartTimer, metricTime, onDeferredDeepLink, onRemoteConfigChange, parseUniversalLink, profile, propagateTrace, refreshFlags, registerIdentifyHook, registerWebManagerFactories, resetAnalytics, resetDbQueryCount, setAnonymousId, setContext, setCurrentScreen, setEnvironment, setRNGetCurrentScreen, setTags, setUser, startProfileSpan, startReplay, startSpan, startTransaction, stopReplay, superlinkClient, identify as superlinkIdentify, track, trackPageView, waitForFlags, writeClipboardToken };
|
|
2865
3157
|
//# sourceMappingURL=index.mjs.map
|
|
2866
3158
|
//# sourceMappingURL=index.mjs.map
|