@jctrans-materials/nuxt 1.0.39 → 1.0.40-beta.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/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "1.0.39",
7
+ "version": "1.0.40-beta.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,5 +1,5 @@
1
- import { defineNuxtPlugin, useRuntimeConfig, useRouter } from "#app";
2
- import { tracker } from "@jctrans-materials/shared";
1
+ import { callOnce, defineNuxtPlugin, useRuntimeConfig, useRouter } from "#app";
2
+ import { getOrCreateClientId, tracker } from "@jctrans-materials/shared";
3
3
  import { nextTick } from "vue";
4
4
  const pickString = (...values) => {
5
5
  for (const value of values) {
@@ -110,6 +110,17 @@ const bindTrackHandler = (element, binding, gio) => {
110
110
  handler
111
111
  };
112
112
  };
113
+ const identifyDeviceIfNeeded = async (forceLogin, key = "jctrans-gio-identify-device") => {
114
+ if (!import.meta.client || !forceLogin) return;
115
+ await callOnce(key, () => {
116
+ const deviceId = getOrCreateClientId();
117
+ if (!deviceId) return;
118
+ const gdp = window.gdp;
119
+ if (typeof gdp === "function") {
120
+ gdp("identify", deviceId);
121
+ }
122
+ });
123
+ };
113
124
  export default defineNuxtPlugin((nuxtApp) => {
114
125
  const runtimeConfig = useRuntimeConfig();
115
126
  const router = useRouter();
@@ -171,12 +182,21 @@ export default defineNuxtPlugin((nuxtApp) => {
171
182
  runtimeTracking.autoInit,
172
183
  globalTracking.autoInit
173
184
  );
185
+ const forceLogin = pickBoolean(
186
+ globalTracking.initOptions?.forceLogin,
187
+ runtimeTracking.initOptions?.forceLogin,
188
+ initOptions.forceLogin
189
+ ) ?? false;
174
190
  if ((autoInit ?? true) && accountId && dataSourceId && !gio.isInitialized()) {
175
191
  if (appId) {
176
192
  gio.init(accountId, dataSourceId, appId, initOptions);
177
193
  } else {
178
194
  gio.init(accountId, dataSourceId, initOptions);
179
195
  }
196
+ void identifyDeviceIfNeeded(
197
+ forceLogin,
198
+ `jctrans-gio-identify-device:${accountId}:${dataSourceId}`
199
+ );
180
200
  }
181
201
  const trackEvent = (eventName, attrs) => {
182
202
  const normalizedEvent = pickString(eventName);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jctrans-materials/nuxt",
3
3
  "type": "module",
4
- "version": "1.0.39",
4
+ "version": "1.0.40-beta.0",
5
5
  "description": "Nuxt module for JCtrans UI components",
6
6
  "exports": {
7
7
  ".": {
@@ -22,14 +22,14 @@
22
22
  "nuxt": "^3.0.0",
23
23
  "vue": "^3.5.26",
24
24
  "vue-router": "^4.6.4",
25
- "@jctrans-materials/shared": "1.0.39",
26
- "@jctrans-materials/comps-vue3": "1.0.39"
25
+ "@jctrans-materials/comps-vue3": "1.0.40-beta.0",
26
+ "@jctrans-materials/shared": "1.0.40-beta.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "gio-webjs-sdk": "^4.0.0",
30
30
  "nuxt": "^3.0.0",
31
- "@jctrans-materials/shared": "1.0.39",
32
- "@jctrans-materials/comps-vue3": "1.0.39"
31
+ "@jctrans-materials/shared": "1.0.40-beta.0",
32
+ "@jctrans-materials/comps-vue3": "1.0.40-beta.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@nuxt/module-builder": "latest",