@zappar/zappar-cv 2.0.1 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,13 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## [2.1.0] - 2023-02-06
3
+ ## [2.0.2] - 2023-05-04
4
4
 
5
- ### Added
6
- - Spanish, Portuguese and German translations for permissions screen
5
+ ### Fixed
7
6
 
8
- ### Changed
7
+ - Unique user calculation when using the Zapworks built-in analytics system
8
+
9
+ ## [2.0.1] - 2023-03-24
10
+
11
+ ### Fixed
9
12
 
10
- - Improvements to curved tracking
13
+ - Workaround for bug in iOS Safari 16.4 that selects the wrong rear-facing camera on some devices
11
14
 
12
15
  ## [2.0.0] - 2022-08-23
13
16
 
package/README.md CHANGED
@@ -18,8 +18,8 @@ npm i @zappar/zappar-cv
18
18
 
19
19
  You can use our CDN from within your HTML:
20
20
  ```
21
- <script src="https://libs.zappar.com/zappar-cv/2.0.1/zappar-cv.js"></script>
21
+ <script src="https://libs.zappar.com/zappar-cv/2.0.2/zappar-cv.js"></script>
22
22
  ```
23
23
 
24
24
  Or you can download and host our standalone JavaScript bundle:
25
- [https://libs.zappar.com/zappar-cv/2.0.1/zappar-cv.zip](https://libs.zappar.com/zappar-cv/2.0.1/zappar-cv.zip)
25
+ [https://libs.zappar.com/zappar-cv/2.0.2/zappar-cv.zip](https://libs.zappar.com/zappar-cv/2.0.2/zappar-cv.zip)
@@ -23,4 +23,5 @@ export interface Additional {
23
23
  browser_incompatible: () => boolean;
24
24
  browser_incompatible_ui: () => void;
25
25
  sequence_source_time_set: (o: zappar_sequence_source_t, ms: number) => void;
26
+ cookies_permitted: (p: boolean) => void;
26
27
  }
@@ -29,9 +29,10 @@ export class zappar_client {
29
29
  m.logLevel(level);
30
30
  });
31
31
  },
32
- analytics_project_id_set: (id) => {
32
+ analytics_project_id_set: (id, uid) => {
33
33
  this.serializer.sendMessage(31, m => {
34
34
  m.string(id);
35
+ m.string(uid);
35
36
  });
36
37
  },
37
38
  // #### pipeline ####
@@ -4,7 +4,7 @@ export function getRuntimeObject(mod) {
4
4
  "number"
5
5
  ]);
6
6
  let analytics_project_id_set_wrapped = mod.cwrap("zappar_analytics_project_id_set", null, [
7
- "string"
7
+ "string", "string"
8
8
  ]);
9
9
  let pipeline_create_wrapped = mod.cwrap("zappar_pipeline_create", "number", []);
10
10
  let pipeline_destroy_wrapped = mod.cwrap("zappar_pipeline_destroy", null, ["number"]);
@@ -195,9 +195,10 @@ export function getRuntimeObject(mod) {
195
195
  let ret = log_level_set_wrapped(arg_level);
196
196
  return ret;
197
197
  },
198
- analytics_project_id_set: (id) => {
198
+ analytics_project_id_set: (id, uid) => {
199
199
  let arg_id = id;
200
- let ret = analytics_project_id_set_wrapped(arg_id);
200
+ let arg_uid = uid;
201
+ let ret = analytics_project_id_set_wrapped(arg_id, arg_uid);
201
202
  return ret;
202
203
  },
203
204
  pipeline_create: () => {
@@ -91,7 +91,7 @@ export declare type zappar_instant_world_tracker_t = number & {
91
91
  export interface zappar_cwrap {
92
92
  log_level(): log_level_t;
93
93
  log_level_set(level: log_level_t): void;
94
- analytics_project_id_set(id: string): void;
94
+ analytics_project_id_set(id: string, uid: string): void;
95
95
  pipeline_create(): zappar_pipeline_t;
96
96
  pipeline_destroy(o: zappar_pipeline_t): void;
97
97
  pipeline_frame_update(o: zappar_pipeline_t): void;
@@ -34,7 +34,7 @@ export class zappar_server {
34
34
  break;
35
35
  }
36
36
  case 31: {
37
- this._impl.analytics_project_id_set(msg.string());
37
+ this._impl.analytics_project_id_set(msg.string(), msg.string());
38
38
  break;
39
39
  }
40
40
  case 27: {
@@ -58,7 +58,7 @@ export interface zappar {
58
58
  permission_denied_any(): boolean;
59
59
  permission_denied_camera(): boolean;
60
60
  permission_denied_motion(): boolean;
61
- analytics_project_id_set(id: string): void;
61
+ analytics_project_id_set(id: string, uid: string): void;
62
62
  pipeline_create(): zappar_pipeline_t;
63
63
  pipeline_destroy(o: zappar_pipeline_t): void;
64
64
  pipeline_camera_frame_upload_gl(o: zappar_pipeline_t): void;
package/lib/native.js CHANGED
@@ -40,10 +40,12 @@ export function initialize(opts) {
40
40
  d: ab
41
41
  }, [ab]);
42
42
  });
43
+ const uid = getUID();
44
+ let hasPersistedUID = false;
43
45
  if (window.location.hostname.toLowerCase().indexOf(".zappar.io") > 0 || window.location.hostname.toLowerCase().indexOf(".webar.run") > 0) {
44
46
  let pathParts = window.location.pathname.split("/");
45
47
  if (pathParts.length > 1 && pathParts[1].length > 0)
46
- c.impl.analytics_project_id_set(".wiz" + pathParts[1]);
48
+ c.impl.analytics_project_id_set(".wiz" + pathParts[1], uid);
47
49
  }
48
50
  messageManager.onIncomingMessage.bind(msg => {
49
51
  var _a, _b, _c, _d, _e, _f, _g;
@@ -479,6 +481,16 @@ export function initialize(opts) {
479
481
  }, html_element_source_create: (pipeline, elm) => HTMLElementSource.createVideoElementSource(pipeline, elm), html_element_source_start: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.start(); }, html_element_source_pause: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, html_element_source_destroy: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, sequence_source_create: p => SequenceSource.create(p), sequence_source_load_from_memory: (o, data) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.loadFromMemory(data); }, sequence_source_pause: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, sequence_source_start: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.start(); }, sequence_source_max_playback_fps_set: (o, fps) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.maxPlaybackFpsSet(fps); }, sequence_source_time_set: (o, t) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.setTime(t); }, sequence_source_destroy: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, permission_granted_all: permissionGrantedAll, permission_granted_camera: permissionGrantedCamera, permission_granted_motion: permissionGrantedMotion, permission_denied_any: permissionDeniedAny, permission_denied_camera: permissionDeniedCamera, permission_denied_motion: permissionDeniedMotion, permission_request_motion: permissionRequestMotion, permission_request_camera: permissionRequestCamera, permission_request_all: permissionRequestAll, permission_request_ui: permissionRequestUI, permission_request_ui_promise: permissionRequestUI, permission_denied_ui: permissionDeniedUI, browser_incompatible: compatibility.incompatible, browser_incompatible_ui: compatibility.incompatible_ui, log_level_set: l => {
480
482
  setLogLevel(l);
481
483
  c.impl.log_level_set(l);
484
+ }, cookies_permitted: p => {
485
+ if (p) {
486
+ if (!hasPersistedUID) {
487
+ persistUID(uid);
488
+ hasPersistedUID = true;
489
+ }
490
+ }
491
+ else {
492
+ deleteUID();
493
+ }
482
494
  } });
483
495
  return client;
484
496
  }
@@ -490,3 +502,25 @@ function loadDefaultFaceModel(o) {
490
502
  client === null || client === void 0 ? void 0 : client.face_tracker_model_load_from_memory(o, ab);
491
503
  });
492
504
  }
505
+ function getUID() {
506
+ let uid = window.localStorage.getItem('z_uar_lid');
507
+ if (uid === null) {
508
+ const destination = new Uint8Array(8);
509
+ window.crypto.getRandomValues(destination);
510
+ uid = '';
511
+ for (let i = 0; i < destination.byteLength; i++) {
512
+ const part = destination[i].toString(16);
513
+ if (part.length === 1)
514
+ uid += '0' + part;
515
+ else if (part.length === 2)
516
+ uid += part;
517
+ }
518
+ }
519
+ return uid;
520
+ }
521
+ function persistUID(u) {
522
+ window.localStorage.setItem('z_uar_lid', u);
523
+ }
524
+ function deleteUID() {
525
+ window.localStorage.removeItem('z_uar_lid');
526
+ }
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.1";
1
+ export declare const VERSION = "2.0.2";
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "2.0.1";
1
+ export const VERSION = "2.0.2";