saasco-sdk 0.1.30 → 0.1.31
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/index.cjs.js +70 -4
- package/index.esm.js +70 -4
- package/package.json +1 -1
- package/src/lib/tracking/types.d.ts +6 -0
package/index.cjs.js
CHANGED
|
@@ -7,7 +7,7 @@ var uuid = require('@lukeed/uuid');
|
|
|
7
7
|
var psl = require('psl');
|
|
8
8
|
var zod = require('zod');
|
|
9
9
|
|
|
10
|
-
var version = "0.1.
|
|
10
|
+
var version = "0.1.31";
|
|
11
11
|
|
|
12
12
|
const timezones = {
|
|
13
13
|
'Asia/Barnaul': 'RU',
|
|
@@ -466,6 +466,68 @@ function getBrowserContext() {
|
|
|
466
466
|
const $utmCampaignId = params.get('utm_campaign_id');
|
|
467
467
|
const $utmCreativeFormat = params.get('utm_creative_format');
|
|
468
468
|
const $utmMarketingTactic = params.get('utm_marketing_tactic');
|
|
469
|
+
let $utmAdSource = params.get('utm_ad_source');
|
|
470
|
+
let $utmAdId = params.get('utm_ad_id');
|
|
471
|
+
// If the adId is not set directly attempt to get it from each ad network
|
|
472
|
+
// Also set the ad source to the ad network if it's not set
|
|
473
|
+
if (!$utmAdId) {
|
|
474
|
+
const fbAdId = params.get('fbadid');
|
|
475
|
+
if (fbAdId) {
|
|
476
|
+
$utmAdId = fbAdId;
|
|
477
|
+
if (!$utmAdSource) {
|
|
478
|
+
$utmAdSource = 'facebook';
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const googleAdId = params.get('gadid');
|
|
482
|
+
if (googleAdId) {
|
|
483
|
+
$utmAdId = googleAdId;
|
|
484
|
+
if (!$utmAdSource) {
|
|
485
|
+
$utmAdSource = 'google';
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
const xAdId = params.get('xadid');
|
|
489
|
+
if (xAdId) {
|
|
490
|
+
$utmAdId = xAdId;
|
|
491
|
+
if (!$utmAdSource) {
|
|
492
|
+
$utmAdSource = 'x';
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
const pinterestAdId = params.get('padid');
|
|
496
|
+
if (pinterestAdId) {
|
|
497
|
+
$utmAdId = pinterestAdId;
|
|
498
|
+
if (!$utmAdSource) {
|
|
499
|
+
$utmAdSource = 'pinterest';
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const tiktokAdId = params.get('ttadid');
|
|
503
|
+
if (tiktokAdId) {
|
|
504
|
+
$utmAdId = tiktokAdId;
|
|
505
|
+
if (!$utmAdSource) {
|
|
506
|
+
$utmAdSource = 'tiktok';
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const snapchatAdId = params.get('scadid');
|
|
510
|
+
if (snapchatAdId) {
|
|
511
|
+
$utmAdId = snapchatAdId;
|
|
512
|
+
if (!$utmAdSource) {
|
|
513
|
+
$utmAdSource = 'snapchat';
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
const redditAdId = params.get('radid');
|
|
517
|
+
if (redditAdId) {
|
|
518
|
+
$utmAdId = redditAdId;
|
|
519
|
+
if (!$utmAdSource) {
|
|
520
|
+
$utmAdSource = 'reddit';
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const linkedinAdId = params.get('liadid');
|
|
524
|
+
if (linkedinAdId) {
|
|
525
|
+
$utmAdId = linkedinAdId;
|
|
526
|
+
if (!$utmAdSource) {
|
|
527
|
+
$utmAdSource = 'linkedin';
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
469
531
|
return {
|
|
470
532
|
$locale,
|
|
471
533
|
$location,
|
|
@@ -486,7 +548,9 @@ function getBrowserContext() {
|
|
|
486
548
|
$utmSourcePlatform,
|
|
487
549
|
$utmCampaignId,
|
|
488
550
|
$utmCreativeFormat,
|
|
489
|
-
$utmMarketingTactic
|
|
551
|
+
$utmMarketingTactic,
|
|
552
|
+
$utmAdSource,
|
|
553
|
+
$utmAdId
|
|
490
554
|
};
|
|
491
555
|
}
|
|
492
556
|
|
|
@@ -653,7 +717,7 @@ function setSuperContext(superContext) {
|
|
|
653
717
|
}
|
|
654
718
|
function updateSuperContext(browserContext) {
|
|
655
719
|
const existingSuperContext = getSuperContext();
|
|
656
|
-
const defaultSuperContextKeys = ['$utmSource', '$utmMedium', '$utmCampaign', '$utmTerm', '$utmContent', '$utmId', '$utmSourcePlatform', '$utmCampaignId', '$utmCreativeFormat', '$utmMarketingTactic'];
|
|
720
|
+
const defaultSuperContextKeys = ['$utmSource', '$utmMedium', '$utmCampaign', '$utmTerm', '$utmContent', '$utmId', '$utmSourcePlatform', '$utmCampaignId', '$utmCreativeFormat', '$utmMarketingTactic', '$utmAdSource', '$utmAdId'];
|
|
657
721
|
const superContext = defaultSuperContextKeys.reduce((acc, key) => {
|
|
658
722
|
const value = Object.assign({}, browserContext)[key];
|
|
659
723
|
if (value) acc[key] = value;
|
|
@@ -985,7 +1049,9 @@ const browserContextSchema = zod.z.object({
|
|
|
985
1049
|
$utmSourcePlatform: zod.z.string().nullable(),
|
|
986
1050
|
$utmCampaignId: zod.z.string().nullable(),
|
|
987
1051
|
$utmCreativeFormat: zod.z.string().nullable(),
|
|
988
|
-
$utmMarketingTactic: zod.z.string().nullable()
|
|
1052
|
+
$utmMarketingTactic: zod.z.string().nullable(),
|
|
1053
|
+
$utmAdSource: zod.z.string().nullable(),
|
|
1054
|
+
$utmAdId: zod.z.string().nullable()
|
|
989
1055
|
});
|
|
990
1056
|
|
|
991
1057
|
exports.Saasco = Saasco;
|
package/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import { v4 } from '@lukeed/uuid';
|
|
|
3
3
|
import { isValid, parse } from 'psl';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
var version = "0.1.
|
|
6
|
+
var version = "0.1.31";
|
|
7
7
|
|
|
8
8
|
const timezones = {
|
|
9
9
|
'Asia/Barnaul': 'RU',
|
|
@@ -462,6 +462,68 @@ function getBrowserContext() {
|
|
|
462
462
|
const $utmCampaignId = params.get('utm_campaign_id');
|
|
463
463
|
const $utmCreativeFormat = params.get('utm_creative_format');
|
|
464
464
|
const $utmMarketingTactic = params.get('utm_marketing_tactic');
|
|
465
|
+
let $utmAdSource = params.get('utm_ad_source');
|
|
466
|
+
let $utmAdId = params.get('utm_ad_id');
|
|
467
|
+
// If the adId is not set directly attempt to get it from each ad network
|
|
468
|
+
// Also set the ad source to the ad network if it's not set
|
|
469
|
+
if (!$utmAdId) {
|
|
470
|
+
const fbAdId = params.get('fbadid');
|
|
471
|
+
if (fbAdId) {
|
|
472
|
+
$utmAdId = fbAdId;
|
|
473
|
+
if (!$utmAdSource) {
|
|
474
|
+
$utmAdSource = 'facebook';
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const googleAdId = params.get('gadid');
|
|
478
|
+
if (googleAdId) {
|
|
479
|
+
$utmAdId = googleAdId;
|
|
480
|
+
if (!$utmAdSource) {
|
|
481
|
+
$utmAdSource = 'google';
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
const xAdId = params.get('xadid');
|
|
485
|
+
if (xAdId) {
|
|
486
|
+
$utmAdId = xAdId;
|
|
487
|
+
if (!$utmAdSource) {
|
|
488
|
+
$utmAdSource = 'x';
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
const pinterestAdId = params.get('padid');
|
|
492
|
+
if (pinterestAdId) {
|
|
493
|
+
$utmAdId = pinterestAdId;
|
|
494
|
+
if (!$utmAdSource) {
|
|
495
|
+
$utmAdSource = 'pinterest';
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
const tiktokAdId = params.get('ttadid');
|
|
499
|
+
if (tiktokAdId) {
|
|
500
|
+
$utmAdId = tiktokAdId;
|
|
501
|
+
if (!$utmAdSource) {
|
|
502
|
+
$utmAdSource = 'tiktok';
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
const snapchatAdId = params.get('scadid');
|
|
506
|
+
if (snapchatAdId) {
|
|
507
|
+
$utmAdId = snapchatAdId;
|
|
508
|
+
if (!$utmAdSource) {
|
|
509
|
+
$utmAdSource = 'snapchat';
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const redditAdId = params.get('radid');
|
|
513
|
+
if (redditAdId) {
|
|
514
|
+
$utmAdId = redditAdId;
|
|
515
|
+
if (!$utmAdSource) {
|
|
516
|
+
$utmAdSource = 'reddit';
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const linkedinAdId = params.get('liadid');
|
|
520
|
+
if (linkedinAdId) {
|
|
521
|
+
$utmAdId = linkedinAdId;
|
|
522
|
+
if (!$utmAdSource) {
|
|
523
|
+
$utmAdSource = 'linkedin';
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
465
527
|
return {
|
|
466
528
|
$locale,
|
|
467
529
|
$location,
|
|
@@ -482,7 +544,9 @@ function getBrowserContext() {
|
|
|
482
544
|
$utmSourcePlatform,
|
|
483
545
|
$utmCampaignId,
|
|
484
546
|
$utmCreativeFormat,
|
|
485
|
-
$utmMarketingTactic
|
|
547
|
+
$utmMarketingTactic,
|
|
548
|
+
$utmAdSource,
|
|
549
|
+
$utmAdId
|
|
486
550
|
};
|
|
487
551
|
}
|
|
488
552
|
|
|
@@ -649,7 +713,7 @@ function setSuperContext(superContext) {
|
|
|
649
713
|
}
|
|
650
714
|
function updateSuperContext(browserContext) {
|
|
651
715
|
const existingSuperContext = getSuperContext();
|
|
652
|
-
const defaultSuperContextKeys = ['$utmSource', '$utmMedium', '$utmCampaign', '$utmTerm', '$utmContent', '$utmId', '$utmSourcePlatform', '$utmCampaignId', '$utmCreativeFormat', '$utmMarketingTactic'];
|
|
716
|
+
const defaultSuperContextKeys = ['$utmSource', '$utmMedium', '$utmCampaign', '$utmTerm', '$utmContent', '$utmId', '$utmSourcePlatform', '$utmCampaignId', '$utmCreativeFormat', '$utmMarketingTactic', '$utmAdSource', '$utmAdId'];
|
|
653
717
|
const superContext = defaultSuperContextKeys.reduce((acc, key) => {
|
|
654
718
|
const value = Object.assign({}, browserContext)[key];
|
|
655
719
|
if (value) acc[key] = value;
|
|
@@ -981,7 +1045,9 @@ const browserContextSchema = z.object({
|
|
|
981
1045
|
$utmSourcePlatform: z.string().nullable(),
|
|
982
1046
|
$utmCampaignId: z.string().nullable(),
|
|
983
1047
|
$utmCreativeFormat: z.string().nullable(),
|
|
984
|
-
$utmMarketingTactic: z.string().nullable()
|
|
1048
|
+
$utmMarketingTactic: z.string().nullable(),
|
|
1049
|
+
$utmAdSource: z.string().nullable(),
|
|
1050
|
+
$utmAdId: z.string().nullable()
|
|
985
1051
|
});
|
|
986
1052
|
|
|
987
1053
|
export { Saasco, browserContextSchema, getBrowserContext, timezones };
|
package/package.json
CHANGED
|
@@ -20,6 +20,8 @@ export declare const browserContextSchema: z.ZodObject<{
|
|
|
20
20
|
$utmCampaignId: z.ZodNullable<z.ZodString>;
|
|
21
21
|
$utmCreativeFormat: z.ZodNullable<z.ZodString>;
|
|
22
22
|
$utmMarketingTactic: z.ZodNullable<z.ZodString>;
|
|
23
|
+
$utmAdSource: z.ZodNullable<z.ZodString>;
|
|
24
|
+
$utmAdId: z.ZodNullable<z.ZodString>;
|
|
23
25
|
}, "strip", z.ZodTypeAny, {
|
|
24
26
|
$locale: string;
|
|
25
27
|
$location: string;
|
|
@@ -41,6 +43,8 @@ export declare const browserContextSchema: z.ZodObject<{
|
|
|
41
43
|
$utmCampaignId: string | null;
|
|
42
44
|
$utmCreativeFormat: string | null;
|
|
43
45
|
$utmMarketingTactic: string | null;
|
|
46
|
+
$utmAdSource: string | null;
|
|
47
|
+
$utmAdId: string | null;
|
|
44
48
|
}, {
|
|
45
49
|
$locale: string;
|
|
46
50
|
$location: string;
|
|
@@ -62,6 +66,8 @@ export declare const browserContextSchema: z.ZodObject<{
|
|
|
62
66
|
$utmCampaignId: string | null;
|
|
63
67
|
$utmCreativeFormat: string | null;
|
|
64
68
|
$utmMarketingTactic: string | null;
|
|
69
|
+
$utmAdSource: string | null;
|
|
70
|
+
$utmAdId: string | null;
|
|
65
71
|
}>;
|
|
66
72
|
export type BrowserContext = z.infer<typeof browserContextSchema>;
|
|
67
73
|
export type SuperContext = Record<string, any>;
|