@ray-js/ipc-player-integration 0.0.67-beta.0 → 0.0.67-beta.1

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/lib/ctx/ctx.js CHANGED
@@ -47,6 +47,7 @@ export const createUseCtx = _ref => {
47
47
  const streamStatus = useRef();
48
48
  // The page owns this context; player UI remounts must retain exposure history.
49
49
  const trialBadgeViewedRef = useRef(false);
50
+ const trialBadgeRtidRef = useRef(new Map());
50
51
  // 全屏、竖屏
51
52
  const [screenType, setScreenType] = useAtom('vertical');
52
53
  const IPCPlayerInstance = useRef();
@@ -347,6 +348,7 @@ export const createUseCtx = _ref => {
347
348
  return {
348
349
  devId,
349
350
  trialBadgeViewedRef,
351
+ trialBadgeRtidRef,
350
352
  brandColor,
351
353
  verticalMic,
352
354
  saveToAlbum,
@@ -55,6 +55,7 @@ export type UseCtx = (options: {
55
55
  }) => {
56
56
  devId: string;
57
57
  trialBadgeViewedRef: React.MutableRefObject<boolean>;
58
+ trialBadgeRtidRef: React.MutableRefObject<Map<string, string>>;
58
59
  brandColor: RetAtom<string>;
59
60
  verticalMic: RetAtom<boolean>;
60
61
  saveToAlbum: 0 | 1;
@@ -85,7 +85,7 @@ const BottomLeftContent = _ref => {
85
85
  handleTrialView,
86
86
  handleTrialSubscribe,
87
87
  handleCountdownEnd
88
- } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef);
88
+ } = useTrialBadge(ctx.event, ctx.devId, trialRemainingSec, ctx.trialBadgeViewedRef, ctx.trialBadgeRtidRef);
89
89
 
90
90
  // 横向滚动状态:内容溢出且未滑到对应边缘时,显示左 / 右箭头提示
91
91
  const idRef = useRef(++scrollClsSeq);
@@ -1,5 +1,5 @@
1
1
  export type EntryTracking = Record<'utm_source' | 'utm_medium' | 'entry_source_type' | 'utm_rtid', string>;
2
- export declare const createEntryTracking: () => EntryTracking;
2
+ export declare const createEntryTracking: (fallbackRtid?: string) => EntryTracking;
3
3
  export declare const appendTrackingQuery: (url: string, tracking: EntryTracking) => string;
4
4
  export declare const reportEntryView: (devId: string, tracking: EntryTracking) => Promise<void>;
5
5
  export declare const reportEntryClick: (devId: string, tracking: EntryTracking) => Promise<void>;
@@ -4,7 +4,7 @@ import "core-js/modules/esnext.iterator.filter.js";
4
4
  import "core-js/modules/esnext.iterator.for-each.js";
5
5
  import { getLaunchOptionsSync } from '@ray-js/ray';
6
6
  import { getInitUtmTid } from '@ray-js/ray-ipc-utils';
7
- export const createEntryTracking = () => {
7
+ export const createEntryTracking = fallbackRtid => {
8
8
  let upstreamRtid;
9
9
  try {
10
10
  var _getLaunchOptionsSync;
@@ -16,7 +16,7 @@ export const createEntryTracking = () => {
16
16
  utm_source: 'miniprogram',
17
17
  utm_medium: 'panel_smart_quality',
18
18
  entry_source_type: 'organic',
19
- utm_rtid: upstreamRtid || getInitUtmTid()
19
+ utm_rtid: upstreamRtid || fallbackRtid || getInitUtmTid()
20
20
  };
21
21
  };
22
22
  export const appendTrackingQuery = (url, tracking) => {
@@ -1,6 +1,6 @@
1
1
  import type { MutableRefObject } from 'react';
2
2
  import type { EventInstance } from '../../interface';
3
- export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number, viewedRef?: MutableRefObject<boolean>) => {
3
+ export declare const useTrialBadge: (event: EventInstance, devId: string, trialRemainingSec: number, viewedRef?: MutableRefObject<boolean>, rtidRef?: MutableRefObject<Map<string, string>>) => {
4
4
  showTrialBadge: boolean;
5
5
  setShowTrialBadge: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
6
  handleTrialView: () => void;
@@ -4,9 +4,16 @@ import { gotoSecurityCloudService2 } from '../../utils';
4
4
  import { trialCountdownEnd } from '../../ui/constant';
5
5
  import Strings from '../../i18n';
6
6
  import { createEntryTracking, reportEntryClick, reportEntryView } from '../../utils/fullLinkTracking';
7
- export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
7
+ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef, rtidRef) => {
8
8
  const localViewedRef = useRef(false);
9
9
  const pageViewedRef = viewedRef || localViewedRef;
10
+ const localRtidRef = useRef(new Map());
11
+ const pageRtidRef = rtidRef || localRtidRef;
12
+ const getTracking = useCallback(() => {
13
+ const tracking = createEntryTracking(pageRtidRef.current.get(devId));
14
+ pageRtidRef.current.set(devId, tracking.utm_rtid);
15
+ return tracking;
16
+ }, [devId, pageRtidRef]);
10
17
  const [showTrialBadge, setShowTrialBadge] = useState(false);
11
18
  const prevTrialSecRef = useRef(trialRemainingSec);
12
19
  useEffect(() => {
@@ -20,11 +27,11 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
20
27
  const handleTrialView = useCallback(() => {
21
28
  if (pageViewedRef.current) return;
22
29
  pageViewedRef.current = true;
23
- reportEntryView(devId, createEntryTracking());
24
- }, [devId, pageViewedRef]);
30
+ reportEntryView(devId, getTracking());
31
+ }, [devId, pageViewedRef, getTracking]);
25
32
  const handleTrialSubscribe = useCallback(async () => {
26
33
  try {
27
- const tracking = createEntryTracking();
34
+ const tracking = getTracking();
28
35
  await reportEntryClick(devId, tracking);
29
36
  await gotoSecurityCloudService2(devId, tracking);
30
37
  } catch (error) {
@@ -33,7 +40,7 @@ export const useTrialBadge = (event, devId, trialRemainingSec, viewedRef) => {
33
40
  icon: 'none'
34
41
  });
35
42
  }
36
- }, [devId]);
43
+ }, [devId, getTracking]);
37
44
  const handleCountdownEnd = useCallback(async () => {
38
45
  try {
39
46
  setShowTrialBadge(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/ipc-player-integration",
3
- "version": "0.0.67-beta.0",
3
+ "version": "0.0.67-beta.1",
4
4
  "description": "IPC 融合播放器",
5
5
  "main": "lib/index",
6
6
  "files": [