@blotoutio/edgetag-sdk-js 0.5.0 → 0.5.2

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 CHANGED
@@ -433,15 +433,18 @@ const handleManifest = manifest => {
433
433
  const providers = [];
434
434
  manifest.forEach(provider => {
435
435
  providers.push(provider.package);
436
- Object.entries(provider.rules).forEach(([name, recipe]) => {
437
- switch (name) {
438
- case 'capture':
439
- {
440
- handleCapture(provider.package, recipe);
441
- return;
442
- }
443
- }
444
- });
436
+
437
+ if (provider.rules) {
438
+ Object.entries(provider.rules).forEach(([name, recipe]) => {
439
+ switch (name) {
440
+ case 'capture':
441
+ {
442
+ handleCapture(provider.package, recipe);
443
+ return;
444
+ }
445
+ }
446
+ });
447
+ }
445
448
  });
446
449
  savePerKey('local', tagStorage, providers, providersKey);
447
450
  };
@@ -453,16 +456,20 @@ const handleInit = preferences => {
453
456
  return;
454
457
  }
455
458
 
456
- let url = `${getInitURL()}`;
459
+ const url = new URL(getInitURL());
457
460
 
458
461
  if (preferences.disableConsentCheck) {
459
- url = `${url}?consentDisabled=true`;
462
+ url.searchParams.set('consentDisabled', 'true');
460
463
  saveConsent({
461
464
  all: true
462
465
  });
463
466
  }
464
467
 
465
- getRequest(url).then(result => {
468
+ if (preferences.userId) {
469
+ url.searchParams.set('userId', preferences.userId);
470
+ }
471
+
472
+ getRequest(url.href).then(result => {
466
473
  if (!result) {
467
474
  console.log('init failed');
468
475
  return;
package/index.js CHANGED
@@ -429,15 +429,18 @@ const handleManifest = manifest => {
429
429
  const providers = [];
430
430
  manifest.forEach(provider => {
431
431
  providers.push(provider.package);
432
- Object.entries(provider.rules).forEach(([name, recipe]) => {
433
- switch (name) {
434
- case 'capture':
435
- {
436
- handleCapture(provider.package, recipe);
437
- return;
438
- }
439
- }
440
- });
432
+
433
+ if (provider.rules) {
434
+ Object.entries(provider.rules).forEach(([name, recipe]) => {
435
+ switch (name) {
436
+ case 'capture':
437
+ {
438
+ handleCapture(provider.package, recipe);
439
+ return;
440
+ }
441
+ }
442
+ });
443
+ }
441
444
  });
442
445
  savePerKey('local', tagStorage, providers, providersKey);
443
446
  };
@@ -449,16 +452,20 @@ const handleInit = preferences => {
449
452
  return;
450
453
  }
451
454
 
452
- let url = `${getInitURL()}`;
455
+ const url = new URL(getInitURL());
453
456
 
454
457
  if (preferences.disableConsentCheck) {
455
- url = `${url}?consentDisabled=true`;
458
+ url.searchParams.set('consentDisabled', 'true');
456
459
  saveConsent({
457
460
  all: true
458
461
  });
459
462
  }
460
463
 
461
- getRequest(url).then(result => {
464
+ if (preferences.userId) {
465
+ url.searchParams.set('userId', preferences.userId);
466
+ }
467
+
468
+ getRequest(url.href).then(result => {
462
469
  if (!result) {
463
470
  console.log('init failed');
464
471
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/edgetag-sdk-js",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "JS SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",
@@ -16,6 +16,7 @@ type Data = Record<string, unknown>
16
16
  interface InitPreferences {
17
17
  edgeURL: string
18
18
  disableConsentCheck?: boolean
19
+ userId?: string
19
20
  }
20
21
 
21
22
  interface EventOptions {