@reservamos/browser-analytics 1.1.2 → 1.1.3
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/CHANGELOG.md +4 -0
- package/README.md +35 -0
- package/dist/browser-analytics.cjs +3 -3
- package/dist/browser-analytics.cjs.map +1 -1
- package/dist/browser-analytics.d.ts +7 -0
- package/dist/browser-analytics.esm.js +28 -6
- package/dist/browser-analytics.esm.js.map +1 -1
- package/dist/browser-analytics.iife.js +3 -3
- package/dist/browser-analytics.iife.js.map +1 -1
- package/package.json +1 -1
- package/src/events/identify/identify.test.ts +102 -0
- package/src/events/identify/identify.ts +3 -0
- package/src/init.ts +4 -0
- package/src/services/config.test.ts +39 -0
- package/src/services/config.ts +16 -1
- package/src/services/validator/validator.test.ts +34 -1
- package/src/services/validator/validator.ts +5 -0
|
@@ -1243,6 +1243,11 @@ declare const InitConfigSchema: z.ZodObject<{
|
|
|
1243
1243
|
* Optional proxy URL for identify requests.
|
|
1244
1244
|
*/
|
|
1245
1245
|
identifyProxyUrl: z.ZodOptional<z.ZodString>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Optional client platform identifier sent as the `x-app-name` header on Datalake
|
|
1248
|
+
* identify and anonymous-profile requests.
|
|
1249
|
+
*/
|
|
1250
|
+
appName: z.ZodOptional<z.ZodString>;
|
|
1246
1251
|
}, "strip", z.ZodTypeAny, {
|
|
1247
1252
|
mixpanelToken: string;
|
|
1248
1253
|
identificationKey: string;
|
|
@@ -1250,6 +1255,7 @@ declare const InitConfigSchema: z.ZodObject<{
|
|
|
1250
1255
|
isSandbox?: boolean | undefined;
|
|
1251
1256
|
mixpanelProxyUrl?: string | undefined;
|
|
1252
1257
|
identifyProxyUrl?: string | undefined;
|
|
1258
|
+
appName?: string | undefined;
|
|
1253
1259
|
}, {
|
|
1254
1260
|
mixpanelToken: string;
|
|
1255
1261
|
identificationKey: string;
|
|
@@ -1257,6 +1263,7 @@ declare const InitConfigSchema: z.ZodObject<{
|
|
|
1257
1263
|
isSandbox?: boolean | undefined;
|
|
1258
1264
|
mixpanelProxyUrl?: string | undefined;
|
|
1259
1265
|
identifyProxyUrl?: string | undefined;
|
|
1266
|
+
appName?: string | undefined;
|
|
1260
1267
|
}>;
|
|
1261
1268
|
/**
|
|
1262
1269
|
* Configuration object for initializing the tracking library.
|
|
@@ -4963,6 +4963,7 @@ const f = {
|
|
|
4963
4963
|
profiles: s
|
|
4964
4964
|
};
|
|
4965
4965
|
let environment;
|
|
4966
|
+
let appName;
|
|
4966
4967
|
const origin = window.location.origin;
|
|
4967
4968
|
const coreAPIConfig = {
|
|
4968
4969
|
sandbox: {
|
|
@@ -4983,16 +4984,27 @@ const coreAPIConfig = {
|
|
|
4983
4984
|
function setEnvironment(env) {
|
|
4984
4985
|
environment = env;
|
|
4985
4986
|
}
|
|
4987
|
+
function setAppName(name) {
|
|
4988
|
+
appName = name;
|
|
4989
|
+
}
|
|
4986
4990
|
function getCoreAPIConfig() {
|
|
4987
4991
|
if (!environment) {
|
|
4988
4992
|
throw new Error(
|
|
4989
4993
|
"Unable to get core API config, environment not set. Use configService.setEnvironment(environment) to set the environment."
|
|
4990
4994
|
);
|
|
4991
4995
|
}
|
|
4992
|
-
|
|
4996
|
+
const config = coreAPIConfig[environment];
|
|
4997
|
+
return {
|
|
4998
|
+
...config,
|
|
4999
|
+
defaultHeaders: {
|
|
5000
|
+
...config.defaultHeaders,
|
|
5001
|
+
...appName ? { "x-app-name": appName } : {}
|
|
5002
|
+
}
|
|
5003
|
+
};
|
|
4993
5004
|
}
|
|
4994
5005
|
const configService = {
|
|
4995
5006
|
setEnvironment,
|
|
5007
|
+
setAppName,
|
|
4996
5008
|
getCoreAPIConfig
|
|
4997
5009
|
};
|
|
4998
5010
|
var NodeType;
|
|
@@ -13395,7 +13407,7 @@ function loadNoop(_src, onload) {
|
|
|
13395
13407
|
onload();
|
|
13396
13408
|
}
|
|
13397
13409
|
var mixpanel = init_as_module(loadNoop);
|
|
13398
|
-
const version = "1.1.
|
|
13410
|
+
const version = "1.1.3";
|
|
13399
13411
|
const MIXPANEL_DISTINCT_ID_CACHE_KEY = "mp_distinct_id";
|
|
13400
13412
|
const EVENT_SOURCE_SUPER_PROPERTY = {
|
|
13401
13413
|
"Event Source": "sdk"
|
|
@@ -13738,7 +13750,12 @@ const InitConfigSchema = z.object({
|
|
|
13738
13750
|
/**
|
|
13739
13751
|
* Optional proxy URL for identify requests.
|
|
13740
13752
|
*/
|
|
13741
|
-
identifyProxyUrl: z.string().optional()
|
|
13753
|
+
identifyProxyUrl: z.string().optional(),
|
|
13754
|
+
/**
|
|
13755
|
+
* Optional client platform identifier sent as the `x-app-name` header on Datalake
|
|
13756
|
+
* identify and anonymous-profile requests.
|
|
13757
|
+
*/
|
|
13758
|
+
appName: z.string().min(1, "App name cannot be empty").optional()
|
|
13742
13759
|
});
|
|
13743
13760
|
const SchemaErrorFormatter = (error) => {
|
|
13744
13761
|
return error.issues.map((issue) => {
|
|
@@ -13829,7 +13846,8 @@ async function init$1(config) {
|
|
|
13829
13846
|
identificationKey,
|
|
13830
13847
|
isSandbox = false,
|
|
13831
13848
|
mixpanelProxyUrl,
|
|
13832
|
-
identifyProxyUrl
|
|
13849
|
+
identifyProxyUrl,
|
|
13850
|
+
appName: appName2
|
|
13833
13851
|
} = config;
|
|
13834
13852
|
await mixpanelService.init(mixpanelToken, debug, mixpanelProxyUrl);
|
|
13835
13853
|
try {
|
|
@@ -13842,6 +13860,9 @@ async function init$1(config) {
|
|
|
13842
13860
|
}
|
|
13843
13861
|
await geolocationService.init();
|
|
13844
13862
|
configService.setEnvironment(isSandbox ? "sandbox" : "prod");
|
|
13863
|
+
if (appName2) {
|
|
13864
|
+
configService.setAppName(appName2);
|
|
13865
|
+
}
|
|
13845
13866
|
f.setConfig(configService.getCoreAPIConfig());
|
|
13846
13867
|
onLoaded();
|
|
13847
13868
|
}
|
|
@@ -14263,7 +14284,7 @@ function mapProperties(properties) {
|
|
|
14263
14284
|
return { ...parsedProperties, ...additionalProperties };
|
|
14264
14285
|
}
|
|
14265
14286
|
const identifyWithLocation = async (userId, properties) => {
|
|
14266
|
-
var _a, _b;
|
|
14287
|
+
var _a, _b, _c;
|
|
14267
14288
|
try {
|
|
14268
14289
|
const coordinates = geolocationService.getCoordinates();
|
|
14269
14290
|
if (!coordinates) {
|
|
@@ -14283,7 +14304,8 @@ const identifyWithLocation = async (userId, properties) => {
|
|
|
14283
14304
|
headers: {
|
|
14284
14305
|
"Content-Type": "application/json",
|
|
14285
14306
|
"Authorization": ((_a = coreApiConfig.defaultHeaders) == null ? void 0 : _a.Authorization) || "",
|
|
14286
|
-
"Origin": ((_b = coreApiConfig.defaultHeaders) == null ? void 0 : _b.Origin) || ""
|
|
14307
|
+
"Origin": ((_b = coreApiConfig.defaultHeaders) == null ? void 0 : _b.Origin) || "",
|
|
14308
|
+
...((_c = coreApiConfig.defaultHeaders) == null ? void 0 : _c["x-app-name"]) ? { "x-app-name": coreApiConfig.defaultHeaders["x-app-name"] } : {}
|
|
14287
14309
|
},
|
|
14288
14310
|
body: JSON.stringify({
|
|
14289
14311
|
profile_params: {
|