Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增 mip 前端小流量机制 #560

Merged
merged 3 commits into from
Apr 2, 2019
Merged

新增 mip 前端小流量机制 #560

merged 3 commits into from
Apr 2, 2019

Conversation

zoumiaojiang
Copy link
Contributor

相关 ISSUE: (ISSUE 链接地址)

#559

1、升级点 (清晰准确的描述升级的功能点)

新增前端小流量机制

2、影响范围 (描述该需求上线会影响什么功能)

暂时不会对线上造成影响

3、自测 Checklist

4、需要覆盖的场景和 Case

  • 是否覆盖了 sf 打开 MIP 页
  • 是否验证了极速服务 MIP 页面效果

5、自测机型和浏览器

  • 是否覆盖了 iOS 系统手机
  • 是否覆盖了 Android 系统手机
  • 是否覆盖了 iPhone 版式浏览器(比如 QQ、UC、Chrome、Safari、安卓自带浏览器)
  • 是否覆盖了手百

@coveralls
Copy link

coveralls commented Mar 25, 2019

Pull Request Test Coverage Report for Build 1001

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 94.397%

Totals Coverage Status
Change from base Build 1016: -0.2%
Covered Lines: 3808
Relevant Lines: 3947

💛 - Coveralls

@zoumiaojiang zoumiaojiang changed the title 【免测】 新增 mip 前端小流量机制 新增 mip 前端小流量机制 Mar 25, 2019
var domain = document.domain
let date = new Date()
date.setTime(Date.now() + expires)
document.cookie = `${key}=${escape(value)};path=/;expires=${date.toGMTString()};domain=${domain};`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escape 应该用 encodeURIComponent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方不是对 URI 类型的串进行转义的,由于前端操作 cookie 安全性要求更高, escape 的转义更全面,https://stackoverflow.com/questions/14317861/difference-between-escape-encodeuri-encodeuricomponent

let arr = document.cookie.match(reg)

if (arr && arr[2]) {
return unescape(arr[2])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decodeURIComponent,同上

}

for (let i = 0; i < 100; i++) {
abArr[i] = (i < ratio) ? 1 : 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

abArr 命名有点看不懂
另外 abArr = Array.from(Array(100), (_, i) => +(i < ratio)) 应该就行了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

核心不是不支持 Array.from?

@zoumiaojiang
Copy link
Contributor Author

实验机制专用测试分支为 dev-test-experiment, 此分支可以进行修改 /src/experiment/config.js 配置和 /src/index.jsassertSite(), assertAbTest() 调用方式进行不断测试,当然也可以在其他的文件使用 experiment 模块的方法进行测试。

注意:

  • 需要自行修改 dev-test-experiment 分支内容进行编译部署
  • dev-test-experiment 分支在完成测试后会被删除
  • 当 abTest 命中后,如需重新测试概率命中机制的话,需要清除 cookie

机制方案详见 issue:#559

@gaoshan003
Copy link

gaoshan003 commented Mar 27, 2019

测试内容

站点实验:
一、时间设置
正常值:
1.测试开始时间在起始时间和结束时间范围内,查看实验效果正常
2.起始时间默认、结束时间在测试开始时间之后,查看实验效果正常
3.起始时间在测试开始时间之前、结束时间默认,查看实验效果正常
4.起始时间和默认时间都默认,查看实验效果正常
5.起始时间在测试开始时间之后,待到起始时间开始,查看实验效果正常
6.结束时间在测试开始时间之前,查看无小流量实验效果

异常值(cr会发现,不重点):
1.时间格式错误
2.起始时间大于结束时间
二、站点设置
站点:选取医疗和小说站点

Abtest实验:
一、时间设置
1.测试开始时间在起始时间和结束时间范围内,查看实验效果正常
2.起始时间默认、结束时间在测试开始时间之后,查看实验效果正常
3.起始时间在测试开始时间之前、结束时间默认,查看实验效果正常
4.起始时间和默认时间都默认,查看实验效果正常
5.起始时间在测试开始时间之后,待到起始时间开始,查看实验效果正常
6.结束时间在测试开始时间之前,查看无小流量实验效果

二、百分比设置

  1. 100%
  2. 0%
  3. 50%
  4. 10%

测试配置如下:
https://github.com/mipengine/mip2/blob/dev-test-experiment/packages/mip/src/experiment/config.js

测试完成,通过

@yenshih yenshih merged commit 885e637 into dev Apr 2, 2019
@yenshih yenshih deleted the dev-expr branch April 2, 2019 08:03
yenshih pushed a commit that referenced this pull request Apr 2, 2019
* feat: 新增 mip 前端小流量机制

* 修改注释

* 调整变量名和 cookie 的失效时间
PengXing added a commit that referenced this pull request Apr 29, 2019
* fix: 修复核心全量后已知 bugs (#546)

* fix: mip 链接使用默认行为 (#548)

* fix: Register built-in components when document interactive (#555)

* fix: Fix external resources protocol (#558)

* feat: 增强 templates 判断逻辑 (#567)

* 新增 mip 前端小流量机制 (#560)

* feat: 新增 mip 前端小流量机制

* 修改注释

* 调整变量名和 cookie 的失效时间

* fixed: 无需在 js 中指向 mip cahce url

* mip.js 沙盒对象增加 BMap\BMapLib (#577)

* 增加 sandbox 白名单

* 将 BMap 改成 readywrite

* 升级 mip.js 核心的 sandbox

* MIP 核心中移除 Vue 代码 (#357)
clark-t added a commit that referenced this pull request May 7, 2019
* mip 核心升级 babel v7

* 去除多余配置和模块

* 删掉多余注释

* 更新 mip-compoenents-webpack-helpers

* 将 css-loader 锁在0.28

* fix: 修复核心全量后已知 bugs (#546)

* 增加 symbol 的 polyfill

* 增加注释

* fix: mip 链接使用默认行为 (#548)

* 把 symbol 加上

* lock babel version

* add component helper version

* 升级 component helpers 版本

* fix: Register built-in components when document interactive (#555)

* fix: Fix external resources protocol (#558)

* 修改test case

* 修改 test case

* add sleep

* feat: 增强 templates 判断逻辑 (#567)

* 新增 mip 前端小流量机制 (#560)

* feat: 新增 mip 前端小流量机制

* 修改注释

* 调整变量名和 cookie 的失效时间

* fixed: 无需在 js 中指向 mip cahce url

* mip.js 沙盒对象增加 BMap\BMapLib (#577)

* 增加 sandbox 白名单

* 将 BMap 改成 readywrite

* 升级 mip.js 核心的 sandbox

* update

* add promise finally polyfill

* 挪个位置

* 消除其他影响

* change position

* recover test case

* readd maintemplate

* MIP 核心中移除 Vue 代码 (#357)

* mip-img 支持调起手百图片浏览器 (#587)

* mip-img 支持调起手百图片浏览器

* fix: Fix base url calculation (#590)

* update helper

* update helper

* 修改 mip-img 手百调起逻辑 (#592)

* 修改调起逻辑

* mip-img 修复滑动调起 (#597)

* 修复滑动调起
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants